Skip to content

Commit e01fe36

Browse files
committed
reduced load for race tests
1 parent b42f09e commit e01fe36

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.23
44

55
require (
66
github.com/google/uuid v1.6.0
7+
github.com/ipfs/go-detect-race v0.0.1
78
github.com/ipfs/go-ipfs-delay v0.0.1
89
go.opentelemetry.io/otel v1.16.0
910
go.opentelemetry.io/otel/trace v1.16.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
99
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1010
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
1111
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
12+
github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
13+
github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
1214
github.com/ipfs/go-ipfs-delay v0.0.1 h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1IeRQ=
1315
github.com/ipfs/go-ipfs-delay v0.0.1/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
1416
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=

test/basic_tests.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,22 @@ import (
1111

1212
dstore "github.com/ipfs/go-datastore"
1313
dsq "github.com/ipfs/go-datastore/query"
14+
detectrace "github.com/ipfs/go-detect-race"
1415
)
1516

1617
// ElemCount sets with how many elements the datastore suit
1718
// tests are usually run with. Best to set to round numbers like
1819
// 20, 30, 40... and at least to 20.
1920
var ElemCount = 100
2021

22+
func init() {
23+
// Reduce the default element count when the race detector is enabled so these tests don't
24+
// take forever.
25+
if detectrace.WithRace() {
26+
ElemCount = 20
27+
}
28+
}
29+
2130
func TestElemCount(t *testing.T) {
2231
if ElemCount < 20 {
2332
t.Fatal("ElemCount should be set to 20 at least")

test/suite.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
dstore "github.com/ipfs/go-datastore"
1010
query "github.com/ipfs/go-datastore/query"
11+
detectrace "github.com/ipfs/go-detect-race"
1112
)
1213

1314
// BasicSubtests is a list of all basic tests.
@@ -21,7 +22,13 @@ var BasicSubtests = []func(t *testing.T, ds dstore.Datastore){
2122
SubtestManyKeysAndQuery,
2223
SubtestReturnSizes,
2324
SubtestBasicSync,
24-
SubtestCombinations,
25+
}
26+
27+
// Only enable the expensive "combinations" test when not running the race detector.
28+
func init() {
29+
if !detectrace.WithRace() {
30+
BasicSubtests = append(BasicSubtests, SubtestCombinations)
31+
}
2532
}
2633

2734
// BatchSubtests is a list of all basic batching datastore tests.

0 commit comments

Comments
 (0)