diff --git a/ceph-provisioners/templates/bin/_helm-tests.sh.tpl b/ceph-provisioners/templates/bin/_helm-tests.sh.tpl index f3d296148..e98b0210d 100644 --- a/ceph-provisioners/templates/bin/_helm-tests.sh.tpl +++ b/ceph-provisioners/templates/bin/_helm-tests.sh.tpl @@ -40,6 +40,7 @@ function storageclass_validation() pod_name=$2 pvc_name=$3 storageclass=$4 + echo "--> Starting validation" # storageclass check @@ -64,9 +65,9 @@ spec: EOF # waiting for pvc to get create - end=$(($(date +%s) + 120)) - while ! kubectl get pvc -n $pvc_namespace $pvc_name|grep Bound; do - if [ "$(date +%s)" -gt $end ]; then + end=$(($(date +%s) + TEST_POD_WAIT_TIMEOUT)) + while ! kubectl get pvc -n $pvc_namespace $pvc_name | grep Bound; do + if [ "$(date +%s)" -gt "${end}" ]; then kubectl get pvc -n $pvc_namespace $pvc_name kubectl get pv echo "Storageclass is available but can't create PersistentVolumeClaim." @@ -101,12 +102,16 @@ spec: claimName: $pvc_name EOF - # waiting for pod to get create - sleep 60 - if ! kubectl get pods -n $pvc_namespace $pod_name; then - echo "Can not create POD with rbd storage class $storageclass based PersistentVolumeClaim." - echo 1 - fi + # waiting for pod to get completed + end=$(($(date +%s) + TEST_POD_WAIT_TIMEOUT)) + while ! kubectl get pods -n $pvc_namespace $pod_name | grep -i Completed; do + if [ "$(date +%s)" -gt "${end}" ]; then + kubectl get pods -n $pvc_namespace $pod_name + echo "Cannot create POD with rbd storage class $storageclass based PersistentVolumeClaim." + exit 1 + fi + sleep 10 + done } diff --git a/ceph-provisioners/templates/pod-helm-tests.yaml b/ceph-provisioners/templates/pod-helm-tests.yaml index bd428f8cd..d9781f95a 100644 --- a/ceph-provisioners/templates/pod-helm-tests.yaml +++ b/ceph-provisioners/templates/pod-helm-tests.yaml @@ -91,6 +91,8 @@ spec: value: {{ .Values.pod.test_pod.cephfs.name }} - name: CEPHFS_TEST_PVC_NAME value: {{ .Values.pod.test_pod.cephfs.pvc_name }} + - name: TEST_POD_WAIT_TIMEOUT + value: {{ .Values.pod.test_pod.wait_timeout | quote }} command: - /tmp/helm-tests.sh volumeMounts: diff --git a/ceph-provisioners/values.yaml b/ceph-provisioners/values.yaml index c401d2c0c..0f8038918 100644 --- a/ceph-provisioners/values.yaml +++ b/ceph-provisioners/values.yaml @@ -53,6 +53,7 @@ labels: pod: test_pod: + wait_timeout: 120 rbd: name: rbd-prov-test-pod pvc_name: rbd-prov-test-pvc