Skip to content

Commit 66f8672

Browse files
committed
Rename functions and skip CCM check on managed platforms
1 parent 3148520 commit 66f8672

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

test/e2e/operator_test.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,9 +2604,6 @@ func TestContainerLoggingMinLength(t *testing.T) {
26042604
}
26052605

26062606
func TestIngressControllerCustomEndpoints(t *testing.T) {
2607-
if infraConfig.Status.ControlPlaneTopology == configv1.ExternalTopologyMode {
2608-
t.Skipf("skipping TestIngressControllerCustomEndpoints test due to controlplanetopology: %v", infraConfig.Status.ControlPlaneTopology)
2609-
}
26102607
platform := infraConfig.Status.PlatformStatus
26112608
if platform == nil {
26122609
t.Fatalf("platform status is missing for infrastructure %s", infraConfig.Name)
@@ -2646,13 +2643,20 @@ func TestIngressControllerCustomEndpoints(t *testing.T) {
26462643
URL: fmt.Sprintf("https://elasticloadbalancing.%s.amazonaws.com", platform.AWS.Region),
26472644
}
26482645

2649-
oldCCMDeployment := waitForCCMReadiness(t, 5*time.Minute, "")
2650-
oldConfigHash := retrieveCCMConfigurationHash(oldCCMDeployment)
2651-
if oldConfigHash == "" {
2652-
t.Fatalf("CCM does not have a config hash, this should never happen: %v", oldCCMDeployment)
2646+
// On a non-managed environment, retrieve the current Cloud Controller Manager
2647+
// configuration hash, so later we can verify if the new configuration was applied
2648+
// as part of the infrastructure.config update
2649+
var oldConfigHash string
2650+
if infraConfig.Status.ControlPlaneTopology != configv1.ExternalTopologyMode {
2651+
oldCCMDeployment := waitForCCMAvailableAndUpdated(t, 5*time.Minute, "")
2652+
oldConfigHash = retrieveCCMConfigurationHash(oldCCMDeployment)
2653+
if oldConfigHash == "" {
2654+
t.Fatalf("CCM does not have a config hash, this should never happen: %v", oldCCMDeployment)
2655+
}
26532656
}
26542657

2655-
if err := updateInfrastructureConfigWithRetryOnConflict(t, types.NamespacedName{Name: "cluster"}, timeout, func(spec *configv1.InfrastructureSpec) {
2658+
// Wait for infrastructure status to update with custom endpoints.
2659+
if err := updateAndVerifyInfrastructureConfigWithRetry(t, types.NamespacedName{Name: "cluster"}, timeout, func(spec *configv1.InfrastructureSpec) {
26562660
spec.PlatformSpec.AWS = &configv1.AWSPlatformSpec{
26572661
ServiceEndpoints: []configv1.AWSServiceEndpoint{
26582662
route53Endpoint,
@@ -2665,22 +2669,19 @@ func TestIngressControllerCustomEndpoints(t *testing.T) {
26652669
}
26662670
defer func() {
26672671
// Remove the custom endpoints from the infrastructure config.
2668-
if err := updateInfrastructureConfigWithRetryOnConflict(t, types.NamespacedName{Name: "cluster"}, timeout, func(spec *configv1.InfrastructureSpec) {
2672+
if err := updateAndVerifyInfrastructureConfigWithRetry(t, types.NamespacedName{Name: "cluster"}, timeout, func(spec *configv1.InfrastructureSpec) {
26692673
spec.PlatformSpec.AWS = nil
26702674
}); err != nil {
26712675
t.Fatalf("failed to update infrastructure config: %v", err)
26722676
}
26732677
}()
26742678

2675-
// Wait for infrastructure status to update with custom endpoints,
2676-
// for CCM deploy to get a new configuration hash and for pods to be scheduled
2677-
// and available
2678-
// This configuration change and replicas available may take up to 5 minutes, depending on
2679-
// the environment load
2680-
2681-
// Wait for CCM to be ready with the new configuration, so we can guarantee that
2682-
// the LoadBalancer will be created correctly
2683-
_ = waitForCCMReadiness(t, 5*time.Minute, oldConfigHash)
2679+
if infraConfig.Status.ControlPlaneTopology != configv1.ExternalTopologyMode {
2680+
// Wait for CCM to be ready with the new configuration, so we can guarantee that
2681+
// the LoadBalancer will be created correctly. This assertion is not possible
2682+
// on managed control planes (eg.: hypershift or rosa)
2683+
_ = waitForCCMAvailableAndUpdated(t, 5*time.Minute, oldConfigHash)
2684+
}
26842685

26852686
// The default ingresscontroller should surface the expected status conditions.
26862687
if err := waitForIngressControllerCondition(t, kclient, 30*time.Second, defaultName, availableConditionsForIngressControllerWithLoadBalancer...); err != nil {

test/e2e/util_test.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -623,15 +623,15 @@ func updateIngressConfigSpecWithRetryOnConflict(t *testing.T, name types.Namespa
623623
})
624624
}
625625

626-
// updateInfrastructureConfigWithRetryOnConflict gets a fresh copy
626+
// updateAndVerifyInfrastructureConfigWithRetry gets a fresh copy
627627
// of the named infrastructure object, calls updateSpecFn() where
628628
// callers can modify fields of the spec, and then updates the infrastructure
629629
// config object. If there is a conflict error on update then the
630630
// complete operation of get, mutate, and update is retried until
631631
// timeout is reached.
632632
// After updating, it will check if the desired spec.Endpoints where applied to
633-
// the infraconfig
634-
func updateInfrastructureConfigWithRetryOnConflict(t *testing.T, name types.NamespacedName, timeout time.Duration, mutateSpecFn func(*configv1.InfrastructureSpec)) error {
633+
// the infrastructure config
634+
func updateAndVerifyInfrastructureConfigWithRetry(t *testing.T, name types.NamespacedName, timeout time.Duration, mutateSpecFn func(*configv1.InfrastructureSpec)) error {
635635
infraConfig := configv1.Infrastructure{}
636636
// First we apply the configuration
637637
err := wait.PollUntilContextTimeout(context.TODO(), 1*time.Second, timeout, false, func(ctx context.Context) (done bool, err error) {
@@ -680,17 +680,11 @@ func updateInfrastructureConfigWithRetryOnConflict(t *testing.T, name types.Name
680680
})
681681
}
682682

683-
// waitForCCMReadiness waits for Cloud Controller Manager to be ready.
684-
//
685-
// for infrastructure status to update with custom endpoints,
686-
//
687-
// for CCM deploy to get a new configuration hash and for pods to be scheduled
688-
// and available
689-
// This configuration change and replicas available may take up to 5 minutes, depending on
690-
// the environment load
683+
// waitForCCMAvailableAndUpdated waits for Cloud Controller Manager Deployment
684+
// to be reported as ready.
691685
// If oldConfigurationHash is not empty it will additionally verify that the configuration hash
692686
// is different between the deployments
693-
func waitForCCMReadiness(t *testing.T, timeout time.Duration, oldConfigurationHash string) appsv1.Deployment {
687+
func waitForCCMAvailableAndUpdated(t *testing.T, timeout time.Duration, oldConfigurationHash string) appsv1.Deployment {
694688
// The pooler below will never return an error, and instead it will log and try until it fails.
695689
// This avoids errors that are network errors to cause a failure on the test, and instead retries until it
696690
// is successful

0 commit comments

Comments
 (0)