Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI pipeline step to run the race detector against the tests #92

Merged
merged 2 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/relay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
run: go build -v ./pkg/...
- name: Test
run: go test ./pkg/... -v
- name: Test with the race detector enabled
run: go test ./pkg/... -v -race -count=10

lint:
runs-on: ubuntu-latest
Expand Down
11 changes: 6 additions & 5 deletions pkg/monitoring/multi_feed_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package monitoring
import (
"context"
"sync"
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -121,7 +122,7 @@ func TestMultiFeedMonitorForPerformance(t *testing.T) {
)
go monitor.Start(ctx, wg)

trCount, stCount := 0, 0
var trCount, stCount int64 = 0, 0
messages := []producerMessage{}

wg.Add(1)
Expand All @@ -133,9 +134,9 @@ func TestMultiFeedMonitorForPerformance(t *testing.T) {
require.NoError(t, err)
select {
case transmissionReader.readCh <- generateTransmissionEnvelope():
trCount += 1
_ = atomic.AddInt64(&trCount, 1)
case stateReader.readCh <- StateEnvelope{newState, 100}:
stCount += 1
_ = atomic.AddInt64(&stCount, 1)
case <-ctx.Done():
break LOOP
}
Expand All @@ -156,7 +157,7 @@ func TestMultiFeedMonitorForPerformance(t *testing.T) {
}()

wg.Wait()
require.Equal(t, 10, trCount, "should only be able to do initial read of the latest transmission")
require.Equal(t, 10, stCount, "should only be able to do initial read of the state account")
require.Equal(t, int64(10), trCount, "should only be able to do initial read of the latest transmission")
require.Equal(t, int64(10), stCount, "should only be able to do initial read of the state account")
require.Equal(t, 30, len(messages))
}