Skip to content

Commit 5ff929c

Browse files
authored
les/vflux: run tests in parallel (#28524)
1 parent 3cfcd25 commit 5ff929c

11 files changed

+129
-7
lines changed

les/vflux/client/fillset_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ func (i *testIter) waiting(timeout time.Duration) bool {
6565
}
6666

6767
func TestFillSet(t *testing.T) {
68+
t.Parallel()
69+
6870
ns := nodestate.NewNodeStateMachine(nil, nil, &mclock.Simulated{}, testSetup)
6971
iter := &testIter{
7072
waitCh: make(chan struct{}),

les/vflux/client/queueiterator_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ func testNode(i int) *enode.Node {
3131
}
3232

3333
func TestQueueIteratorFIFO(t *testing.T) {
34+
t.Parallel()
35+
3436
testQueueIterator(t, true)
3537
}
3638

3739
func TestQueueIteratorLIFO(t *testing.T) {
40+
t.Parallel()
41+
3842
testQueueIterator(t, false)
3943
}
4044

les/vflux/client/requestbasket_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ func checkF64(t *testing.T, name string, value, exp, tol float64) {
3636
}
3737

3838
func TestServerBasket(t *testing.T) {
39+
t.Parallel()
40+
3941
var s serverBasket
4042
s.init(2)
4143
// add some requests with different request value factors
@@ -70,6 +72,8 @@ func TestServerBasket(t *testing.T) {
7072
}
7173

7274
func TestConvertMapping(t *testing.T) {
75+
t.Parallel()
76+
7377
b := requestBasket{items: []basketItem{{3, 3}, {1, 1}, {2, 2}}}
7478
oldMap := []string{"req3", "req1", "req2"}
7579
newMap := []string{"req1", "req2", "req3", "req4"}
@@ -82,6 +86,8 @@ func TestConvertMapping(t *testing.T) {
8286
}
8387

8488
func TestReqValueFactor(t *testing.T) {
89+
t.Parallel()
90+
8591
var ref referenceBasket
8692
ref.basket = requestBasket{items: make([]basketItem, 4)}
8793
for i := range ref.basket.items {
@@ -95,6 +101,8 @@ func TestReqValueFactor(t *testing.T) {
95101
}
96102

97103
func TestNormalize(t *testing.T) {
104+
t.Parallel()
105+
98106
for cycle := 0; cycle < 100; cycle += 1 {
99107
// Initialize data for testing
100108
valueRange, lower := 1000000, 1000000
@@ -119,6 +127,8 @@ func TestNormalize(t *testing.T) {
119127
}
120128

121129
func TestReqValueAdjustment(t *testing.T) {
130+
t.Parallel()
131+
122132
var s1, s2 serverBasket
123133
s1.init(3)
124134
s2.init(3)

les/vflux/client/serverpool_test.go

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,21 @@ func (s *ServerPoolTest) checkNodes(t *testing.T, nodes []int) {
326326
}
327327
}
328328

329-
func TestServerPool(t *testing.T) { testServerPool(t, false, false) }
330-
func TestServerPoolWithPreNeg(t *testing.T) { testServerPool(t, true, false) }
331-
func TestServerPoolWithPreNegFail(t *testing.T) { testServerPool(t, true, true) }
329+
func TestServerPool(t *testing.T) {
330+
t.Parallel()
331+
332+
testServerPool(t, false, false)
333+
}
334+
func TestServerPoolWithPreNeg(t *testing.T) {
335+
t.Parallel()
336+
337+
testServerPool(t, true, false)
338+
}
339+
func TestServerPoolWithPreNegFail(t *testing.T) {
340+
t.Parallel()
341+
342+
testServerPool(t, true, true)
343+
}
332344
func testServerPool(t *testing.T, preNeg, fail bool) {
333345
s := newServerPoolTest(preNeg, fail)
334346
nodes := s.setNodes(100, 200, 200, true, false)
@@ -339,8 +351,16 @@ func testServerPool(t *testing.T, preNeg, fail bool) {
339351
s.checkNodes(t, nodes)
340352
}
341353

342-
func TestServerPoolChangedNodes(t *testing.T) { testServerPoolChangedNodes(t, false) }
343-
func TestServerPoolChangedNodesWithPreNeg(t *testing.T) { testServerPoolChangedNodes(t, true) }
354+
func TestServerPoolChangedNodes(t *testing.T) {
355+
t.Parallel()
356+
357+
testServerPoolChangedNodes(t, false)
358+
}
359+
func TestServerPoolChangedNodesWithPreNeg(t *testing.T) {
360+
t.Parallel()
361+
362+
testServerPoolChangedNodes(t, true)
363+
}
344364
func testServerPoolChangedNodes(t *testing.T, preNeg bool) {
345365
s := newServerPoolTest(preNeg, false)
346366
nodes := s.setNodes(100, 200, 200, true, false)
@@ -358,8 +378,14 @@ func testServerPoolChangedNodes(t *testing.T, preNeg bool) {
358378
s.stop()
359379
}
360380

361-
func TestServerPoolRestartNoDiscovery(t *testing.T) { testServerPoolRestartNoDiscovery(t, false) }
381+
func TestServerPoolRestartNoDiscovery(t *testing.T) {
382+
t.Parallel()
383+
384+
testServerPoolRestartNoDiscovery(t, false)
385+
}
362386
func TestServerPoolRestartNoDiscoveryWithPreNeg(t *testing.T) {
387+
t.Parallel()
388+
363389
testServerPoolRestartNoDiscovery(t, true)
364390
}
365391
func testServerPoolRestartNoDiscovery(t *testing.T, preNeg bool) {
@@ -377,8 +403,14 @@ func testServerPoolRestartNoDiscovery(t *testing.T, preNeg bool) {
377403
s.checkNodes(t, nodes)
378404
}
379405

380-
func TestServerPoolTrustedNoDiscovery(t *testing.T) { testServerPoolTrustedNoDiscovery(t, false) }
406+
func TestServerPoolTrustedNoDiscovery(t *testing.T) {
407+
t.Parallel()
408+
409+
testServerPoolTrustedNoDiscovery(t, false)
410+
}
381411
func TestServerPoolTrustedNoDiscoveryWithPreNeg(t *testing.T) {
412+
t.Parallel()
413+
382414
testServerPoolTrustedNoDiscovery(t, true)
383415
}
384416
func testServerPoolTrustedNoDiscovery(t *testing.T, preNeg bool) {

les/vflux/client/timestats_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626
)
2727

2828
func TestTransition(t *testing.T) {
29+
t.Parallel()
30+
2931
var epsilon = 0.01
3032
var cases = []time.Duration{
3133
time.Millisecond, minResponseTime,
@@ -47,6 +49,8 @@ func TestTransition(t *testing.T) {
4749
var maxResponseWeights = TimeoutWeights(maxResponseTime)
4850

4951
func TestValue(t *testing.T) {
52+
t.Parallel()
53+
5054
noexp := utils.ExpirationFactor{Factor: 1}
5155
for i := 0; i < 1000; i++ {
5256
max := minResponseTime + time.Duration(rand.Int63n(int64(maxResponseTime-minResponseTime)))
@@ -70,6 +74,8 @@ func TestValue(t *testing.T) {
7074
}
7175

7276
func TestAddSubExpire(t *testing.T) {
77+
t.Parallel()
78+
7379
var (
7480
sum1, sum2 ResponseTimeStats
7581
sum1ValueExp, sum2ValueExp float64
@@ -110,6 +116,8 @@ func TestAddSubExpire(t *testing.T) {
110116
}
111117

112118
func TestTimeout(t *testing.T) {
119+
t.Parallel()
120+
113121
testTimeoutRange(t, 0, time.Second)
114122
testTimeoutRange(t, time.Second, time.Second*2)
115123
testTimeoutRange(t, time.Second, maxResponseTime)

les/vflux/client/valuetracker_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const (
3838
)
3939

4040
func TestValueTracker(t *testing.T) {
41+
t.Parallel()
42+
4143
db := memorydb.New()
4244
clock := &mclock.Simulated{}
4345
requestList := make([]RequestInfo, testReqTypes)

les/vflux/client/wrsiterator_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ var (
3737
const iterTestNodeCount = 6
3838

3939
func TestWrsIterator(t *testing.T) {
40+
t.Parallel()
41+
4042
ns := nodestate.NewNodeStateMachine(nil, nil, &mclock.Simulated{}, testSetup)
4143
w := NewWrsIterator(ns, sfTest2, sfTest3.Or(sfTest4), sfiTestWeight)
4244
ns.Start()

les/vflux/server/balance_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ func (b *balanceTestSetup) stop() {
107107
}
108108

109109
func TestAddBalance(t *testing.T) {
110+
t.Parallel()
111+
110112
b := newBalanceTestSetup(nil, nil, nil)
111113
defer b.stop()
112114

@@ -143,6 +145,8 @@ func TestAddBalance(t *testing.T) {
143145
}
144146

145147
func TestSetBalance(t *testing.T) {
148+
t.Parallel()
149+
146150
b := newBalanceTestSetup(nil, nil, nil)
147151
defer b.stop()
148152
node := b.newNode(1000)
@@ -167,6 +171,8 @@ func TestSetBalance(t *testing.T) {
167171
}
168172

169173
func TestBalanceTimeCost(t *testing.T) {
174+
t.Parallel()
175+
170176
b := newBalanceTestSetup(nil, nil, nil)
171177
defer b.stop()
172178
node := b.newNode(1000)
@@ -207,6 +213,8 @@ func TestBalanceTimeCost(t *testing.T) {
207213
}
208214

209215
func TestBalanceReqCost(t *testing.T) {
216+
t.Parallel()
217+
210218
b := newBalanceTestSetup(nil, nil, nil)
211219
defer b.stop()
212220
node := b.newNode(1000)
@@ -235,6 +243,8 @@ func TestBalanceReqCost(t *testing.T) {
235243
}
236244

237245
func TestBalanceToPriority(t *testing.T) {
246+
t.Parallel()
247+
238248
b := newBalanceTestSetup(nil, nil, nil)
239249
defer b.stop()
240250
node := b.newNode(1000)
@@ -260,6 +270,8 @@ func TestBalanceToPriority(t *testing.T) {
260270
}
261271

262272
func TestEstimatedPriority(t *testing.T) {
273+
t.Parallel()
274+
263275
b := newBalanceTestSetup(nil, nil, nil)
264276
defer b.stop()
265277
node := b.newNode(1000000000)
@@ -299,6 +311,8 @@ func TestEstimatedPriority(t *testing.T) {
299311
}
300312

301313
func TestPositiveBalanceCounting(t *testing.T) {
314+
t.Parallel()
315+
302316
b := newBalanceTestSetup(nil, nil, nil)
303317
defer b.stop()
304318

@@ -340,6 +354,8 @@ func TestPositiveBalanceCounting(t *testing.T) {
340354
}
341355

342356
func TestCallbackChecking(t *testing.T) {
357+
t.Parallel()
358+
343359
b := newBalanceTestSetup(nil, nil, nil)
344360
defer b.stop()
345361
node := b.newNode(1000000)
@@ -363,6 +379,8 @@ func TestCallbackChecking(t *testing.T) {
363379
}
364380

365381
func TestCallback(t *testing.T) {
382+
t.Parallel()
383+
366384
b := newBalanceTestSetup(nil, nil, nil)
367385
defer b.stop()
368386
node := b.newNode(1000)
@@ -392,6 +410,8 @@ func TestCallback(t *testing.T) {
392410
}
393411

394412
func TestBalancePersistence(t *testing.T) {
413+
t.Parallel()
414+
395415
posExp := &utils.Expirer{}
396416
negExp := &utils.Expirer{}
397417
posExp.SetRate(0, math.Log(2)/float64(time.Hour*2)) // halves every two hours

les/vflux/server/clientdb_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ func expval(v uint64) utils.ExpiredValue {
3232
}
3333

3434
func TestNodeDB(t *testing.T) {
35+
t.Parallel()
36+
3537
ndb := newNodeDB(rawdb.NewMemoryDatabase(), mclock.System{})
3638
defer ndb.close()
3739

@@ -85,6 +87,8 @@ func TestNodeDB(t *testing.T) {
8587
}
8688

8789
func TestNodeDBExpiration(t *testing.T) {
90+
t.Parallel()
91+
8892
var (
8993
iterated int
9094
done = make(chan struct{}, 1)

0 commit comments

Comments
 (0)