Skip to content

Commit 27e3f96

Browse files
frncmxnonsense
authored andcommitted
swarm: CI race detector test adjustments (#19017)
1 parent cde02e0 commit 27e3f96

File tree

6 files changed

+60
-84
lines changed

6 files changed

+60
-84
lines changed

swarm/network/networkid_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var (
4444

4545
const (
4646
NumberOfNets = 4
47-
MaxTimeout = 6
47+
MaxTimeout = 15 * time.Second
4848
)
4949

5050
func init() {
@@ -146,7 +146,7 @@ func setupNetwork(numnodes int) (net *simulations.Network, err error) {
146146
return nil, fmt.Errorf("create node %d rpc client fail: %v", i, err)
147147
}
148148
//now setup and start event watching in order to know when we can upload
149-
ctx, watchCancel := context.WithTimeout(context.Background(), MaxTimeout*time.Second)
149+
ctx, watchCancel := context.WithTimeout(context.Background(), MaxTimeout)
150150
defer watchCancel()
151151
watchSubscriptionEvents(ctx, nodes[i].ID(), client, errc, quitC)
152152
//on every iteration we connect to all previous ones

swarm/network/simulations/overlay_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
)
3333

3434
var (
35-
nodeCount = 16
35+
nodeCount = 10
3636
)
3737

3838
//This test is used to test the overlay simulation.

swarm/network/stream/snapshot_retrieval_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func runFileRetrievalTest(nodeCount int) error {
151151
return err
152152
}
153153

154-
ctx, cancelSimRun := context.WithTimeout(context.Background(), 1*time.Minute)
154+
ctx, cancelSimRun := context.WithTimeout(context.Background(), 3*time.Minute)
155155
defer cancelSimRun()
156156

157157
result := sim.Run(ctx, func(ctx context.Context, sim *simulation.Simulation) error {

swarm/storage/common_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ func newLDBStore(t *testing.T) (*LDBStore, func()) {
8383
return db, cleanup
8484
}
8585

86-
func mputRandomChunks(store ChunkStore, n int, chunksize int64) ([]Chunk, error) {
86+
func mputRandomChunks(store ChunkStore, n int) ([]Chunk, error) {
8787
return mput(store, n, GenerateRandomChunk)
8888
}
8989

9090
func mput(store ChunkStore, n int, f func(i int64) Chunk) (hs []Chunk, err error) {
9191
// put to localstore and wait for stored channel
9292
// does not check delivery error state
9393
errc := make(chan error)
94-
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
94+
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
9595
defer cancel()
9696
for i := int64(0); i < int64(n); i++ {
9797
chunk := f(ch.DefaultSize)
@@ -159,8 +159,8 @@ func (r *brokenLimitedReader) Read(buf []byte) (int, error) {
159159
return r.lr.Read(buf)
160160
}
161161

162-
func testStoreRandom(m ChunkStore, n int, chunksize int64, t *testing.T) {
163-
chunks, err := mputRandomChunks(m, n, chunksize)
162+
func testStoreRandom(m ChunkStore, n int, t *testing.T) {
163+
chunks, err := mputRandomChunks(m, n)
164164
if err != nil {
165165
t.Fatalf("expected no error, got %v", err)
166166
}
@@ -170,8 +170,8 @@ func testStoreRandom(m ChunkStore, n int, chunksize int64, t *testing.T) {
170170
}
171171
}
172172

173-
func testStoreCorrect(m ChunkStore, n int, chunksize int64, t *testing.T) {
174-
chunks, err := mputRandomChunks(m, n, chunksize)
173+
func testStoreCorrect(m ChunkStore, n int, t *testing.T) {
174+
chunks, err := mputRandomChunks(m, n)
175175
if err != nil {
176176
t.Fatalf("expected no error, got %v", err)
177177
}
@@ -195,7 +195,7 @@ func testStoreCorrect(m ChunkStore, n int, chunksize int64, t *testing.T) {
195195
}
196196
}
197197

198-
func benchmarkStorePut(store ChunkStore, n int, chunksize int64, b *testing.B) {
198+
func benchmarkStorePut(store ChunkStore, n int, b *testing.B) {
199199
chunks := make([]Chunk, n)
200200
i := 0
201201
f := func(dataSize int64) Chunk {
@@ -222,8 +222,8 @@ func benchmarkStorePut(store ChunkStore, n int, chunksize int64, b *testing.B) {
222222
}
223223
}
224224

225-
func benchmarkStoreGet(store ChunkStore, n int, chunksize int64, b *testing.B) {
226-
chunks, err := mputRandomChunks(store, n, chunksize)
225+
func benchmarkStoreGet(store ChunkStore, n int, b *testing.B) {
226+
chunks, err := mputRandomChunks(store, n)
227227
if err != nil {
228228
b.Fatalf("expected no error, got %v", err)
229229
}

swarm/storage/ldbstore_test.go

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,22 @@ func testPoFunc(k Address) (ret uint8) {
7878
return uint8(Proximity(basekey, k[:]))
7979
}
8080

81-
func testDbStoreRandom(n int, chunksize int64, mock bool, t *testing.T) {
81+
func testDbStoreRandom(n int, mock bool, t *testing.T) {
8282
db, cleanup, err := newTestDbStore(mock, true)
8383
defer cleanup()
8484
if err != nil {
8585
t.Fatalf("init dbStore failed: %v", err)
8686
}
87-
testStoreRandom(db, n, chunksize, t)
87+
testStoreRandom(db, n, t)
8888
}
8989

90-
func testDbStoreCorrect(n int, chunksize int64, mock bool, t *testing.T) {
90+
func testDbStoreCorrect(n int, mock bool, t *testing.T) {
9191
db, cleanup, err := newTestDbStore(mock, false)
9292
defer cleanup()
9393
if err != nil {
9494
t.Fatalf("init dbStore failed: %v", err)
9595
}
96-
testStoreCorrect(db, n, chunksize, t)
96+
testStoreCorrect(db, n, t)
9797
}
9898

9999
func TestMarkAccessed(t *testing.T) {
@@ -137,35 +137,35 @@ func TestMarkAccessed(t *testing.T) {
137137
}
138138

139139
func TestDbStoreRandom_1(t *testing.T) {
140-
testDbStoreRandom(1, 0, false, t)
140+
testDbStoreRandom(1, false, t)
141141
}
142142

143143
func TestDbStoreCorrect_1(t *testing.T) {
144-
testDbStoreCorrect(1, 4096, false, t)
144+
testDbStoreCorrect(1, false, t)
145145
}
146146

147147
func TestDbStoreRandom_1k(t *testing.T) {
148-
testDbStoreRandom(1000, 0, false, t)
148+
testDbStoreRandom(1000, false, t)
149149
}
150150

151151
func TestDbStoreCorrect_1k(t *testing.T) {
152-
testDbStoreCorrect(1000, 4096, false, t)
152+
testDbStoreCorrect(1000, false, t)
153153
}
154154

155155
func TestMockDbStoreRandom_1(t *testing.T) {
156-
testDbStoreRandom(1, 0, true, t)
156+
testDbStoreRandom(1, true, t)
157157
}
158158

159159
func TestMockDbStoreCorrect_1(t *testing.T) {
160-
testDbStoreCorrect(1, 4096, true, t)
160+
testDbStoreCorrect(1, true, t)
161161
}
162162

163163
func TestMockDbStoreRandom_1k(t *testing.T) {
164-
testDbStoreRandom(1000, 0, true, t)
164+
testDbStoreRandom(1000, true, t)
165165
}
166166

167167
func TestMockDbStoreCorrect_1k(t *testing.T) {
168-
testDbStoreCorrect(1000, 4096, true, t)
168+
testDbStoreCorrect(1000, true, t)
169169
}
170170

171171
func testDbStoreNotFound(t *testing.T, mock bool) {
@@ -242,54 +242,38 @@ func TestMockIterator(t *testing.T) {
242242
testIterator(t, true)
243243
}
244244

245-
func benchmarkDbStorePut(n int, processors int, chunksize int64, mock bool, b *testing.B) {
245+
func benchmarkDbStorePut(n int, mock bool, b *testing.B) {
246246
db, cleanup, err := newTestDbStore(mock, true)
247247
defer cleanup()
248248
if err != nil {
249249
b.Fatalf("init dbStore failed: %v", err)
250250
}
251-
benchmarkStorePut(db, n, chunksize, b)
251+
benchmarkStorePut(db, n, b)
252252
}
253253

254-
func benchmarkDbStoreGet(n int, processors int, chunksize int64, mock bool, b *testing.B) {
254+
func benchmarkDbStoreGet(n int, mock bool, b *testing.B) {
255255
db, cleanup, err := newTestDbStore(mock, true)
256256
defer cleanup()
257257
if err != nil {
258258
b.Fatalf("init dbStore failed: %v", err)
259259
}
260-
benchmarkStoreGet(db, n, chunksize, b)
260+
benchmarkStoreGet(db, n, b)
261261
}
262262

263-
func BenchmarkDbStorePut_1_500(b *testing.B) {
264-
benchmarkDbStorePut(500, 1, 4096, false, b)
263+
func BenchmarkDbStorePut_500(b *testing.B) {
264+
benchmarkDbStorePut(500, false, b)
265265
}
266266

267-
func BenchmarkDbStorePut_8_500(b *testing.B) {
268-
benchmarkDbStorePut(500, 8, 4096, false, b)
267+
func BenchmarkDbStoreGet_500(b *testing.B) {
268+
benchmarkDbStoreGet(500, false, b)
269269
}
270270

271-
func BenchmarkDbStoreGet_1_500(b *testing.B) {
272-
benchmarkDbStoreGet(500, 1, 4096, false, b)
271+
func BenchmarkMockDbStorePut_500(b *testing.B) {
272+
benchmarkDbStorePut(500, true, b)
273273
}
274274

275-
func BenchmarkDbStoreGet_8_500(b *testing.B) {
276-
benchmarkDbStoreGet(500, 8, 4096, false, b)
277-
}
278-
279-
func BenchmarkMockDbStorePut_1_500(b *testing.B) {
280-
benchmarkDbStorePut(500, 1, 4096, true, b)
281-
}
282-
283-
func BenchmarkMockDbStorePut_8_500(b *testing.B) {
284-
benchmarkDbStorePut(500, 8, 4096, true, b)
285-
}
286-
287-
func BenchmarkMockDbStoreGet_1_500(b *testing.B) {
288-
benchmarkDbStoreGet(500, 1, 4096, true, b)
289-
}
290-
291-
func BenchmarkMockDbStoreGet_8_500(b *testing.B) {
292-
benchmarkDbStoreGet(500, 8, 4096, true, b)
275+
func BenchmarkMockDbStoreGet_500(b *testing.B) {
276+
benchmarkDbStoreGet(500, true, b)
293277
}
294278

295279
// TestLDBStoreWithoutCollectGarbage tests that we can put a number of random chunks in the LevelDB store, and
@@ -302,7 +286,7 @@ func TestLDBStoreWithoutCollectGarbage(t *testing.T) {
302286
ldb.setCapacity(uint64(capacity))
303287
defer cleanup()
304288

305-
chunks, err := mputRandomChunks(ldb, n, int64(ch.DefaultSize))
289+
chunks, err := mputRandomChunks(ldb, n)
306290
if err != nil {
307291
t.Fatal(err.Error())
308292
}
@@ -382,7 +366,7 @@ func testLDBStoreCollectGarbage(t *testing.T) {
382366
putCount = roundTarget
383367
}
384368
remaining -= putCount
385-
chunks, err := mputRandomChunks(ldb, putCount, int64(ch.DefaultSize))
369+
chunks, err := mputRandomChunks(ldb, putCount)
386370
if err != nil {
387371
t.Fatal(err.Error())
388372
}
@@ -429,7 +413,7 @@ func TestLDBStoreAddRemove(t *testing.T) {
429413
defer cleanup()
430414

431415
n := 100
432-
chunks, err := mputRandomChunks(ldb, n, int64(ch.DefaultSize))
416+
chunks, err := mputRandomChunks(ldb, n)
433417
if err != nil {
434418
t.Fatalf(err.Error())
435419
}
@@ -576,7 +560,7 @@ func TestLDBStoreCollectGarbageAccessUnlikeIndex(t *testing.T) {
576560
ldb.setCapacity(uint64(capacity))
577561
defer cleanup()
578562

579-
chunks, err := mputRandomChunks(ldb, n, int64(ch.DefaultSize))
563+
chunks, err := mputRandomChunks(ldb, n)
580564
if err != nil {
581565
t.Fatal(err.Error())
582566
}
@@ -589,7 +573,7 @@ func TestLDBStoreCollectGarbageAccessUnlikeIndex(t *testing.T) {
589573
t.Fatalf("fail add chunk #%d - %s: %v", i, chunks[i].Address(), err)
590574
}
591575
}
592-
_, err = mputRandomChunks(ldb, 2, int64(ch.DefaultSize))
576+
_, err = mputRandomChunks(ldb, 2)
593577
if err != nil {
594578
t.Fatal(err.Error())
595579
}
@@ -621,7 +605,7 @@ func TestCleanIndex(t *testing.T) {
621605
ldb.setCapacity(uint64(capacity))
622606
defer cleanup()
623607

624-
chunks, err := mputRandomChunks(ldb, n, 4096)
608+
chunks, err := mputRandomChunks(ldb, n)
625609
if err != nil {
626610
t.Fatal(err)
627611
}
@@ -752,7 +736,7 @@ func TestCleanIndex(t *testing.T) {
752736
}
753737

754738
// check that the iterator quits properly
755-
chunks, err = mputRandomChunks(ldb, 4100, 4096)
739+
chunks, err = mputRandomChunks(ldb, 4100)
756740
if err != nil {
757741
t.Fatal(err)
758742
}

swarm/storage/memstore_test.go

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,32 @@ func newTestMemStore() *MemStore {
2828
return NewMemStore(storeparams, nil)
2929
}
3030

31-
func testMemStoreRandom(n int, chunksize int64, t *testing.T) {
31+
func testMemStoreRandom(n int, t *testing.T) {
3232
m := newTestMemStore()
3333
defer m.Close()
34-
testStoreRandom(m, n, chunksize, t)
34+
testStoreRandom(m, n, t)
3535
}
3636

37-
func testMemStoreCorrect(n int, chunksize int64, t *testing.T) {
37+
func testMemStoreCorrect(n int, t *testing.T) {
3838
m := newTestMemStore()
3939
defer m.Close()
40-
testStoreCorrect(m, n, chunksize, t)
40+
testStoreCorrect(m, n, t)
4141
}
4242

4343
func TestMemStoreRandom_1(t *testing.T) {
44-
testMemStoreRandom(1, 0, t)
44+
testMemStoreRandom(1, t)
4545
}
4646

4747
func TestMemStoreCorrect_1(t *testing.T) {
48-
testMemStoreCorrect(1, 4104, t)
48+
testMemStoreCorrect(1, t)
4949
}
5050

5151
func TestMemStoreRandom_1k(t *testing.T) {
52-
testMemStoreRandom(1000, 0, t)
52+
testMemStoreRandom(1000, t)
5353
}
5454

5555
func TestMemStoreCorrect_1k(t *testing.T) {
56-
testMemStoreCorrect(100, 4096, t)
56+
testMemStoreCorrect(100, t)
5757
}
5858

5959
func TestMemStoreNotFound(t *testing.T) {
@@ -66,32 +66,24 @@ func TestMemStoreNotFound(t *testing.T) {
6666
}
6767
}
6868

69-
func benchmarkMemStorePut(n int, processors int, chunksize int64, b *testing.B) {
69+
func benchmarkMemStorePut(n int, b *testing.B) {
7070
m := newTestMemStore()
7171
defer m.Close()
72-
benchmarkStorePut(m, n, chunksize, b)
72+
benchmarkStorePut(m, n, b)
7373
}
7474

75-
func benchmarkMemStoreGet(n int, processors int, chunksize int64, b *testing.B) {
75+
func benchmarkMemStoreGet(n int, b *testing.B) {
7676
m := newTestMemStore()
7777
defer m.Close()
78-
benchmarkStoreGet(m, n, chunksize, b)
78+
benchmarkStoreGet(m, n, b)
7979
}
8080

81-
func BenchmarkMemStorePut_1_500(b *testing.B) {
82-
benchmarkMemStorePut(500, 1, 4096, b)
81+
func BenchmarkMemStorePut_500(b *testing.B) {
82+
benchmarkMemStorePut(500, b)
8383
}
8484

85-
func BenchmarkMemStorePut_8_500(b *testing.B) {
86-
benchmarkMemStorePut(500, 8, 4096, b)
87-
}
88-
89-
func BenchmarkMemStoreGet_1_500(b *testing.B) {
90-
benchmarkMemStoreGet(500, 1, 4096, b)
91-
}
92-
93-
func BenchmarkMemStoreGet_8_500(b *testing.B) {
94-
benchmarkMemStoreGet(500, 8, 4096, b)
85+
func BenchmarkMemStoreGet_500(b *testing.B) {
86+
benchmarkMemStoreGet(500, b)
9587
}
9688

9789
func TestMemStoreAndLDBStore(t *testing.T) {

0 commit comments

Comments
 (0)