From b2a697f98d49337ecbaf4d055e71761ffa619f97 Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Mon, 23 Jun 2025 14:31:27 +0300 Subject: [PATCH] Run E2E tests as separate parallel jobs Signed-off-by: Timofei Larkin --- .github/workflows/pull-requests.yaml | 62 ++++++++++++++++------- hack/e2e-apps/clickhouse.bats | 42 ++++++++++++++++ hack/e2e-apps/kubernetes.bats | 73 ++++++++++++++++++++++++++++ hack/e2e-apps/mysql.bats | 47 ++++++++++++++++++ hack/e2e-apps/postgres.bats | 53 ++++++++++++++++++++ hack/e2e-apps/tenant.bats | 22 +++++++++ hack/e2e-apps/virtualmachine.bats | 48 ++++++++++++++++++ hack/e2e-apps/vminstance.bats | 70 ++++++++++++++++++++++++++ packages/core/testing/Makefile | 3 ++ 9 files changed, 402 insertions(+), 18 deletions(-) create mode 100644 hack/e2e-apps/clickhouse.bats create mode 100644 hack/e2e-apps/kubernetes.bats create mode 100644 hack/e2e-apps/mysql.bats create mode 100644 hack/e2e-apps/postgres.bats create mode 100644 hack/e2e-apps/tenant.bats create mode 100644 hack/e2e-apps/virtualmachine.bats create mode 100644 hack/e2e-apps/vminstance.bats diff --git a/.github/workflows/pull-requests.yaml b/.github/workflows/pull-requests.yaml index e2996516..33b361a8 100644 --- a/.github/workflows/pull-requests.yaml +++ b/.github/workflows/pull-requests.yaml @@ -87,8 +87,20 @@ jobs: - name: Set sandbox ID run: echo "SANDBOX_NAME=cozy-e2e-sandbox-$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" | sha256sum | cut -c1-10)" >> $GITHUB_ENV + - name: Prepare workspace + run: | + cd .. + rm -rf /tmp/$SANDBOX_NAME + mv cozystack /tmp/$SANDBOX_NAME + sudo systemd-run + --on-calendar="$(date -d 'now + 24 hours' '+%Y-%m-%d %H:%M:%S')" + --unit=rm-workspace-$SANDBOX_NAME + rm -rf /tmp/$SANDBOX_NAME + - name: Prepare environment - run: make SANDBOX_NAME=$SANDBOX_NAME prepare-env + run: | + cd /tmp/$SANDBOX_NAME + make SANDBOX_NAME=$SANDBOX_NAME prepare-env install_cozystack: name: Install Cozystack @@ -100,20 +112,16 @@ jobs: !contains(github.event.pull_request.labels.*.name, 'release') steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - name: Set sandbox ID run: echo "SANDBOX_NAME=cozy-e2e-sandbox-$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" | sha256sum | cut -c1-10)" >> $GITHUB_ENV - name: Install Cozystack - run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME install-cozystack + run: | + cd /tmp/$SANDBOX_NAME + make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME install-cozystack - test_apps: - name: Test applications + setup_tenant: + name: Setup tenant-test runs-on: [self-hosted] needs: install_cozystack @@ -122,17 +130,35 @@ jobs: !contains(github.event.pull_request.labels.*.name, 'release') steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - name: Set sandbox ID run: echo "SANDBOX_NAME=cozy-e2e-sandbox-$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" | sha256sum | cut -c1-10)" >> $GITHUB_ENV - name: E2E Apps - run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME test-apps + run: | + cd /tmp/$SANDBOX_NAME + make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME test-apps-tenant + + + test_apps: + strategy: + matrix: + app: [clickhouse,kubernetes,mysql,postgres,virtualmachine,vminstance] + name: Test ${{ matrix.app }} + runs-on: [self-hosted] + needs: setup_tenant + + # Never run when the PR carries the "release" label. + if: | + !contains(github.event.pull_request.labels.*.name, 'release') + + steps: + - name: Set sandbox ID + run: echo "SANDBOX_NAME=cozy-e2e-sandbox-$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" | sha256sum | cut -c1-10)" >> $GITHUB_ENV + + - name: E2E Apps + run: | + cd /tmp/$SANDBOX_NAME + make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME test-apps-${{ matrix.app }} cleanup: name: Tear down environment @@ -153,5 +179,5 @@ jobs: - name: Set sandbox ID run: echo "SANDBOX_NAME=cozy-e2e-sandbox-$(echo "${GITHUB_REPOSITORY}:${GITHUB_WORKFLOW}:${GITHUB_REF}" | sha256sum | cut -c1-10)" >> $GITHUB_ENV - - name: E2E Apps + - name: Tear down sandbox run: make -C packages/core/testing SANDBOX_NAME=$SANDBOX_NAME delete diff --git a/hack/e2e-apps/clickhouse.bats b/hack/e2e-apps/clickhouse.bats new file mode 100644 index 00000000..b1d1f29c --- /dev/null +++ b/hack/e2e-apps/clickhouse.bats @@ -0,0 +1,42 @@ +#!/usr/bin/env bats + +@test "Create DB ClickHouse" { + name='test' + kubectl -n tenant-test get clickhouses.apps.cozystack.io $name || + kubectl create -f- <