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

Fix ProviderQueryManager test timings #534

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions internal/providerquerymanager/providerquerymanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestNormalSimultaneousFetch(t *testing.T) {
providerQueryManager.Startup()
keys := testutil.GenerateCids(2)

sessionCtx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
sessionCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
firstRequestChan := providerQueryManager.FindProvidersAsync(sessionCtx, keys[0])
secondRequestChan := providerQueryManager.FindProvidersAsync(sessionCtx, keys[1])
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestDedupingProviderRequests(t *testing.T) {
providerQueryManager.Startup()
key := testutil.GenerateCids(1)[0]

sessionCtx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
sessionCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
firstRequestChan := providerQueryManager.FindProvidersAsync(sessionCtx, key)
secondRequestChan := providerQueryManager.FindProvidersAsync(sessionCtx, key)
Expand Down 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