Skip to content

Commit 0b3bff0

Browse files
committed
chore: improve example test runner to check for new labels #15002
Since we have changed how we identify if an example runs correctly as test this commit applies to the new protocol in the test runner. Signed-off-by: Gianluca Arbezzano <[email protected]>
1 parent 3a677cf commit 0b3bff0

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

.github/workflows/ci-build.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,11 @@ jobs:
262262
profile: minimal
263263
use-api: false
264264
retries: 0
265+
# Example tests are not retryable withou a controller restart
265266
- test: test-examples
266267
profile: minimal
267268
use-api: false
269+
retries: 0
268270
- test: test-plugins
269271
profile: plugins
270272
use-api: false

test/e2e/examples_test.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package e2e
44

55
import (
6+
"strconv"
67
"testing"
78

89
"github.com/stretchr/testify/suite"
@@ -30,14 +31,33 @@ func (s *ExamplesSuite) TestExampleWorkflows() {
3031
s.T().Fatalf("Error parsing %s: %v", path, err)
3132
}
3233
for _, wf := range wfs {
33-
if _, ok := wf.GetLabels()["workflows.argoproj.io/test"]; ok {
34-
s.T().Logf("Found example workflow at %s with test label\n", path)
34+
isTestBroken := false
35+
isEvironmentNotReady := false
36+
isTestBrokenRaw, noTestBrokenLabelExists := wf.GetLabels()["workflows.argoproj.io/no-test-broken"]
37+
if noTestBrokenLabelExists {
38+
isTestBroken, err = strconv.ParseBool(isTestBrokenRaw)
39+
if err != nil {
40+
s.T().Fatalf("Error parsing annotation \"workflows.argoproj.io/no-test-broken\": %v", err)
41+
}
42+
}
43+
isEvironmentNotReadyRaw, noTestBrokenEnvironmentLabelExists := wf.GetLabels()["workflows.argoproj.io/no-test-environment"]
44+
if noTestBrokenEnvironmentLabelExists {
45+
isEvironmentNotReady, err = strconv.ParseBool(isEvironmentNotReadyRaw)
46+
if err != nil {
47+
s.T().Fatalf("Error parsing annotation \"workflows.argoproj.io/no-test-environment\": %v", err)
48+
}
49+
}
50+
if isTestBroken || isEvironmentNotReady {
51+
continue
52+
}
53+
s.T().Run(path, func(t *testing.T) {
54+
s.T().Logf("Found example workflow at %s\n", path)
3555
s.Given().
3656
ExampleWorkflow(&wf).
3757
When().
3858
SubmitWorkflow().
3959
WaitForWorkflow(fixtures.ToBeSucceeded)
40-
}
60+
})
4161
}
4262
return nil
4363
})

test/e2e/fixtures/given.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,18 @@ func (g *Given) checkImages(wf interface{}, isExample bool) {
136136
image == "argoproj/argosay:v1" ||
137137
image == "argoproj/argosay:v2" ||
138138
image == "quay.io/argoproj/argocli:latest" ||
139-
(isExample && (image == "busybox" || image == "python:alpine3.6"))
139+
(isExample && (image == "busybox" ||
140+
image == "python:alpine3.6" ||
141+
image == "golang:1.18" ||
142+
image == "nginx:1.13" ||
143+
image == "curlimages/curl:latest" ||
144+
image == "node:9.1-alpine" ||
145+
image == "docker:19.03.13" ||
146+
image == "docker:19.03.13-dind" ||
147+
image == "alpine/git:v2.26.2" ||
148+
image == "alpine:3.6" ||
149+
image == "stedolan/jq:latest" ||
150+
image == "influxdb:1.2"))
140151
}
141152
for _, t := range templates {
142153
container := t.Container

0 commit comments

Comments
 (0)