Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky tests: Provider code is taken in test suite #5092

Merged
merged 2 commits into from
Mar 31, 2025

Conversation

tomas-stefano
Copy link
Contributor

@tomas-stefano tomas-stefano commented Mar 27, 2025

Context

We are seeing flaky tests in our test suite in Publish.

We need to adjust how the provider code is generated in the provider factory so that it is guaranteed to be unique.

Changes proposed in this pull request

Make sure provider code is unique when generating in tests.

@tomas-stefano tomas-stefano changed the title WIP Fix flaky tests: Provider code is taken in test suite Mar 27, 2025
@tomas-stefano tomas-stefano force-pushed the td/fix-provider-code-flakey-specs branch from 9bdc780 to fd21786 Compare March 27, 2025 11:06
@tomas-stefano tomas-stefano marked this pull request as ready for review March 27, 2025 11:06
@tomas-stefano tomas-stefano requested a review from a team as a code owner March 27, 2025 11:06
@tomas-stefano
Copy link
Contributor Author

@inulty-dfe
Copy link
Contributor

Is there another way to do this other than making DB queries until it works?

@inulty-dfe
Copy link
Contributor

Is there another way to do this other than making DB queries until it works?

Would it be better to select all the provider codes at once and use a code that wasn't in the result rather than generate, query, generate, query?

@tomas-stefano
Copy link
Contributor Author

Is there another way to do this other than making DB queries until it works?

Would it be better to select all the provider codes at once and use a code that wasn't in the result rather than generate, query, generate, query?

Ok, I changed the implementation. Let me know your thoughts.

@inulty-dfe
Copy link
Contributor

Is there another way to do this other than making DB queries until it works?

Would it be better to select all the provider codes at once and use a code that wasn't in the result rather than generate, query, generate, query?

Ok, I changed the implementation. Let me know your thoughts.

Lets keep an eye on build / test times and see if this is slows down the test suite in the coming weeks

Copy link
Contributor

@inulty-dfe inulty-dfe left a comment

Choose a reason for hiding this comment

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

Let's keep an eye on the test suite to see if this makes it much slower

Move to a class so we can properly organise the code.

Get the provider code first and then attempt to generate an unique
provider code.

I used #to_set

Why .to_set?

Set uses hash-based lookups, which are O(1) (constant time).
@tomas-stefano tomas-stefano force-pushed the td/fix-provider-code-flakey-specs branch from 21b5a07 to 8918856 Compare March 31, 2025 09:09
@tomas-stefano tomas-stefano merged commit 2b79765 into main Mar 31, 2025
34 checks passed
@tomas-stefano tomas-stefano deleted the td/fix-provider-code-flakey-specs branch March 31, 2025 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants