Skip to content

Commit

Permalink
tests: wait in "kubectl delete"
Browse files Browse the repository at this point in the history
Avoid some of the memory pressure during K8s tests by waiting in
"kubectl delete" before starting the next tests.

Fixes: #8769

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
  • Loading branch information
danmihai1 committed Jan 4, 2024
1 parent 67b91c1 commit 7dc061d
Show file tree
Hide file tree
Showing 41 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-attach-handlers.bats
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ teardown(){
kubectl describe "pod/$pod_name"

rm -f "${pod_config_dir}/test-lifecycle-events.yaml"
kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-caps.bats
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ teardown() {
echo "observed: "
kubectl logs "pod/$pod_name"
kubectl exec "$pod_name" -- sh -c "cat /proc/self/status | grep Cap"
kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-confidential.bats
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ teardown() {
[[ " ${SUPPORTED_HYPERVISORS[*]} " =~ " ${KATA_HYPERVISOR} " ]] || skip "Test not supported for ${KATA_HYPERVISOR}."

kubectl describe "pod/${pod_name}" || true
kubectl delete -f "${pod_config_dir}/pod-confidential-unencrypted.yaml" || true
kubectl delete --wait=true -f "${pod_config_dir}/pod-confidential-unencrypted.yaml" || true
}
4 changes: 2 additions & 2 deletions tests/integration/kubernetes/k8s-configmap.bats
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete configmap "$config_name"
kubectl delete --wait=true pod "$pod_name"
kubectl delete --wait=true configmap "$config_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-copy-file.bats
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ teardown() {
kubectl describe "pod/$pod_name"

rm -f "$file_name"
kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"

rm -f "$pod_config"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-cpu-ns.bats
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
4 changes: 2 additions & 2 deletions tests/integration/kubernetes/k8s-credentials-secrets.bats
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ teardown() {
kubectl describe "pod/$pod_name"
kubectl describe "pod/$second_pod_name"

kubectl delete pod "$pod_name" "$second_pod_name"
kubectl delete secret "$secret_name"
kubectl delete --wait=true pod "$pod_name" "$second_pod_name"
kubectl delete --wait=true secret "$secret_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-custom-dns.bats
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-empty-dirs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"

[ ! -f "$pod_logs_file" ] || rm -f "$pod_logs_file"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-env.bats
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-exec-rejected.bats
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-exec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-file-volume.bats
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ setup() {
teardown() {
[ "${KATA_HYPERVISOR}" == "firecracker" ] && skip "test not working see: ${fc_limitations}"
[ "${KATA_HYPERVISOR}" == "fc" ] && skip "test not working see: ${fc_limitations}"
kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
exec_host "$node" rm -f $tmp_file
rm -f ${pod_config_dir}/test-pod-file-volume.yaml.yaml
}
4 changes: 2 additions & 2 deletions tests/integration/kubernetes/k8s-inotify.bats
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ setup() {
result=$(kubectl get pod "$pod_name" --output="jsonpath={.status.containerStatuses[]}")
echo $result | grep -vq Error

kubectl delete configmap cm
kubectl delete --wait=true configmap cm
}


Expand All @@ -44,5 +44,5 @@ teardown() {
[ "${KATA_HYPERVISOR}" == "fc" ] && skip "test not working see: ${fc_limitations}"
# Debugging information
kubectl describe "pod/$pod_name"
kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
4 changes: 2 additions & 2 deletions tests/integration/kubernetes/k8s-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ teardown() {
kubectl describe jobs/"$job_name"

# Clean-up
kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
# Verify that pod is not running
run kubectl get pods
echo "$output"
[[ "$output" =~ "No resources found" ]]


kubectl delete jobs/"$job_name"
kubectl delete --wait=true jobs/"$job_name"
# Verify that the job is not running
run kubectl get jobs
echo "$output"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
4 changes: 2 additions & 2 deletions tests/integration/kubernetes/k8s-limit-range.bats
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete namespaces "$namespace_name"
kubectl delete --wait=true pod "$pod_name"
kubectl delete --wait=true namespaces "$namespace_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-liveness-probes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-measured-rootfs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ teardown() {
check_and_skip

kubectl describe -f "${pod_config}" || true
kubectl delete -f "${pod_config}" || true
kubectl delete --wait=true -f "${pod_config}" || true
}

@test "Test cannnot launch pod with measured boot enabled and incorrect hash" {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-memory.bats
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ setup_yaml() {
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"

rm -f "${pod_config_dir}/test_within_memory.yaml"
kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}

teardown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ teardown() {
kubectl describe "pod/$pod_name"

# Delete the configmap, secret, and pod used for testing
kubectl delete -f "${pod_config_dir}/pod-nested-configmap-secret.yaml"
kubectl delete --wait=true -f "${pod_config_dir}/pod-nested-configmap-secret.yaml"
}
6 changes: 3 additions & 3 deletions tests/integration/kubernetes/k8s-nginx-connectivity.bats
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ teardown() {
kubectl get endpoints/${deployment} -o yaml

rm -f "${pod_config_dir}/test-${deployment}.yaml"
kubectl delete deployment "$deployment"
kubectl delete service "$deployment"
kubectl delete pod "$busybox_pod"
kubectl delete --wait=true deployment "$deployment"
kubectl delete --wait=true service "$deployment"
kubectl delete --wait=true pod "$busybox_pod"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-number-cpus.bats
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-oom.bats
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ teardown() {
kubectl describe "pod/$pod_name"
kubectl get "pod/$pod_name" -o yaml

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete configmap "$config_name"
kubectl delete --wait=true pod "$pod_name"
kubectl delete --wait=true configmap "$config_name"
}
4 changes: 2 additions & 2 deletions tests/integration/kubernetes/k8s-optional-empty-secret.bats
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete secret "$secret_name"
kubectl delete --wait=true pod "$pod_name"
kubectl delete --wait=true secret "$secret_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-parallel.bats
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ setup() {

teardown() {
# Delete jobs
kubectl delete jobs -l jobgroup=${job_name}
kubectl delete --wait=true jobs -l jobgroup=${job_name}

# Remove generated yaml files
for i in "${names[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-pid-ns.bats
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
4 changes: 2 additions & 2 deletions tests/integration/kubernetes/k8s-pod-quota.bats
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ teardown() {
kubectl describe deployment ${deployment_name}

# Clean-up
kubectl delete -f "${pod_config_dir}/pod-quota-deployment.yaml"
kubectl delete -f "${pod_config_dir}/resource-quota.yaml"
kubectl delete --wait=true -f "${pod_config_dir}/pod-quota-deployment.yaml"
kubectl delete --wait=true -f "${pod_config_dir}/resource-quota.yaml"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-policy-set-keys.bats
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
4 changes: 2 additions & 2 deletions tests/integration/kubernetes/k8s-port-forward.bats
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ setup() {

teardown() {
skip "test not working see: ${issue}"
kubectl delete -f "${pod_config_dir}/redis-master-deployment.yaml"
kubectl delete -f "${pod_config_dir}/redis-master-service.yaml"
kubectl delete --wait=true -f "${pod_config_dir}/redis-master-deployment.yaml"
kubectl delete --wait=true -f "${pod_config_dir}/redis-master-service.yaml"
}
4 changes: 2 additions & 2 deletions tests/integration/kubernetes/k8s-projected-volume.bats
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ teardown() {
kubectl describe "pod/$pod_name"

rm -f $TMP_FILE $SECOND_TMP_FILE
kubectl delete pod "$pod_name"
kubectl delete secret pass user
kubectl delete --wait=true pod "$pod_name"
kubectl delete --wait=true secret pass user
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-qos-pods.bats
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ setup() {
}

teardown() {
kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-replication.bats
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ teardown() {
kubectl describe replicationcontrollers/"$replication_name"

rm -f "${pod_config_dir}/test-replication-controller.yaml"
kubectl delete rc "$replication_name"
kubectl delete --wait=true rc "$replication_name"
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ teardown() {
kubectl logs ${pod}
done

kubectl delete -f "${pod_config_dir}/pod-sandbox-vcpus-allocation.yaml"
kubectl delete --wait=true -f "${pod_config_dir}/pod-sandbox-vcpus-allocation.yaml"
}
4 changes: 2 additions & 2 deletions tests/integration/kubernetes/k8s-scale-nginx.bats
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ setup() {

teardown() {
rm -f "${pod_config_dir}/test-${deployment}.yaml"
kubectl delete deployment "$deployment"
kubectl delete service "$deployment"
kubectl delete --wait=true deployment "$deployment"
kubectl delete --wait=true service "$deployment"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-seccomp.bats
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ teardown() {
echo "seccomp mode is ${seccomp_mode}, expected $expected_seccomp_mode"
kubectl describe "pod/${pod_name}"

kubectl delete -f "${pod_config_dir}/pod-seccomp.yaml" || true
kubectl delete --wait=true -f "${pod_config_dir}/pod-seccomp.yaml" || true
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-security-context.bats
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-shared-volume.bats
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/k8s-sysctls.bats
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
}
6 changes: 3 additions & 3 deletions tests/integration/kubernetes/k8s-volume.bats
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ teardown() {
# Debugging information
kubectl describe "pod/$pod_name"

kubectl delete pod "$pod_name"
kubectl delete --wait=true pod "$pod_name"
rm -f "$pod_yaml"
kubectl delete pvc "$volume_claim"
kubectl delete pv "$volume_name"
kubectl delete --wait=true pvc "$volume_claim"
kubectl delete --wait=true pv "$volume_name"
rm -f "$pv_yaml"
exec_host "$node" rm -rf "$tmp_file"
}

0 comments on commit 7dc061d

Please sign in to comment.