Skip to content

Commit 1d9ba4e

Browse files
committed
e2e: remove old static test infrastructure and clean up
1 parent dcf0187 commit 1d9ba4e

File tree

54 files changed

+135
-3425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+135
-3425
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ e2e: #EXHELP Run the e2e tests.
260260
go test -count=1 -v ./test/e2e/features_test.go -timeout=$(E2E_TIMEOUT)
261261

262262
export CLUSTER_REGISTRY_HOST := docker-registry.operator-controller-e2e.svc:5000
263-
export LOCAL_REGISTRY_HOST := localhost:30000
264263
.PHONY: extension-developer-e2e
265264
extension-developer-e2e: export OPERATOR_SDK := $(OPERATOR_SDK)
266265
extension-developer-e2e: export CONTAINER_RUNTIME := $(CONTAINER_RUNTIME)

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ require (
141141
github.com/google/gnostic-models v0.7.1 // indirect
142142
github.com/google/uuid v1.6.0 // indirect
143143
github.com/gorilla/mux v1.8.1 // indirect
144+
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
144145
github.com/gosuri/uitable v0.0.4 // indirect
145146
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
146147
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7 // indirect
@@ -172,6 +173,7 @@ require (
172173
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
173174
github.com/mitchellh/reflectwalk v1.0.2 // indirect
174175
github.com/moby/locker v1.0.1 // indirect
176+
github.com/moby/spdystream v0.5.0 // indirect
175177
github.com/moby/sys/capability v0.4.0 // indirect
176178
github.com/moby/sys/mountinfo v0.7.2 // indirect
177179
github.com/moby/sys/sequential v0.6.0 // indirect
@@ -182,6 +184,7 @@ require (
182184
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
183185
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
184186
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
187+
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
185188
github.com/nxadm/tail v1.4.11 // indirect
186189
github.com/onsi/gomega v1.39.1 // indirect
187190
github.com/opencontainers/runtime-spec v1.3.0 // indirect

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpH
3434
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
3535
github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
3636
github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
37+
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
38+
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
3739
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
3840
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
3941
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -274,6 +276,8 @@ github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyE
274276
github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=
275277
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
276278
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
279+
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 h1:JeSE6pjso5THxAzdVpqr6/geYxZytqFMBCOtn/ujyeo=
280+
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674/go.mod h1:r4w70xmWCQKmi1ONH4KIaBptdivuRPyosB9RmPlGEwA=
277281
github.com/gosuri/uitable v0.0.4 h1:IG2xLKRvErL3uhY6e1BylFzG+aJiwQviDDTfOKeKTpY=
278282
github.com/gosuri/uitable v0.0.4/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo=
279283
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA=
@@ -369,6 +373,8 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx
369373
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
370374
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=
371375
github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc=
376+
github.com/moby/spdystream v0.5.0 h1:7r0J1Si3QO/kjRitvSLVVFUjxMEb/YLj6S9FF62JBCU=
377+
github.com/moby/spdystream v0.5.0/go.mod h1:xBAYlnt/ay+11ShkdFKNAG7LsyK/tmNBVvVOwrfMgdI=
372378
github.com/moby/sys/capability v0.4.0 h1:4D4mI6KlNtWMCM1Z/K0i7RV1FkX+DBDHKVJpCndZoHk=
373379
github.com/moby/sys/capability v0.4.0/go.mod h1:4g9IK291rVkms3LKCDOoYlnV8xKwoDTpIrNEE35Wq0I=
374380
github.com/moby/sys/mountinfo v0.7.2 h1:1shs6aH5s4o5H2zQLn796ADW1wMrIwHsyJ2v9KouLrg=
@@ -393,6 +399,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
393399
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
394400
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
395401
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
402+
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
403+
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
396404
github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
397405
github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc=
398406
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=

kind-config/kind-config-2node.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ kind: Cluster
33
nodes:
44
- role: control-plane
55
extraPortMappings:
6-
# e2e image registry service's NodePort
7-
- containerPort: 30000
8-
hostPort: 30000
9-
listenAddress: "127.0.0.1"
10-
protocol: tcp
116
# prometheus metrics service's NodePort
127
- containerPort: 30900
138
hostPort: 30900

kind-config/kind-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ kind: Cluster
33
nodes:
44
- role: control-plane
55
extraPortMappings:
6-
# e2e image registry service's NodePort
7-
- containerPort: 30000
8-
hostPort: 30000
9-
listenAddress: "127.0.0.1"
10-
protocol: tcp
116
# prometheus metrics service's NodePort
127
- containerPort: 30900
138
hostPort: 30900

test/e2e/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ 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-
- `LOCAL_REGISTRY_HOST`: Local registry host for pushing catalog images (default: `localhost:30000`)
281280
- `CLUSTER_REGISTRY_HOST`: In-cluster registry host for pulling catalog images
282281

283282
## Design Patterns

test/e2e/steps/steps.go

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,23 @@ var (
7272
}
7373
return testregistry.Deploy(context.Background(), cfg, testregistry.DefaultNamespace, testregistry.DefaultName)
7474
})
75+
startRegistryPortForward = sync.OnceValues(func() (string, error) {
76+
if err := deployImageRegistry(); err != nil {
77+
return "", err
78+
}
79+
cfg, err := ctrl.GetConfig()
80+
if err != nil {
81+
return "", fmt.Errorf("failed to get kubeconfig: %w", err)
82+
}
83+
// Port-forward lives for the duration of the test process;
84+
// the stop function is not needed because the goroutine is
85+
// cleaned up on process exit.
86+
localAddr, _, err := testregistry.PortForward(context.Background(), cfg, testregistry.DefaultNamespace, testregistry.DefaultName)
87+
if err != nil {
88+
return "", fmt.Errorf("failed to start port-forward to registry: %w", err)
89+
}
90+
return localAddr, nil
91+
})
7592
)
7693

7794
func RegisterSteps(sc *godog.ScenarioContext) {
@@ -211,18 +228,19 @@ func projectRootDir() string {
211228
}
212229
}
213230

214-
// registryHosts returns the local and in-cluster registry addresses from environment
215-
// variables, falling back to defaults suitable for kind clusters.
216-
func registryHosts() (string, string) {
217-
local := os.Getenv("LOCAL_REGISTRY_HOST")
218-
if local == "" {
219-
local = "localhost:30000"
231+
// registryHosts returns the local and in-cluster registry addresses.
232+
// The local address is obtained by port-forwarding to the in-cluster registry,
233+
// which works regardless of the cluster's network topology.
234+
func registryHosts() (string, string, error) {
235+
local, err := startRegistryPortForward()
236+
if err != nil {
237+
return "", "", fmt.Errorf("failed to get local registry address: %w", err)
220238
}
221239
cluster := os.Getenv("CLUSTER_REGISTRY_HOST")
222240
if cluster == "" {
223241
cluster = "docker-registry.operator-controller-e2e.svc.cluster.local:5000"
224242
}
225-
return local, cluster
243+
return local, cluster, nil
226244
}
227245

228246
// ImageRegistryIsAvailable ensures the in-cluster image registry is deployed and ready.
@@ -1387,7 +1405,10 @@ func CatalogVersionWithPackages(ctx context.Context, catalogUserName, version st
13871405
}
13881406

13891407
cat := catalog.NewCatalog(catalogUserName, sc.id, pkgOpts...)
1390-
localRegistry, clusterRegistry := registryHosts()
1408+
localRegistry, clusterRegistry, err := registryHosts()
1409+
if err != nil {
1410+
return err
1411+
}
13911412

13921413
result, err := cat.Build(ctx, version, localRegistry, clusterRegistry)
13931414
if err != nil {
@@ -1437,7 +1458,10 @@ func ScenarioCatalogIsUpdatedToVersion(ctx context.Context, catalogUserName, ver
14371458

14381459
// ScenarioCatalogTagImage tags an existing per-scenario catalog image with a new tag.
14391460
func ScenarioCatalogTagImage(ctx context.Context, catalogUserName, oldTag, newTag string) error {
1440-
localRegistry, _ := registryHosts()
1461+
localRegistry, _, err := registryHosts()
1462+
if err != nil {
1463+
return err
1464+
}
14411465
sc := scenarioCtx(ctx)
14421466
imageRef := fmt.Sprintf("%s/e2e/%s-catalog-%s:%s", localRegistry, catalogUserName, sc.id, oldTag)
14431467
return crane.Tag(imageRef, newTag, crane.Insecure)
@@ -1534,7 +1558,10 @@ func CatalogWithPackages(ctx context.Context, catalogUserName string, table *god
15341558
}
15351559

15361560
cat := catalog.NewCatalog(catalogUserName, sc.id, pkgOpts...)
1537-
localRegistry, clusterRegistry := registryHosts()
1561+
localRegistry, clusterRegistry, err := registryHosts()
1562+
if err != nil {
1563+
return err
1564+
}
15381565

15391566
result, err := cat.Build(ctx, "v1", localRegistry, clusterRegistry)
15401567
if err != nil {

test/extension-developer-e2e/extension_developer_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,27 @@ const (
2929
)
3030

3131
func TestMain(m *testing.M) {
32+
ctx := context.Background()
3233
cfg := ctrl.GetConfigOrDie()
33-
if err := testregistry.Deploy(context.Background(), cfg, testregistry.DefaultNamespace, testregistry.DefaultName); err != nil {
34+
if err := testregistry.Deploy(ctx, cfg, testregistry.DefaultNamespace, testregistry.DefaultName); err != nil {
3435
panic(fmt.Sprintf("failed to deploy image registry: %v", err))
3536
}
3637

38+
// Port-forward lives for the duration of the test process;
39+
// the stop function is not needed because the goroutine is
40+
// cleaned up on process exit.
41+
localAddr, _, err := testregistry.PortForward(ctx, cfg, testregistry.DefaultNamespace, testregistry.DefaultName)
42+
if err != nil {
43+
panic(fmt.Sprintf("failed to port-forward to registry: %v", err))
44+
}
45+
3746
clusterRegistryHost := os.Getenv("CLUSTER_REGISTRY_HOST")
3847
if clusterRegistryHost == "" {
3948
panic("CLUSTER_REGISTRY_HOST environment variable must be set")
4049
}
4150

4251
// Set env vars for setup.sh — single source of truth
52+
os.Setenv("LOCAL_REGISTRY_HOST", localAddr)
4353
os.Setenv("CATALOG_TAG", catalogTag)
4454
os.Setenv("REG_PKG_NAME", regPkgName)
4555

test/helpers/feature_gates.go

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)