From 87851886970abb1934f66b7aa37a98eb2faa1fea Mon Sep 17 00:00:00 2001 From: Chandan-DK Date: Sat, 24 Aug 2024 18:01:52 +0000 Subject: [PATCH] skip running vap tests for policies with variables when K8s version is 1.27 or 1.26 Signed-off-by: Chandan-DK --- .github/actions/run-tests/action.yaml | 15 ++++++++++++++- .github/workflows/cel-test.yml | 4 +++- .../.chainsaw-test/chainsaw-test-vap.yaml | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/actions/run-tests/action.yaml b/.github/actions/run-tests/action.yaml index c8ba428d0..a24e3ea54 100644 --- a/.github/actions/run-tests/action.yaml +++ b/.github/actions/run-tests/action.yaml @@ -1,6 +1,9 @@ name: "Runs E2E Tests" description: "Runs E2E tests using chainsaw" inputs: + k8s-version: + description: "Kubernetes version" + required: false tests: description: "Test regex" required: true @@ -16,4 +19,14 @@ runs: shell: bash run: | set -e - chainsaw test --config .chainsaw.yaml --include-test-regex '^chainsaw$/${{ matrix.tests }}' --test-file='${{ inputs.test-file }}' --no-color=false + + K8S_VERSION="${{ inputs.k8s-version }}" + TEST_FILE="${{ inputs.test-file }}" + TESTS="${{ inputs.tests }}" + + if [[ "$TEST_FILE" == "chainsaw-test-vap" && -n "$K8S_VERSION" ]] && + [[ "$K8S_VERSION" == "v1.26."* || "$K8S_VERSION" == "v1.27."* ]]; then + chainsaw test --config .chainsaw.yaml --include-test-regex '^chainsaw$/${{ inputs.tests }}' --test-file='${{ inputs.test-file }}' --no-color=false --selector='!skipForVapAlpha' + else + chainsaw test --config .chainsaw.yaml --include-test-regex '^chainsaw$/${{ inputs.tests }}' --test-file='${{ inputs.test-file }}' --no-color=false + fi diff --git a/.github/workflows/cel-test.yml b/.github/workflows/cel-test.yml index 87b11011d..fa9d66990 100644 --- a/.github/workflows/cel-test.yml +++ b/.github/workflows/cel-test.yml @@ -95,6 +95,7 @@ jobs: with: tests: ${{ matrix.tests }} test-file: chainsaw-test-vap + k8s-version: ${{ matrix.k8s-version.version }} validatingadmissionpolicies-tests-above-1-28: runs-on: ubuntu-latest @@ -130,4 +131,5 @@ jobs: uses: ./.github/actions/run-tests with: tests: ${{ matrix.tests }} - test-file: chainsaw-test-vap \ No newline at end of file + test-file: chainsaw-test-vap + k8s-version: ${{ matrix.k8s-version.version }} \ No newline at end of file diff --git a/pod-security-cel/baseline/disallow-host-process/.chainsaw-test/chainsaw-test-vap.yaml b/pod-security-cel/baseline/disallow-host-process/.chainsaw-test/chainsaw-test-vap.yaml index cd11e28b0..4a8b1e6bf 100755 --- a/pod-security-cel/baseline/disallow-host-process/.chainsaw-test/chainsaw-test-vap.yaml +++ b/pod-security-cel/baseline/disallow-host-process/.chainsaw-test/chainsaw-test-vap.yaml @@ -4,6 +4,8 @@ kind: Test metadata: creationTimestamp: null name: disallow-host-process + labels: + skipForVapAlpha: "" spec: # disable templating because it can cause issues with CEL expressions template: false