From 2d896ad12fe39c71d5cbb9cb7be9ec2d8e816b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 17 Aug 2023 10:52:18 +0200 Subject: [PATCH] gha: kata-deploy: Do the runtime class cleanup as part of the cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of doing this as part of the test itself, let's ensure it's done before running the tests and during the tests cleanup. Signed-off-by: Fabiano FidĂȘncio --- tests/functional/kata-deploy/gha-run.sh | 23 +++++++++++++++++++ tests/functional/kata-deploy/kata-deploy.bats | 13 ----------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/tests/functional/kata-deploy/gha-run.sh b/tests/functional/kata-deploy/gha-run.sh index 211990482f..8e1c9a1d05 100755 --- a/tests/functional/kata-deploy/gha-run.sh +++ b/tests/functional/kata-deploy/gha-run.sh @@ -13,11 +13,34 @@ kata_deploy_dir="$(dirname "$(readlink -f "$0")")" source "${kata_deploy_dir}/../../gha-run-k8s-common.sh" function run_tests() { + cleanup_runtimeclasses || true + pushd "${kata_deploy_dir}" bash run-kata-deploy-tests.sh popd } +function cleanup_runtimeclasses() { + # Cleanup any runtime class that was left behind in the cluster, in + # case of a test failure, apart from the default one that comes from + # AKS + for rc in `kubectl get runtimeclass -o name | grep -v "kata-mshv-vm-isolation" | sed 's|runtimeclass.node.k8s.io/||'` + do + kubectl delete runtimeclass $rc; + done +} + +function cleanup() { + platform="${1}" + test_type="${2:-k8s}" + + cleanup_runtimeclasses || true + + if [ "${platform}" = "aks" ]; then + delete_cluster ${test_type} + fi +} + function main() { export KATA_HOST_OS="${KATA_HOST_OS:-}" diff --git a/tests/functional/kata-deploy/kata-deploy.bats b/tests/functional/kata-deploy/kata-deploy.bats index 531c3eb64c..84faf8fe14 100644 --- a/tests/functional/kata-deploy/kata-deploy.bats +++ b/tests/functional/kata-deploy/kata-deploy.bats @@ -11,12 +11,6 @@ setup() { repo_root_dir="${BATS_TEST_DIRNAME}/../../../" ensure_yq - # Cleanup any runtimeclass already present in the cluster - # apart from the default one that comes from AKS - for rc in `kubectl get runtimeclass -o name | grep -v "kata-mshv-vm-isolation" | sed 's|runtimeclass.node.k8s.io/||'`; do - kubectl delete runtimeclass $rc; - done - # We expect 2 runtime classes because: # * `kata` is the default runtimeclass created, basically an alias for `kata-${KATA_HYPERVISOR}`. # * `kata-${KATA_HYPERVISOR}` is the other one @@ -109,11 +103,4 @@ teardown() { kubectl delete ${cleanup_spec} kubectl delete -f "${repo_root_dir}/tools/packaging/kata-deploy/kata-rbac/base/kata-rbac.yaml" - - # Cleanup any runtime class that was left behind in the cluster, in - # case of a test failure, apart from the default one that comes from - # AKS - for rc in `kubectl get runtimeclass -o name | grep -v "kata-mshv-vm-isolation" | sed 's|runtimeclass.node.k8s.io/||'`; do - kubectl delete runtimeclass $rc; - done }