From 69b894d4cd8735623f485ed75a5a5b4db082a99d Mon Sep 17 00:00:00 2001 From: muhammad adil ghaffar Date: Mon, 25 Mar 2024 12:52:56 +0200 Subject: [PATCH] Fix for TestServerSideApplyWithDefaulting Signed-off-by: muhammad adil ghaffar --- .../cluster/structuredmerge/serversidepathhelper_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/controllers/topology/cluster/structuredmerge/serversidepathhelper_test.go b/internal/controllers/topology/cluster/structuredmerge/serversidepathhelper_test.go index c0d5e85a96c8..6e9b42ec0285 100644 --- a/internal/controllers/topology/cluster/structuredmerge/serversidepathhelper_test.go +++ b/internal/controllers/topology/cluster/structuredmerge/serversidepathhelper_test.go @@ -651,6 +651,11 @@ func TestServerSideApplyWithDefaulting(t *testing.T) { g.Expect(env.CleanupAndWait(ctx, kct.DeepCopy())).To(Succeed()) }() + // Wait until the initial KubeadmConfigTemplate is visible in the local cache. Otherwise the test fails below. + g.Eventually(ctx, func(g Gomega) { + g.Expect(env.Get(ctx, client.ObjectKeyFromObject(kct), &bootstrapv1.KubeadmConfigTemplate{})).To(Succeed()) + }, 5*time.Second).Should(Succeed()) + // Enable the new defaulting logic (i.e. simulate the Cluster API update). // The webhook will default the users field to `[{Name: "default-user"}]`. g.Expect(env.Create(ctx, mutatingWebhookConfiguration)).To(Succeed())