Files
tasks/tools/testrunner/testdata/alerts-input.log
Sean KaneandGitHub d1834f9e54 tests: expand testrunner support to alert on panics or dataraces (#8351)
## What changed?
Expanding `testrunner` tool to add alerts for panics and data races.
Sample table with an injected data race (and real panic):

<table><tr><th><th>Tests</th><th>Passed ✅</th><th>Skipped
⏭️</th><th>Failed ❌</th></tr><tr><td>JUnit Test Report</td><td>721
ran</td><td>340 passed</td><td>370 skipped</td><td>11
failed</td></tr></table>
<table><tr><th>Test</th><th>Result</th></tr><tr><td
colspan="2"><strong>JUnit Test
Report</strong></td></tr><tr><td>functional-test (crash)</td><td>❌
failure</td></tr><tr><td>io/server/tests.TestActivityApiBatchResetClientTestSuite/TestActivityBatchReset_DataRace</td><td>❌
failure</td></tr><tr><td>io/server/tests.TestTaskQueueStats_Pri_Suite/TestNoTasks_ValidateStats</td><td>❌
failure</td></tr><tr><td>io/server/tests.TestVersioning3FunctionalSuite/TestUnpinnedQuery_NoSticky/ForceTaskForwardForcePollForwardForceAsync</td><td>❌
failure</td></tr><tr><td>io/server/tests.TestVersioningFunctionalSuite/TestDispatchQueryOld/ForceTaskForwardForcePollForwardForceAsync</td><td>❌
failure</td></tr><tr><td>io/server/tests.TestActivityApiBatchResetClientTestSuite/TestActivityBatchReset_DataRace
(retry 1)</td><td>❌
failure</td></tr><tr><td>io/server/tests.TestActivityApiBatchResetClientTestSuite/TestActivityBatchReset_DataRace
(retry 2)</td><td>❌ failure</td></tr><tr><td>func1.DATA RACE: Data race
detected — in
go.temporal.io/server/tests.(*ActivityApiBatchResetClientTestSuite).TestActivityBatchReset_DataRace.func1</td><td>❌
failure</td></tr><tr><td>PANIC: runtime error: invalid memory address or
nil pointer dereference — in
TestTaskQueueStats_Pri_Suite/TestAddMultipleTasks_MultiplePartitions_ValidateStats_Cached</td><td>❌
failure</td></tr><tr><td>func1.DATA RACE: Data race detected — in
go.temporal.io/server/tests.(*ActivityApiBatchResetClientTestSuite).TestActivityBatchReset_DataRace.func1</td><td>❌
failure</td></tr><tr><td>func1.DATA RACE: Data race detected — in
go.temporal.io/server/tests.(*ActivityApiBatchResetClientTestSuite).TestActivityBatchReset_DataRace.func1</td><td>❌
failure</td></tr></table>

Source:
https://github.com/temporalio/temporal/actions/runs/17870152469?pr=8351

## Why?
This change will help the temporal team find bugs sooner.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [X] added new unit test(s)
- [ ] added new functional test(s)

## Potential risks
NA
2025-09-22 11:01:29 -06:00

97 lines
3.7 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
❯ go test -race
==================
WARNING: DATA RACE
Read at 0x00c0001121e8 by goroutine 8:
test.dataRaceExample.func2()
/Users/seankane/github.com/test/main.go:27 +0x2c
Previous write at 0x00c0001121e8 by goroutine 7:
test.dataRaceExample.func1()
/Users/seankane/github.com/test/main.go:23 +0x3c
Goroutine 8 (running) created at:
test.dataRaceExample()
/Users/seankane/github.com/test/main.go:26 +0x100
test.TestDataRaceExample()
/Users/seankane/github.com/test/main_test.go:13 +0x20
testing.tRunner()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1792 +0x180
testing.(*T).Run.gowrap1()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1851 +0x40
Goroutine 7 (finished) created at:
test.dataRaceExample()
/Users/seankane/github.com/test/main.go:22 +0x9c
test.TestDataRaceExample()
/Users/seankane/github.com/test/main_test.go:13 +0x20
testing.tRunner()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1792 +0x180
testing.(*T).Run.gowrap1()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1851 +0x40
==================
==================
WARNING: DATA RACE
Read at 0x00c0001121e8 by goroutine 6:
test.dataRaceExample()
/Users/seankane/github.com/test/main.go:33 +0x118
test.TestDataRaceExample()
/Users/seankane/github.com/test/main_test.go:13 +0x20
testing.tRunner()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1792 +0x180
testing.(*T).Run.gowrap1()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1851 +0x40
Previous write at 0x00c0001121e8 by goroutine 8:
test.dataRaceExample.func2()
/Users/seankane/github.com/test/main.go:27 +0x3c
Goroutine 6 (running) created at:
testing.(*T).Run()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1851 +0x684
testing.runTests.func1()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:2279 +0x7c
testing.tRunner()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1792 +0x180
testing.runTests()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:2277 +0x77c
testing.(*M).Run()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:2142 +0xb68
main.main()
_testmain.go:47 +0x110
Goroutine 8 (finished) created at:
test.dataRaceExample()
/Users/seankane/github.com/test/main.go:26 +0x100
test.TestDataRaceExample()
/Users/seankane/github.com/test/main_test.go:13 +0x20
testing.tRunner()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1792 +0x180
testing.(*T).Run.gowrap1()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1851 +0x40
==================
Counter value: 2
--- FAIL: TestDataRaceExample (0.01s)
testing.go:1490: race detected during execution of test
--- FAIL: TestPanicExample (0.00s)
panic: This is a panic [recovered]
panic: This is a panic
goroutine 37 [running]:
testing.tRunner.func1.2({0x100668b00, 0x100699d40})
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1734 +0x2bc
testing.tRunner.func1()
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1737 +0x47c
panic({0x100668b00?, 0x100699d40?})
/opt/homebrew/Cellar/go/1.24.4/libexec/src/runtime/panic.go:792 +0x124
test.panicExample(...)
/Users/seankane/github.com/test/main.go:13
test.TestPanicExample(0xc000102e00?)
/Users/seankane/github.com/test/main_test.go:17 +0x38
testing.tRunner(0xc000102e00, 0x1006992b0)
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1792 +0x184
created by testing.(*T).Run in goroutine 1
/opt/homebrew/Cellar/go/1.24.4/libexec/src/testing/testing.go:1851 +0x688
exit status 2
FAIL test 0.311s