Skip to content

Commit 9caef7c

Browse files
joelanfordclaude
andcommitted
e2e: convert all tests to per-scenario dynamic catalogs
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f1cb1a5 commit 9caef7c

15 files changed

Lines changed: 662 additions & 336 deletions

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ test-e2e: GO_BUILD_EXTRA_FLAGS := -cover
320320
test-e2e: COVERAGE_NAME := e2e
321321
test-e2e: export MANIFEST := $(STANDARD_RELEASE_MANIFEST)
322322
test-e2e: export INSTALL_DEFAULT_CATALOGS := false
323-
test-e2e: run-internal image-registry prometheus e2e e2e-coverage kind-clean #HELP Run e2e test suite on local kind cluster
323+
test-e2e: run-internal prometheus e2e e2e-coverage kind-clean #HELP Run e2e test suite on local kind cluster
324324

325325
.PHONY: test-experimental-e2e
326326
test-experimental-e2e: SOURCE_MANIFEST := $(EXPERIMENTAL_E2E_MANIFEST)
@@ -332,7 +332,7 @@ test-experimental-e2e: export MANIFEST := $(EXPERIMENTAL_RELEASE_MANIFEST)
332332
test-experimental-e2e: export INSTALL_DEFAULT_CATALOGS := false
333333
test-experimental-e2e: PROMETHEUS_VALUES := helm/prom_experimental.yaml
334334
test-experimental-e2e: E2E_TIMEOUT := 15m
335-
test-experimental-e2e: run-internal image-registry prometheus e2e e2e-coverage kind-clean #HELP Run experimental e2e test suite on local kind cluster
335+
test-experimental-e2e: run-internal prometheus e2e e2e-coverage kind-clean #HELP Run experimental e2e test suite on local kind cluster
336336

337337
.PHONY: prometheus
338338
prometheus: PROMETHEUS_NAMESPACE := olmv1-system

test/e2e/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,13 @@ test/e2e/
3232
└── steps/ # Step definitions and test utilities
3333
├── steps.go # Step definition implementations
3434
├── hooks.go # Test hooks and scenario context
35-
└── testdata/ # Test data (RBAC templates, catalogs)
35+
└── testdata/ # Test data (RBAC templates)
3636
├── serviceaccount-template.yaml
3737
├── olm-sa-helm-rbac-template.yaml
3838
├── olm-sa-boxcutter-rbac-template.yaml
3939
├── pvc-probe-sa-boxcutter-rbac-template.yaml
4040
├── cluster-admin-rbac-template.yaml
41-
├── metrics-reader-rbac-template.yaml
42-
├── test-catalog-template.yaml
43-
└── extra-catalog-template.yaml
41+
└── metrics-reader-rbac-template.yaml
4442
```
4543

4644
## Architecture
@@ -149,7 +147,7 @@ Manages test lifecycle and scenario-specific context.
149147

150148
**Variable Substitution:**
151149

152-
Replaces `${TEST_NAMESPACE}`, `${NAME}`, and `${CATALOG_IMG}` with scenario-specific values.
150+
Replaces `${TEST_NAMESPACE}`, `${NAME}`, `${SCENARIO_ID}`, `${PACKAGE:<name>}`, and `${CATALOG:<name>}` with scenario-specific values.
153151

154152
## Writing Tests
155153

@@ -203,7 +201,9 @@ Use these variables in YAML templates:
203201
- `${NAME}`: Scenario-specific ClusterExtension name (e.g., `ce-123`)
204202
- `${COS_NAME}`: Scenario-specific ClusterObjectSet name (e.g., `cos-123`; for applying ClusterObjectSets directly)
205203
- `${TEST_NAMESPACE}`: Scenario-specific namespace (e.g., `ns-123`)
206-
- `${CATALOG_IMG}`: Catalog image reference (defaults to in-cluster registry, overridable via `CATALOG_IMG` env var)
204+
- `${SCENARIO_ID}`: Unique scenario identifier used for resource name isolation
205+
- `${PACKAGE:<name>}`: Parameterized package name (e.g., `${PACKAGE:test}` expands to `test-<scenario-id>`)
206+
- `${CATALOG:<name>}`: Catalog resource name (e.g., `${CATALOG:test}` expands to `test-catalog-<scenario-id>`)
207207

208208
### 5. Feature Tags
209209

@@ -277,8 +277,8 @@ go test test/e2e/features_test.go --log.debug --k8s.cli=oc
277277

278278
- `KUBECONFIG`: Path to kubeconfig file (defaults to `~/.kube/config`)
279279
- `E2E_SUMMARY_OUTPUT`: Path to write test summary (optional)
280-
- `CATALOG_IMG`: Override default catalog image reference (optional)
281-
- `LOCAL_REGISTRY_HOST`: Local registry host for catalog images
280+
- `LOCAL_REGISTRY_HOST`: Local registry host for pushing catalog images (default: `localhost:30000`)
281+
- `CLUSTER_REGISTRY_HOST`: In-cluster registry host for pulling catalog images
282282

283283
## Design Patterns
284284

@@ -293,8 +293,8 @@ Each scenario runs in its own namespace with unique resource names, ensuring com
293293

294294
The `ScenarioCleanup` hook ensures all resources are deleted after each scenario:
295295

296-
- Kills background processes (e.g., kubectl port-forward)
297-
- Deletes ClusterExtensions
296+
- Deletes ClusterExtensions and ClusterObjectSets
297+
- Deletes ClusterCatalogs
298298
- Deletes namespaces
299299
- Deletes added resources
300300

test/e2e/features/install.feature

Lines changed: 134 additions & 85 deletions
Large diffs are not rendered by default.

test/e2e/features/recover.feature

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ Feature: Recover cluster extension from errors that might occur during its lifet
22

33
Background:
44
Given OLM is available
5-
And ClusterCatalog "test" serves bundles
5+
And an image registry is available
6+
And a catalog "test" with packages:
7+
| package | version | channel | replaces | contents |
8+
| test | 1.2.0 | beta | | CRD, Deployment, ConfigMap |
69

710
Scenario: Restore removed resource
811
Given ServiceAccount "olm-sa" with needed permissions is available in test namespace
@@ -19,15 +22,15 @@ Feature: Recover cluster extension from errors that might occur during its lifet
1922
source:
2023
sourceType: Catalog
2124
catalog:
22-
packageName: test
25+
packageName: ${PACKAGE:test}
2326
selector:
2427
matchLabels:
25-
"olm.operatorframework.io/metadata.name": test-catalog
28+
"olm.operatorframework.io/metadata.name": ${CATALOG:test}
2629
"""
2730
And ClusterExtension is available
28-
And resource "configmap/test-configmap" exists
29-
When resource "configmap/test-configmap" is removed
30-
Then resource "configmap/test-configmap" is eventually restored
31+
And resource "configmap/test-configmap-${SCENARIO_ID}" exists
32+
When resource "configmap/test-configmap-${SCENARIO_ID}" is removed
33+
Then resource "configmap/test-configmap-${SCENARIO_ID}" is eventually restored
3134

3235
Scenario: Install ClusterExtension after target namespace becomes available
3336
Given ClusterExtension is applied
@@ -43,10 +46,10 @@ Feature: Recover cluster extension from errors that might occur during its lifet
4346
source:
4447
sourceType: Catalog
4548
catalog:
46-
packageName: test
49+
packageName: ${PACKAGE:test}
4750
selector:
4851
matchLabels:
49-
"olm.operatorframework.io/metadata.name": test-catalog
52+
"olm.operatorframework.io/metadata.name": ${CATALOG:test}
5053
"""
5154
And ClusterExtension reports Progressing as True with Reason Retrying
5255
When ServiceAccount "olm-sa" with needed permissions is available in test namespace
@@ -60,17 +63,17 @@ Feature: Recover cluster extension from errors that might occur during its lifet
6063
apiVersion: apps/v1
6164
kind: Deployment
6265
metadata:
63-
name: test-operator
66+
name: test-operator-${SCENARIO_ID}
6467
namespace: ${TEST_NAMESPACE}
6568
spec:
6669
replicas: 1
6770
selector:
6871
matchLabels:
69-
app: test-operator
72+
app: test-operator-${SCENARIO_ID}
7073
template:
7174
metadata:
7275
labels:
73-
app: test-operator
76+
app: test-operator-${SCENARIO_ID}
7477
spec:
7578
containers:
7679
- command:
@@ -103,14 +106,14 @@ Feature: Recover cluster extension from errors that might occur during its lifet
103106
source:
104107
sourceType: Catalog
105108
catalog:
106-
packageName: test
109+
packageName: ${PACKAGE:test}
107110
selector:
108111
matchLabels:
109-
"olm.operatorframework.io/metadata.name": test-catalog
112+
"olm.operatorframework.io/metadata.name": ${CATALOG:test}
110113
"""
111114
And ClusterExtension reports Progressing as True with Reason Retrying
112115
And ClusterExtension reports Installed as False
113-
When resource "deployment/test-operator" is removed
116+
When resource "deployment/test-operator-${SCENARIO_ID}" is removed
114117
Then ClusterExtension is available
115118
And ClusterExtension reports Progressing as True with Reason Succeeded
116119
And ClusterExtension reports Installed as True
@@ -132,26 +135,26 @@ Feature: Recover cluster extension from errors that might occur during its lifet
132135
source:
133136
sourceType: Catalog
134137
catalog:
135-
packageName: test
138+
packageName: ${PACKAGE:test}
136139
selector:
137140
matchLabels:
138-
"olm.operatorframework.io/metadata.name": test-catalog
141+
"olm.operatorframework.io/metadata.name": ${CATALOG:test}
139142
"""
140143
And ClusterExtension reports Progressing as True with Reason Retrying and Message includes:
141144
"""
142-
error for resolved bundle "test-operator.1.2.0" with version "1.2.0": creating new Revision: pre-authorization failed: service account requires the following permissions to manage cluster extension:
145+
pre-authorization failed: service account requires the following permissions to manage cluster extension:
143146
"""
144147
And ClusterExtension reports Progressing as True with Reason Retrying and Message includes:
145148
"""
146-
Namespace:"" APIGroups:[apiextensions.k8s.io] Resources:[customresourcedefinitions] ResourceNames:[olme2etests.olm.operatorframework.io] Verbs:[delete,get,patch,update]
149+
Namespace:"" APIGroups:[apiextensions.k8s.io] Resources:[customresourcedefinitions] ResourceNames:[e2e-${SCENARIO_ID}tests.e2e-${SCENARIO_ID}.e2e.operatorframework.io] Verbs:[delete,get,patch,update]
147150
"""
148151
When ServiceAccount "olm-sa" with needed permissions is available in test namespace
149152
Then ClusterExtension is available
150153
And ClusterExtension reports Progressing as True with Reason Succeeded
151154
And ClusterExtension reports Installed as True
152155

153156
# CATALOG DELETION RESILIENCE SCENARIOS
154-
157+
155158
Scenario: Auto-healing continues working after catalog deletion
156159
# This test proves that extensions continue to auto-heal (restore deleted resources) even when
157160
# their source catalog is unavailable. We verify this by:
@@ -177,19 +180,19 @@ Feature: Recover cluster extension from errors that might occur during its lifet
177180
source:
178181
sourceType: Catalog
179182
catalog:
180-
packageName: test
183+
packageName: ${PACKAGE:test}
181184
selector:
182185
matchLabels:
183-
"olm.operatorframework.io/metadata.name": test-catalog
186+
"olm.operatorframework.io/metadata.name": ${CATALOG:test}
184187
"""
185188
And ClusterExtension is rolled out
186189
And ClusterExtension is available
187-
And resource "deployment/test-operator" is available
188-
And resource "configmap/test-configmap" is available
189-
When ClusterCatalog "test" is deleted
190-
And resource "configmap/test-configmap" is removed
191-
Then resource "configmap/test-configmap" is eventually restored
192-
And resource "deployment/test-operator" is available
190+
And resource "deployment/test-operator-${SCENARIO_ID}" is available
191+
And resource "configmap/test-configmap-${SCENARIO_ID}" is available
192+
When catalog "test" is deleted
193+
And resource "configmap/test-configmap-${SCENARIO_ID}" is removed
194+
Then resource "configmap/test-configmap-${SCENARIO_ID}" is eventually restored
195+
And resource "deployment/test-operator-${SCENARIO_ID}" is available
193196

194197
Scenario: Spec changes are allowed when catalog is unavailable
195198
# This test proves that users can modify extension configuration (non-version changes) even when
@@ -217,14 +220,14 @@ Feature: Recover cluster extension from errors that might occur during its lifet
217220
source:
218221
sourceType: Catalog
219222
catalog:
220-
packageName: test
223+
packageName: ${PACKAGE:test}
221224
selector:
222225
matchLabels:
223-
"olm.operatorframework.io/metadata.name": test-catalog
226+
"olm.operatorframework.io/metadata.name": ${CATALOG:test}
224227
"""
225228
And ClusterExtension is rolled out
226229
And ClusterExtension is available
227-
And ClusterCatalog "test" is deleted
230+
And catalog "test" is deleted
228231
When ClusterExtension is updated to add preflight config
229232
"""
230233
apiVersion: olm.operatorframework.io/v1
@@ -242,10 +245,10 @@ Feature: Recover cluster extension from errors that might occur during its lifet
242245
source:
243246
sourceType: Catalog
244247
catalog:
245-
packageName: test
248+
packageName: ${PACKAGE:test}
246249
selector:
247250
matchLabels:
248-
"olm.operatorframework.io/metadata.name": test-catalog
251+
"olm.operatorframework.io/metadata.name": ${CATALOG:test}
249252
"""
250253
And ClusterExtension latest generation has been reconciled
251254
And ClusterExtension reports Progressing as True with Reason Succeeded

test/e2e/features/status.feature

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ Feature: Report status of the managed ClusterExtension workload
55

66
Background:
77
Given OLM is available
8-
And ClusterCatalog "test" serves bundles
8+
And an image registry is available
9+
And a catalog "test" with packages:
10+
| package | version | channel | replaces | contents |
11+
| test | 1.0.0 | alpha | | CRD, Deployment, ConfigMap |
912
And ServiceAccount "olm-sa" with needed permissions is available in test namespace
1013
And ClusterExtension is applied
1114
"""
@@ -20,26 +23,26 @@ Feature: Report status of the managed ClusterExtension workload
2023
source:
2124
sourceType: Catalog
2225
catalog:
23-
packageName: test
26+
packageName: ${PACKAGE:test}
2427
selector:
2528
matchLabels:
26-
"olm.operatorframework.io/metadata.name": test-catalog
29+
"olm.operatorframework.io/metadata.name": ${CATALOG:test}
2730
version: 1.0.0
2831
"""
2932
And ClusterExtension is rolled out
3033
And ClusterExtension is available
3134

3235
@BoxcutterRuntime
3336
Scenario: Report availability change when managed workload is not ready
34-
When resource "deployment/test-operator" reports as not ready
37+
When deployment "test-operator-${SCENARIO_ID}" reports as not ready
3538
Then ClusterExtension reports Available as False with Reason ProbeFailure
3639
And ClusterObjectSet "${NAME}-1" reports Available as False with Reason ProbeFailure
3740

3841
@BoxcutterRuntime
3942
Scenario: Report availability change when managed workload restores its readiness
40-
Given resource "deployment/test-operator" reports as not ready
43+
Given deployment "test-operator-${SCENARIO_ID}" reports as not ready
4144
And ClusterExtension reports Available as False with Reason ProbeFailure
4245
And ClusterObjectSet "${NAME}-1" reports Available as False with Reason ProbeFailure
43-
When resource "deployment/test-operator" reports as ready
46+
When deployment "test-operator-${SCENARIO_ID}" reports as ready
4447
Then ClusterExtension is available
45-
And ClusterObjectSet "${NAME}-1" reports Available as True with Reason ProbesSucceeded
48+
And ClusterObjectSet "${NAME}-1" reports Available as True with Reason ProbesSucceeded

test/e2e/features/uninstall.feature

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ Feature: Uninstall ClusterExtension
55

66
Background:
77
Given OLM is available
8-
And ClusterCatalog "test" serves bundles
8+
And an image registry is available
9+
And a catalog "test" with packages:
10+
| package | version | channel | replaces | contents |
11+
| test | 1.2.0 | beta | | CRD, Deployment, ConfigMap |
912
And ServiceAccount "olm-sa" with needed permissions is available in test namespace
1013
And ClusterExtension is applied
1114
"""
@@ -20,12 +23,12 @@ Feature: Uninstall ClusterExtension
2023
source:
2124
sourceType: Catalog
2225
catalog:
23-
packageName: test
26+
packageName: ${PACKAGE:test}
2427
selector:
2528
matchLabels:
26-
"olm.operatorframework.io/metadata.name": test-catalog
29+
"olm.operatorframework.io/metadata.name": ${CATALOG:test}
2730
"""
28-
And bundle "test-operator.1.2.0" is installed in version "1.2.0"
31+
And bundle "${PACKAGE:test}.1.2.0" is installed in version "1.2.0"
2932
And ClusterExtension is rolled out
3033
And ClusterExtension resources are created and labeled
3134

0 commit comments

Comments
 (0)