Skip to content

fix(test): replace flaky 1ms sleep with polling in engine test#5306

Merged
geyslan merged 1 commit into
aquasecurity:mainfrom
geyslan:fix-unit-test
May 19, 2026
Merged

fix(test): replace flaky 1ms sleep with polling in engine test#5306
geyslan merged 1 commit into
aquasecurity:mainfrom
geyslan:fix-unit-test

Conversation

@geyslan
Copy link
Copy Markdown
Member

@geyslan geyslan commented May 19, 2026

1. Explain what the PR does

022cbe8 fix(test): replace flaky 1ms sleep with polling in engine test

The TestEngine_ConsumeSources test relied on a 1ms sleep for event
propagation, causing intermittent failures on loaded x86_64 runners
when the engine goroutine hadn't processed the event in time.

Use require.Eventually (5s timeout, 10ms poll) with exact count
matching for positive-event cases, and require.Never over a 50ms
window for zero-event assertions. Remove dead gotEvent/emptyEvent
comparison that always passed regardless of behavior.

--

2. Explain how to test it

3. Other comments

@geyslan geyslan self-assigned this May 19, 2026
@geyslan geyslan requested review from a team, Copilot and trvll May 19, 2026 13:07
Copy link
Copy Markdown

Copilot AI left a comment

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 improves the reliability of TestEngine_ConsumeSources in the signatures engine by replacing a brittle fixed 1ms sleep with polling-based synchronization to reduce intermittent CI failures under load.

Changes:

  • Replaces the 1ms propagation sleep with require.Eventually polling for positive event-delivery cases.
  • Adds a short delay for zero-event cases before asserting no events were received.

Comment thread pkg/signatures/engine/engine_test.go Outdated
Comment thread pkg/signatures/engine/engine_test.go Outdated
Comment thread pkg/signatures/engine/engine_test.go Outdated
The TestEngine_ConsumeSources test relied on a 1ms sleep for event
propagation, causing intermittent failures on loaded x86_64 runners
when the engine goroutine hadn't processed the event in time.

Use require.Eventually (5s timeout, 10ms poll) with exact count
matching for positive-event cases, and require.Never over a 50ms
window for zero-event assertions. Remove dead gotEvent/emptyEvent
comparison that always passed regardless of behavior.
Copilot AI review requested due to automatic review settings May 19, 2026 13:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread pkg/signatures/engine/engine_test.go
Comment thread pkg/signatures/engine/engine_test.go
Copy link
Copy Markdown
Contributor

@trvll trvll left a comment

Choose a reason for hiding this comment

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

+1

@geyslan geyslan merged commit 57b0020 into aquasecurity:main May 19, 2026
38 of 39 checks passed
@geyslan geyslan deleted the fix-unit-test branch May 19, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants