Fix unstable test TestBroadcastEventHandlers#670
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
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.Mutexto guard concurrentappendoperations intoreceivedArandrequestReceived1. - Adds locking around reads of those slices during predicate polling and failure logging.
- Fixes the failure-path condition in
TestBroadcastEventHandlersto compare against the correct expected total (noEvents*(noPools+1)).
jakub-id
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.