Skip to content

Commit f3b196c

Browse files
authored
Fixed race condition test (#1866)
* Added go test `-race` option Signed-off-by: yutachaos <[email protected]> * Fixed the possibility of race condition when loading observedCount variable. Signed-off-by: yutachaos <[email protected]>
1 parent a011b94 commit f3b196c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ all: controller
1515

1616
# Run tests
1717
test: generate fmt vet manifests
18-
go test ./pkg/... ./webhooks/... -coverprofile cover.out
18+
go test -race ./pkg/... ./webhooks/... -coverprofile cover.out
1919

2020
# Build controller binary
2121
controller: generate fmt vet

pkg/aws/throttle/throttler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func Test_throttler_beforeSign(t *testing.T) {
195195
<-testQPSThrottle
196196
}
197197
elapsed := time.Since(start)
198-
tt.validCallsCount(elapsed, observedCount)
198+
tt.validCallsCount(elapsed, atomic.LoadInt64(&observedCount))
199199
cancel()
200200
wg.Wait()
201201
})

0 commit comments

Comments
 (0)