Skip to content

feat: add failfast support per test #1745

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

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .crds/chainsaw.kyverno.io_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,10 @@ spec:
description:
description: Description contains a description of the test.
type: string
failFast:
description: FailFast determines whether the test should stop upon
encountering the first failure.
type: boolean
forceTerminationGracePeriod:
description: ForceTerminationGracePeriod forces the termination grace
period on pods, statefulsets, daemonsets and deployments.
Expand Down
1 change: 1 addition & 0 deletions .release-notes/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Release notes for `TODO`.
- `null` means inherit the current cluster
- an empty string means the default cluster
- Made default timeouts part of the schemas
- Added support to fail fast at the test level (test will be skipped if a previous error was already reported)

## 🔧 Fixes 🔧

Expand Down
7 changes: 7 additions & 0 deletions .schemas/json/test-chainsaw-v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,13 @@
"null"
]
},
"failFast": {
"description": "FailFast determines whether the test should stop upon encountering the first failure.",
"type": [
"boolean",
"null"
]
},
"forceTerminationGracePeriod": {
"description": "ForceTerminationGracePeriod forces the termination grace period on pods, statefulsets, daemonsets and deployments.",
"type": [
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/v1alpha1/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type TestSpec struct {
// +optional
Description string `json:"description,omitempty"`

// FailFast determines whether the test should stop upon encountering the first failure.
// +optional
FailFast *bool `json:"failFast,omitempty"`

// Timeouts for the test. Overrides the global timeouts set in the Configuration on a per operation basis.
// +optional
Timeouts *Timeouts `json:"timeouts,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/data/crds/chainsaw.kyverno.io_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,10 @@ spec:
description:
description: Description contains a description of the test.
type: string
failFast:
description: FailFast determines whether the test should stop upon
encountering the first failure.
type: boolean
forceTerminationGracePeriod:
description: ForceTerminationGracePeriod forces the termination grace
period on pods, statefulsets, daemonsets and deployments.
Expand Down
7 changes: 7 additions & 0 deletions pkg/data/schemas/json/test-chainsaw-v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,13 @@
"null"
]
},
"failFast": {
"description": "FailFast determines whether the test should stop upon encountering the first failure.",
"type": [
"boolean",
"null"
]
},
"forceTerminationGracePeriod": {
"description": "ForceTerminationGracePeriod forces the termination grace period on pods, statefulsets, daemonsets and deployments.",
"type": [
Expand Down
6 changes: 5 additions & 1 deletion pkg/runner/processors/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ func (p *testsProcessor) Run(ctx context.Context, tc model.TestContext, tests ..
if test.Test.Spec.Skip != nil && *test.Test.Spec.Skip {
t.SkipNow()
}
if p.config.Execution.FailFast {
failFast := p.config.Execution.FailFast
if test.Test.Spec.FailFast != nil {
failFast = *test.Test.Spec.FailFast
}
if failFast {
if tc.Failed() > 0 {
t.SkipNow()
}
Expand Down
1 change: 1 addition & 0 deletions website/docs/reference/apis/chainsaw.v1alpha1.md
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ If a resource doesn't exist yet in the cluster it will fail.</p>
| Field | Type | Required | Inline | Description |
|---|---|---|---|---|
| `description` | `string` | | | <p>Description contains a description of the test.</p> |
| `failFast` | `bool` | | | <p>FailFast determines whether the test should stop upon encountering the first failure.</p> |
| `timeouts` | [`Timeouts`](#chainsaw-kyverno-io-v1alpha1-Timeouts) | | | <p>Timeouts for the test. Overrides the global timeouts set in the Configuration on a per operation basis.</p> |
| `cluster` | `string` | | | <p>Cluster defines the target cluster (default cluster will be used if not specified and/or overridden).</p> |
| `clusters` | [`Clusters`](#chainsaw-kyverno-io-v1alpha1-Clusters) | | | <p>Clusters holds a registry to clusters to support multi-cluster tests.</p> |
Expand Down
Loading