Skip to content

Commit 1685b5e

Browse files
authored
rosa: deflake unit test (#5)
* rosa: deflake unit test * fixup
1 parent 852783a commit 1685b5e

File tree

2 files changed

+33
-31
lines changed

2 files changed

+33
-31
lines changed

exp/controllers/rosaroleconfig_controller_test.go

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -598,38 +598,40 @@ func TestROSARoleConfigReconcileExist(t *testing.T) {
598598
// Assertions - since all resources exist, reconciliation should succeed
599599
g.Expect(errReconcile).ToNot(HaveOccurred())
600600

601-
// Sleep to ensure the status is updated
602-
time.Sleep(100 * time.Millisecond)
603-
604-
// Check the status of the ROSARoleConfig resource
605-
updatedRoleConfig := &expinfrav1.ROSARoleConfig{}
606-
err = reconciler.Client.Get(ctx, req.NamespacedName, updatedRoleConfig)
607-
g.Expect(err).ToNot(HaveOccurred())
608-
609-
// Verify that all existing account roles are preserved
610-
g.Expect(updatedRoleConfig.Status.AccountRolesRef.InstallerRoleARN).To(Equal("arn:aws:iam::123456789012:role/test-HCP-ROSA-Installer-Role"))
611-
g.Expect(updatedRoleConfig.Status.AccountRolesRef.SupportRoleARN).To(Equal("arn:aws:iam::123456789012:role/test-HCP-ROSA-Support-Role"))
612-
g.Expect(updatedRoleConfig.Status.AccountRolesRef.WorkerRoleARN).To(Equal("arn:aws:iam::123456789012:role/test-HCP-ROSA-Worker-Role"))
613-
614-
// Verify OIDC config is preserved
615-
g.Expect(updatedRoleConfig.Status.OIDCID).To(Equal("test-existing-oidc-id"))
616-
g.Expect(updatedRoleConfig.Status.OIDCProviderARN).To(Equal("arn:aws:iam::123456789012:oidc-provider/test-existing-oidc-id"))
617-
618-
// Verify operator roles are populated with existing roles
619-
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.IngressARN).To(Equal("arn:aws:iam::123456789012:role/test-openshift-ingress-operator-cloud-credentials"))
620-
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.ImageRegistryARN).To(Equal("arn:aws:iam::123456789012:role/test-openshift-image-registry-installer-cloud-credentials"))
621-
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.StorageARN).To(Equal("arn:aws:iam::123456789012:role/test-openshift-cluster-csi-drivers-ebs-cloud-credentials"))
622-
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.NetworkARN).To(Equal("arn:aws:iam::123456789012:role/test-openshift-cloud-network-config-controller-cloud-credentials"))
623-
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.KubeCloudControllerARN).To(Equal("arn:aws:iam::123456789012:role/test-kube-system-kube-controller-manager"))
624-
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.NodePoolManagementARN).To(Equal("arn:aws:iam::123456789012:role/test-kube-system-capa-controller-manager"))
625-
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.ControlPlaneOperatorARN).To(Equal("arn:aws:iam::123456789012:role/test-kube-system-control-plane-operator"))
626-
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.KMSProviderARN).To(Equal("arn:aws:iam::123456789012:role/test-kube-system-kms-provider"))
601+
var updatedRoleConfig *expinfrav1.ROSARoleConfig
602+
603+
g.Eventually(func(g Gomega) {
604+
// Check the status of the ROSARoleConfig resource
605+
updatedRoleConfig = &expinfrav1.ROSARoleConfig{}
606+
g.Expect(reconciler.Client.Get(ctx, req.NamespacedName, updatedRoleConfig)).ToNot(HaveOccurred())
607+
608+
// Verify that all existing account roles are preserved
609+
g.Expect(updatedRoleConfig.Status.AccountRolesRef.InstallerRoleARN).To(Equal("arn:aws:iam::123456789012:role/test-HCP-ROSA-Installer-Role"))
610+
g.Expect(updatedRoleConfig.Status.AccountRolesRef.SupportRoleARN).To(Equal("arn:aws:iam::123456789012:role/test-HCP-ROSA-Support-Role"))
611+
g.Expect(updatedRoleConfig.Status.AccountRolesRef.WorkerRoleARN).To(Equal("arn:aws:iam::123456789012:role/test-HCP-ROSA-Worker-Role"))
612+
613+
// Verify OIDC config is preserved
614+
g.Expect(updatedRoleConfig.Status.OIDCID).To(Equal("test-existing-oidc-id"))
615+
g.Expect(updatedRoleConfig.Status.OIDCProviderARN).To(Equal("arn:aws:iam::123456789012:oidc-provider/test-existing-oidc-id"))
616+
617+
// Verify operator roles are populated with existing roles
618+
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.IngressARN).To(Equal("arn:aws:iam::123456789012:role/test-openshift-ingress-operator-cloud-credentials"))
619+
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.ImageRegistryARN).To(Equal("arn:aws:iam::123456789012:role/test-openshift-image-registry-installer-cloud-credentials"))
620+
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.StorageARN).To(Equal("arn:aws:iam::123456789012:role/test-openshift-cluster-csi-drivers-ebs-cloud-credentials"))
621+
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.NetworkARN).To(Equal("arn:aws:iam::123456789012:role/test-openshift-cloud-network-config-controller-cloud-credentials"))
622+
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.KubeCloudControllerARN).To(Equal("arn:aws:iam::123456789012:role/test-kube-system-kube-controller-manager"))
623+
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.NodePoolManagementARN).To(Equal("arn:aws:iam::123456789012:role/test-kube-system-capa-controller-manager"))
624+
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.ControlPlaneOperatorARN).To(Equal("arn:aws:iam::123456789012:role/test-kube-system-control-plane-operator"))
625+
g.Expect(updatedRoleConfig.Status.OperatorRolesRef.KMSProviderARN).To(Equal("arn:aws:iam::123456789012:role/test-kube-system-kms-provider"))
626+
}).Should(Succeed())
627627

628628
// Should have a condition indicating success - expect Ready condition to be True
629-
readyCondition := v1beta1conditions.Get(updatedRoleConfig, expinfrav1.RosaRoleConfigReadyCondition)
630-
g.Expect(readyCondition).ToNot(BeNil())
631-
g.Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue))
632-
g.Expect(readyCondition.Reason).To(Equal(expinfrav1.RosaRoleConfigCreatedReason))
629+
g.Eventually(func(g Gomega) {
630+
readyCondition := v1beta1conditions.Get(updatedRoleConfig, expinfrav1.RosaRoleConfigReadyCondition)
631+
g.Expect(readyCondition).ToNot(BeNil())
632+
g.Expect(readyCondition.Status).To(Equal(corev1.ConditionTrue))
633+
g.Expect(readyCondition.Reason).To(Equal(expinfrav1.RosaRoleConfigCreatedReason))
634+
}).Should(Succeed())
633635
}
634636

635637
func TestROSARoleConfigReconcileDelete(t *testing.T) {

test/e2e/suites/unmanaged/unmanaged_CAPI_clusterclass_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ var _ = ginkgo.Context("[unmanaged] [Cluster API Framework] [ClusterClass]", fun
117117
// ControlPlaneTemplate of the ClusterClass after the initial Cluster creation.
118118
// The test verifies that these fields are rolled out to the ControlPlane.
119119
ModifyControlPlaneFields: map[string]interface{}{
120-
"spec.machineTemplate.spec.deletion.nodeDrainTimeoutSeconds": ptr.To[int32](10),
120+
"spec.machineTemplate.spec.deletion.nodeDrainTimeoutSeconds": int64(10),
121121
},
122122
// ModifyMachineDeploymentBootstrapConfigTemplateFields are the fields which will be set on the
123123
// BootstrapConfigTemplate of all MachineDeploymentClasses of the ClusterClass after the initial Cluster creation.

0 commit comments

Comments
 (0)