Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Hiltunen <shiltunen@gitlab.com>2022-04-26 12:28:30 +0300
committerSami Hiltunen <shiltunen@gitlab.com>2022-04-26 12:28:30 +0300
commit46fad7855bd5dc991008b7852f424152d32c7b82 (patch)
tree71fd6d9a10855515e21f7b40ea7bdb0300221e8f
parent2a51da95824f64a71b99f94a325309c58264845f (diff)
Fix flaky ObjectReader testsmh-fix-flaky-object-reader-test
TestCache_ObjectReader/uncacheable is asserting that the object reader is closed after the context provided in the constructor is canceled. The clean up happens in a goroutine that listens for context cancellation and is thus not synchronizable by the calling code. It would be better if the clean up calls were explicit and synchronous so the calling code could synchronize if it wanted to. That's a bigger change though, so for now, let's use require.Eventually in the test to fix the flakiness by retrying the condition until it succeeds.
-rw-r--r--internal/git/catfile/cache_test.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/internal/git/catfile/cache_test.go b/internal/git/catfile/cache_test.go
index b90124ec8..b253869d9 100644
--- a/internal/git/catfile/cache_test.go
+++ b/internal/git/catfile/cache_test.go
@@ -218,7 +218,9 @@ func TestCache_ObjectReader(t *testing.T) {
}
require.Empty(t, output)
- require.True(t, reader.isClosed())
+ // The clean up happens in a goroutine on context cancellation. require.Eventually
+ // is used to here to avoid the flakiness.
+ require.Eventually(t, reader.isClosed, 5*time.Second, time.Millisecond)
require.Empty(t, keys(t, &cache.objectReaders))
})