Open inancgumus opened 2 years ago
I came across a data race in the logger and test browser.
Enabling parallel might have caused the issue? #389
==================
WARNING: DATA RACE
Write at 0x00c0000fa000 by goroutine 1305:
github.com/sirupsen/logrus.(*Logger).SetOutput()
/Users/inanc/go/pkg/mod/github.com/sirupsen/logrus@v1.8.1/logger.go:388 +0x90
github.com/grafana/xk6-browser/tests.attachLogCache()
/Users/inanc/grafana/xk6-browser/tests/logrus_hook.go:74 +0x140
github.com/grafana/xk6-browser/tests.newTestBrowser()
/Users/inanc/grafana/xk6-browser/tests/test_browser.go:122 +0x4f8
github.com/grafana/xk6-browser/tests.TestURLSkipRequest()
/Users/inanc/grafana/xk6-browser/tests/network_manager_test.go:41 +0x64
testing.tRunner()
/usr/local/go/src/testing/testing.go:1439 +0x18c
testing.(*T).Run.func1()
/usr/local/go/src/testing/testing.go:1486 +0x44
Previous read at 0x00c0000fa000 by goroutine 983:
github.com/grafana/xk6-browser/log.(*Logger).ConsoleLogFormatterSerializer()
/Users/inanc/grafana/xk6-browser/log/logger.go:169 +0x270
github.com/grafana/xk6-browser/common.NewFrameSession()
/Users/inanc/grafana/xk6-browser/common/frame_session.go:112 +0x384
github.com/grafana/xk6-browser/common.NewPage()
/Users/inanc/grafana/xk6-browser/common/page.go:139 +0x874
github.com/grafana/xk6-browser/common.(*Browser).onAttachedToTarget()
/Users/inanc/grafana/xk6-browser/common/browser.go:287 +0x80c
github.com/grafana/xk6-browser/common.(*Browser).initEvents.func1()
/Users/inanc/grafana/xk6-browser/common/browser.go:194 +0x2fc
Goroutine 1305 (running) created at:
testing.(*T).Run()
/usr/local/go/src/testing/testing.go:1486 +0x560
testing.runTests.func1()
/usr/local/go/src/testing/testing.go:1839 +0x94
testing.tRunner()
/usr/local/go/src/testing/testing.go:1439 +0x18c
testing.runTests()
/usr/local/go/src/testing/testing.go:1837 +0x6c8
testing.(*M).Run()
/usr/local/go/src/testing/testing.go:1719 +0x878
main.main()
_testmain.go:175 +0x2fc
Goroutine 983 (running) created at:
github.com/grafana/xk6-browser/common.(*Browser).initEvents()
/Users/inanc/grafana/xk6-browser/common/browser.go:179 +0x2c8
github.com/grafana/xk6-browser/common.(*Browser).connect()
/Users/inanc/grafana/xk6-browser/common/browser.go:140 +0x584
github.com/grafana/xk6-browser/common.NewBrowser()
/Users/inanc/grafana/xk6-browser/common/browser.go:99 +0x5c
github.com/grafana/xk6-browser/chromium.(*BrowserType).Launch()
/Users/inanc/grafana/xk6-browser/chromium/browser_type.go:156 +0x704
github.com/grafana/xk6-browser/tests.newTestBrowser()
/Users/inanc/grafana/xk6-browser/tests/test_browser.go:127 +0x59c
github.com/grafana/xk6-browser/tests.TestLocatorTap()
/Users/inanc/grafana/xk6-browser/tests/locator_test.go:394 +0x64
testing.tRunner()
/usr/local/go/src/testing/testing.go:1439 +0x18c
testing.(*T).Run.func1()
/usr/local/go/src/testing/testing.go:1486 +0x44
==================
--- FAIL: TestLocatorInnerText (1.56s)
testing.go:1312: race detected during execution of test
--- FAIL: TestLocatorTextContent (1.59s)
--- FAIL: TestLocatorTextContent/ok (0.29s)
testing.go:1312: race detected during execution of test
testing.go:1312: race detected during execution of test
--- FAIL: TestLocatorFocus (1.60s)
--- FAIL: TestLocatorFocus/strict (0.05s)
testing.go:1312: race detected during execution of test
testing.go:1312: race detected during execution of test
--- FAIL: TestLocatorHover (1.72s)
--- FAIL: TestLocatorHover/ok (0.56s)
testing.go:1312: race detected during execution of test
testing.go:1312: race detected during execution of test
--- FAIL: TestLocatorClick (1.72s)
--- FAIL: TestLocatorClick/ok (0.51s)
testing.go:1312: race detected during execution of test
testing.go:1312: race detected during execution of test
--- FAIL: TestLocatorSelectOption (0.83s)
testing.go:1312: race detected during execution of test
--- FAIL: TestLocatorPress (0.97s)
testing.go:1312: race detected during execution of test
--- FAIL: TestLocatorTap (0.96s)
testing.go:1312: race detected during execution of test
--- FAIL: TestURLSkipRequest (0.84s)
testing.go:1312: race detected during execution of test
--- FAIL: TestLocatorElementState (2.45s)
--- FAIL: TestLocatorElementState/readOnly (1.57s)
testing.go:1312: race detected during execution of test
testing.go:1312: race detected during execution of test
FAIL
FAIL github.com/grafana/xk6-browser/tests 33.731s
FAIL
Discovered by #141. I'm not sure this is related to logging.