From bef97cb76ca7f5f3aaad3ab9f01282b4b76f2baf Mon Sep 17 00:00:00 2001 From: Andrea Mazzotti Date: Thu, 12 Dec 2024 15:17:33 +0100 Subject: [PATCH] Increase timeout when waiting for reconciler Signed-off-by: Andrea Mazzotti --- .../capiprovider_controller_test.go | 18 +++++++++--------- test/framework/const.go | 4 ++++ test/framework/turtles.go | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/internal/controllers/capiprovider_controller_test.go b/internal/controllers/capiprovider_controller_test.go index a7fd9d32..423a538b 100644 --- a/internal/controllers/capiprovider_controller_test.go +++ b/internal/controllers/capiprovider_controller_test.go @@ -70,8 +70,8 @@ var _ = Describe("Reconcile CAPIProvider", func() { dockerProvider := objectFromKey(client.ObjectKeyFromObject(provider), &operatorv1.InfrastructureProvider{}) dockerSecret := objectFromKey(client.ObjectKeyFromObject(provider), &corev1.Secret{}) - Eventually(Object(dockerProvider)).ShouldNot(BeNil()) - Eventually(Object(dockerSecret)).Should(HaveField("Data", Equal(map[string][]byte{ + Eventually(Object(dockerProvider)).WithTimeout(5 * time.Second).ShouldNot(BeNil()) + Eventually(Object(dockerSecret)).WithTimeout(5 * time.Second).Should(HaveField("Data", Equal(map[string][]byte{ "CLUSTER_TOPOLOGY": []byte("true"), "EXP_CLUSTER_RESOURCE_SET": []byte("true"), "EXP_MACHINE_POOL": []byte("true"), @@ -87,7 +87,7 @@ var _ = Describe("Reconcile CAPIProvider", func() { }} Expect(cl.Create(ctx, provider)).ToNot(HaveOccurred()) - Eventually(Object(provider)).Should( + Eventually(Object(provider)).WithTimeout(5 * time.Second).Should( HaveField("Status.Name", Equal(provider.Name))) }) @@ -101,7 +101,7 @@ var _ = Describe("Reconcile CAPIProvider", func() { }} Expect(cl.Create(ctx, provider)).ToNot(HaveOccurred()) - Eventually(Object(provider)).Should( + Eventually(Object(provider)).WithTimeout(5 * time.Second).Should( HaveField("Status.Name", Equal(provider.Spec.Name))) }) @@ -116,8 +116,8 @@ var _ = Describe("Reconcile CAPIProvider", func() { dockerProvider := objectFromKey(client.ObjectKeyFromObject(provider), &operatorv1.InfrastructureProvider{}) dockerSecret := objectFromKey(client.ObjectKeyFromObject(provider), &corev1.Secret{}) - Eventually(Object(dockerProvider)).ShouldNot(BeNil()) - Eventually(Object(dockerSecret)).ShouldNot(BeNil()) + Eventually(Object(dockerProvider)).WithTimeout(5 * time.Second).ShouldNot(BeNil()) + Eventually(Object(dockerSecret)).WithTimeout(5 * time.Second).ShouldNot(BeNil()) Eventually(Update(provider, func() { provider.Spec.Version = "v1.2.3" @@ -126,8 +126,8 @@ var _ = Describe("Reconcile CAPIProvider", func() { } })).Should(Succeed()) - Eventually(Object(dockerProvider)).Should(HaveField("Spec.Version", Equal("v1.2.3"))) - Eventually(Object(dockerSecret)).Should(HaveField("Data", Equal(map[string][]byte{ + Eventually(Object(dockerProvider)).WithTimeout(5 * time.Second).Should(HaveField("Spec.Version", Equal("v1.2.3"))) + Eventually(Object(dockerSecret)).WithTimeout(5 * time.Second).Should(HaveField("Data", Equal(map[string][]byte{ "other": []byte("var"), "CLUSTER_TOPOLOGY": []byte("true"), "EXP_CLUSTER_RESOURCE_SET": []byte("true"), @@ -177,7 +177,7 @@ var _ = Describe("Reconcile CAPIProvider", func() { } })).Should(Succeed()) - Eventually(Object(doSecret)).Should(HaveField("Data", Equal(map[string][]byte{ + Eventually(Object(doSecret)).WithTimeout(5 * time.Second).Should(HaveField("Data", Equal(map[string][]byte{ "EXP_MACHINE_POOL": []byte("true"), "CLUSTER_TOPOLOGY": []byte("false"), "EXP_CLUSTER_RESOURCE_SET": []byte("false"), diff --git a/test/framework/const.go b/test/framework/const.go index 5231842e..7cb51ae8 100644 --- a/test/framework/const.go +++ b/test/framework/const.go @@ -16,6 +16,8 @@ limitations under the License. package framework +import "time" + const ( // DefaultNamespace is the name of the default Kubernetes namespace. DefaultNamespace = "default" @@ -27,4 +29,6 @@ const ( MagicDNS = "sslip.io" // DefaulRancherTurtlesNamespace is the name of the default namespace for Rancher Turtles. DefaultRancherTurtlesNamespace = "rancher-turtles-system" + // Default reconciliation timeout. + DefaultReconciliationTimeout = 5 * time.Second ) diff --git a/test/framework/turtles.go b/test/framework/turtles.go index fd6a65f3..38c5703e 100644 --- a/test/framework/turtles.go +++ b/test/framework/turtles.go @@ -50,7 +50,7 @@ func WaitForCAPIProviderRollout(ctx context.Context, input WaitForCAPIProviderRo g.Expect(input.Getter.Get(ctx, key, capiProvider)).To(Succeed()) g.Expect(capiProvider.Status.InstalledVersion).ToNot(BeNil()) g.Expect(*capiProvider.Status.InstalledVersion).To(Equal(input.Version)) - }, intervals...).Should(Succeed(), + }, intervals...).WithTimeout(DefaultReconciliationTimeout).Should(Succeed(), "Failed to get CAPIProvider %s with version %s. Last observed: %s", key.String(), input.Version, klog.KObj(capiProvider)) } @@ -66,7 +66,7 @@ func WaitForCAPIProviderRollout(ctx context.Context, input WaitForCAPIProviderRo } } g.Expect(found).To(BeTrue()) - }, intervals...).Should(Succeed(), + }, intervals...).WithTimeout(DefaultReconciliationTimeout).Should(Succeed(), "Failed to get Deployment %s with image %s. Last observed: %s", client.ObjectKeyFromObject(input.Deployment).String(), input.Image, klog.KObj(input.Deployment)) }