Skip to content

Commit 4600e1e

Browse files
committed
test: fix webhook test race condition
The webhook test was creating the GitRepo resource after pushing content, which caused a race condition. The git push would trigger the post-receive webhook, but the GitRepo resource didn't exist yet, so the webhook was ignored. With polling disabled (24h), the GitRepo never synced. Fixed by creating the GitRepo resource first, then pushing content. This ensures the webhook can find and update the GitRepo when triggered.
1 parent fa21580 commit 4600e1e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

e2e/single-cluster/gitrepo_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,8 @@ var _ = Describe("Monitoring Git repos via HTTP for change", Label("infra-setup"
270270
return err
271271
}).ShouldNot(HaveOccurred(), out)
272272

273-
// Clone previously created repo
274-
clone, err = gh.Create(clonedir, testenv.AssetPath("gitrepo/sleeper-chart"), "examples")
275-
Expect(err).ToNot(HaveOccurred())
276-
273+
// Create the GitRepo resource first, before pushing content
274+
// This ensures the webhook will find the GitRepo when the push triggers it
277275
err = testenv.ApplyTemplate(k, testenv.AssetPath("gitrepo/gitrepo.yaml"), gitRepoTestValues{
278276
Name: gitrepoName,
279277
Repo: inClusterRepoURL,
@@ -282,6 +280,10 @@ var _ = Describe("Monitoring Git repos via HTTP for change", Label("infra-setup"
282280
TargetNamespace: targetNamespace, // to avoid conflicts with other tests
283281
})
284282
Expect(err).ToNot(HaveOccurred())
283+
284+
// Now push content, which will trigger the webhook
285+
clone, err = gh.Create(clonedir, testenv.AssetPath("gitrepo/sleeper-chart"), "examples")
286+
Expect(err).ToNot(HaveOccurred())
285287
})
286288

287289
It("updates the deployment", func() {

0 commit comments

Comments
 (0)