Skip to content

Commit ec011ab

Browse files
committed
e2e: support @serial tag for scenarios that modify shared state
Add E2E_GODOG_TAGS and E2E_GODOG_CONCURRENCY env vars to control godog options from CI. Tag TLS scenarios as @serial since they modify shared deployment manifests. Add serial-e2e and experimental-serial-e2e CI workflow entries that run @serial scenarios with concurrency 1.
1 parent e9082dd commit ec011ab

File tree

4 files changed

+59
-17
lines changed

4 files changed

+59
-17
lines changed

.github/workflows/e2e.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,22 @@ jobs:
2121
use-codecov: false
2222
- name: e2e
2323
make-target: test-e2e
24+
e2e-flags: '--godog.tags=~@Serial'
25+
use-artifacts: true
26+
use-codecov: true
27+
- name: serial-e2e
28+
make-target: test-e2e
29+
e2e-flags: '--godog.tags=@Serial'
2430
use-artifacts: true
2531
use-codecov: true
2632
- name: experimental-e2e
2733
make-target: test-experimental-e2e
34+
e2e-flags: '--godog.tags=~@Serial'
35+
use-artifacts: true
36+
use-codecov: true
37+
- name: experimental-serial-e2e
38+
make-target: test-experimental-e2e
39+
e2e-flags: '--godog.tags=@Serial'
2840
use-artifacts: true
2941
use-codecov: true
3042
- name: upgrade-st2st-e2e
@@ -50,9 +62,9 @@ jobs:
5062
- name: Run e2e test
5163
run: |
5264
if [[ "${{ matrix.test.use-artifacts }}" == "true" ]]; then
53-
ARTIFACT_PATH=/tmp/artifacts E2E_SUMMARY_OUTPUT=$GITHUB_STEP_SUMMARY make ${{ matrix.test.make-target }}
65+
ARTIFACT_PATH=/tmp/artifacts E2E_SUMMARY_OUTPUT=$GITHUB_STEP_SUMMARY E2E_FLAGS="${{ matrix.test.e2e-flags }}" make ${{ matrix.test.make-target }}
5466
else
55-
make ${{ matrix.test.make-target }}
67+
E2E_FLAGS="${{ matrix.test.e2e-flags }}" make ${{ matrix.test.make-target }}
5668
fi
5769
5870
- uses: actions/upload-artifact@v7
@@ -68,4 +80,3 @@ jobs:
6880
files: coverage/${{ matrix.test.name }}.out
6981
flags: ${{ matrix.test.name }}
7082
token: ${{ secrets.CODECOV_TOKEN }}
71-

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,10 @@ $(eval $(call install-sh,standard,operator-controller-standard.yaml))
255255
test: manifests generate fmt lint test-unit test-e2e test-regression #HELP Run all tests.
256256

257257
E2E_TIMEOUT ?= 10m
258+
E2E_FLAGS ?=
258259
.PHONY: e2e
259260
e2e: #EXHELP Run the e2e tests.
260-
go test -count=1 -v ./test/e2e/features_test.go -timeout=$(E2E_TIMEOUT)
261+
go test -count=1 -v ./test/e2e/features_test.go -timeout=$(E2E_TIMEOUT) $(E2E_FLAGS)
261262

262263
export CLUSTER_REGISTRY_HOST := docker-registry.operator-controller-e2e.svc:5000
263264
.PHONY: extension-developer-e2e

test/e2e/features/tls.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ Feature: TLS profile enforcement on metrics endpoints
1111
# and curve enforcement because Go's crypto/tls does not allow the server to restrict
1212
# TLS 1.3 cipher suites — CipherSuites config only applies to TLS 1.2. The e2e cert
1313
# uses ECDSA, so ECDHE_ECDSA cipher families are required.
14-
@TLSProfile
14+
@TLSProfile @Serial
1515
Scenario: catalogd metrics endpoint enforces configured minimum TLS version
1616
Given the "catalogd" deployment is configured with custom TLS minimum version "TLSv1.3"
1717
Then the "catalogd" metrics endpoint accepts a TLS 1.3 connection
1818
And the "catalogd" metrics endpoint rejects a TLS 1.2 connection
1919

20-
@TLSProfile
20+
@TLSProfile @Serial
2121
Scenario: catalogd metrics endpoint negotiates and enforces configured cipher suite
2222
Given the "catalogd" deployment is configured with custom TLS version "TLSv1.2", ciphers "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", and curves "prime256v1"
2323
Then the "catalogd" metrics endpoint negotiates cipher "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" over TLS 1.2
2424
And the "catalogd" metrics endpoint rejects a TLS 1.2 connection offering only cipher "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
2525

26-
@TLSProfile
26+
@TLSProfile @Serial
2727
Scenario: catalogd metrics endpoint enforces configured curve preferences
2828
Given the "catalogd" deployment is configured with custom TLS version "TLSv1.2", ciphers "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", and curves "prime256v1"
2929
Then the "catalogd" metrics endpoint accepts a TLS 1.2 connection with cipher "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" and curve "prime256v1"

test/e2e/features_test.go

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"fmt"
55
"log"
66
"os"
7+
"slices"
8+
"strings"
79
"testing"
810

911
"github.com/cucumber/godog"
@@ -27,41 +29,69 @@ func init() {
2729
}
2830

2931
func TestMain(m *testing.M) {
30-
// parse CLI arguments
3132
pflag.Parse()
3233
opts.Paths = pflag.Args()
3334

34-
// run tests
35+
fmt.Println("")
36+
fmt.Println("========================================")
37+
fmt.Println(" PARALLEL scenarios (~@Serial)")
38+
fmt.Println("========================================")
39+
fmt.Println("")
40+
parallelOpts := opts
41+
parallelOpts.Paths = slices.Clone(opts.Paths)
42+
parallelOpts.Tags = andTags(opts.Tags, "~@Serial")
43+
parallelOpts.Concurrency = 100
3544
sc := godog.TestSuite{
3645
TestSuiteInitializer: InitializeSuite,
3746
ScenarioInitializer: InitializeScenario,
38-
Options: &opts,
47+
Options: &parallelOpts,
3948
}.Run()
4049

50+
if sc == 0 {
51+
fmt.Println("")
52+
fmt.Println("========================================")
53+
fmt.Println(" SERIAL scenarios (@Serial)")
54+
fmt.Println("========================================")
55+
fmt.Println("")
56+
serialOpts := opts
57+
serialOpts.Paths = slices.Clone(opts.Paths)
58+
serialOpts.Tags = andTags(opts.Tags, "@Serial")
59+
serialOpts.Concurrency = 1
60+
sc = godog.TestSuite{
61+
TestSuiteInitializer: InitializeSuite,
62+
ScenarioInitializer: InitializeScenario,
63+
Options: &serialOpts,
64+
}.Run()
65+
}
66+
4167
switch sc {
42-
// 0 - success
4368
case 0:
44-
4569
path := os.Getenv("E2E_SUMMARY_OUTPUT")
4670
if path == "" {
4771
fmt.Println("Note: E2E_SUMMARY_OUTPUT is unset; skipping summary generation")
4872
} else {
4973
if err := testutil.PrintSummary(path); err != nil {
50-
// Fail the run if alerts are found
5174
fmt.Printf("%v", err)
5275
os.Exit(1)
5376
}
5477
}
5578
return
56-
57-
// 1 - failed
58-
// 2 - command line usage error
59-
// 128 - or higher, os signal related error exit codes
6079
default:
6180
log.Fatalf("non-zero status returned (%d), failed to run feature tests", sc)
6281
}
6382
}
6483

84+
func andTags(base string, extra ...string) string {
85+
parts := append([]string{base}, extra...)
86+
var nonEmpty []string
87+
for _, p := range parts {
88+
if p != "" {
89+
nonEmpty = append(nonEmpty, p)
90+
}
91+
}
92+
return strings.Join(nonEmpty, " && ")
93+
}
94+
6595
func InitializeSuite(tc *godog.TestSuiteContext) {
6696
tc.BeforeSuite(steps.BeforeSuite)
6797
}

0 commit comments

Comments
 (0)