From 42608d3c6747a0eec4a5a990f280b85b54bae1b6 Mon Sep 17 00:00:00 2001 From: Sayan Chowdhury Date: Fri, 27 May 2022 11:31:59 +0530 Subject: [PATCH] ci-automation/azure: Add initial container tests infra for Azure (#274) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Azure tests use a similar logic as the GCE tests where an the instance type parameter normally used in AWS/Equinix Metal tests is here used to specify whether the VM gets started in Gen V1 or V2 mode. Signed-off-by: Sayan Chowdhury Co-authored-by: Kai Lüke --- ci-automation/ci-config.env | 10 +++ ci-automation/vendor-testing/azure.sh | 87 +++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100755 ci-automation/vendor-testing/azure.sh diff --git a/ci-automation/ci-config.env b/ci-automation/ci-config.env index 2875c8f5b1..afd9212c92 100644 --- a/ci-automation/ci-config.env +++ b/ci-automation/ci-config.env @@ -119,3 +119,13 @@ VMWARE_ESX_PARALLEL="${PARALLEL_TESTS:-4}" AWS_PARALLEL="${PARALLEL_TESTS:-8}" # AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY should come from # sdk_container/.env + +# -- Azure -- +: ${AZURE_IMAGE_NAME:="flatcar_production_azure_image.vhd"} +: ${AZURE_MACHINE_SIZE:="Standard_D2s_v4"} +: ${AZURE_MORE_MACHINE_SIZE:="Standard_D2s_v4"} +: ${AZURE_USE_GALLERY:=""} +: ${AZURE_USE_PRIVATE_IPS:=true} +: ${AZURE_VNET_SUBNET_NAME:="jenkins-vnet-westeurope"} +AZURE_PARALLEL="${PARALLEL_TESTS:-20}" +AZURE_LOCATION="${AZURE_LOCATION:-westeurope}" diff --git a/ci-automation/vendor-testing/azure.sh b/ci-automation/vendor-testing/azure.sh new file mode 100755 index 0000000000..f7d3517769 --- /dev/null +++ b/ci-automation/vendor-testing/azure.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# Copyright (c) 2021 The Flatcar Maintainers. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +set -euo pipefail + + +# Test execution script for the qemu vendor image. +# This script is supposed to run in the SDK container. + +# $@ now contains tests / test patterns to run + +source ci-automation/vendor_test.sh + +board="${CIA_ARCH}-usr" +basename="ci-${CIA_VERNUM//+/-}-${CIA_ARCH}" +azure_instance_type="${AZURE_MACHINE_SIZE}" +azure_vnet_subnet_name="jenkins-vnet-${AZURE_LOCATION}" +IS_AMD64=${CIA_ARCH//arm64/} + +azure_profile_config_file='' +secret_to_file azure_profile_config_file "${AZURE_PROFILE}" +azure_auth_config_file='' +secret_to_file azure_auth_config_file "${AZURE_AUTH_CREDENTIALS}" + +testscript="$(basename "$0")" + +# Fetch the Azure image if not present +if [ -f "${AZURE_IMAGE_NAME}" ] ; then + echo "++++ ${testscript}: Using existing ${work_dir}/${AZURE_IMAGE_NAME} for testing ${CIA_VERNUM} (${CIA_ARCH}) ++++" +else + echo "++++ ${testscript}: downloading ${AZURE_IMAGE_NAME} for ${CIA_VERNUM} (${CIA_ARCH}) ++++" + copy_from_buildcache "images/${CIA_ARCH}/${CIA_VERNUM}/${AZURE_IMAGE_NAME}.bz2" . + cp --sparse=always <(lbzcat "${AZURE_IMAGE_NAME}.bz2") "${AZURE_IMAGE_NAME}" + rm "${AZURE_IMAGE_NAME}.bz2" +fi + +if [[ "${CIA_ARCH}" == "arm64" ]]; then + AZURE_USE_GALLERY="--azure-use-gallery" +fi + + +run_kola_tests() { + local instance_type="${1}"; shift + local instance_tapfile="${1}"; shift + local hyperv_gen="v2" + if [ "${instance_type}" = "v1" ]; then + hyperv_gen="v1" + instance_type="${azure_instance_type}" + fi + + timeout --signal=SIGQUIT 20h \ + kola run \ + --board="${board}" \ + --basename="${basename}" \ + --parallel="${AZURE_PARALLEL}" \ + --offering=basic \ + --platform=azure \ + --azure-image-file="${AZURE_IMAGE_NAME}" \ + --azure-location="${AZURE_LOCATION}" \ + --azure-profile="${azure_profile_config_file}" \ + --azure-auth="${azure_auth_config_file}" \ + --torcx-manifest=${CIA_TORCX_MANIFEST} \ + --tapfile="${instance_tapfile}" \ + --azure-size=${instance_type} \ + --azure-hyper-v-generation=${hyperv_gen} \ + ${AZURE_USE_GALLERY} \ + ${azure_vnet_subnet_name:+--azure-vnet-subnet-name=${azure_vnet_subnet_name}} \ + ${AZURE_USE_PRIVATE_IPS:+--azure-use-private-ips=${AZURE_USE_PRIVATE_IPS}} \ + "${@}" +} + +query_kola_tests() { + shift; # ignore the instance type + kola list --platform=azure --filter "${@}" +} + +run_kola_tests_on_instances \ + "${azure_instance_type}" \ + "${CIA_TAPFILE}" \ + "${CIA_FIRST_RUN}" \ + ${IS_AMD64:+v1} \ + '--' \ + 'cl.internet' \ + '--' \ + "${@}"