Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change fixes the obvious data races in the signer/apki2 tests. It also adds the `EMPTY_TESTCACHE` environment variable to run-unit-tests.sh to allow easy resetting of the Go test cache to reproduce data races easily. When run with `docker run unit-test -e RACE_TEST=1`, the following data race was found: ``` ================== WARNING: DATA RACE Read at 0x000000988860 by goroutine 21: github.com/mozilla-services/autograph/signer/apk2.TestNewSigner.func1() /app/src/autograph/signer/apk2/apk2_test.go:39 +0x40 testing.tRunner() /usr/lib/go-1.22/src/testing/testing.go:1689 +0x180 testing.(*T).Run.gowrap1() /usr/lib/go-1.22/src/testing/testing.go:1742 +0x40 Previous write at 0x000000988860 by goroutine 22: github.com/mozilla-services/autograph/signer/apk2.TestNewSigner.func2() /app/src/autograph/signer/apk2/apk2_test.go:48 +0x3c testing.tRunner() /usr/lib/go-1.22/src/testing/testing.go:1689 +0x180 testing.(*T).Run.gowrap1() /usr/lib/go-1.22/src/testing/testing.go:1742 +0x40 Goroutine 21 (running) created at: testing.(*T).Run() /usr/lib/go-1.22/src/testing/testing.go:1742 +0x5e4 github.com/mozilla-services/autograph/signer/apk2.TestNewSigner() /app/src/autograph/signer/apk2/apk2_test.go:36 +0x44 testing.tRunner() /usr/lib/go-1.22/src/testing/testing.go:1689 +0x180 testing.(*T).Run.gowrap1() /usr/lib/go-1.22/src/testing/testing.go:1742 +0x40 Goroutine 22 (running) created at: testing.(*T).Run() /usr/lib/go-1.22/src/testing/testing.go:1742 +0x5e4 github.com/mozilla-services/autograph/signer/apk2.TestNewSigner() /app/src/autograph/signer/apk2/apk2_test.go:45 +0x60 testing.tRunner() /usr/lib/go-1.22/src/testing/testing.go:1689 +0x180 testing.(*T).Run.gowrap1() /usr/lib/go-1.22/src/testing/testing.go:1742 +0x40 ================== ``` This was caused by tests modifying two global variables `apk2signerconf` and `apk2signerconfModeV3enabled`. This was worsened by the tests being marked as `t.Parallel` allowing them to be run concurrently. This change removes those globals and provides their data from two new functions in the tests, instead. The names are still bad in some cases, but we're fixing problems, not trying to clean up the world. Updates AUT-188
- Loading branch information