Skip to content

Commit a695d98

Browse files
committed
Make tests run under the race detector
This fixes up a few tests that didn't run under the race detector. The reasons ranged from silly variable re-use issues that weren't required to actual bugs in our tests that we just probably accidentally didn't hit. This also enables the race detector in hack/test-all.sh
1 parent 93d6546 commit a695d98

File tree

6 files changed

+167
-79
lines changed

6 files changed

+167
-79
lines changed

hack/test-all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ setup_envs
2222

2323
header_text "running go test"
2424

25+
# TODO(directxman12): enable the race detector once the LeaderElector race condition is resolved in client-go
2526
go test ${MOD_OPT} ./... -parallel 4
2627

2728
header_text "running coverage"

pkg/cache/cache_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ func CacheTest(createCacheFunc func(config *rest.Config, opts cache.Options) (ca
115115
informerCache, err = createCacheFunc(cfg, cache.Options{})
116116
Expect(err).NotTo(HaveOccurred())
117117
By("running the cache and waiting for it to sync")
118-
go func() {
118+
// pass as an arg so that we don't race between close and re-assign
119+
go func(stopCh chan struct{}) {
119120
defer GinkgoRecover()
120-
Expect(informerCache.Start(stop)).To(Succeed())
121-
}()
121+
Expect(informerCache.Start(stopCh)).To(Succeed())
122+
}(stop)
122123
Expect(informerCache.WaitForCacheSync(stop)).To(BeTrue())
123124
})
124125

0 commit comments

Comments
 (0)