Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
integration/kubernetes: Strength the k8s-block-volume test
Browse files Browse the repository at this point in the history
Wait on the created volume to be "Available" before proceed with
the remaining of the test; Also refactor the code to use variables
that hold the name of the resources.

Fixes #3123

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
  • Loading branch information
wainersm committed Dec 15, 2020
1 parent 6e1b5b7 commit a341d7b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions integration/kubernetes/k8s-block-volume.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ setup() {
get_pod_config_dir

pod_name="pod-block-pv"
volume_name="block-loop-pv"
volume_claim="block-loop-pvc"
wait_time=10
sleep_time=2
ctr_dev_path="/dev/xda"
vol_capacity="500M"

Expand All @@ -33,6 +37,8 @@ setup() {
sed -i "s|HOSTNAME|$(hostname)|" "$tmp_pv_yaml"
sed -i "s|CAPACITY|${vol_capacity}|" "$tmp_pv_yaml"
kubectl create -f "$tmp_pv_yaml"
cmd="kubectl get pv/${volume_name} | grep Available"
waitForProcess "$wait_time" "$sleep_time" "$cmd"

# Create Persistent Volume Claim
tmp_pvc_yaml=$(mktemp --tmpdir block_persistent_vol.XXXXX.yaml)
Expand All @@ -46,7 +52,7 @@ setup() {
kubectl wait --for condition=ready "pod/${pod_name}"

# Verify persistent volume claim is bound
kubectl get pvc | grep "Bound"
kubectl get "pvc/${volume_claim}" | grep "Bound"

# make fs, mount device and write on it
kubectl exec "$pod_name" -- sh -c "mkfs.ext4 $ctr_dev_path"
Expand All @@ -61,8 +67,8 @@ setup() {
teardown() {
# Delete k8s resources
kubectl delete pod "$pod_name"
kubectl delete pvc block-loop-pvc
kubectl delete pv block-loop-pv
kubectl delete pvc "$volume_claim"
kubectl delete pv "$volume_name"
kubectl delete storageclass local-storage

# Delete temporary yaml files
Expand Down

0 comments on commit a341d7b

Please # to comment.