Commit d866361
Assertion function and TestLogger (temporalio#7411)
## What changed?
<!-- Describe what has changed in this PR -->
- Added a new function `softassert.That` that logs an error if the
provided condition is false
- Added `testlogger.Testlogger` (copied and slightly modified from our
internal repository) to functional tests
## Why?
<!-- Tell your future self why have you made these changes -->
To allow developers to verify pre- and post-conditions in their code.
**Why not panic?** Maybe in the future. For now, we're happy with
finding these failed assertions in functional tests.
**What about nightlies/long-haul tests?** I've filed a ticket to detect
a failed assertion there and surface them as an alert.
## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
Planted a failing assertion.
**The error log:**
```
logger.go:146: 2025-03-04T20:50:08.578Z ERROR log/zap_logger.go:154 Unexpected Error log encountered: failed assertion: wake called twice {"host": "127.0.0.1:35427", "component": "matching-engine", "wf-task-queue-name": "/_sys/temporal-sys-processor-parent-close-policy/1", "wf-task-queue-type": "Workflow", "wf-namespace": "temporal-system", "worker-build-id": "_unversioned_", "failed-assertion": true, "logging-call-at": "/home/runner/work/temporal/temporal/common/log/with_logger.go:72"}
go.temporal.io/server/common/log.(*zapLogger).Error
/home/runner/work/temporal/temporal/common/log/zap_logger.go:154
go.temporal.io/server/common/testing/testlogger.(*TestLogger).Error
/home/runner/work/temporal/temporal/common/testing/testlogger/testlogger.go:359
go.temporal.io/server/common/log.(*withLogger).Error
/home/runner/work/temporal/temporal/common/log/with_logger.go:72
go.temporal.io/server/common/log.(*withLogger).Error
/home/runner/work/temporal/temporal/common/log/with_logger.go:72
go.temporal.io/server/common/log.(*withLogger).Error
/home/runner/work/temporal/temporal/common/log/with_logger.go:72
go.temporal.io/server/common/log.(*withLogger).Error
/home/runner/work/temporal/temporal/common/log/with_logger.go:72
go.temporal.io/server/common/softassert.That
/home/runner/work/temporal/temporal/common/softassert/softassert.go:50
go.temporal.io/server/service/matching.(*waitableMatchResult).wake
/home/runner/work/temporal/temporal/service/matching/matcher_data.go:560
```
https://github.com/temporalio/temporal/actions/runs/13662479940/job/38196953773?pr=7411#step:9:1638
**The test result:**
```
=== Failed
=== FAIL: tests TestPriorityFairnessSuite/TestPriority_Activity_Basic (0.00s)
functional_test_base.go:301: Running TestPriorityFairnessSuite/TestPriority_Activity_Basic in test shard 2/3
functional_test_base.go:373:
Error Trace: /home/runner/work/temporal/temporal/tests/testcore/functional_test_base.go:373
/home/runner/work/temporal/temporal/tests/testcore/functional_test_base.go:272
/home/runner/work/temporal/temporal/tests/testcore/functional_test_base.go:254
/home/runner/work/temporal/temporal/tests/testcore/functional_test_sdk_suite.go:97
/home/runner/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:192
Error: Failing test as unexpected error logs were found.
Look for 'Unexpected Error log encountered'.
Test: TestPriorityFairnessSuite/TestPriority_Activity_Basic
```
https://github.com/temporalio/temporal/actions/runs/13662479940/job/38196953773?pr=7411#step:9:1053
## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->
## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
---------
Co-authored-by: David Reiss <[email protected]>
Co-authored-by: David Reiss <[email protected]>
Co-authored-by: Tim Deeb-Swihart <[email protected]>1 parent ec26c25 commit d866361
File tree
10 files changed
+605
-2
lines changed- common
- log/tag
- softassert
- testing/testlogger
- tests
- testcore
10 files changed
+605
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
571 | 574 | | |
572 | 575 | | |
573 | 576 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
0 commit comments