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

Use seeded random generator in tests. #437

Merged
merged 1 commit into from
Nov 22, 2023
Merged

Use seeded random generator in tests. #437

merged 1 commit into from
Nov 22, 2023

Conversation

pstibrany
Copy link
Member

What this PR does:

This PR replaces use of GenerateTokens in tests with generator initialized by initTokenGenerator(b), which also logs used seed.

Extracted from #433, to make it smaller.

Checklist

  • Tests updated
  • [na] CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@@ -34,8 +34,3 @@ func TestRandomTokenGenerator_IgnoresOldTokens(t *testing.T) {
}
}
}

// GenerateTokens generates numTokens unique, random and sorted tokens for testing purposes.
func GenerateTokens(tokensCount int, takenTokens []uint32) Tokens {
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] WDYT if we keep this function, and initialize the token generator inside it?
This way the diff in ring_test.go would be minimizined.

Copy link
Member Author

Choose a reason for hiding this comment

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

Many tests call that function multiple times, which would then initialize multiple generators. I tried to avoid having too many generators per test, although there may be some tests where there is more than one used.

Copy link
Contributor

@duricanikolic duricanikolic left a comment

Choose a reason for hiding this comment

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

LGTM
Thank you

@pstibrany pstibrany merged commit 020b67d into main Nov 22, 2023
3 checks passed
@pstibrany pstibrany deleted the random-generator branch November 22, 2023 12:23
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.

None yet

2 participants