weaveworks / weave

Simple, resilient multi-host containers networking and more.
https://www.weave.works
Apache License 2.0
6.62k stars 671 forks source link

make tests fail on data races #1489

Open rade opened 9 years ago

rade commented 9 years ago

It appears that they don't, e.g. #1480 was only discovered because there were some "proper" failures in the same test run.

tomwilkie commented 9 years ago

Can confirm, race detector does not affect exit code:

vagrant@ubuntu-14:~/src/github.com/weaveworks/weave/nameserver$ go test --race --run TestRace
==================
WARNING: DATA RACE
Read by goroutine 8:
  github.com/weaveworks/weave/nameserver.func·018()
      /home/vagrant/src/github.com/weaveworks/weave/nameserver/dns_test.go:26 +0x52

Previous write by goroutine 7:
  github.com/weaveworks/weave/nameserver.func·018()
      /home/vagrant/src/github.com/weaveworks/weave/nameserver/dns_test.go:26 +0x68

Goroutine 8 (running) created at:
  github.com/weaveworks/weave/nameserver.TestRace()
      /home/vagrant/src/github.com/weaveworks/weave/nameserver/dns_test.go:29 +0x19d
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:447 +0x133

Goroutine 7 (finished) created at:
  github.com/weaveworks/weave/nameserver.TestRace()
      /home/vagrant/src/github.com/weaveworks/weave/nameserver/dns_test.go:29 +0x19d
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:447 +0x133
==================
PASS
ok      github.com/weaveworks/weave/nameserver  18.051s
vagrant@ubuntu-14:~/src/github.com/weaveworks/weave/nameserver$ echo $?
0
tomwilkie commented 9 years ago

Got weird behaviour, can't get go test -race to work reliably:

vagrant@ubuntu-14:~/src/github.com/weaveworks/weave/nameserver$ GORACE="exitcode=1" go test -race -run TestRace
==================
WARNING: DATA RACE
Read by goroutine 8:
  github.com/weaveworks/weave/nameserver.func·018()
      /home/vagrant/src/github.com/weaveworks/weave/nameserver/dns_test.go:26 +0x52

Previous write by goroutine 7:
  github.com/weaveworks/weave/nameserver.func·018()
      /home/vagrant/src/github.com/weaveworks/weave/nameserver/dns_test.go:26 +0x68

Goroutine 8 (running) created at:
  github.com/weaveworks/weave/nameserver.TestRace()
      /home/vagrant/src/github.com/weaveworks/weave/nameserver/dns_test.go:29 +0x19d
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:447 +0x133

Goroutine 7 (finished) created at:
  github.com/weaveworks/weave/nameserver.TestRace()
      /home/vagrant/src/github.com/weaveworks/weave/nameserver/dns_test.go:29 +0x19d
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:447 +0x133
==================
PASS
ok      github.com/weaveworks/weave/nameserver  3.702s
vagrant@ubuntu-14:~/src/github.com/weaveworks/weave/nameserver$ echo $?
0
vagrant@ubuntu-14:~/src/github.com/weaveworks/weave/nameserver$ go version
go version go1.4.2 linux/amd64
rade commented 9 years ago

can't get go test -race to work reliably

Is it racy? ;)