Skip to content

Commit 537e38c

Browse files
committed
e2e: add OpenShift infrastructure support for single and multi-region operator tests
Adds OpenShift as a supported cloud provider in the e2e operator test framework, enabling the full operator test suite to run on OpenShift clusters provisioned on GCP via openshift-install, for both single-region and multi-region setups.
1 parent 3432f76 commit 537e38c

11 files changed

Lines changed: 2376 additions & 59 deletions

File tree

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@
22
bin/
33
build/artifacts
44
bazel-*
5-
/vendor/
5+
/vendor/
6+
7+
# Submariner broker credentials — generated at runtime by subctl deploy-broker,
8+
# never committed. Contains service account tokens, CA certs, and PSK.
9+
broker-info.subm
10+
*.subm

Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,20 @@ test/e2e/%: bin/cockroach bin/kubectl bin/helm build/self-signer test/cluster/up
123123
$(MAKE) test/cluster/down; \
124124
exit $${EXIT_CODE:-0}
125125

126+
# E2E_MULTI_REGION_TIMEOUT controls the go test timeout for multi-region tests.
127+
# OpenShift clusters take ~40–60 min to provision, so the default is generous.
128+
# Override to a lower value (e.g. 60m) when running against faster providers.
129+
E2E_MULTI_REGION_TIMEOUT ?= 300m
130+
126131
test/e2e/multi-region: bin/cockroach bin/kubectl bin/helm build/self-signer bin/k3d bin/kind
127-
@PATH="$(PWD)/bin:${PATH}" go test -timeout 60m -v -test.run TestOperatorInMultiRegion ./tests/e2e/operator/multiRegion/... || (echo "Multi region tests failed with exit code $$?" && exit 1)
132+
@PATH="$(PWD)/bin:${PATH}" go test -timeout $(E2E_MULTI_REGION_TIMEOUT) -v -test.run TestOperatorInMultiRegion ./tests/e2e/operator/multiRegion/... || (echo "Multi region tests failed with exit code $$?" && exit 1)
133+
134+
# E2E_SINGLE_REGION_TIMEOUT controls the go test timeout for single-region tests.
135+
# OpenShift provisioning takes ~40-60 min, so override when running against it.
136+
E2E_SINGLE_REGION_TIMEOUT ?= 60m
128137

129138
test/e2e/single-region: bin/cockroach bin/kubectl bin/helm build/self-signer bin/k3d bin/kind
130-
@PATH="$(PWD)/bin:${PATH}" go test -timeout 60m -v -test.run TestOperatorInSingleRegion ./tests/e2e/operator/singleRegion/... || (echo "Single region tests failed with exit code $$?" && exit 1)
139+
@PATH="$(PWD)/bin:${PATH}" go test -timeout $(E2E_SINGLE_REGION_TIMEOUT) -v -test.run TestOperatorInSingleRegion ./tests/e2e/operator/singleRegion/... || (echo "Single region tests failed with exit code $$?" && exit 1)
131140

132141
test/e2e/migrate: bin/cockroach bin/kubectl bin/helm bin/migration-helper build/self-signer test/cluster/up/3
133142
@PATH="$(PWD)/bin:${PATH}" go test -timeout 60m -v ./tests/e2e/migrate/... || EXIT_CODE=$$?; \

tests/e2e/coredns/coredns.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,46 @@ func CoreDNSService(IpAddress *string, annotations map[string]string) *corev1.Se
148148
return svc
149149
}
150150

151+
// CoreDNSInternalService returns a ClusterIP-only Service that exposes both UDP/53 and TCP/53
152+
// to the CoreDNS pods. This is used by OpenShift so the built-in DNS operator can forward
153+
// queries via UDP (its default protocol) to our custom CoreDNS. The main LoadBalancer service
154+
// (CoreDNSService) only exposes TCP/53 due to GCP LB constraints.
155+
func CoreDNSInternalService() *corev1.Service {
156+
return &corev1.Service{
157+
TypeMeta: metav1.TypeMeta{
158+
Kind: "Service",
159+
APIVersion: "v1",
160+
},
161+
ObjectMeta: metav1.ObjectMeta{
162+
Name: "crl-core-dns-internal",
163+
Namespace: "kube-system",
164+
Labels: map[string]string{
165+
"k8s-app": "kube-dns",
166+
},
167+
},
168+
Spec: corev1.ServiceSpec{
169+
Type: corev1.ServiceTypeClusterIP,
170+
Ports: []corev1.ServicePort{
171+
{
172+
Name: "dns-udp",
173+
Port: 53,
174+
Protocol: corev1.ProtocolUDP,
175+
TargetPort: intstr.Parse("53"),
176+
},
177+
{
178+
Name: "dns-tcp",
179+
Port: 53,
180+
Protocol: corev1.ProtocolTCP,
181+
TargetPort: intstr.Parse("53"),
182+
},
183+
},
184+
Selector: map[string]string{
185+
"k8s-app": "kube-dns",
186+
},
187+
},
188+
}
189+
}
190+
151191
// CoreDNSDeployment returns coredns deployment object.
152192
func CoreDNSDeployment(replicas int32) *appsv1.Deployment {
153193
healthCheckPort := intstr.FromInt32(8080)

tests/e2e/operator/infra/common.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ import (
1818

1919
// Provider types.
2020
const (
21-
ProviderK3D = "k3d"
22-
ProviderKind = "kind"
23-
ProviderGCP = "gcp"
21+
ProviderK3D = "k3d"
22+
ProviderKind = "kind"
23+
ProviderGCP = "gcp"
24+
ProviderOpenShift = "openshift"
2425
)
2526

2627
// Common constants.
@@ -32,7 +33,8 @@ const (
3233
loadBalancerInterval = 10 * time.Second
3334
coreDNSDeploymentName = "coredns"
3435
coreDNSServiceName = "crl-core-dns"
35-
coreDNSNamespace = "kube-system"
36+
coreDNSInternalServiceName = "crl-core-dns-internal"
37+
coreDNSNamespace = "kube-system"
3638
coreDNSReplicas = 2
3739
)
3840

@@ -50,9 +52,10 @@ const (
5052

5153
// RegionCodes maps provider types to their region codes
5254
var RegionCodes = map[string][]string{
53-
ProviderK3D: {"us-east1", "us-east2"},
54-
ProviderKind: {"us-east1", "us-east2"},
55-
ProviderGCP: {"us-central1", "us-east1"},
55+
ProviderK3D: {"us-east1", "us-east2"},
56+
ProviderKind: {"us-east1", "us-east2"},
57+
ProviderGCP: {"us-central1", "us-east1"},
58+
ProviderOpenShift: {"us-central1", "us-east1"},
5659
}
5760

5861
// LoadBalancerAnnotations contains provider-specific service annotations.
@@ -62,8 +65,9 @@ var LoadBalancerAnnotations = map[string]map[string]string{
6265
"networking.gke.io/load-balancer-type": "Internal",
6366
"cloud.google.com/load-balancer-type": "Internal",
6467
},
65-
ProviderK3D: {},
66-
ProviderKind: {},
68+
ProviderK3D: {},
69+
ProviderKind: {},
70+
ProviderOpenShift: {},
6771
}
6872

6973
// NetworkConfigs defines standard network configurations for each provider and region.
@@ -216,6 +220,15 @@ func deployCoreDNSService(t *testing.T, kubectlOpts *k8s.KubectlOptions, staticI
216220
return fmt.Errorf("failed to apply CoreDNS Service: %w", err)
217221
}
218222

223+
// For OpenShift, also deploy an internal ClusterIP service
224+
if provider == ProviderOpenShift {
225+
internalSvc := coredns.CoreDNSInternalService()
226+
internalSvcYAML := coredns.ToYAML(t, internalSvc)
227+
if err := k8s.KubectlApplyFromStringE(t, kubectlOpts, internalSvcYAML); err != nil {
228+
return fmt.Errorf("failed to apply CoreDNS internal ClusterIP service: %w", err)
229+
}
230+
}
231+
219232
return nil
220233
}
221234

0 commit comments

Comments
 (0)