Skip to content

Commit

Permalink
Fix flake in remote tests
Browse files Browse the repository at this point in the history
The remote target tests check that a target app is marked as unready
with an error of "not found" if it doesn't exist. But, running from
scratch, first the target will be unready because the cache for that
cluster has not synced yet, _then_ it will be unready because it's not
found. When the tests are run locally, it goes through that first
state fast enough that you probably wouldn't notice it; but in hosted
test runs (i.e., in GitHub Actions), running a test env for the remote
server is taxing enough that the flake becomes observable.

Thus: use `Eventually` here to check that it reaches that state,
rather than asserting it straight away.

Signed-off-by: Michael Bridgen <[email protected]>
  • Loading branch information
squaremo committed Nov 20, 2023
1 parent 5e11f46 commit 7d64eae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion controllers/leveltriggered/controller_remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ func TestRemoteTargets(t *testing.T) {
// the application hasn't been created, so we expect "not found"
p := getPipeline(ctx, g, client.ObjectKeyFromObject(pipeline))
g.Expect(getTargetStatus(g, p, "test", 0).Ready).NotTo(BeTrue())
g.Expect(getTargetStatus(g, p, "test", 0).Error).To(ContainSubstring("not found"))
// we can see "target cluster client not synced" before "not found"
g.Eventually(func() string {
return getTargetStatus(g, p, "test", 0).Error
}).Should(ContainSubstring("not found"))

targetNs := corev1.Namespace{}
targetNs.Name = ns.Name // newPipeline makes the target namespace the same as the pipeline namespace
Expand Down

0 comments on commit 7d64eae

Please sign in to comment.