mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-26 15:32:30 +00:00
tests: common: Ensure test_type is used as part of the cluster's name
By doing this we can make sure there won't be any clash on the cluster name created for either the k8s or the kata-deploy tests. Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
parent
790bd3548d
commit
285e616b5e
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user