This file provides guidance to AI coding agents working with code in this repository.
Unified E2E test suite for ROSA and OSD. Go/Ginkgo v2 binary using OCM SDK directly for cluster lifecycle, with composable verifiers for health checks. Supports multiple cluster topologies: ROSA HCP, ROSA Classic STS, and OSD GCP.
make build # Build test binary (ginkgo build with E2Etests tag)
make test # Run all e2e tests with JUnit report
make dry-run # List tests without executing
make unit-test # Run unit tests (pkg/ only)
make lint # go vet + golangci-lint
make image # Build container image
make clean # Remove build artifacts
# Run filtered tests by topology
LABEL_FILTER="Platform:HCP" make test
LABEL_FILTER="Platform:Classic" make test
LABEL_FILTER="Platform:OSD-GCP" make test
LABEL_FILTER="Platform:HCP && Importance:Critical" make test
# Required env vars for test execution
OCM_TOKEN=$(ocm token) OCM_ENV=staging CLUSTER_ID=<id> make testpkg/config/ Config loading: YAML file < env var overrides. Includes ClusterTopology field.
pkg/labels/ Ginkgo v2 label constants (Platform, Area, Importance, Speed, Positivity)
pkg/framework/ OCM connection, cluster CRUD (HCP + Classic), topology detection, kube/dynamic clients, AWS clients
pkg/verifiers/ Composable health checks. classic.go for Classic-specific, hostedcluster.go for HCP-specific.
test/e2e/ Ginkgo test specs (build tag: E2Etests)
configs/ YAML config files per environment
| Topology | Label | Cluster Creation | Upgrade API | Worker Scaling |
|---|---|---|---|---|
| ROSA HCP | Platform:HCP |
CreateRosaHCPCluster() |
ControlPlane().UpgradePolicies() |
NodePool |
| ROSA Classic STS | Platform:Classic |
CreateRosaClassicCluster() |
UpgradePolicies() with UpgradeType("OSD") |
MachinePool |
| OSD GCP | Platform:OSD-GCP |
External (Prow) | UpgradePolicies() with UpgradeType("OSD") |
MachinePool |
The framework auto-detects topology from the OCM API via DetectClusterTopology():
- Checks
Hypershift().Enabled()and cloud provider - Override with
CLUSTER_TOPOLOGYenv var (values:hcp,classic,osd-gcp) - Input is normalized to lowercase
TestContext provides IsHCP(), IsClassic(), IsOSDGCP() for conditional test logic. These lazy-initialize topology detection on first call.
- Build tag: All test files use
//go:build E2Eteststo separate from unit tests - Suite-level singletons:
cfgandconnintest/e2e/setup.go, shared across all tests - TestContext per test:
framework.NewTestContext(cfg, conn)then callInitHCClients(),InitMCClients(), orInitAWSClients()as needed - Two verifier patterns:
ClusterVerifierinterface withRunVerifiers()for kube-client checks, standalone functions for OCM/AWS/dynamic client checks - Graceful skips: Tests skip when required access (MC, AWS) isn't configured, or when topology doesn't match
- DeferCleanup: Used for test resource cleanup (namespaces, deployments)
- Dynamic client for CRDs: ClusterOperator, HostedCluster, NodePool, RouteMonitor, VpcEndpoint are parsed from unstructured to avoid heavy API type imports
- MC/SC access (HCP only): Use
MC_KUBECONFIG/SC_KUBECONFIGenv vars orMANAGEMENT_CLUSTER_IDfor OCM credentials API - HCP namespace resolution: Automatically discovered via HostedCluster CR lookup. Skipped for Classic topology.
Tests use dual platform labels when they work on both topologies.
Multi-topology tests (labeled Platform:HCP + Platform:Classic + Platform:OSD-GCP):
- Data plane: workload, networking, storage
- Managed service: ClusterOperators
- Customer features: RBAC, ingress, log forwarding, network policies, KMS, PrivateLink, OIDC
- Management plane: OCM API health, cluster service health, cluster health indicators
- Upgrade: post-upgrade verification
HCP + Classic only (labeled Platform:HCP + Platform:Classic):
- IAM validation (AWS CloudTrail)
- Infrastructure tags (AWS EBS)
HCP-only tests (labeled Platform:HCP only):
- HostedCluster/NodePool CR health (requires MC)
- MC infrastructure: HyperShift operator, external-dns, CAPI
- SC infrastructure: ACM hub, cert-manager, Hive, MCE
- MC-based managed operators: RMO, AVO, audit-webhook
- OSDFM health
- NodePool upgrades, control plane upgrades
- HCP node pool listing
Classic-only tests (labeled Platform:Classic only):
- Classic cluster upgrade
- Classic full lifecycle (create/verify/delete)
Classic + OSD GCP tests (labeled Platform:Classic + Platform:OSD-GCP):
- MachinePool list/verify
OSD GCP-only tests (labeled Platform:OSD-GCP only):
- OSD GCP existing cluster lifecycle verification
- OSD GCP cluster upgrade
- Create
test/e2e/<name>_test.gowith//go:build E2Etestsandpackage e2e - Use suite-level
cfgandconn(don't create your own) - Apply labels: include
labels.HCP,labels.Classic, andlabels.OSDGCPif the test works across topologies. Omit labels for topologies that don't apply (e.g., AWS-specific tests should not includelabels.OSDGCP) - Create TestContext, init required clients, skip if access unavailable
- For topology-specific behavior, use
tc.IsHCP()/tc.IsClassic()/tc.IsOSDGCP()to branch or skip - Use existing verifiers from
pkg/verifiers/or create new ones - Clean up with
DeferCleanup
- For kube-client checks: implement
ClusterVerifierinterface inpkg/verifiers/ - For OCM/AWS/dynamic checks: create standalone
Verify*function (followVerifyClusterReadypattern) - Use dynamic client for any OpenShift/HyperShift CRDs to avoid API type imports
- Accept
context.Contextas first parameter and useSendContext(ctx)for cancellation support
- AWS SDK validates credentials lazily.
InitAWSClientsuses eagerRetrieve()to fail fast. - golangci-lint v2 with k8s/OCM SDK dependencies can use excessive memory (48+ GB). Use
go vetfor local validation. - Classic STS clusters take 30-45 min to provision vs 15 min for HCP.
- OSD GCP cluster creation is handled externally (Prow);
CreateOSDGCPCluster()does not exist in the framework. Tests assume a pre-provisioned cluster viaCLUSTER_ID. - OSD GCP storage tests use the cluster's default storage class (empty string) instead of the AWS-specific
gp3-csi. - OSD GCP version queries omit
rosa_enabledfilter since OSD is a separate product from ROSA.