Skip to content

Commit

Permalink
test: enable race detection in Go tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikołaj Świątek committed Feb 9, 2023
1 parent f9aa446 commit 485b151
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ifeq ($(OS),Windows_NT)
OS=windows
endif

GOTEST=go test -count 1
GOTEST=go test -count 1 -race
LINT=golangci-lint

.PHONY: test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ func concurrencyTest(t *testing.T, numBatches, newBatchesInitialCapacity, batchC
}
}()

ids := generateSequentialIds(10000)
// don't set this too high, we spawn a goroutine for each one, and the race detector on Windows has
// a limit of 8192
traceIdCount := 1000
ids := generateSequentialIds(uint64(traceIdCount))
wg := &sync.WaitGroup{}
for i := 0; i < len(ids); i++ {
wg.Add(1)
Expand Down
6 changes: 3 additions & 3 deletions pkg/processor/cascadingfilterprocessor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestDecisionHistory(t *testing.T) {
}

func TestConcurrentTraceArrival(t *testing.T) {
traceIds, batches := generateIdsAndBatches(128)
traceIds, batches := generateIdsAndBatches(64)
tsp := buildBasicCFSP(t, uint64(2*len(traceIds)))

var wg sync.WaitGroup
Expand Down Expand Up @@ -153,8 +153,8 @@ func TestSequentialTraceMapSize(t *testing.T) {
}

func TestConcurrentTraceMapSize(t *testing.T) {
_, batches := generateIdsAndBatches(210)
const maxSize = 100
_, batches := generateIdsAndBatches(64)
const maxSize = 50
var wg sync.WaitGroup
tsp := buildBasicCFSP(t, uint64(maxSize))
for _, batch := range batches {
Expand Down
2 changes: 1 addition & 1 deletion pkg/receiver/rawk8seventsreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func TestStorage(t *testing.T) {

// Create the second k8s event.
secondEvent := getEvent()
firstEvent.UID = types.UID("ec279341-e2d8-4b2a-b17d-6e0566481002")
secondEvent.UID = types.UID("ec279341-e2d8-4b2a-b17d-6e0566481002")
listWatch.Add(secondEvent)

// Both events should be picked up by the receiver.
Expand Down

0 comments on commit 485b151

Please sign in to comment.