Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
test(providerquerymanager): fix timings
Browse files Browse the repository at this point in the history
Fix several sensitive timings on ProviderQueryManager tests
that could lead to intermittent failures in CI
  • Loading branch information
hannahhoward committed Oct 8, 2021
1 parent 958b163 commit a2e8191
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/providerquerymanager/providerquerymanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestCancelOneRequestDoesNotTerminateAnother(t *testing.T) {
firstSessionCtx, firstCancel := context.WithTimeout(ctx, 3*time.Millisecond)
defer firstCancel()
firstRequestChan := providerQueryManager.FindProvidersAsync(firstSessionCtx, key)
secondSessionCtx, secondCancel := context.WithTimeout(ctx, 100*time.Millisecond)
secondSessionCtx, secondCancel := context.WithTimeout(ctx, 5*time.Second)
defer secondCancel()
secondRequestChan := providerQueryManager.FindProvidersAsync(secondSessionCtx, key)

Expand Down Expand Up @@ -262,7 +262,7 @@ func TestRateLimitingRequests(t *testing.T) {
providerQueryManager.Startup()

keys := testutil.GenerateCids(maxInProcessRequests + 1)
sessionCtx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
sessionCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
var requestChannels []<-chan peer.ID
for i := 0; i < maxInProcessRequests+1; i++ {
Expand All @@ -283,6 +283,7 @@ func TestRateLimitingRequests(t *testing.T) {
fpn.queriesMadeMutex.Lock()
defer fpn.queriesMadeMutex.Unlock()
if fpn.queriesMade != maxInProcessRequests+1 {
t.Logf("Queries made: %d\n", fpn.queriesMade)
t.Fatal("Did not make all seperate requests")
}
}
Expand All @@ -291,15 +292,15 @@ func TestFindProviderTimeout(t *testing.T) {
peers := testutil.GeneratePeers(10)
fpn := &fakeProviderNetwork{
peersFound: peers,
delay: 1 * time.Millisecond,
delay: 10 * time.Millisecond,
}
ctx := context.Background()
providerQueryManager := New(ctx, fpn)
providerQueryManager.Startup()
providerQueryManager.SetFindProviderTimeout(2 * time.Millisecond)
keys := testutil.GenerateCids(1)

sessionCtx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
sessionCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
firstRequestChan := providerQueryManager.FindProvidersAsync(sessionCtx, keys[0])
var firstPeersReceived []peer.ID
Expand Down

0 comments on commit a2e8191

Please sign in to comment.