Skip to content

Commit 4985f93

Browse files
authored
bitswap/client/internal/messagequeue: run tests in parallel (#835)
On my computer, make the tests take 12s rather than 65s. Skimming through them I didn't found any dependency or shared resources in them.
1 parent 7c1f0a3 commit 4985f93

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

bitswap/client/internal/messagequeue/donthavetimeoutmgr_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func (tr *timeoutRecorder) clear() {
7373
}
7474

7575
func TestDontHaveTimeoutMgrTimeout(t *testing.T) {
76+
t.Parallel()
7677
firstks := random.Cids(2)
7778
secondks := append(firstks, random.Cids(3)...)
7879
latency := time.Millisecond * 20
@@ -133,6 +134,7 @@ func TestDontHaveTimeoutMgrTimeout(t *testing.T) {
133134
}
134135

135136
func TestDontHaveTimeoutMgrCancel(t *testing.T) {
137+
t.Parallel()
136138
ks := random.Cids(3)
137139
latency := time.Millisecond * 10
138140
latMultiplier := 1
@@ -173,6 +175,7 @@ func TestDontHaveTimeoutMgrCancel(t *testing.T) {
173175
}
174176

175177
func TestDontHaveTimeoutWantCancelWant(t *testing.T) {
178+
t.Parallel()
176179
ks := random.Cids(3)
177180
latency := time.Millisecond * 20
178181
latMultiplier := 1
@@ -229,6 +232,7 @@ func TestDontHaveTimeoutWantCancelWant(t *testing.T) {
229232
}
230233

231234
func TestDontHaveTimeoutRepeatedAddPending(t *testing.T) {
235+
t.Parallel()
232236
ks := random.Cids(10)
233237
latency := time.Millisecond * 5
234238
latMultiplier := 1
@@ -266,6 +270,7 @@ func TestDontHaveTimeoutRepeatedAddPending(t *testing.T) {
266270
}
267271

268272
func TestDontHaveTimeoutMgrMessageLatency(t *testing.T) {
273+
t.Parallel()
269274
ks := random.Cids(2)
270275
latency := time.Millisecond * 40
271276
latMultiplier := 1
@@ -320,6 +325,7 @@ func TestDontHaveTimeoutMgrMessageLatency(t *testing.T) {
320325
}
321326

322327
func TestDontHaveTimeoutMgrMessageLatencyMax(t *testing.T) {
328+
t.Parallel()
323329
ks := random.Cids(2)
324330
clock := clock.NewMock()
325331
pinged := make(chan struct{})
@@ -357,6 +363,7 @@ func TestDontHaveTimeoutMgrMessageLatencyMax(t *testing.T) {
357363
}
358364

359365
func TestDontHaveTimeoutMgrUsesDefaultTimeoutIfPingError(t *testing.T) {
366+
t.Parallel()
360367
ks := random.Cids(2)
361368
latency := time.Millisecond
362369
latMultiplier := 2
@@ -403,6 +410,7 @@ func TestDontHaveTimeoutMgrUsesDefaultTimeoutIfPingError(t *testing.T) {
403410
}
404411

405412
func TestDontHaveTimeoutMgrUsesDefaultTimeoutIfLatencyLonger(t *testing.T) {
413+
t.Parallel()
406414
ks := random.Cids(2)
407415
latency := time.Millisecond * 200
408416
latMultiplier := 1
@@ -448,6 +456,7 @@ func TestDontHaveTimeoutMgrUsesDefaultTimeoutIfLatencyLonger(t *testing.T) {
448456
}
449457

450458
func TestDontHaveTimeoutNoTimeoutAfterShutdown(t *testing.T) {
459+
t.Parallel()
451460
ks := random.Cids(2)
452461
latency := time.Millisecond * 10
453462
latMultiplier := 1

bitswap/client/internal/messagequeue/messagequeue_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ func expectEvent(t *testing.T, events <-chan messageEvent, expectedEvent message
163163
}
164164

165165
func TestStartupAndShutdown(t *testing.T) {
166+
t.Parallel()
166167
ctx := context.Background()
167168
messagesSent := make(chan []bsmsg.Entry)
168169
resetChan := make(chan struct{}, 1)
@@ -201,6 +202,7 @@ func TestStartupAndShutdown(t *testing.T) {
201202
}
202203

203204
func TestSendingMessagesDeduped(t *testing.T) {
205+
t.Parallel()
204206
ctx := context.Background()
205207
messagesSent := make(chan []bsmsg.Entry)
206208
resetChan := make(chan struct{}, 1)
@@ -223,6 +225,7 @@ func TestSendingMessagesDeduped(t *testing.T) {
223225
}
224226

225227
func TestSendingMessagesPartialDupe(t *testing.T) {
228+
t.Parallel()
226229
ctx := context.Background()
227230
messagesSent := make(chan []bsmsg.Entry)
228231
resetChan := make(chan struct{}, 1)
@@ -245,6 +248,7 @@ func TestSendingMessagesPartialDupe(t *testing.T) {
245248
}
246249

247250
func TestSendingMessagesPriority(t *testing.T) {
251+
t.Parallel()
248252
ctx := context.Background()
249253
messagesSent := make(chan []bsmsg.Entry)
250254
resetChan := make(chan struct{}, 1)
@@ -313,6 +317,7 @@ func TestSendingMessagesPriority(t *testing.T) {
313317
}
314318

315319
func TestCancelOverridesPendingWants(t *testing.T) {
320+
t.Parallel()
316321
ctx := context.Background()
317322
messagesSent := make(chan []bsmsg.Entry)
318323
resetChan := make(chan struct{}, 1)
@@ -364,6 +369,7 @@ func TestCancelOverridesPendingWants(t *testing.T) {
364369
}
365370

366371
func TestWantOverridesPendingCancels(t *testing.T) {
372+
t.Parallel()
367373
ctx := context.Background()
368374
messagesSent := make(chan []bsmsg.Entry)
369375
resetChan := make(chan struct{}, 1)
@@ -411,6 +417,7 @@ func TestWantOverridesPendingCancels(t *testing.T) {
411417
}
412418

413419
func TestWantlistRebroadcast(t *testing.T) {
420+
t.Parallel()
414421
ctx := context.Background()
415422
messagesSent := make(chan []bsmsg.Entry)
416423
resetChan := make(chan struct{}, 1)
@@ -512,6 +519,7 @@ func TestWantlistRebroadcast(t *testing.T) {
512519
}
513520

514521
func TestSendingLargeMessages(t *testing.T) {
522+
t.Parallel()
515523
ctx := context.Background()
516524
messagesSent := make(chan []bsmsg.Entry)
517525
resetChan := make(chan struct{}, 1)
@@ -542,6 +550,7 @@ func TestSendingLargeMessages(t *testing.T) {
542550
}
543551

544552
func TestSendToPeerThatDoesntSupportHave(t *testing.T) {
553+
t.Parallel()
545554
ctx := context.Background()
546555
messagesSent := make(chan []bsmsg.Entry)
547556
resetChan := make(chan struct{}, 1)
@@ -597,6 +606,7 @@ func TestSendToPeerThatDoesntSupportHave(t *testing.T) {
597606
}
598607

599608
func TestSendToPeerThatDoesntSupportHaveMonitorsTimeouts(t *testing.T) {
609+
t.Parallel()
600610
ctx := context.Background()
601611
messagesSent := make(chan []bsmsg.Entry)
602612
resetChan := make(chan struct{}, 1)
@@ -629,6 +639,7 @@ func TestSendToPeerThatDoesntSupportHaveMonitorsTimeouts(t *testing.T) {
629639
}
630640

631641
func TestResponseReceived(t *testing.T) {
642+
t.Parallel()
632643
ctx := context.Background()
633644
messagesSent := make(chan []bsmsg.Entry)
634645
resetChan := make(chan struct{}, 1)
@@ -680,6 +691,7 @@ func TestResponseReceived(t *testing.T) {
680691
}
681692

682693
func TestResponseReceivedAppliesForFirstResponseOnly(t *testing.T) {
694+
t.Parallel()
683695
ctx := context.Background()
684696
messagesSent := make(chan []bsmsg.Entry)
685697
resetChan := make(chan struct{}, 1)
@@ -725,6 +737,7 @@ func TestResponseReceivedAppliesForFirstResponseOnly(t *testing.T) {
725737
}
726738

727739
func TestResponseReceivedDiscardsOutliers(t *testing.T) {
740+
t.Parallel()
728741
ctx := context.Background()
729742
messagesSent := make(chan []bsmsg.Entry)
730743
resetChan := make(chan struct{}, 1)

0 commit comments

Comments
 (0)