Skip to content

Commit a6d048d

Browse files
chore(ci): fix e2e run in nested cluster, add cleanup for nested cluster (#1908)
Description Run all e2e tests instead single test "VirtualMachineConfiguration" in nested cluster Also add cleanup for nested cluster with failed e2e tests that older than 3 days (namespace and vmaclass) ------------- Signed-off-by: Nikita Korolev <nikita.korolev@flant.com>
1 parent 6bcbd79 commit a6d048d

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

.github/workflows/e2e-matrix.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,31 @@ defaults:
2828
shell: bash
2929

3030
jobs:
31+
cleanup-nested-clusters:
32+
name: Cleanup nested clusters
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Configure kubectl via azure/k8s-set-context@v4
36+
uses: azure/k8s-set-context@v4
37+
with:
38+
method: kubeconfig
39+
context: e2e-cluster-nightly-e2e-virt-sa
40+
kubeconfig: ${{ secrets.VIRT_E2E_NIGHTLY_SA_TOKEN }}
41+
- name: Delete nested clusters
42+
run: |
43+
echo "[INFO] Show namespaces with label test=nightly-e2e older than 3 days for delete"
44+
kubectl get namespaces -l test=nightly-e2e -o jsonpath='{range .items[?(@.metadata.creationTimestamp<"'$(date -d '3 day ago' -u +'%Y-%m-%dT%H:%M:%SZ')'")]}{.metadata.name}{"\t"}{.metadata.creationTimestamp}{"\n"}{end}' || true
45+
echo "[INFO] Show vmclass with label test=nightly-e2e older than 3 days for delete"
46+
kubectl get namespaces -l test=nightly-e2e -o jsonpath='{range .items[?(@.metadata.creationTimestamp<"'$(date -d '3 day ago' -u +'%Y-%m-%dT%H:%M:%SZ')'")]}{.metadata.name}{"\t"}{.metadata.creationTimestamp}{"\n"}{end}' || true
47+
48+
echo "[INFO] Delete namespaces with label test=nightly-e2e older than 3 days"
49+
kubectl get namespaces -l test=nightly-e2e -o jsonpath='{range .items[?(@.metadata.creationTimestamp<"'$(date -d '3 day ago' -u +'%Y-%m-%dT%H:%M:%SZ')'")]}{.metadata.name}{"\n"}{end}' | xargs -r kubectl delete namespace || true
50+
echo "[INFO] Delete vmclass with label test=nightly-e2e older than 3 days"
51+
kubectl get vmclass -l test=nightly-e2e -o jsonpath='{range .items[?(@.metadata.creationTimestamp<"'$(date -d '3 day ago' -u +'%Y-%m-%dT%H:%M:%SZ')'")]}{.metadata.name}{"\n"}{end}' | xargs -r kubectl delete vmclass || true
52+
3153
e2e-ceph:
3254
name: E2E Pipeline (Ceph)
55+
needs: cleanup-nested-clusters
3356
uses: ./.github/workflows/e2e-reusable-pipeline.yml
3457
with:
3558
storage_type: ceph
@@ -48,6 +71,7 @@ jobs:
4871

4972
e2e-replicated:
5073
name: E2E Pipeline (Replicated)
74+
needs: cleanup-nested-clusters
5175
uses: ./.github/workflows/e2e-reusable-pipeline.yml
5276
with:
5377
storage_type: replicated
@@ -63,6 +87,7 @@ jobs:
6387
VIRT_E2E_NIGHTLY_SA_TOKEN: ${{ secrets.VIRT_E2E_NIGHTLY_SA_TOKEN }}
6488
PROD_IO_REGISTRY_DOCKER_CFG: ${{ secrets.PROD_IO_REGISTRY_DOCKER_CFG }}
6589
BOOTSTRAP_DEV_PROXY: ${{ secrets.BOOTSTRAP_DEV_PROXY }}
90+
6691
report-to-channel:
6792
runs-on: ubuntu-latest
6893
name: End-to-End tests report

.github/workflows/e2e-reusable-pipeline.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ on:
7070
type: string
7171
default: "3h"
7272
description: "E2E tests timeout"
73+
e2e_focus_tests:
74+
required: false
75+
type: string
76+
default: ""
77+
description: "E2E tests focus tests like 'VirtualMachineConfiguration' and so on (by default all tests are run)"
7378
secrets:
7479
DEV_REGISTRY_DOCKER_CFG:
7580
required: true
@@ -1147,8 +1152,8 @@ jobs:
11471152
cp -a legacy/testdata /tmp/testdata
11481153
11491154
set +e
1150-
FOCUS="VirtualMachineConfiguration"
1151-
if [ -n $FOCUS ]; then
1155+
FOCUS="${{ inputs.e2e_focus_tests }}"
1156+
if [ -n "$FOCUS" ]; then
11521157
go tool ginkgo \
11531158
--focus="$FOCUS" \
11541159
-v --race --timeout=$TIMEOUT \

0 commit comments

Comments
 (0)