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 f60929a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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
5 changes: 4 additions & 1 deletion pkg/file/joiner/joiner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1128,10 +1128,11 @@ func TestJoinerRedundancy(t *testing.T) {
}
i := 0
eg, ectx := errgroup.WithContext(ctx)
scnt:
for ; i < shardCnt; i++ {
select {
case <-ectx.Done():
break
break scnt
default:
}
i := i
Expand Down Expand Up @@ -1226,6 +1227,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 @@ -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 f60929a

Please sign in to comment.