From 4d4972bbe8b939169b0f97bdc8dba9da3658f482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Fri, 22 Sep 2023 06:24:56 +0200 Subject: [PATCH] e2e: Move tests to gh action using azure workers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit use the azure runners provided by "confidential-containers/infra" to run the kata-clh and kata-qemu workflows. Signed-off-by: Lukáš Doktor --- .github/workflows/ccruntime_e2e.yaml | 30 ++++++++++++++++++++++++++++ tests/e2e/cluster/up.sh | 4 ++-- tests/e2e/lib.sh | 3 +++ tests/e2e/operator.sh | 8 ++++---- 4 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/ccruntime_e2e.yaml diff --git a/.github/workflows/ccruntime_e2e.yaml b/.github/workflows/ccruntime_e2e.yaml new file mode 100644 index 00000000..afdb2685 --- /dev/null +++ b/.github/workflows/ccruntime_e2e.yaml @@ -0,0 +1,30 @@ +name: ccruntime e2e tests +on: + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + e2e: + name: operator tests + strategy: + matrix: + runtimeclass: ["kata-qemu", "kata-clh"] + instance: ["az-ubuntu-2004", "az-ubuntu-2204"] + runs-on: ${{ matrix.instance }} + steps: + - uses: actions/checkout@v4 + + - name: Install deps + run: | + sudo apt-get update -y + sudo apt-get install -y ansible python-is-python3 + + - name: Run e2e tests + run: | + cd tests/e2e + export PATH="$PATH:/usr/local/bin" + ./run-local.sh -r "${{ matrix.runtimeclass }}" -u diff --git a/tests/e2e/cluster/up.sh b/tests/e2e/cluster/up.sh index 1a414223..35374dd2 100755 --- a/tests/e2e/cluster/up.sh +++ b/tests/e2e/cluster/up.sh @@ -57,11 +57,11 @@ main() { # Untaint the node so that pods can be scheduled on it. for role in master control-plane; do - kubectl taint nodes "$(hostname)" \ + kubectl taint nodes "$SAFE_HOST_NAME" \ "node-role.kubernetes.io/$role:NoSchedule-" done - kubectl label node "$(hostname)" node.kubernetes.io/worker= + kubectl label node "$SAFE_HOST_NAME" node.kubernetes.io/worker= } main "$@" diff --git a/tests/e2e/lib.sh b/tests/e2e/lib.sh index 6e489e25..0452644d 100644 --- a/tests/e2e/lib.sh +++ b/tests/e2e/lib.sh @@ -5,6 +5,9 @@ # SPDX-License-Identifier: Apache-2.0 # +# Normalize system hostname to the usual kubectl node name +export SAFE_HOST_NAME=$(hostname | tr '[:upper:]' '[:lower:]') + # Wait until the node is ready. It is set a timeout of 180 seconds. # check_node_is_ready() { diff --git a/tests/e2e/operator.sh b/tests/e2e/operator.sh index 45870444..4c90b1a5 100755 --- a/tests/e2e/operator.sh +++ b/tests/e2e/operator.sh @@ -87,9 +87,9 @@ install_operator() { # The node should be 'worker' labeled local label="node.kubernetes.io/worker" - if ! kubectl get node "$(hostname)" -o jsonpath='{.metadata.labels}' \ + if ! kubectl get node "$SAFE_HOST_NAME" -o jsonpath='{.metadata.labels}' \ | grep -q "$label"; then - kubectl label node "$(hostname)" "$label=" + kubectl label node "$SAFE_HOST_NAME" "$label=" fi handle_older_containerd @@ -182,10 +182,10 @@ uninstall_ccruntime() { ! kubectl get --no-headers runtimeclass 2>/dev/null | grep -q kata # Labels should be gone - if kubectl get nodes "$(hostname)" -o jsonpath='{.metadata.labels}' | \ + if kubectl get nodes "$SAFE_HOST_NAME" -o jsonpath='{.metadata.labels}' | \ grep -q -e cc-preinstall -e katacontainers.io; then echo "ERROR: there are labels left behind" - kubectl get nodes "$(hostname)" -o jsonpath='{.metadata.labels}' + kubectl get nodes "$SAFE_HOST_NAME" -o jsonpath='{.metadata.labels}' return 1 fi