Skip to content

Fix unstable test TestBroadcastEventHandlers#670

Merged
adamdickmeiss merged 2 commits into
mainfrom
fix-test-TestBroadcastEventHandlers
Jul 20, 2026
Merged

Fix unstable test TestBroadcastEventHandlers#670
adamdickmeiss merged 2 commits into
mainfrom
fix-test-TestBroadcastEventHandlers

Conversation

@adamdickmeiss

Copy link
Copy Markdown
Contributor

TestBroadcastEventHandlers (2.06s)
eventbus_test.go:184: Expected to have some events
eventbus_test.go:190:
Error Trace: /home/adam/proj/crosslink/broker/test/events/eventbus_test.go:190
Error: Not equal:
expected: 8
actual : 7
Test: TestBroadcastEventHandlers
Messages: Total number of events should match the number of created tasks
eventbus_test.go:194: Request event 0: 872b2beb-78dd-4cad-8132-747ee5340d53
eventbus_test.go:194: Request event 1: cf09ec08-9dd1-435e-b990-012e36477a5c
eventbus_test.go:198: Received event 0 from pool 0: 872b2beb-78dd-4cad-8132-747ee5340d53
eventbus_test.go:198: Received event 0 from pool 1: cf09ec08-9dd1-435e-b990-012e36477a5c
eventbus_test.go:198: Received event 1 from pool 1: 872b2beb-78dd-4cad-8132-747ee5340d53
eventbus_test.go:198: Received event 0 from pool 2: cf09ec08-9dd1-435e-b990-012e36477a5c
eventbus_test.go:198: Received event 1 from pool 2: 872b2beb-78dd-4cad-8132-747ee5340d53

Fix by lock the append of events received as it can happen async.

TestBroadcastEventHandlers (2.06s)
    eventbus_test.go:184: Expected to have some events
    eventbus_test.go:190:
                Error Trace:    /home/adam/proj/crosslink/broker/test/events/eventbus_test.go:190
                Error:          Not equal:
                                expected: 8
                                actual  : 7
                Test:           TestBroadcastEventHandlers
                Messages:       Total number of events should match the number of created tasks
    eventbus_test.go:194: Request event 0: 872b2beb-78dd-4cad-8132-747ee5340d53
    eventbus_test.go:194: Request event 1: cf09ec08-9dd1-435e-b990-012e36477a5c
    eventbus_test.go:198: Received event 0 from pool 0: 872b2beb-78dd-4cad-8132-747ee5340d53
    eventbus_test.go:198: Received event 0 from pool 1: cf09ec08-9dd1-435e-b990-012e36477a5c
    eventbus_test.go:198: Received event 1 from pool 1: 872b2beb-78dd-4cad-8132-747ee5340d53
    eventbus_test.go:198: Received event 0 from pool 2: cf09ec08-9dd1-435e-b990-012e36477a5c
    eventbus_test.go:198: Received event 1 from pool 2: 872b2beb-78dd-4cad-8132-747ee5340d53

Fix by lock the append of events received as it can happen async.
Copilot AI review requested due to automatic review settings July 19, 2026 18:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to stabilize the TestBroadcastEventHandlers integration test by preventing concurrent unsynchronized access to shared slices that collect received events.

Changes:

  • Introduces a sync.Mutex to guard concurrent append operations into receivedAr and requestReceived1.
  • Adds locking around reads of those slices during predicate polling and failure logging.
  • Fixes the failure-path condition in TestBroadcastEventHandlers to compare against the correct expected total (noEvents*(noPools+1)).

Comment thread broker/test/events/eventbus_test.go
Comment thread broker/test/events/eventbus_test.go
@adamdickmeiss adamdickmeiss changed the title Fix unstable test iTestBroadcastEventHandlers Fix unstable test TestBroadcastEventHandlers Jul 19, 2026
@adamdickmeiss
adamdickmeiss merged commit 5783927 into main Jul 20, 2026
6 checks passed
@adamdickmeiss
adamdickmeiss deleted the fix-test-TestBroadcastEventHandlers branch July 20, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants