Skip to content

Commit defac86

Browse files
feat: add failfast support per test (#1745) (#1746)
Signed-off-by: Charles-Edouard Brétéché <[email protected]> Co-authored-by: Charles-Edouard Brétéché <[email protected]>
1 parent fc4290b commit defac86

File tree

9 files changed

+38
-1
lines changed

9 files changed

+38
-1
lines changed

.crds/chainsaw.kyverno.io_tests.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,10 @@ spec:
810810
description:
811811
description: Description contains a description of the test.
812812
type: string
813+
failFast:
814+
description: FailFast determines whether the test should stop upon
815+
encountering the first failure.
816+
type: boolean
813817
forceTerminationGracePeriod:
814818
description: ForceTerminationGracePeriod forces the termination grace
815819
period on pods, statefulsets, daemonsets and deployments.

.release-notes/main.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Release notes for `TODO`.
2323
- `null` means inherit the current cluster
2424
- an empty string means the default cluster
2525
- Made default timeouts part of the schemas
26+
- Added support to fail fast at the test level (test will be skipped if a previous error was already reported)
2627

2728
## 🔧 Fixes 🔧
2829

.schemas/json/test-chainsaw-v1alpha1.json

+7
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,13 @@
15921592
"null"
15931593
]
15941594
},
1595+
"failFast": {
1596+
"description": "FailFast determines whether the test should stop upon encountering the first failure.",
1597+
"type": [
1598+
"boolean",
1599+
"null"
1600+
]
1601+
},
15951602
"forceTerminationGracePeriod": {
15961603
"description": "ForceTerminationGracePeriod forces the termination grace period on pods, statefulsets, daemonsets and deployments.",
15971604
"type": [

pkg/apis/v1alpha1/test.go

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ type TestSpec struct {
2828
// +optional
2929
Description string `json:"description,omitempty"`
3030

31+
// FailFast determines whether the test should stop upon encountering the first failure.
32+
// +optional
33+
FailFast *bool `json:"failFast,omitempty"`
34+
3135
// Timeouts for the test. Overrides the global timeouts set in the Configuration on a per operation basis.
3236
// +optional
3337
Timeouts *Timeouts `json:"timeouts,omitempty"`

pkg/apis/v1alpha1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/data/crds/chainsaw.kyverno.io_tests.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,10 @@ spec:
810810
description:
811811
description: Description contains a description of the test.
812812
type: string
813+
failFast:
814+
description: FailFast determines whether the test should stop upon
815+
encountering the first failure.
816+
type: boolean
813817
forceTerminationGracePeriod:
814818
description: ForceTerminationGracePeriod forces the termination grace
815819
period on pods, statefulsets, daemonsets and deployments.

pkg/data/schemas/json/test-chainsaw-v1alpha1.json

+7
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,13 @@
15921592
"null"
15931593
]
15941594
},
1595+
"failFast": {
1596+
"description": "FailFast determines whether the test should stop upon encountering the first failure.",
1597+
"type": [
1598+
"boolean",
1599+
"null"
1600+
]
1601+
},
15951602
"forceTerminationGracePeriod": {
15961603
"description": "ForceTerminationGracePeriod forces the termination grace period on pods, statefulsets, daemonsets and deployments.",
15971604
"type": [

pkg/runner/processors/tests.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ func (p *testsProcessor) Run(ctx context.Context, tc model.TestContext, tests ..
8888
if test.Test.Spec.Skip != nil && *test.Test.Spec.Skip {
8989
t.SkipNow()
9090
}
91-
if p.config.Execution.FailFast {
91+
failFast := p.config.Execution.FailFast
92+
if test.Test.Spec.FailFast != nil {
93+
failFast = *test.Test.Spec.FailFast
94+
}
95+
if failFast {
9296
if tc.Failed() > 0 {
9397
t.SkipNow()
9498
}

website/docs/reference/apis/chainsaw.v1alpha1.md

+1
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ If a resource doesn't exist yet in the cluster it will fail.</p>
852852
| Field | Type | Required | Inline | Description |
853853
|---|---|---|---|---|
854854
| `description` | `string` | | | <p>Description contains a description of the test.</p> |
855+
| `failFast` | `bool` | | | <p>FailFast determines whether the test should stop upon encountering the first failure.</p> |
855856
| `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> |
856857
| `cluster` | `string` | | | <p>Cluster defines the target cluster (default cluster will be used if not specified and/or overridden).</p> |
857858
| `clusters` | [`Clusters`](#chainsaw-kyverno-io-v1alpha1-Clusters) | | | <p>Clusters holds a registry to clusters to support multi-cluster tests.</p> |

0 commit comments

Comments
 (0)