April 2016: Testing

Please RSVP at Meetup or Google+.

We get started at 6:30 pm.

Sponsors

Food provided by Bellstone Engineering.

Venue provided by Startup Edmonton.

Talks

Testing concurrent things

Matthias Stone gave a practical tour of testing concurrent code in Go. He started with the testing basics — _test.go files, func TestX(t *testing.T), and go test — before focusing on the built-in data race detector, which since Go 1.1 reports unsynchronized memory accesses that violate the Go Memory Model. He showed -race in action, read through a race report, and recommended GORACE=strip_path_prefix to shorten file paths. The talk covered testing blocking behaviour and deadlocks (noting the default 10-minute test timeout), the difficulty of testing goroutine ordering, and the limitations of concurrent tests — t.Fatal/t.FailNow must run on the test goroutine and goroutine completion order is unspecified. He closed with tips such as keeping goroutine counts low, instrumenting from the main goroutine, using concurrent-safe test doubles, and re-running tests many times to surface rare timing bugs.

Key points:

  • The race detector is the key tool for concurrent tests.
  • go test -race finds unsynchronized reads/writes, even without visible misbehaviour.
  • GORACE=strip_path_prefix cleans up race reports.
  • Watch for deadlocks/timeouts; tests have a 10-minute default timeout.
  • t.Fatal/t.FailNow must be called from the test goroutine.
  • Goroutine completion order can't be asserted.
  • Run tests repeatedly to catch nondeterministic bugs.

Slides

Events

  • Monthly Hack Day - April 2 (Registration required)
  • Edmonton Go Meetup - May