Skip to content

tests: retry deferred test assertion in t.Cleanup#1095

Merged
oxzi merged 1 commit intomainfrom
fix-object-sync-tests
Mar 17, 2026
Merged

tests: retry deferred test assertion in t.Cleanup#1095
oxzi merged 1 commit intomainfrom
fix-object-sync-tests

Conversation

@yhabteab
Copy link
Member

All the time, I was thinking that there must be some race condition in my Icinga/icinga2#10619 PR that causes the test to fail occasionally1 and almost gone crazy trying to figure out what it is. However, it turns out that the issue is simply that the assertion is being executed before the queries have been processed, which is why it fails occasionally. After adding the retry mechanism, not a single failure has occurred after running the test hundreds of times.

Footnotes

  1. https://github.com/Icinga/icinga2/pull/10619#issuecomment-3998801275

Copy link
Member

@oxzi oxzi left a comment

Choose a reason for hiding this comment

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

Sounds reasonable, thanks!

However, could you please add the same guard to the other function call as well?

t.Cleanup(func() { assertNoDependencyDanglingReferences(t, r, db) })

@oxzi oxzi added this to the 1.6.0 milestone Mar 16, 2026
@yhabteab
Copy link
Member Author

However, could you please add the same guard to the other function call as well?

Sure! Though, it doesn't need such a guard, since that assertion is for the initial-config sync, and my PR didn't add any behavioral changes to the initial-config sync. But I can guard it if you think it's necessary for consistency.

Just like all other test assertions, this one should also be retried
until it succeeds or times out. It seems this wasn't a problem before,
but with the upcoming changes to Icinga 2.16, this assertion will fail
occasionally since the queries are now sent with a bit of delay. By
retrying the assertion, we can ensure that it will eventually succeed
once the queries are processed or time out after a reasonable period.
@yhabteab yhabteab force-pushed the fix-object-sync-tests branch from 98ebe0e to 7497d4c Compare March 16, 2026 09:05
@yhabteab yhabteab requested a review from oxzi March 16, 2026 09:06
@yhabteab
Copy link
Member Author

However, could you please add the same guard to the other function call as well?

Sure! Though, it doesn't need such a guard, since that assertion is for the initial-config sync, and my PR didn't add any behavioral changes to the initial-config sync. But I can guard it if you think it's necessary for consistency.

Done.

@oxzi oxzi merged commit fb430e9 into main Mar 17, 2026
31 checks passed
@oxzi oxzi deleted the fix-object-sync-tests branch March 17, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants