Skip to content

Conversation

@xaionaro
Copy link
Member

@xaionaro xaionaro commented Jun 16, 2023

The problem

2023-06-16T15:44:06.5841874Z ==================
2023-06-16T15:44:06.5841968Z WARNING: DATA RACE
2023-06-16T15:44:06.5842097Z Write at 0x000001522d18 by goroutine 52:
2023-06-16T15:44:06.5842310Z   github.com/linuxboot/contest/cmds/contest/server.initFlags()
2023-06-16T15:44:06.5842652Z       /go/src/github.com/linuxboot/contest/cmds/contest/server/server.go:81 +0x684
2023-06-16T15:44:06.5842848Z   github.com/linuxboot/contest/cmds/contest/server.Main()
2023-06-16T15:44:06.5843189Z       /go/src/github.com/linuxboot/contest/cmds/contest/server/server.go:156 +0x9c
2023-06-16T15:44:06.5843529Z   github.com/linuxboot/contest/tests/e2e.(*E2ETestSuite).startServer.func1()
2023-06-16T15:44:06.5843831Z       /go/src/github.com/linuxboot/contest/tests/e2e/e2e_test.go:130 +0x224
2023-06-16T15:44:06.5843856Z 
2023-06-16T15:44:06.5843986Z Previous read at 0x000001522d18 by goroutine 99:
2023-06-16T15:44:06.5844196Z   github.com/linuxboot/contest/cmds/contest/server.Main.func2()
2023-06-16T15:44:06.5844534Z       /go/src/github.com/linuxboot/contest/cmds/contest/server/server.go:328 +0x369
2023-06-16T15:44:06.5844543Z 
2023-06-16T15:44:06.5844666Z Goroutine 52 (running) created at:
2023-06-16T15:44:06.5844887Z   github.com/linuxboot/contest/tests/e2e.(*E2ETestSuite).startServer()
2023-06-16T15:44:06.5845327Z       /go/src/github.com/linuxboot/contest/tests/e2e/e2e_test.go:120 +0x464
2023-06-16T15:44:06.5845560Z   github.com/linuxboot/contest/tests/e2e.(*E2ETestSuite).TestPauseResume()
2023-06-16T15:44:06.5845873Z       /go/src/github.com/linuxboot/contest/tests/e2e/e2e_test.go:344 +0x21e
2023-06-16T15:44:06.5846095Z   github.com/linuxboot/contest/tests/e2e.(*E2ETestSuite).TestPauseResume()
2023-06-16T15:44:06.5846402Z       /go/src/github.com/linuxboot/contest/tests/e2e/e2e_test.go:323 +0xbd
2023-06-16T15:44:06.5846507Z   runtime.call16()
2023-06-16T15:44:06.5846728Z       /usr/local/go/src/runtime/asm_amd64.s:701 +0x48
2023-06-16T15:44:06.5846847Z   reflect.Value.Call()
2023-06-16T15:44:06.5847080Z       /usr/local/go/src/reflect/value.go:339 +0xbc
2023-06-16T15:44:06.5847374Z   github.com/stretchr/testify/suite.Run.func1()
2023-06-16T15:44:06.5847691Z       /go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:197 +0x515
2023-06-16T15:44:06.5847799Z   testing.tRunner()
2023-06-16T15:44:06.5848046Z       /usr/local/go/src/testing/testing.go:1439 +0x24f
2023-06-16T15:44:06.5848163Z   testing.(*T).Run.func1()
2023-06-16T15:44:06.5848406Z       /usr/local/go/src/testing/testing.go:1486 +0x47
2023-06-16T15:44:06.5848415Z 
2023-06-16T15:44:06.5848539Z Goroutine 99 (finished) created at:
2023-06-16T15:44:06.5848735Z   github.com/linuxboot/contest/cmds/contest/server.Main()
2023-06-16T15:44:06.5849079Z       /go/src/github.com/linuxboot/contest/cmds/contest/server/server.go:305 +0x2b07
2023-06-16T15:44:06.5849301Z   github.com/linuxboot/contest/tests/e2e.(*E2ETestSuite).startServer.func1()
2023-06-16T15:44:06.5849616Z       /go/src/github.com/linuxboot/contest/tests/e2e/e2e_test.go:130 +0x224
2023-06-16T15:44:06.5849701Z ==================

The problem is that the flags are global. So if we have multiple end2end tests then they can have race condition on reading/writing the flags.

In this PR I make all the flags local to a specific Main() execution.

@xaionaro xaionaro force-pushed the bugfix/e2etest_race_condition branch from fe5d2d4 to 4a6eb1e Compare June 16, 2023 16:35
@xaionaro xaionaro merged commit eca9e1e into develop Jun 16, 2023
@mimir-d mimir-d deleted the bugfix/e2etest_race_condition branch June 20, 2023 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants