diff --git a/tests/functional/kata-deploy/gha-run.sh b/tests/functional/kata-deploy/gha-run.sh index ef362f40e0..0e3f2057a1 100755 --- a/tests/functional/kata-deploy/gha-run.sh +++ b/tests/functional/kata-deploy/gha-run.sh @@ -25,12 +25,12 @@ function main() { case "${action}" in install-azure-cli) install_azure_cli ;; login-azure) login_azure ;; - create-cluster) create_cluster ;; + create-cluster) create_cluster "kata-deploy" ;; install-bats) install_bats ;; install-kubectl) install_kubectl ;; - get-cluster-credentials) get_cluster_credentials ;; + get-cluster-credentials) get_cluster_credentials "kata-deploy" ;; run-tests) run_tests ;; - delete-cluster) cleanup "aks" ;; + delete-cluster) cleanup "aks" "kata-deploy" ;; *) >&2 echo "Invalid argument"; exit 2 ;; esac } diff --git a/tests/gha-run-k8s-common.sh b/tests/gha-run-k8s-common.sh index cb727a7b72..bf0d202e53 100644 --- a/tests/gha-run-k8s-common.sh +++ b/tests/gha-run-k8s-common.sh @@ -14,8 +14,10 @@ source "${tests_dir}/common.bash" AZ_RG="${AZ_RG:-kataCI}" function _print_cluster_name() { + test_type="${1:-k8s}" + short_sha="$(git rev-parse --short=12 HEAD)" - echo "${GH_PR_NUMBER}-${short_sha}-${KATA_HYPERVISOR}-${KATA_HOST_OS}-amd64" + echo "${test_type}-${GH_PR_NUMBER}-${short_sha}-${KATA_HYPERVISOR}-${KATA_HOST_OS}-amd64" } function install_azure_cli() { @@ -33,12 +35,14 @@ function login_azure() { } function create_cluster() { + test_type="${1:-k8s}" + # First, ensure that the cluster didn't fail to get cleaned up from a previous run. - delete_cluster || true + delete_cluster "${test_type}" || true az aks create \ -g "${AZ_RG}" \ - -n "$(_print_cluster_name)" \ + -n "$(_print_cluster_name ${test_type})" \ -s "Standard_D4s_v5" \ --node-count 1 \ --generate-ssh-keys \ @@ -61,15 +65,19 @@ function install_kubectl() { } function get_cluster_credentials() { + test_type="${1:-k8s}" + az aks get-credentials \ -g "${AZ_RG}" \ - -n "$(_print_cluster_name)" + -n "$(_print_cluster_name ${test_type})" } function delete_cluster() { + test_type="${1:-k8s}" + az aks delete \ -g "${AZ_RG}" \ - -n "$(_print_cluster_name)" \ + -n "$(_print_cluster_name ${test_type})" \ --yes } diff --git a/tests/integration/kubernetes/gha-run.sh b/tests/integration/kubernetes/gha-run.sh index 07a16a1963..10c7aa483a 100755 --- a/tests/integration/kubernetes/gha-run.sh +++ b/tests/integration/kubernetes/gha-run.sh @@ -84,13 +84,14 @@ function run_tests() { function cleanup() { platform="${1}" + test_type="${2:-k8s}" ensure_yq echo "Gather information about the nodes and pods before cleaning up the node" get_nodes_and_pods_info if [ "${platform}" = "aks" ]; then - delete_cluster + delete_cluster ${test_type} return fi