Skip to content

Commit 75bb2ac

Browse files
committed
Refactored OTE and added new 3CMO OTE binary
1 parent 6a3101c commit 75bb2ac

17 files changed

Lines changed: 1225 additions & 80 deletions

File tree

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.25-openshift-4.22 AS
22
WORKDIR /go/src/github.com/openshift/cluster-cloud-controller-manager-operator
33
COPY . .
44
RUN make build &&\
5-
gzip /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/bin/cloud-controller-manager-aws-tests-ext
5+
gzip /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/openshift-tests/bin/cloud-controller-manager-aws-tests-ext &&\
6+
gzip /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/openshift-tests/bin/cluster-cloud-controller-manager-operator-tests-ext
67

78
FROM registry.ci.openshift.org/ocp/4.22:base-rhel9
89
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/bin/cluster-controller-manager-operator .
910
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/bin/config-sync-controllers .
1011
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/bin/azure-config-credentials-injector .
1112
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/manifests manifests
12-
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/bin/cloud-controller-manager-aws-tests-ext.gz /usr/bin/cloud-controller-manager-aws-tests-ext.gz
13+
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/openshift-tests/bin/cloud-controller-manager-aws-tests-ext.gz /usr/bin/cloud-controller-manager-aws-tests-ext.gz
14+
COPY --from=builder /go/src/github.com/openshift/cluster-cloud-controller-manager-operator/openshift-tests/bin/cluster-cloud-controller-manager-operator-tests-ext.gz /usr/bin/cluster-cloud-controller-manager-operator-tests-ext.gz
1315

1416
LABEL io.openshift.release.operator true

Makefile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
99
CONTROLLER_GEN = go run ${PROJECT_DIR}/vendor/sigs.k8s.io/controller-tools/cmd/controller-gen
1010
ENVTEST = go run ${PROJECT_DIR}/vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest
1111
GOLANGCI_LINT = go run ${PROJECT_DIR}/vendor/github.com/golangci/golangci-lint/v2/cmd/golangci-lint
12+
REPO_PATH ?= github.com/openshift/cluster-cloud-controller-manager-operator
1213

1314
HOME ?= /tmp/kubebuilder-testing
1415
ifeq ($(HOME), /)
@@ -37,7 +38,8 @@ unit:
3738
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path --bin-dir $(PROJECT_DIR)/bin --index https://raw.githubusercontent.com/openshift/api/master/envtest-releases.yaml)" ./hack/ci-test.sh
3839

3940
# Build operator binaries
40-
build: operator config-sync-controllers azure-config-credentials-injector cloud-controller-manager-aws-tests-ext
41+
.PHONY: build
42+
build: operator config-sync-controllers azure-config-credentials-injector cloud-controller-manager-aws-tests-ext cluster-cloud-controller-manager-operator-tests-ext
4143

4244
operator:
4345
go build -o bin/cluster-controller-manager-operator cmd/cluster-cloud-controller-manager-operator/main.go
@@ -49,12 +51,16 @@ azure-config-credentials-injector:
4951
go build -o bin/azure-config-credentials-injector cmd/azure-config-credentials-injector/main.go
5052

5153
cloud-controller-manager-aws-tests-ext:
52-
cd cmd/cloud-controller-manager-aws-tests-ext && \
53-
GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) GOPROXY=$(GOPROXY) go build \
54-
-trimpath \
55-
-ldflags="$(LDFLAGS)" \
56-
-o=../../bin/cloud-controller-manager-aws-tests-ext .
54+
cd openshift-tests/aws-tests && \
55+
mkdir -p ../bin && \
56+
go build $(GOGCFLAGS) -o "../bin/cloud-controller-manager-aws-tests-ext" \
57+
-trimpath -ldflags "$(LD_FLAGS)" .
5758

59+
cluster-cloud-controller-manager-operator-tests-ext:
60+
cd openshift-tests/operator-tests && \
61+
mkdir -p ../bin && \
62+
go build $(GOGCFLAGS) -o "../bin/cluster-cloud-controller-manager-operator-tests-ext" \
63+
-trimpath -ldflags "$(LD_FLAGS)" .
5864

5965
# Run against the configured Kubernetes cluster in ~/.kube/config
6066
run: verify manifests
@@ -82,9 +88,7 @@ lint:
8288
# Run go mod
8389
.PHONY: vendor
8490
vendor:
85-
go mod tidy
86-
go mod vendor
87-
go mod verify
91+
hack/go-mod.sh
8892

8993
# Generate code
9094
generate:

cmd/cloud-controller-manager-aws-tests-ext/go.mod

Whitespace-only changes.

openshift-tests/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Binaries
2+
/bin/
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
9+
# Test binary, built with `go test -c`
10+
*.test
11+
12+
# Output of the go coverage tool
13+
*.out

openshift-tests/README.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# OpenShift Cloud Controller Manager Operator Tests
2+
3+
This directory contains OpenShift Tests Extension (OTE) binaries for testing the cluster-cloud-controller-manager-operator.
4+
5+
## Structure
6+
7+
The test suite is organized into separate sub-projects, each with independent dependencies:
8+
9+
- **`aws-tests/`** - AWS-specific cloud controller manager tests
10+
- `e2e/aws/` - AWS-specific test implementations
11+
- `e2e/common/` - Common helper functions (feature gate checks)
12+
- `main.go` - Binary entry point
13+
- `go.mod` - Independent dependencies (includes AWS SDK)
14+
- **`operator-tests/`** - Multi-platform operator conformance tests
15+
- `e2e/operator/` - Operator test implementations
16+
- `e2e/common/` - Common helper functions (client config)
17+
- `main.go` - Binary entry point
18+
- `go.mod` - Independent dependencies (no AWS SDK)
19+
- **`bin/`** - Compiled test binaries
20+
21+
## Test Binaries
22+
23+
### 1. `cluster-cloud-controller-manager-operator-tests-ext`
24+
25+
**Purpose:** General cloud controller manager operator tests that run on multiple platforms
26+
27+
**Suites:**
28+
- `ccm/operator/conformance/parallel` - Parallel conformance tests
29+
- `ccm/operator/conformance/serial` - Serial conformance tests
30+
31+
**Test Selection:**
32+
- Platform-agnostic tests that work across cloud providers
33+
- OpenShift-specific CCM operator functionality tests
34+
- Automatically filters tests based on platform labels (e.g., `[platform:vsphere]`)
35+
36+
**Use Cases:**
37+
- General operator conformance testing
38+
- Multi-platform test runs
39+
- OpenShift-specific feature validation (e.g., VSphereMixedNodeEnv)
40+
41+
### 2. `cloud-controller-manager-aws-tests-ext`
42+
43+
**Purpose:** AWS-specific cloud controller manager tests
44+
45+
**Suite:** `ccm/aws/conformance/parallel`
46+
47+
**Test Selection:**
48+
- AWS load balancer tests (`[cloud-provider-aws-e2e] loadbalancer`)
49+
- AWS node tests (`[cloud-provider-aws-e2e] nodes`)
50+
- OpenShift AWS-specific tests (`[cloud-provider-aws-e2e-openshift]`)
51+
- Filters out ECR tests and Serial tests
52+
53+
**Platform Filter:** AWS only (`PlatformEquals("aws")`)
54+
55+
**Topology Exclusions:**
56+
- On SingleReplica topology, excludes:
57+
- "nodes should label nodes with topology network info if instance is supported"
58+
- "nodes should set zone-id topology label"
59+
60+
61+
## Test Organization
62+
63+
### AWS Tests (`aws-tests/e2e/`)
64+
65+
- `aws/helper.go` - AWS helper functions (feature gate checks, AWS clients)
66+
- `aws/loadbalancer.go` - AWS NLB and load balancer tests
67+
- `common/helper.go` - Feature gate checking (`IsFeatureEnabled`)
68+
69+
### Operator Tests (`operator-tests/e2e/`)
70+
71+
- `operator/vsphere_mixed_node.go` - VSphereMixedNodeEnv feature gate tests
72+
- `common/helper.go` - Client configuration (`NewClientConfigForTest`)
73+
74+
### Test Prefixes
75+
76+
- `[cloud-provider-aws-e2e-openshift]` - OpenShift-specific tests
77+
78+
### Feature Gates Tested
79+
80+
- `AWSServiceLBNetworkSecurityGroup` - Managed security groups for NLBs
81+
- `VSphereMixedNodeEnv` - Platform-type node labels on vSphere
82+
83+
## Development
84+
85+
### Adding New Tests
86+
87+
1. Add test files to the appropriate sub-project's `e2e/` directory:
88+
- `aws-tests/e2e/aws/` - AWS-specific tests
89+
- `aws-tests/e2e/common/` - AWS-specific shared helpers
90+
- `operator-tests/e2e/operator/` - Operator tests
91+
- `operator-tests/e2e/common/` - Operator-specific shared helpers
92+
93+
2. Import the test package in the binary's `main.go` (blank import for side effects):
94+
```go
95+
import _ "github.com/openshift/cluster-cloud-controller-manager-operator/openshift-tests/aws-tests/e2e/aws"
96+
```
97+
98+
3. Tests are automatically discovered by the OTE framework via Ginkgo suite scanning
99+
100+
**Note:** The `e2e/common/` directories are independent in each sub-project and contain only the helper functions needed by that specific binary.
101+
102+
### Building Binaries
103+
104+
```bash
105+
# From project root - build both binaries
106+
make cloud-controller-manager-aws-tests-ext cluster-cloud-controller-manager-operator-tests-ext
107+
108+
# Or build all test binaries
109+
make build
110+
111+
# Or build individually from within each sub-project
112+
cd openshift-tests/aws-tests && go build -o ../bin/cloud-controller-manager-aws-tests-ext .
113+
cd openshift-tests/operator-tests && go build -o ../bin/cluster-cloud-controller-manager-operator-tests-ext .
114+
```
115+
116+
Binaries are built to `openshift-tests/bin/`:
117+
- `cloud-controller-manager-aws-tests-ext` (~95MB)
118+
- `cluster-cloud-controller-manager-operator-tests-ext` (~85MB)
119+
120+
### Running Tests
121+
122+
The test binaries are OpenShift Tests Extension (OTE) binaries and follow the OTE command structure:
123+
124+
```bash
125+
# List available test suites
126+
./openshift-tests/bin/cloud-controller-manager-aws-tests-ext list
127+
128+
# Run a specific suite
129+
./openshift-tests/bin/cloud-controller-manager-aws-tests-ext run ccm/aws/conformance/parallel
130+
131+
# List operator tests
132+
./openshift-tests/bin/cluster-cloud-controller-manager-operator-tests-ext list
133+
134+
# Run operator tests (parallel or serial)
135+
./openshift-tests/bin/cluster-cloud-controller-manager-operator-tests-ext run ccm/operator/conformance/parallel
136+
./openshift-tests/bin/cluster-cloud-controller-manager-operator-tests-ext run ccm/operator/conformance/serial
137+
```
138+
139+
**Prerequisites:**
140+
- `KUBECONFIG` environment variable must be set
141+
- For AWS tests: AWS credentials configured (via `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY` or instance profile)
142+
- For AWS tests: `AWS_REGION` or `LEASED_RESOURCE` environment variable set
143+
144+
### Updating Dependencies
145+
146+
Each sub-project has its own `go.mod` file, allowing independent dependency management:
147+
148+
```bash
149+
# From project root - update all modules in the workspace
150+
./hack/go-mod.sh
151+
152+
# Or update a specific sub-project independently
153+
cd openshift-tests/aws-tests && go mod tidy
154+
cd openshift-tests/operator-tests && go mod tidy
155+
```
156+
157+
The `hack/go-mod.sh` script (run from project root):
158+
- Tidies all modules in the workspace (root, aws-tests, operator-tests)
159+
- Syncs workspace dependencies via `go work sync`
160+
- Re-tidies after sync to apply version bumps
161+
- Verifies all modules
162+
- Creates unified vendor directory
163+
164+
**Benefits of separate modules:**
165+
- AWS SDK updates only affect `aws-tests/` - operator tests remain stable
166+
- Each binary can update dependencies independently without blocking the other
167+
- Faster, more focused dependency updates
168+
- Reduced dependency bloat (operator tests don't pull in AWS SDK)
169+
170+
## Architecture
171+
172+
### Go Workspace
173+
174+
This directory contains multiple Go modules organized as a workspace:
175+
- Root module: `github.com/openshift/cluster-cloud-controller-manager-operator`
176+
- AWS tests: `github.com/openshift/cluster-cloud-controller-manager-operator/openshift-tests/aws-tests`
177+
- Operator tests: `github.com/openshift/cluster-cloud-controller-manager-operator/openshift-tests/operator-tests`
178+
179+
All modules are coordinated via the workspace defined in `../go.work`.
180+
181+
### OTE Framework
182+
183+
Uses OpenShift Tests Extension framework:
184+
- Test discovery via Ginkgo suite scanning
185+
- Extension registration and suite management
186+
- Platform and topology filtering
187+
- Kubernetes E2E framework integration
188+
189+
## References
190+
191+
- [OpenShift Tests Extension](https://github.com/openshift-eng/openshift-tests-extension)
192+
- [Kubernetes E2E Framework](https://github.com/kubernetes/kubernetes/tree/master/test/e2e/framework)
193+
- [Cloud Provider AWS Tests](https://github.com/kubernetes/cloud-provider-aws/tree/master/tests/e2e)

cmd/cloud-controller-manager-aws-tests-ext/e2e/helper.go renamed to openshift-tests/aws-tests/e2e/aws/helper.go

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package e2e
1+
package aws
22

33
import (
44
"context"
@@ -11,8 +11,7 @@ import (
1111
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
1212
elbv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
1313
elbv2types "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
14-
configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
15-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14+
"github.com/openshift/cluster-cloud-controller-manager-operator/openshift-tests/aws-tests/e2e/common"
1615
"k8s.io/kubernetes/test/e2e/framework"
1716
)
1817

@@ -60,64 +59,10 @@ func getAWSLoadBalancerFromDNSName(ctx context.Context, elbClient *elbv2.Client,
6059
return foundLB, nil
6160
}
6261

63-
// isFeatureEnabled checks if an OpenShift feature gate is enabled by querying the
64-
// FeatureGate resource named "cluster" using the typed OpenShift config API.
65-
//
66-
// This function uses the official OpenShift config/v1 API types for type-safe
67-
// access to feature gate information, providing better performance and maintainability
68-
// compared to dynamic client approaches.
69-
//
70-
// Parameters:
71-
// - ctx: Context for the API call
72-
// - featureName: Name of the feature gate to check (e.g., "AWSServiceLBNetworkSecurityGroup")
73-
//
74-
// Returns:
75-
// - bool: true if the feature is enabled, false if disabled or not found
76-
// - error: error if the API call fails
77-
//
78-
// Note: For HyperShift clusters, this checks the management cluster's feature gates.
79-
// To check hosted cluster feature gates, use the hosted cluster's kubeconfig.
62+
// isFeatureEnabled is a convenience wrapper around common.IsFeatureEnabled.
63+
// Deprecated: Use common.IsFeatureEnabled directly instead.
8064
func isFeatureEnabled(ctx context.Context, featureName string) (bool, error) {
81-
// Get the REST config
82-
restConfig, err := framework.LoadConfig()
83-
if err != nil {
84-
return false, fmt.Errorf("failed to load kubeconfig: %v", err)
85-
}
86-
87-
// Create typed config client (more efficient than dynamic client)
88-
configClient, err := configv1client.NewForConfig(restConfig)
89-
if err != nil {
90-
return false, fmt.Errorf("failed to create config client: %v", err)
91-
}
92-
93-
// Get the FeatureGate resource using typed API
94-
featureGate, err := configClient.FeatureGates().Get(ctx, "cluster", metav1.GetOptions{})
95-
if err != nil {
96-
return false, fmt.Errorf("failed to get FeatureGate 'cluster': %v", err)
97-
}
98-
99-
// Iterate through the feature gates status (typed structs)
100-
for _, fg := range featureGate.Status.FeatureGates {
101-
// Check enabled list
102-
for _, enabled := range fg.Enabled {
103-
if string(enabled.Name) == featureName {
104-
framework.Logf("Feature %s is enabled (version %s)", featureName, fg.Version)
105-
return true, nil
106-
}
107-
}
108-
109-
// Check disabled list
110-
for _, disabled := range fg.Disabled {
111-
if string(disabled.Name) == featureName {
112-
framework.Logf("Feature %s is disabled (version %s)", featureName, fg.Version)
113-
return false, nil
114-
}
115-
}
116-
}
117-
118-
// Feature not found in either list
119-
framework.Logf("Feature %s not found in FeatureGate status", featureName)
120-
return false, nil
65+
return common.IsFeatureEnabled(ctx, featureName)
12166
}
12267

12368
// getAWSClientEC2 creates an AWS EC2 client using default credentials configured in the environment.

cmd/cloud-controller-manager-aws-tests-ext/e2e/loadbalancer.go renamed to openshift-tests/aws-tests/e2e/aws/loadbalancer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package e2e
1+
package aws
22

33
import (
44
"context"

0 commit comments

Comments
 (0)