Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix flaky WithClearCacheOnBatch test #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tonyghita
Copy link
Member

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
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TestLoader/allows_clearAll_values_in_cache fails non-deterministically
1 participant