Fail integration tests on race (#990)
This commit is contained in:
parent
9e55a7209d
commit
7721c594a2
@ -72,9 +72,9 @@ matrix:
|
||||
- source scripts/install-awscli.sh
|
||||
- go install -race storj.io/storj/cmd/{storj-sdk,satellite,storagenode,uplink,gateway,certificates,captplanet}
|
||||
script:
|
||||
- make test-storj-sdk
|
||||
- make test-certificate-signing
|
||||
- make test-captplanet
|
||||
- make test-storj-sdk |& go run scripts/fail-on-race.go
|
||||
- make test-certificate-signing |& go run scripts/fail-on-race.go
|
||||
- make test-captplanet |& go run scripts/fail-on-race.go
|
||||
|
||||
### Docker tests ###
|
||||
- env: MODE=docker
|
||||
@ -85,7 +85,7 @@ matrix:
|
||||
install:
|
||||
- source scripts/install-awscli.sh
|
||||
script:
|
||||
- make test-all-in-one
|
||||
- make test-all-in-one |& go run scripts/fail-on-race.go
|
||||
|
||||
### windows tests ###
|
||||
- env: MODE=windows-tests
|
||||
|
55
scripts/fail-on-race.go
Normal file
55
scripts/fail-on-race.go
Normal file
@ -0,0 +1,55 @@
|
||||
// Copyright (C) 2019 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
// fail-on-race detects for keyword "DATA RACE" in output
|
||||
// and returns error code, if the output contains it.
|
||||
|
||||
func main() {
|
||||
var buffer [8192]byte
|
||||
|
||||
raceDetected := false
|
||||
search := []byte("DATA RACE")
|
||||
|
||||
start := 0
|
||||
for {
|
||||
n, readErr := os.Stdin.Read(buffer[start:])
|
||||
end := start + n
|
||||
|
||||
_, writeErr := os.Stdout.Write(buffer[start:end])
|
||||
if writeErr != nil {
|
||||
os.Stderr.Write([]byte(writeErr.Error()))
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
if bytes.Contains(buffer[:end], search) {
|
||||
raceDetected = true
|
||||
break
|
||||
}
|
||||
|
||||
// copy buffer tail to the beginning of the content
|
||||
if end > len(search) {
|
||||
copy(buffer[:], buffer[end-len(search):end])
|
||||
start = len(search)
|
||||
}
|
||||
|
||||
if readErr != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
_, _ = io.Copy(os.Stdout, os.Stdin)
|
||||
if raceDetected {
|
||||
os.Stderr.Write([]byte("\nTest failed due to data race.\n"))
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user