@@ -27,8 +27,11 @@ import (
2727)
2828
2929const (
30- artifactName = "operator-controller-e2e"
31- pollDuration = time .Minute
30+ artifactName = "operator-controller-e2e"
31+ // pollDuration is set to 3 minutes to account for leader election time in multi-replica deployments.
32+ // In the worst case (previous leader crashed), leader election can take up to 163 seconds
33+ // (LeaseDuration: 137s + RetryPeriod: 26s). Adding buffer for reconciliation time.
34+ pollDuration = 3 * time .Minute
3235 pollInterval = time .Second
3336 testCatalogRefEnvVar = "CATALOG_IMG"
3437 testCatalogName = "test-catalog"
@@ -169,18 +172,19 @@ location = "docker-registry.operator-controller-e2e.svc.cluster.local:5000"`,
169172 require .NoError (ct , c .Get (context .Background (), types.NamespacedName {Name : clusterExtension .Name }, clusterExtension ))
170173 }, 2 * time .Minute , pollInterval )
171174
172- // Give the check 2 minutes instead of the typical 1 for the pod's
173- // files to update from the configmap change.
175+ // Give the check extra time for the pod's files to update from the configmap change.
174176 // The theoretical max time is the kubelet sync period of 1 minute +
175- // ConfigMap cache TTL of 1 minute = 2 minutes
177+ // ConfigMap cache TTL of 1 minute = 2 minutes.
178+ // With multi-replica deployments, add leader election time (up to 163s in worst case).
179+ // Total: 2 min (ConfigMap) + 2.7 min (leader election) + buffer = 5 minutes
176180 t .Log ("By eventually reporting progressing as True" )
177181 require .EventuallyWithT (t , func (ct * assert.CollectT ) {
178182 require .NoError (ct , c .Get (context .Background (), types.NamespacedName {Name : clusterExtension .Name }, clusterExtension ))
179183 cond := apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1 .TypeProgressing )
180184 require .NotNil (ct , cond )
181185 require .Equal (ct , metav1 .ConditionTrue , cond .Status )
182186 require .Equal (ct , ocv1 .ReasonSucceeded , cond .Reason )
183- }, 2 * time .Minute , pollInterval )
187+ }, 5 * time .Minute , pollInterval )
184188
185189 t .Log ("By eventually installing the package successfully" )
186190 require .EventuallyWithT (t , func (ct * assert.CollectT ) {
@@ -655,6 +659,8 @@ func TestClusterExtensionRecoversFromNoNamespaceWhenFailureFixed(t *testing.T) {
655659 // backoff of this eventually check we MUST ensure we do not touch the ClusterExtension
656660 // after creating int the Namespace and ServiceAccount.
657661 t .Log ("By eventually installing the package successfully" )
662+ // Use 5 minutes for recovery tests to account for exponential backoff after repeated failures
663+ // plus leader election time (up to 163s in worst case)
658664 require .EventuallyWithT (t , func (ct * assert.CollectT ) {
659665 require .NoError (ct , c .Get (context .Background (), types.NamespacedName {Name : clusterExtension .Name }, clusterExtension ))
660666 cond := apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1 .TypeInstalled )
@@ -663,7 +669,7 @@ func TestClusterExtensionRecoversFromNoNamespaceWhenFailureFixed(t *testing.T) {
663669 require .Equal (ct , ocv1 .ReasonSucceeded , cond .Reason )
664670 require .Contains (ct , cond .Message , "Installed bundle" )
665671 require .NotEmpty (ct , clusterExtension .Status .Install )
666- }, pollDuration , pollInterval )
672+ }, 5 * time . Minute , pollInterval )
667673
668674 t .Log ("By eventually reporting Progressing == True with Reason Success" )
669675 require .EventuallyWithT (t , func (ct * assert.CollectT ) {
@@ -777,6 +783,8 @@ func TestClusterExtensionRecoversFromExistingDeploymentWhenFailureFixed(t *testi
777783 // backoff of this eventually check we MUST ensure we do not touch the ClusterExtension
778784 // after deleting the Deployment.
779785 t .Log ("By eventually installing the package successfully" )
786+ // Use 5 minutes for recovery tests to account for exponential backoff after repeated failures
787+ // plus leader election time (up to 163s in worst case)
780788 require .EventuallyWithT (t , func (ct * assert.CollectT ) {
781789 require .NoError (ct , c .Get (context .Background (), types.NamespacedName {Name : clusterExtension .Name }, clusterExtension ))
782790 cond := apimeta .FindStatusCondition (clusterExtension .Status .Conditions , ocv1 .TypeInstalled )
@@ -785,7 +793,7 @@ func TestClusterExtensionRecoversFromExistingDeploymentWhenFailureFixed(t *testi
785793 require .Equal (ct , ocv1 .ReasonSucceeded , cond .Reason )
786794 require .Contains (ct , cond .Message , "Installed bundle" )
787795 require .NotEmpty (ct , clusterExtension .Status .Install )
788- }, pollDuration , pollInterval )
796+ }, 5 * time . Minute , pollInterval )
789797
790798 t .Log ("By eventually reporting Progressing == True with Reason Success" )
791799 require .EventuallyWithT (t , func (ct * assert.CollectT ) {
0 commit comments