Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information