-
Notifications
You must be signed in to change notification settings - Fork 3.4k
chore: move example suite from testify to go subtest #15002 #15063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: move example suite from testify to go subtest #15002 #15063
Conversation
This commit removes the label `workflows.argoproj.io/test` used to mark examples as testable because now we want as contributors to be more explicit marking examples that DO NOT have tests, this should help maintainers to ask for those tests as part of code review. This commit adds `workflows.argoproj.io/no-test-broken` for genuinely broken examples which can be fixed or that do not have test yet. `workflows.argoproj.io/no-test-environment` for examples which need to run in a different environment, e.g. need access to artifactory but this commit does not mark those. Related argoproj#15002 Signed-off-by: Gianluca Arbezzano <[email protected]>
f871eb2 to
1d9141c
Compare
| labels: | ||
| workflows.argoproj.io/no-test-environment: "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you set this to false, the current code will not correctly handle it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We fixed that by reverting to a single label called no-test and using the value of such label to express why this example can't be tested. In this way there is no really a point to support "true" because "no-test" is there only if you want to no-test it
test/e2e/examples_test.go
Outdated
| _, noTestBrokenLabelExists := wf.GetLabels()["workflows.argoproj.io/no-test-broken"] | ||
| _, noTestBrokenEnvironmentLabelExists := wf.GetLabels()["workflows.argoproj.io/no-test-environment"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just use the previous test label, or in the very least just invert the logic by using "no-test". I don't see a point in introducing two new labels to avoid testing a workflow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was my request in #15002 and also implemented #15014.
The ones which are marked broken should be fixable by someone - which could be a next step. Examples which won't work are not good - if they won't work because they require artifactory or to run in azure then they get marked as 'no-test-environment' meaning they should work if we had that as part of their test environment. Better names welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates the example test suite from testify's suite pattern to native Go subtests to enable parallel test execution, addressing a long-standing limitation of testify.
Key changes:
- Refactored
TestExampleWorkflowsto use Go's nativet.Run()witht.Parallel()instead of testify suite - Made fixture constructors (
NewGiven,NewPersistence) publicly accessible for standalone instantiation - Updated example workflow labels to use
workflows.argoproj.io/no-test-brokenandworkflows.argoproj.io/no-test-environmentinstead ofworkflows.argoproj.io/test - Standardized container images across examples to a consistent set of approved images
Reviewed changes
Copilot reviewed 172 out of 177 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/examples_test.go | Complete rewrite from testify suite to Go subtests with parallel execution |
| test/e2e/fixtures/given.go | Added public NewGiven constructor and expanded allowed image list for examples |
| test/e2e/fixtures/persistence.go | Exported NewPersistence function and OffloadNodeStatusRepo field for external use |
| test/e2e/fixtures/e2e_suite.go | Updated to use exported fixture constructors and fixed import ordering |
| examples/**/*.yaml | Updated labels and standardized container images to approved versions |
| .github/workflows/ci-build.yaml | Added comment explaining example tests are not retryable |
| docs/fields.md | Regenerated documentation reflecting label changes in examples |
| test/e2e/testdata/cluster-workflow-template-ref.yaml | Added no-test-broken label |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.github/workflows/ci-build.yaml
Outdated
| profile: minimal | ||
| use-api: false | ||
| retries: 0 | ||
| # Example tests are not retryable withou a controller restart |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: "withou" should be "without"
examples/volumes-emptydir.yaml
Outdated
| - name: volumes-emptydir-example | ||
| container: | ||
| image: debian:latest | ||
| image: aline:3.6 |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in image name: "aline:3.6" should be "alpine:3.6"
| image: busybox | ||
| command: [bash] |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The image "busybox" doesn't include bash. The command should be changed to "sh" or the image should be changed to one that includes bash (like alpine:3.6). This will cause the script to fail since busybox only has sh, not bash.
| image: busybox | ||
| command: [bash] |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The image "busybox" doesn't include bash. The command should be changed to "sh" or the image should be changed to one that includes bash (like alpine:3.6). This will cause the script to fail since busybox only has sh, not bash.
| image: busybox | ||
| command: [bash] |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The image "busybox" doesn't include bash. The command should be changed to "sh" or the image should be changed to one that includes bash (like alpine:3.6). This will cause the script to fail since busybox only has sh, not bash.
examples/influxdb-ci.yaml
Outdated
| path: /var/lib/influxdb/data | ||
| container: | ||
| image: debian:9.4 | ||
| image: busybox |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The image "busybox" doesn't include the influxd binary that is expected by this workflow. The container will fail when trying to execute "/app/influxd". Consider using a proper influxdb image or keeping the original debian image.
…5002 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]>
0b588e7 to
fcc53eb
Compare
This commits adds two new labels to communicate why an example can't run as part of the validation test suite: 1. `duration` when an example is expected to run for more than the expected test timeout. 2. `expected-failure` when an example is expected to fail. Signed-off-by: Gianluca Arbezzano <[email protected]>
Many examples could pass tests but they were marked as no-test for various reasons. I analyzed all the tests and I marked the one that did not pass as `no-test-broken` or `-no-test-environment` according to why they were not passing. The most common issues for failing example were the image used as part of the workflow since we have a list of allowed images that can run as tests I expanded the list accordingly and I moved some images that were doing easy tasks for already allowed images. For example we had some debian images that were running `sleep` or `cat`, such commands can run from a busybox and it was already allowed so I moved the workflow to use it. As follow up I will update images to their up to date version. Signed-off-by: Gianluca Arbezzano <[email protected]>
Many examples could pass tests but they were marked as no-test for various reasons. I analyzed all the tests and I marked the one that did not pass as `no-test-broken` or `-no-test-environment` according to why they were not passing. The most common issues for failing example were the image used as part of the workflow since we have a list of allowed images that can run as tests I expanded the list accordingly and I moved some images that were doing easy tasks for already allowed images. For example we had some debian images that were running `sleep` or `cat`, such commands can run from a busybox and it was already allowed so I moved the workflow to use it. As follow up I will update images to their up to date version. Signed-off-by: Gianluca Arbezzano <[email protected]>
…5002 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]>
Many examples could pass tests but they were marked as no-test for various reasons. I analyzed all the tests and I marked the one that did not pass as `no-test-broken` or `-no-test-environment` according to why they were not passing. The most common issues for failing example were the image used as part of the workflow since we have a list of allowed images that can run as tests I expanded the list accordingly and I moved some images that were doing easy tasks for already allowed images. For example we had some debian images that were running `sleep` or `cat`, such commands can run from a busybox and it was already allowed so I moved the workflow to use it. As follow up I will update images to their up to date version. Signed-off-by: Gianluca Arbezzano <[email protected]>
d4cbebc to
7c2f372
Compare
This commit moves the examples test from testify suite to plain go subtest. Mainly because we want to run tests in parallel and currently there is an open issue that prevents testify to work like that stretchr/testify#187 . As consequence we can run single examples: ```terminal go test -v ./test/e2e/examples_test.go -run TestExampleWorkflows/../../examples/memoize-simple.yaml ``` Signed-off-by: Gianluca Arbezzano <[email protected]>
3cb5b33 to
2ec7d75
Compare
We decided to get back to `no-test` label because it is easy to check for the presence of a single label and we use the content of such label to explain why we want this example to skip validation. For example we have set `flaky`, `duration`, `expected-failure` and so on. Signed-off-by: Gianluca Arbezzano <[email protected]>
2ec7d75 to
0288014
Compare
examples/timeouts-step.yaml
Outdated
| metadata: | ||
| generateName: timeouts-step- | ||
| labels: | ||
| workflows.argoproj.io/no-test: "broken" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"expected failure" - it's designed to timeout after 10 seconds, yet tries to sleep for 1d.
examples/http-success-condition.yaml
Outdated
| template: http-status-is-201 | ||
| arguments: | ||
| parameters: [{name: url, value: "http://httpstat.us/201"}] # Returns status code 201 | ||
| parameters: [{name: url, value: "http://httpbin:9100/status/201"}] # Returns status code 201 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks it as an example. It would only work in our test environment, so not happy to make this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me, I can use https://httpbin.org/status/201 so it will go to the internet but when I fixed this example such API was down. It looks up for now, but I am not sure how reliable it is.
test/e2e/examples_test.go
Outdated
| config, | ||
| ) | ||
|
|
||
| given.KubectlApply("../../examples/configmaps/simple-parameters-configmap.yaml", fixtures.NoError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need applying every loop around.
I was hoping we could look through all the files twice:
- First time apply all the ConfigMaps, WorkflowTemplates and ClusterWorkflowTemplates. (Then a few more files will be testable from the
workflow-templateandcluster-workflow-templatedirectories - Second time, do this loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created the first loop that applies all the resources that are not workflows from the example directory and I enabled a couple more tests than now are working
test/e2e/examples_test.go
Outdated
| ) | ||
|
|
||
| given.KubectlApply("../../examples/configmaps/simple-parameters-configmap.yaml", fixtures.NoError) | ||
| given. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: just chain all the givens rather than declaring it as a variable.
test/e2e/examples_test.go
Outdated
| if noTextLabelExists { | ||
| t.Skip(fmt.Sprintf("Impossible to run this example: %s", noTestKeyword)) | ||
| } | ||
| given := fixtures.NewGiven( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference here is that we have a new package that looks a lot like fixtures/e2e_suite.go but doesn't inherit from suite.Suite. Let's refactor this later though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, do you think such struct that won't inherit from suite.Suite should turn to be a dependecy of the e2e suite or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do this now, do it in a separate PR.
Ideally we DRY, and common up some code between an e2e_suite that uses Testify, and one that doesn't. I've not tried to do this, so can't really work out what that would look like exactly. If the two can look the same for tests that would be awesome, but the main aim is to pull all of the setup code out of here and make it somewhere that can be reused. The cron tests could drop testify quite easily and be worth doing for example
b33c173 to
1316af8
Compare
1316af8 to
ac9047e
Compare
Joibel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nits
test/e2e/examples_test.go
Outdated
| kindToApply := map[string]bool{ | ||
| "ConfigMap": true, | ||
| "PersistentVolumeClaim": true, | ||
| "ResourceQuota": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't include ResourceQuota here - installing it won't enable any tests to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
ac9047e to
f687fae
Compare
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
Some of our examples depends on other resources such as ClusterWorkflowTemplate, WorkflowTemplate, ConfigMap and so on. Those tests were previous to this commit disabled because we were not resolving such dependencies but right now we visit the example dir and subdirs twice, the first time we apply all those resources, the second time to run the actual workflows Signed-off-by: Gianluca Arbezzano <[email protected]>
f687fae to
0cf57e6
Compare
Joibel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay, thanks
Isitha's comments have been addressed and he is on holiday
…rgoproj#15063) Signed-off-by: Gianluca Arbezzano <[email protected]> Co-authored-by: Alan Clucas <[email protected]>
Reference #15002 on top of #15014
Motivation
We want to move example suite from testify suite to go subtest because there is a long standing issue open for testify suite that can't run in parallel.
Modifications
Remove reference of testify suite from example_test.go and make the
Givenfixture easy to instantiate on its own.Verification
Example test suite should pass like before and tests should run in parallel
Documentation