Skip to content

Commit

Permalink
fix: run subtests in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
notanatol committed Jan 12, 2024
1 parent 0624ea4 commit f826506
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/api/bzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func TestBzzUploadDownloadWithRedundancy(t *testing.T) {
fileDownloadResource := func(addr string) string { return "/bzz/" + addr + "/" }

testRedundancy := func(t *testing.T, rLevel redundancy.Level, encrypt bool, levels int, chunkCnt int, shardCnt int, parityCnt int) {
t.Helper()
seed, err := pseudorand.NewSeed()
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -197,6 +198,7 @@ func TestBzzUploadDownloadWithRedundancy(t *testing.T) {
})
}
for _, rLevel := range []redundancy.Level{1, 2, 3, 4} {
rLevel := rLevel
t.Run(fmt.Sprintf("level=%d", rLevel), func(t *testing.T) {
for _, encrypt := range []bool{false, true} {
encrypt := encrypt
Expand All @@ -216,17 +218,18 @@ func TestBzzUploadDownloadWithRedundancy(t *testing.T) {
case 3:
chunkCnt = shardCnt*shardCnt + 1
}
levels := levels
t.Run(fmt.Sprintf("encrypt=%v levels=%d chunks=%d", encrypt, levels, chunkCnt), func(t *testing.T) {
if levels > 2 && (encrypt == (rLevel%2 == 1)) {
t.Skip("skipping to save time")
}
t.Parallel()
testRedundancy(t, rLevel, encrypt, levels, chunkCnt, shardCnt, parityCnt)
})
}
}
})
}

}

func TestBzzFiles(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/file/joiner/joiner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ func TestJoinerRedundancyMultilevel(t *testing.T) {
getter.StrategyTimeout = 100 * time.Millisecond

test := func(t *testing.T, rLevel redundancy.Level, encrypt bool, size int) {
t.Helper()
store := mockstorer.NewForgettingStore(inmemchunkstore.New())
testutil.CleanupCloser(t, store)
seed, err := pseudorand.NewSeed()
Expand Down Expand Up @@ -1339,6 +1340,7 @@ func TestJoinerRedundancyMultilevel(t *testing.T) {
if r2level[rLevel] != levels || encrypt != encryptChunk[rLevel] {
t.Skip("skipping to save time")
}
t.Parallel()
test(t, rLevel, encrypt, chunkCnt)
})
switch levels {
Expand All @@ -1350,6 +1352,7 @@ func TestJoinerRedundancyMultilevel(t *testing.T) {
continue
}
t.Run(fmt.Sprintf("encrypt=%v levels=%d chunks=%d full", encrypt, levels, chunkCnt), func(t *testing.T) {
t.Parallel()
test(t, rLevel, encrypt, chunkCnt)
})
}
Expand Down

0 comments on commit f826506

Please sign in to comment.