We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
При прогонке тестов возник data-race. Версия gonkey v1.12.0.
Привожу записи из лога:
build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m WARNING: DATA RACE build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m Write at 0x00c000609890 by goroutine 40: build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m github.com/lamoda/gonkey/mocks.(*ServiceMock).ServeHTTP() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /go/pkg/mod/github.com/lamoda/[email protected]/mocks/service_mock.go:64 +0x1f3 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m net/http.serverHandler.ServeHTTP() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /usr/local/go/src/net/http/server.go:2878 +0x89a build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m net/http.(*conn).serve() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /usr/local/go/src/net/http/server.go:1929 +0x12e4 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m net/http.(*Server).Serve- dwrap- 82() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /usr/local/go/src/net/http/server.go:3033 +0x58 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m Previous read at 0x00c000609890 by goroutine 62: build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m github.com/lamoda/gonkey/mocks.(*ServiceMock).EndRunningContext() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /go/pkg/mod/github.com/lamoda/[email protected]/mocks/service_mock.go:88 +0x84 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m github.com/lamoda/gonkey/mocks.(*Mocks).EndRunningContext() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /go/pkg/mod/github.com/lamoda/[email protected]/mocks/mocks.go:85 +0x124 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m github.com/lamoda/gonkey/runner.(*Runner).executeTest() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /go/pkg/mod/github.com/lamoda/[email protected]/runner/runner.go:180 +0x995 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m github.com/lamoda/gonkey/runner.(*Runner).Run() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /go/pkg/mod/github.com/lamoda/[email protected]/runner/runner.go:75 +0x1f0 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m github.com/lamoda/gonkey/runner.RunWithTesting() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /go/pkg/mod/github.com/lamoda/[email protected]/runner/runner_testing.go:98 +0x10fc build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m stash.lamoda.ru/payment/payment-gate/tests/gonkey.TestRunner.Run() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /app/tests/gonkey/test_runner.go:101 +0xbb9 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m stash.lamoda.ru/payment/payment-gate/tests/gonkey.TestRefundNeg() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /app/tests/gonkey/commandbox_test.go:49 +0x204 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m testing.tRunner() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /usr/local/go/src/testing/testing.go:1259 +0x22f build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m testing.(*T).Run- dwrap- 21() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /usr/local/go/src/testing/testing.go:1306 +0x47 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m Goroutine 40 (running) created at: build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m net/http.(*Server).Serve() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /usr/local/go/src/net/http/server.go:3033 +0x847 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m github.com/lamoda/gonkey/mocks.(*ServiceMock).StartServerWithAddr- dwrap- 3() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /go/pkg/mod/github.com/lamoda/[email protected]/mocks/service_mock.go:40 +0x58 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m Goroutine 62 (running) created at: build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m testing.(*T).Run() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /usr/local/go/src/testing/testing.go:1306 +0x726 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m testing.runTests.func1() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /usr/local/go/src/testing/testing.go:1598 +0x99 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m testing.tRunner() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /usr/local/go/src/testing/testing.go:1259 +0x22f build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m testing.runTests() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /usr/local/go/src/testing/testing.go:1596 +0x7ca build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m testing.(*M).Run() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m /usr/local/go/src/testing/testing.go:1504 +0x9d1 build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m main.main() build 01-Apr-2022 15:14:49 [36mpayment-gate-test |[0m _testmain.go:149 +0x324
В методе (*mocks.ServiceMock).ServeHTTP() происходит перезапись слайса m.errors.
func (m *ServiceMock) ServeHTTP(w http.ResponseWriter, r *http.Request) { m.Lock() defer m.Unlock() if m.mock != nil { errs := m.mock.Execute(w, r) m.errors = append(m.errors, errs...) } }
А в методе (*mocks.ServiceMock).EndRunningContext(), происходит чтение из m.errors слайса. И оно мьютексом не закрыто. Получается race condition.
func (m *ServiceMock) EndRunningContext() []error { errs := append(m.errors, m.mock.EndRunningContext()...) for i, e := range errs { errs[i] = &Error{ error: e, ServiceName: m.ServiceName, } } return errs }
The text was updated successfully, but these errors were encountered:
lamoda#133 | fix data race
a646d4f
Merge pull request #155 from architectv/issue-133-fix-data-race
e1b507a
#133 | fix data race
Fixed in #155
Sorry, something went wrong.
No branches or pull requests
При прогонке тестов возник data-race. Версия gonkey v1.12.0.
Привожу записи из лога:
В методе (*mocks.ServiceMock).ServeHTTP() происходит перезапись слайса m.errors.
А в методе (*mocks.ServiceMock).EndRunningContext(), происходит чтение из m.errors слайса. И оно мьютексом не закрыто. Получается race condition.
The text was updated successfully, but these errors were encountered: