Skip to content

Commit c24bad0

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. This also speeds up the test significantly (~14s vs ~21s) since the webhook triggers immediately instead of waiting for timeout-based retries.
1 parent 33e74f3 commit c24bad0

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
@@ -269,10 +269,8 @@ var _ = Describe("Monitoring Git repos via HTTP for change", Label("infra-setup"
269269
return err
270270
}).ShouldNot(HaveOccurred(), out)
271271

272-
// Clone previously created repo
273-
clone, err = gh.Create(clonedir, testenv.AssetPath("gitrepo/sleeper-chart"), "examples")
274-
Expect(err).ToNot(HaveOccurred())
275-
272+
// Create the GitRepo resource first, before pushing content
273+
// This ensures the webhook will find the GitRepo when the push triggers it
276274
err = testenv.ApplyTemplate(k, testenv.AssetPath("gitrepo/gitrepo.yaml"), struct {
277275
Name string
278276
Repo string
@@ -287,6 +285,10 @@ var _ = Describe("Monitoring Git repos via HTTP for change", Label("infra-setup"
287285
targetNamespace, // to avoid conflicts with other tests
288286
})
289287
Expect(err).ToNot(HaveOccurred())
288+
289+
// Now push content, which will trigger the webhook
290+
clone, err = gh.Create(clonedir, testenv.AssetPath("gitrepo/sleeper-chart"), "examples")
291+
Expect(err).ToNot(HaveOccurred())
290292
})
291293

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

0 commit comments

Comments
 (0)