dataloader icon indicating copy to clipboard operation
dataloader copied to clipboard

test: fix flaky WithClearCacheOnBatch test

Open tonyghita opened this issue 4 years ago • 1 comments

This changes the test assertion to avoid test flake. Fixes #76.

I was unable to find any data races using the -race flag for testing. The existing test would rarely fail 0.001% of the time locally on my machine. I changed the test so it's not digging into the cache (which relies on locking external to it's implementation--maybe something to follow up on separately).

I haven't been able to reproduce any test flakiness with this new approach.

tonyghita avatar Apr 02 '21 18:04 tonyghita

Hmm... upon a longer test run I find this test still has issues.

$ go test -race -covermode=atomic -count=30000
--- FAIL: TestLoader (0.00s)
    --- FAIL: TestLoader/clears_cache_on_batch_with_WithClearCacheOnBatch (0.02s)
        dataloader_test.go:370: expected a second batch, got [][]string{[]string{"1"}}
--- FAIL: TestLoader (0.00s)
    --- FAIL: TestLoader/clears_cache_on_batch_with_WithClearCacheOnBatch (0.02s)
        dataloader_test.go:370: expected a second batch, got [][]string{[]string{"1"}}
coverage: 86.0% of statements

tonyghita avatar Apr 02 '21 19:04 tonyghita