From dbc005f50c0b0d58182e83c277ec4af1d2f1f72e Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Fri, 28 Mar 2025 10:45:14 +0100 Subject: [PATCH 01/12] simulate flavor should have 'onExit: stop' handler --- chart/infra-server/static/test-simulate.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chart/infra-server/static/test-simulate.yaml b/chart/infra-server/static/test-simulate.yaml index 2e7f7cd41..d899ec5c2 100644 --- a/chart/infra-server/static/test-simulate.yaml +++ b/chart/infra-server/static/test-simulate.yaml @@ -4,6 +4,7 @@ metadata: generateName: simulate- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -29,6 +30,8 @@ spec: value: '{{ "{{" }}workflow.parameters.create-outcome{{ "}}" }}' - - name: wait template: wait + - name: stop + steps: - - name: destroy template: simulate arguments: From 2c26a764583099617de83c8843ac339c4edf438d Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Fri, 28 Mar 2025 11:37:22 +0100 Subject: [PATCH 02/12] update test workflows --- chart/infra-server/static/test-connect-artifact.yaml | 3 +++ chart/infra-server/static/test-gke-lite.yaml | 3 +++ chart/infra-server/static/test-qa-demo.yaml | 3 +++ chart/infra-server/static/test-url-artifact.yaml | 3 +++ 4 files changed, 12 insertions(+) diff --git a/chart/infra-server/static/test-connect-artifact.yaml b/chart/infra-server/static/test-connect-artifact.yaml index 52d7983bc..8e09ef3d8 100644 --- a/chart/infra-server/static/test-connect-artifact.yaml +++ b/chart/infra-server/static/test-connect-artifact.yaml @@ -4,6 +4,7 @@ metadata: generateName: test-connect-artifact- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -16,6 +17,8 @@ spec: template: create - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy diff --git a/chart/infra-server/static/test-gke-lite.yaml b/chart/infra-server/static/test-gke-lite.yaml index 6e8a1cd8d..6059196b8 100644 --- a/chart/infra-server/static/test-gke-lite.yaml +++ b/chart/infra-server/static/test-gke-lite.yaml @@ -4,6 +4,7 @@ metadata: generateName: gke-lite- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -30,6 +31,8 @@ spec: template: create - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy arguments: diff --git a/chart/infra-server/static/test-qa-demo.yaml b/chart/infra-server/static/test-qa-demo.yaml index ff9df6edf..f9c9514ea 100644 --- a/chart/infra-server/static/test-qa-demo.yaml +++ b/chart/infra-server/static/test-qa-demo.yaml @@ -4,6 +4,7 @@ metadata: generateName: test-qa-demo- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -15,6 +16,8 @@ spec: template: whalesay - - name: wait template: wait + - name: stop + steps: - - name: destroy template: whalesay diff --git a/chart/infra-server/static/test-url-artifact.yaml b/chart/infra-server/static/test-url-artifact.yaml index 2829daf99..a763025bf 100644 --- a/chart/infra-server/static/test-url-artifact.yaml +++ b/chart/infra-server/static/test-url-artifact.yaml @@ -4,6 +4,7 @@ metadata: generateName: test-url-artifact- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -16,6 +17,8 @@ spec: template: create - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy From 31ef9f2b6f692005f367309911899cd50a2a9736 Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Fri, 28 Mar 2025 11:54:30 +0100 Subject: [PATCH 03/12] update remaining workflows and smoke-test --- .github/workflows/smoke-test.yaml | 3 +-- chart/infra-server/static/workflow-aks.yaml | 3 +++ chart/infra-server/static/workflow-eks.yaml | 3 +++ chart/infra-server/static/workflow-gke-default.yaml | 4 ++++ chart/infra-server/static/workflow-openshift-4-demo.yaml | 3 +++ .../infra-server/static/workflow-openshift-4-perf-scale.yaml | 3 +++ chart/infra-server/static/workflow-openshift-4.yaml | 3 +++ chart/infra-server/static/workflow-openshift-aro.yaml | 3 +++ chart/infra-server/static/workflow-openshift-ibmroks.yaml | 3 +++ chart/infra-server/static/workflow-openshift-rosa-hcp.yaml | 3 +++ chart/infra-server/static/workflow-openshift-rosa.yaml | 3 +++ chart/infra-server/static/workflow-osd-aws.yaml | 3 +++ chart/infra-server/static/workflow-osd-gcp.yaml | 4 +++- 13 files changed, 38 insertions(+), 3 deletions(-) diff --git a/.github/workflows/smoke-test.yaml b/.github/workflows/smoke-test.yaml index 131f85517..21ec6a62c 100644 --- a/.github/workflows/smoke-test.yaml +++ b/.github/workflows/smoke-test.yaml @@ -46,10 +46,9 @@ jobs: {name: "ocp-4", "args": "", "uniqueness": "g"}, {name: "ocp-4-demo", "args": "", "uniqueness": "h"}, {name: "ocp-4-perf-scale", "args": "", "uniqueness": "i"}, - {name: "ocp-3", "args": "", "uniqueness": "j"}, {name: "osd-on-aws", "args": "", "uniqueness": "k"}, {name: "osd-on-gcp", "args": "", "uniqueness": "l"}, - {name: "qa-demo", "args": "main-image=quay.io/rhacs-eng/main:4.3.4", "uniqueness": "m"}, + {name: "qa-demo", "args": "main-image=quay.io/rhacs-eng/main:4.7.0", "uniqueness": "m"}, {name: "rosa", "args": "", "uniqueness": "n"}, {name: "rosahcp", "args": "", "uniqueness": "o"}, ] diff --git a/chart/infra-server/static/workflow-aks.yaml b/chart/infra-server/static/workflow-aks.yaml index e3aa81710..1b99c1d8b 100644 --- a/chart/infra-server/static/workflow-aks.yaml +++ b/chart/infra-server/static/workflow-aks.yaml @@ -4,6 +4,7 @@ metadata: generateName: aks- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -27,6 +28,8 @@ spec: - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy diff --git a/chart/infra-server/static/workflow-eks.yaml b/chart/infra-server/static/workflow-eks.yaml index e8a073cc2..acb4b88f4 100644 --- a/chart/infra-server/static/workflow-eks.yaml +++ b/chart/infra-server/static/workflow-eks.yaml @@ -4,6 +4,7 @@ metadata: generateName: eks- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -27,6 +28,8 @@ spec: - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy diff --git a/chart/infra-server/static/workflow-gke-default.yaml b/chart/infra-server/static/workflow-gke-default.yaml index 6dd1d75dc..4f6f6f8e0 100644 --- a/chart/infra-server/static/workflow-gke-default.yaml +++ b/chart/infra-server/static/workflow-gke-default.yaml @@ -4,6 +4,7 @@ metadata: generateName: gke-default- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -30,6 +31,9 @@ spec: template: create - - name: wait template: wait + + - name: stop + steps: - - name: destroy template: destroy arguments: diff --git a/chart/infra-server/static/workflow-openshift-4-demo.yaml b/chart/infra-server/static/workflow-openshift-4-demo.yaml index 4f9557997..76181b3f2 100644 --- a/chart/infra-server/static/workflow-openshift-4-demo.yaml +++ b/chart/infra-server/static/workflow-openshift-4-demo.yaml @@ -4,6 +4,7 @@ metadata: generateName: openshift-4-demo- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -74,6 +75,8 @@ spec: - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy diff --git a/chart/infra-server/static/workflow-openshift-4-perf-scale.yaml b/chart/infra-server/static/workflow-openshift-4-perf-scale.yaml index 3a0bdaaa6..707d16f16 100644 --- a/chart/infra-server/static/workflow-openshift-4-perf-scale.yaml +++ b/chart/infra-server/static/workflow-openshift-4-perf-scale.yaml @@ -4,6 +4,7 @@ metadata: generateName: openshift-4-perf-scale- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -50,6 +51,8 @@ spec: - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy diff --git a/chart/infra-server/static/workflow-openshift-4.yaml b/chart/infra-server/static/workflow-openshift-4.yaml index 5f64bbdb2..0b3ef3b30 100644 --- a/chart/infra-server/static/workflow-openshift-4.yaml +++ b/chart/infra-server/static/workflow-openshift-4.yaml @@ -4,6 +4,7 @@ metadata: generateName: openshift-4- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -51,6 +52,8 @@ spec: - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy diff --git a/chart/infra-server/static/workflow-openshift-aro.yaml b/chart/infra-server/static/workflow-openshift-aro.yaml index e8d9088be..4a9092a13 100644 --- a/chart/infra-server/static/workflow-openshift-aro.yaml +++ b/chart/infra-server/static/workflow-openshift-aro.yaml @@ -4,6 +4,7 @@ metadata: generateName: aro- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -32,6 +33,8 @@ spec: - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy diff --git a/chart/infra-server/static/workflow-openshift-ibmroks.yaml b/chart/infra-server/static/workflow-openshift-ibmroks.yaml index 8d73babab..4b62b1a51 100644 --- a/chart/infra-server/static/workflow-openshift-ibmroks.yaml +++ b/chart/infra-server/static/workflow-openshift-ibmroks.yaml @@ -4,6 +4,7 @@ metadata: generateName: roks- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -39,6 +40,8 @@ spec: - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy diff --git a/chart/infra-server/static/workflow-openshift-rosa-hcp.yaml b/chart/infra-server/static/workflow-openshift-rosa-hcp.yaml index 5b1c7e56a..fdfbfde0b 100644 --- a/chart/infra-server/static/workflow-openshift-rosa-hcp.yaml +++ b/chart/infra-server/static/workflow-openshift-rosa-hcp.yaml @@ -4,6 +4,7 @@ metadata: generateName: rosa- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -40,6 +41,8 @@ spec: - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy diff --git a/chart/infra-server/static/workflow-openshift-rosa.yaml b/chart/infra-server/static/workflow-openshift-rosa.yaml index ad07d6a0d..8ca639b4c 100644 --- a/chart/infra-server/static/workflow-openshift-rosa.yaml +++ b/chart/infra-server/static/workflow-openshift-rosa.yaml @@ -4,6 +4,7 @@ metadata: generateName: rosa- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -34,6 +35,8 @@ spec: - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy diff --git a/chart/infra-server/static/workflow-osd-aws.yaml b/chart/infra-server/static/workflow-osd-aws.yaml index bfcacbb29..b12bd94ff 100644 --- a/chart/infra-server/static/workflow-osd-aws.yaml +++ b/chart/infra-server/static/workflow-osd-aws.yaml @@ -4,6 +4,7 @@ metadata: generateName: rosa- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -34,6 +35,8 @@ spec: - - name: wait template: wait + - name: stop + steps: - - name: destroy template: destroy diff --git a/chart/infra-server/static/workflow-osd-gcp.yaml b/chart/infra-server/static/workflow-osd-gcp.yaml index 335d7e2b2..0107bbfa3 100644 --- a/chart/infra-server/static/workflow-osd-gcp.yaml +++ b/chart/infra-server/static/workflow-osd-gcp.yaml @@ -4,6 +4,7 @@ metadata: generateName: rosa- spec: entrypoint: start + onExit: stop arguments: parameters: - name: name @@ -33,7 +34,8 @@ spec: - - name: wait template: wait - + - name: stop + steps: - - name: destroy template: destroy From 37e0a8e07f069151ccb82114cf2702b73309290f Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Fri, 28 Mar 2025 13:04:21 +0100 Subject: [PATCH 04/12] fix input to gke workflows --- chart/infra-server/static/test-gke-lite.yaml | 2 +- chart/infra-server/static/workflow-gke-default.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chart/infra-server/static/test-gke-lite.yaml b/chart/infra-server/static/test-gke-lite.yaml index 6059196b8..a7b1e00ed 100644 --- a/chart/infra-server/static/test-gke-lite.yaml +++ b/chart/infra-server/static/test-gke-lite.yaml @@ -38,7 +38,7 @@ spec: arguments: parameters: - name: name - value: '{{ "{{" }}steps.create.outputs.parameters.cluster_name{{ "}}" }}' + value: '{{ "{{" }}workflow.parameters.name{{ "}}" }}' - name: create activeDeadlineSeconds: 3600 diff --git a/chart/infra-server/static/workflow-gke-default.yaml b/chart/infra-server/static/workflow-gke-default.yaml index 4f6f6f8e0..b869b874a 100644 --- a/chart/infra-server/static/workflow-gke-default.yaml +++ b/chart/infra-server/static/workflow-gke-default.yaml @@ -39,7 +39,7 @@ spec: arguments: parameters: - name: name - value: '{{ "{{" }}steps.create.outputs.parameters.cluster_name{{ "}}" }}' + value: '{{ "{{" }}workflow.parameters.name{{ "}}" }}' - name: create activeDeadlineSeconds: 3600 From da979ebe5aa44ae061ca88a951a862fec8939bdc Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Wed, 9 Apr 2025 14:48:18 +0200 Subject: [PATCH 05/12] upload and delete a file in the simulate workflow --- chart/infra-server/static/test-simulate.yaml | 29 +++++++++++++++++- test/e2e/cluster/lifecycle_test.go | 9 ++++++ test/utils/gcs.go | 31 ++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 test/utils/gcs.go diff --git a/chart/infra-server/static/test-simulate.yaml b/chart/infra-server/static/test-simulate.yaml index d899ec5c2..b2df52ce8 100644 --- a/chart/infra-server/static/test-simulate.yaml +++ b/chart/infra-server/static/test-simulate.yaml @@ -17,6 +17,11 @@ spec: - name: destroy-outcome value: "" + volumes: + - name: credentials + secret: + secretName: google-credentials + templates: - name: start steps: @@ -47,10 +52,28 @@ spec: - name: delay-seconds - name: outcome script: - image: debian:9.4 + image: gcr.io/google.com/cloudsdktool/google-cloud-cli:stable command: [bash] source: | set -x + + gcloud auth activate-service-account --key-file /tmp/google-credentials.json + gcloud config set core/disable_prompts True + + BUCKET_NAME="infra-e2e-upload-test" + FILE="{{ "{{" }}workflow.name{{ "}}" }}" + touch "${FILE}" + + DESTINATION="gs://${BUCKET_NAME}/${FILE}" + + if gsutil -q stat "${DESTINATION}"; then + echo "File exists. Deleting..." + gsutil rm "${DESTINATION}" + else + echo "File does not exist. Proceeding to upload." + gsutil cp "${FILE}" "${DESTINATION}" + fi + start=0 while sleep 1; do if [[ $((start++)) -ge {{ "{{" }}inputs.parameters.delay-seconds{{ "}}" }} ]]; then @@ -59,5 +82,9 @@ spec: done [[ "{{ "{{" }}inputs.parameters.outcome{{ "}}" }}" == "success" ]] || exit 1 + volumeMounts: + - name: credentials + mountPath: /tmp + - name: wait suspend: {} diff --git a/test/e2e/cluster/lifecycle_test.go b/test/e2e/cluster/lifecycle_test.go index 96e898ef6..d6721270c 100644 --- a/test/e2e/cluster/lifecycle_test.go +++ b/test/e2e/cluster/lifecycle_test.go @@ -4,6 +4,7 @@ package cluster_test import ( + "context" "testing" "time" @@ -15,6 +16,8 @@ import ( func TestClusterCanRunThroughStandardLifecycle(t *testing.T) { utils.CheckContext() + ctx := context.Background() + clusterID, err := mock.InfractlCreateCluster( "test-simulate", utils.GetUniqueClusterName("standard"), "--lifespan=10s", @@ -23,8 +26,14 @@ func TestClusterCanRunThroughStandardLifecycle(t *testing.T) { assert.NotEmpty(t, clusterID) utils.AssertStatusBecomes(t, clusterID, "CREATING") utils.AssertStatusBecomes(t, clusterID, "READY") + exists, err := utils.CheckGCSObjectExists(ctx, clusterID) + assert.NoError(t, err) + assert.True(t, exists) utils.AssertStatusBecomes(t, clusterID, "DESTROYING") utils.AssertStatusBecomes(t, clusterID, "FINISHED") + exists, err = utils.CheckGCSObjectExists(ctx, clusterID) + assert.NoError(t, err) + assert.False(t, exists) } func TestClusterCanFailInCreate(t *testing.T) { diff --git a/test/utils/gcs.go b/test/utils/gcs.go new file mode 100644 index 000000000..206f794f5 --- /dev/null +++ b/test/utils/gcs.go @@ -0,0 +1,31 @@ +package utils + +import ( + "context" + "fmt" + + "cloud.google.com/go/storage" + "google.golang.org/api/iterator" +) + +const bucketName = "infra-e2e-upload-test" + +func CheckGCSObjectExists(ctx context.Context, clusterID string) (bool, error) { + client, err := storage.NewClient(ctx) + if err != nil { + return false, err + } + defer client.Close() + + query := &storage.Query{Prefix: clusterID} + it := client.Bucket(bucketName).Objects(ctx, query) + _, err = it.Next() + if err == iterator.Done { + return false, nil + } + if err != nil { + return false, fmt.Errorf("error finding file for prefix (%s): %v", clusterID, err) + } + + return true, nil +} From f7aad2fe1727a540a451f59ef45f9c75b171e259 Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Wed, 9 Apr 2025 15:27:17 +0200 Subject: [PATCH 06/12] update remaining tests --- test/e2e/cluster/lifecycle_test.go | 11 +++++++++++ test/utils/gcs.go | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/test/e2e/cluster/lifecycle_test.go b/test/e2e/cluster/lifecycle_test.go index d6721270c..1931e4887 100644 --- a/test/e2e/cluster/lifecycle_test.go +++ b/test/e2e/cluster/lifecycle_test.go @@ -38,6 +38,8 @@ func TestClusterCanRunThroughStandardLifecycle(t *testing.T) { func TestClusterCanFailInCreate(t *testing.T) { utils.CheckContext() + ctx := context.Background() + clusterID, err := mock.InfractlCreateCluster( "test-simulate", utils.GetUniqueClusterName("create-fails"), "--lifespan=30s", @@ -47,6 +49,7 @@ func TestClusterCanFailInCreate(t *testing.T) { assert.NotEmpty(t, clusterID) utils.AssertStatusBecomes(t, clusterID, "CREATING") utils.AssertStatusBecomes(t, clusterID, "FAILED") + utils.CheckGCSObjectEventuallyDeleted(ctx, t, clusterID) } func TestClusterCanFailInDestroy(t *testing.T) { @@ -66,6 +69,8 @@ func TestClusterCanFailInDestroy(t *testing.T) { func TestClusterCanBeDeleted(t *testing.T) { utils.CheckContext() + ctx := context.Background() + clusterID, err := mock.InfractlCreateCluster( "test-simulate", utils.GetUniqueClusterName("for-deletion"), "--lifespan=5m", @@ -80,10 +85,13 @@ func TestClusterCanBeDeleted(t *testing.T) { assert.NoError(t, err) utils.AssertStatusBecomes(t, clusterID, "DESTROYING") utils.AssertStatusBecomes(t, clusterID, "FINISHED") + utils.CheckGCSObjectEventuallyDeleted(ctx, t, clusterID) } func TestClusterCanExpireByChangingLifespan(t *testing.T) { utils.CheckContext() + ctx := context.Background() + clusterID, err := mock.InfractlCreateCluster( "test-simulate", utils.GetUniqueClusterName("for-expire"), "--lifespan=5m", @@ -98,6 +106,9 @@ func TestClusterCanExpireByChangingLifespan(t *testing.T) { assert.NoError(t, err) utils.AssertStatusBecomes(t, clusterID, "DESTROYING") utils.AssertStatusBecomes(t, clusterID, "FINISHED") + exists, err := utils.CheckGCSObjectExists(ctx, clusterID) + assert.NoError(t, err) + assert.False(t, exists) } func TestClusterCanBeCreatedWithAliasFlavor(t *testing.T) { diff --git a/test/utils/gcs.go b/test/utils/gcs.go index 206f794f5..bbb2d63cc 100644 --- a/test/utils/gcs.go +++ b/test/utils/gcs.go @@ -3,8 +3,12 @@ package utils import ( "context" "fmt" + "log" + "testing" + "time" "cloud.google.com/go/storage" + "github.com/stretchr/testify/assert" "google.golang.org/api/iterator" ) @@ -29,3 +33,18 @@ func CheckGCSObjectExists(ctx context.Context, clusterID string) (bool, error) { return true, nil } + +func CheckGCSObjectEventuallyDeleted(ctx context.Context, t *testing.T, clusterID string) { + tick := 1 * time.Second + conditionMet := func() bool { + exists, err := CheckGCSObjectExists(ctx, clusterID) + if err != nil { + log.Printf("error when looking for object: %v", err) + return false + } + + return !exists + } + + assert.Eventually(t, conditionMet, defaultTimeout, tick) +} From ac8b082e0061d3b2dceffecc2ff9a4d6d56a948c Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Wed, 9 Apr 2025 15:45:12 +0200 Subject: [PATCH 07/12] add comments --- test/utils/gcs.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/utils/gcs.go b/test/utils/gcs.go index bbb2d63cc..70bc55f52 100644 --- a/test/utils/gcs.go +++ b/test/utils/gcs.go @@ -14,6 +14,7 @@ import ( const bucketName = "infra-e2e-upload-test" +// CheckGCSObjectExists confirms that an object exists in the GCS bucket. func CheckGCSObjectExists(ctx context.Context, clusterID string) (bool, error) { client, err := storage.NewClient(ctx) if err != nil { @@ -34,6 +35,7 @@ func CheckGCSObjectExists(ctx context.Context, clusterID string) (bool, error) { return true, nil } +// CheckGCSObjectEventuallyDeleted confirms that an object is eventually deletion from the GCS bucket. func CheckGCSObjectEventuallyDeleted(ctx context.Context, t *testing.T, clusterID string) { tick := 1 * time.Second conditionMet := func() bool { From 5a22235faadbdf56a06e7e55ca2d06e3764af0e2 Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Wed, 16 Apr 2025 13:29:37 +0200 Subject: [PATCH 08/12] skip GCS test if not required --- chart/infra-server/static/flavors.yaml | 4 ++++ test/e2e/cluster/lifecycle_test.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/chart/infra-server/static/flavors.yaml b/chart/infra-server/static/flavors.yaml index 7c5618fce..833df71ba 100644 --- a/chart/infra-server/static/flavors.yaml +++ b/chart/infra-server/static/flavors.yaml @@ -1221,4 +1221,8 @@ description: success or fail value: success kind: optional + - name: test-gcs + description: whether to upload or delete a test artifact in GCS + value: "false" + kind: optional {{ end }} diff --git a/test/e2e/cluster/lifecycle_test.go b/test/e2e/cluster/lifecycle_test.go index 1931e4887..604d3c186 100644 --- a/test/e2e/cluster/lifecycle_test.go +++ b/test/e2e/cluster/lifecycle_test.go @@ -21,6 +21,7 @@ func TestClusterCanRunThroughStandardLifecycle(t *testing.T) { clusterID, err := mock.InfractlCreateCluster( "test-simulate", utils.GetUniqueClusterName("standard"), "--lifespan=10s", + "--arg=test-gcs=true", ) assert.NoError(t, err) assert.NotEmpty(t, clusterID) @@ -44,6 +45,7 @@ func TestClusterCanFailInCreate(t *testing.T) { "test-simulate", utils.GetUniqueClusterName("create-fails"), "--lifespan=30s", "--arg=create-outcome=fail", + "--arg=test-gcs=true", ) assert.NoError(t, err) assert.NotEmpty(t, clusterID) @@ -74,6 +76,7 @@ func TestClusterCanBeDeleted(t *testing.T) { clusterID, err := mock.InfractlCreateCluster( "test-simulate", utils.GetUniqueClusterName("for-deletion"), "--lifespan=5m", + "--arg=test-gcs=true", ) assert.NoError(t, err) assert.NotEmpty(t, clusterID) From e14d256b7bfc3a7233091055f2c39ee9e549ddcc Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Wed, 16 Apr 2025 13:59:46 +0200 Subject: [PATCH 09/12] make it conditionally in GCS --- chart/infra-server/static/test-simulate.yaml | 33 +++++++++++++------- test/e2e/cluster/lifecycle_test.go | 1 + 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/chart/infra-server/static/test-simulate.yaml b/chart/infra-server/static/test-simulate.yaml index b2df52ce8..5da889555 100644 --- a/chart/infra-server/static/test-simulate.yaml +++ b/chart/infra-server/static/test-simulate.yaml @@ -16,6 +16,8 @@ spec: value: "" - name: destroy-outcome value: "" + - name: test-gcs + value: "" volumes: - name: credentials @@ -33,6 +35,8 @@ spec: value: '{{ "{{" }}workflow.parameters.create-delay-seconds{{ "}}" }}' - name: outcome value: '{{ "{{" }}workflow.parameters.create-outcome{{ "}}" }}' + - name: test-gcs + value: '{{ "{{"}}workflow.parameters.test-gcs{{ "}}" }}' - - name: wait template: wait - name: stop @@ -45,33 +49,38 @@ spec: value: '{{ "{{" }}workflow.parameters.destroy-delay-seconds{{ "}}" }}' - name: outcome value: '{{ "{{" }}workflow.parameters.destroy-outcome{{ "}}" }}' + - name: test-gcs + value: '{{ "{{"}}workflow.parameters.test-gcs{{ "}}" }}' - name: simulate inputs: parameters: - name: delay-seconds - name: outcome + - name: test-gcs script: image: gcr.io/google.com/cloudsdktool/google-cloud-cli:stable command: [bash] source: | set -x - gcloud auth activate-service-account --key-file /tmp/google-credentials.json - gcloud config set core/disable_prompts True + if [[ "{{ "{{" }}inputs.parameters.test-gcs{{ "}}" }}" == "true" ]]; then + gcloud auth activate-service-account --key-file /tmp/google-credentials.json + gcloud config set core/disable_prompts True - BUCKET_NAME="infra-e2e-upload-test" - FILE="{{ "{{" }}workflow.name{{ "}}" }}" - touch "${FILE}" + BUCKET_NAME="infra-e2e-upload-test" + FILE="{{ "{{" }}workflow.name{{ "}}" }}" + touch "${FILE}" - DESTINATION="gs://${BUCKET_NAME}/${FILE}" + DESTINATION="gs://${BUCKET_NAME}/${FILE}" - if gsutil -q stat "${DESTINATION}"; then - echo "File exists. Deleting..." - gsutil rm "${DESTINATION}" - else - echo "File does not exist. Proceeding to upload." - gsutil cp "${FILE}" "${DESTINATION}" + if gsutil -q stat "${DESTINATION}"; then + echo "File exists. Deleting..." + gsutil rm "${DESTINATION}" + else + echo "File does not exist. Proceeding to upload." + gsutil cp "${FILE}" "${DESTINATION}" + fi fi start=0 diff --git a/test/e2e/cluster/lifecycle_test.go b/test/e2e/cluster/lifecycle_test.go index 604d3c186..37c5fe5f9 100644 --- a/test/e2e/cluster/lifecycle_test.go +++ b/test/e2e/cluster/lifecycle_test.go @@ -98,6 +98,7 @@ func TestClusterCanExpireByChangingLifespan(t *testing.T) { clusterID, err := mock.InfractlCreateCluster( "test-simulate", utils.GetUniqueClusterName("for-expire"), "--lifespan=5m", + "--arg=test-gcs=true", ) assert.NoError(t, err) assert.NotEmpty(t, clusterID) From a61ccabe91705880a7625005ea06911d75cdf6cf Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Wed, 16 Apr 2025 14:43:17 +0200 Subject: [PATCH 10/12] skipping sleep by default, making tests 20s faster by default --- chart/infra-server/static/flavors.yaml | 6 ++--- chart/infra-server/static/test-simulate.yaml | 25 ++++++++++++++------ test/e2e/cluster/lifecycle_test.go | 4 +--- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/chart/infra-server/static/flavors.yaml b/chart/infra-server/static/flavors.yaml index c7ad3303a..8037cc371 100644 --- a/chart/infra-server/static/flavors.yaml +++ b/chart/infra-server/static/flavors.yaml @@ -1227,7 +1227,7 @@ - name: main-image description: StackRox Central image Docker name value: quay.io/stackrox-io/main:{{ .Chart.Annotations.acsDemoVersion }} - help: | + help: |g This must be a fully qualified image e.g. quay.io/stackrox-io/main:{{ .Chart.Annotations.acsDemoVersion }}. Private images from quay.io/rhacs-eng and stackrox.io (legacy) can also be used. Other public images should also be OK. @@ -1243,7 +1243,7 @@ value: "" - name: create-delay-seconds description: how long to spend in create - value: "10" + value: "0" kind: optional - name: create-outcome description: success or fail @@ -1251,7 +1251,7 @@ kind: optional - name: destroy-delay-seconds description: how long to spend in destroy - value: "10" + value: "0" kind: optional - name: destroy-outcome description: success or fail diff --git a/chart/infra-server/static/test-simulate.yaml b/chart/infra-server/static/test-simulate.yaml index 5da889555..ba7c5f311 100644 --- a/chart/infra-server/static/test-simulate.yaml +++ b/chart/infra-server/static/test-simulate.yaml @@ -64,7 +64,16 @@ spec: source: | set -x - if [[ "{{ "{{" }}inputs.parameters.test-gcs{{ "}}" }}" == "true" ]]; then + delay() { + start=0 + while sleep 1; do + if [[ $((start++)) -ge {{ "{{" }}inputs.parameters.delay-seconds{{ "}}" }} ]]; then + break + fi + done + } + + upload_or_delete_gcs_object() { gcloud auth activate-service-account --key-file /tmp/google-credentials.json gcloud config set core/disable_prompts True @@ -81,14 +90,16 @@ spec: echo "File does not exist. Proceeding to upload." gsutil cp "${FILE}" "${DESTINATION}" fi + } + + if [[ "{{ "{{" }}inputs.parameters.test-gcs{{ "}}" }}" == "true" ]]; then + upload_or_delete_gcs_object + fi + + if [[ {{ "{{" }}inputs.parameters.delay-seconds{{ "}}" }} -gt 0 ]]; then + delay fi - start=0 - while sleep 1; do - if [[ $((start++)) -ge {{ "{{" }}inputs.parameters.delay-seconds{{ "}}" }} ]]; then - break - fi - done [[ "{{ "{{" }}inputs.parameters.outcome{{ "}}" }}" == "success" ]] || exit 1 volumeMounts: diff --git a/test/e2e/cluster/lifecycle_test.go b/test/e2e/cluster/lifecycle_test.go index 37c5fe5f9..31451bae4 100644 --- a/test/e2e/cluster/lifecycle_test.go +++ b/test/e2e/cluster/lifecycle_test.go @@ -32,9 +32,7 @@ func TestClusterCanRunThroughStandardLifecycle(t *testing.T) { assert.True(t, exists) utils.AssertStatusBecomes(t, clusterID, "DESTROYING") utils.AssertStatusBecomes(t, clusterID, "FINISHED") - exists, err = utils.CheckGCSObjectExists(ctx, clusterID) - assert.NoError(t, err) - assert.False(t, exists) + utils.CheckGCSObjectEventuallyDeleted(ctx, t, clusterID) } func TestClusterCanFailInCreate(t *testing.T) { From eb4438406cb3ab106ff4d0c5cd94fccc7b2ee1a0 Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Wed, 16 Apr 2025 14:56:24 +0200 Subject: [PATCH 11/12] fix consequential typo --- chart/infra-server/static/flavors.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chart/infra-server/static/flavors.yaml b/chart/infra-server/static/flavors.yaml index 8037cc371..387b5fe47 100644 --- a/chart/infra-server/static/flavors.yaml +++ b/chart/infra-server/static/flavors.yaml @@ -1227,7 +1227,7 @@ - name: main-image description: StackRox Central image Docker name value: quay.io/stackrox-io/main:{{ .Chart.Annotations.acsDemoVersion }} - help: |g + help: | This must be a fully qualified image e.g. quay.io/stackrox-io/main:{{ .Chart.Annotations.acsDemoVersion }}. Private images from quay.io/rhacs-eng and stackrox.io (legacy) can also be used. Other public images should also be OK. From 22d1263c55ee108daef4379167c96c4227bb3e3c Mon Sep 17 00:00:00 2001 From: Tom Martensen Date: Wed, 16 Apr 2025 15:54:24 +0200 Subject: [PATCH 12/12] more oomph --- .github/workflows/PR.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/PR.yaml b/.github/workflows/PR.yaml index dc9670ad9..c9f2009bc 100644 --- a/.github/workflows/PR.yaml +++ b/.github/workflows/PR.yaml @@ -34,7 +34,7 @@ jobs: with: flavor: gke-default name: infra-pr-${{ github.event.pull_request.number }} - args: machine-type=e2-medium,nodes=3,gcp-image-type=ubuntu_containerd + args: machine-type=e2-standard-4,nodes=3,gcp-image-type=ubuntu_containerd lifespan: ${{ github.actor == 'dependabot[bot]' && '1h' || '24h' }} wait: true token: ${{ secrets.INFRA_TOKEN }}