From 4af4ced1aaa3c84951bbde717e256235596ca795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bombo?= Date: Thu, 13 Apr 2023 15:05:10 -0700 Subject: [PATCH] gha: Create Mariner host as part of k8s tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current testing setup only supports running Kata on top of an Ubuntu host. This adds Mariner to the matrix of testable hosts for k8s tests, with Cloud Hypervisor as a VMM. As preparation for the upcoming PR that will change only the actual test code (rather than workflow YAMLs), this also introduces a new file `setup.sh` that will be used to set host-specific parameters at test run-time. Fixes: #6961 Signed-off-by: Aurélien Bombo --- .github/workflows/run-k8s-tests-on-aks.yaml | 11 ++++++++-- .../kubernetes/run_kubernetes_tests.sh | 4 ++++ tests/integration/kubernetes/setup.sh | 20 +++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100755 tests/integration/kubernetes/setup.sh diff --git a/.github/workflows/run-k8s-tests-on-aks.yaml b/.github/workflows/run-k8s-tests-on-aks.yaml index aab1ebd78..2f22c70c3 100644 --- a/.github/workflows/run-k8s-tests-on-aks.yaml +++ b/.github/workflows/run-k8s-tests-on-aks.yaml @@ -17,10 +17,15 @@ jobs: strategy: fail-fast: false matrix: + host_os: + - ubuntu vmm: - clh - dragonball - qemu + include: + - host_os: cbl-mariner + vmm: clh runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -46,7 +51,8 @@ jobs: -n "${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}-${{ matrix.vmm }}-amd64" \ -s "Standard_D4s_v5" \ --node-count 1 \ - --generate-ssh-keys + --generate-ssh-keys \ + ${{ matrix.host_os == 'cbl-mariner' && '--os-sku mariner --workload-runtime KataMshvVmIsolation' }} - name: Install `bats` run: | @@ -79,10 +85,11 @@ jobs: sleep 240s pushd tests/integration/kubernetes - sed -i -e 's|runtimeClassName: kata|runtimeClassName: kata-${{ matrix.vmm }}|' runtimeclass_workloads/*.yaml + bash setup.sh bash run_kubernetes_tests.sh popd env: + KATA_HOST_OS: ${{ matrix.host_os }} KATA_HYPERVISOR: ${{ matrix.vmm }} - name: Delete AKS cluster diff --git a/tests/integration/kubernetes/run_kubernetes_tests.sh b/tests/integration/kubernetes/run_kubernetes_tests.sh index db1e16633..0975ec0d5 100644 --- a/tests/integration/kubernetes/run_kubernetes_tests.sh +++ b/tests/integration/kubernetes/run_kubernetes_tests.sh @@ -54,6 +54,10 @@ else ) fi +if [ ${KATA_HOST_OS} == "cbl-mariner" ]; then + exit 0 +fi + # we may need to skip a few test cases when running on non-x86_64 arch arch_config_file="${kubernetes_dir}/filter_out_per_arch/${TARGET_ARCH}.yaml" if [ -f "${arch_config_file}" ]; then diff --git a/tests/integration/kubernetes/setup.sh b/tests/integration/kubernetes/setup.sh new file mode 100755 index 000000000..0c3baf2dc --- /dev/null +++ b/tests/integration/kubernetes/setup.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Copyright (c) 2023 Microsoft Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +set -o errexit +set -o nounset +set -o pipefail + +kubernetes_dir=$(dirname "$(readlink -f "$0")") + +set_runtime_class() { + sed -i -e "s|runtimeClassName: kata|runtimeClassName: kata-${KATA_HYPERVISOR}|" ${kubernetes_dir}/runtimeclass_workloads/*.yaml +} + +main() { + set_runtime_class +} + +main "$@"