Data race in http api tests
When executing tests with gotestsum --junitfile report.xml --format testname -- -short -race -v -coverprofile=coverage.out
I can reproduce the following error.
I'm not sure why this isn't occurring on the CI.
gotestsum --junitfile report.xml --format testname -- -short -race -v -coverprofile=coverage.out
PASS TestRun/Controller_Start_HTTP_API (0.01s)
PASS TestRun (1.01s)
PASS Test_httpApi//livez (0.00s)
PASS Test_httpApi//readyz (0.00s)
PASS Test_httpApi//metrics (0.00s)
=== RUN Test_httpApi
Recovered in f http: multiple registrations for /livez
==================
WARNING: DATA RACE
Write at 0x00c000e48048 by goroutine 53:
code.fbi.h-da.de/danet/gosdn.startHttpServer()
/home/aps/Code/hda/gosdn-makefile/http.go:33 +0x105
code.fbi.h-da.de/danet/gosdn.startHttpServer()
/home/aps/Code/hda/gosdn-makefile/http.go:32 +0x3a
code.fbi.h-da.de/danet/gosdn.Test_httpApi()
/home/aps/Code/hda/gosdn-makefile/http_test.go:36 +0x2cd
testing.tRunner()
/usr/lib/go/src/testing/testing.go:1259 +0x22f
testing.(*T).Run·dwrap·21()
/usr/lib/go/src/testing/testing.go:1306 +0x47
Previous read at 0x00c000e48048 by goroutine 43:
code.fbi.h-da.de/danet/gosdn.startHttpServer.func1()
/home/aps/Code/hda/gosdn-makefile/http.go:35 +0x5b
Goroutine 53 (running) created at:
testing.(*T).Run()
/usr/lib/go/src/testing/testing.go:1306 +0x726
testing.runTests.func1()
/usr/lib/go/src/testing/testing.go:1598 +0x99
testing.tRunner()
/usr/lib/go/src/testing/testing.go:1259 +0x22f
testing.runTests()
/usr/lib/go/src/testing/testing.go:1596 +0x7ca
testing.(*M).Run()
/usr/lib/go/src/testing/testing.go:1504 +0x9d1
code.fbi.h-da.de/danet/gosdn.TestMain()
/home/aps/Code/hda/gosdn-makefile/initialise_test.go:25 +0x8e
main.main()
_testmain.go:97 +0x364
Goroutine 43 (finished) created at:
code.fbi.h-da.de/danet/gosdn.startHttpServer() /home/aps/Code/hda/gosdn-makefile/http.go:34 +0x13b code.fbi.h-da.de/danet/gosdn.initialize()
/home/aps/Code/hda/gosdn-makefile/controller.go:62 +0x6a code.fbi.h-da.de/danet/gosdn.Run.func1() /home/aps/Code/hda/gosdn-makefile/controller.go:171 +0x44
sync.(*Once).doSlow() /usr/lib/go/src/sync/once.go:68 +0x127 sync.(*Once).Do()
/usr/lib/go/src/sync/once.go:59 +0x46 code.fbi.h-da.de/danet/gosdn.Run() /home/aps/Code/hda/gosdn-makefile/controller.go:170 +0x9b
code.fbi.h-da.de/danet/gosdn.TestRun.func1() /home/aps/Code/hda/gosdn-makefile/controller_test.go:34 +0x4b ==================
=== CONT Test_httpApi testing.go:1152: race detected during execution of test --- FAIL: Test_httpApi (0.01s)
FAIL Test_httpApi (0.01s) === CONT testing.go:1152: race detected during execution of test
coverage: 76.3% of statements exit status 1 FAIL .