-
Notifications
You must be signed in to change notification settings - Fork 733
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
Allow to specify the random number generator seed in unit tests #1751
Conversation
In this commit, we add a new parameter to the unit tests binary, called `--seed`, that allows to specify the seed used by the several random numbers generators used in the Valkey server code. We also now print the seed information right before starting the unit tests execution, so that someone that needs to reproduce an error, can use the same seed to re-run the failed tests. Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1751 +/- ##
============================================
- Coverage 71.14% 71.11% -0.03%
============================================
Files 123 123
Lines 65534 65550 +16
============================================
- Hits 46622 46614 -8
- Misses 18912 18936 +24
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove the random seed we do in test_hashtable.c and maybe some other test suites? Otherwise, it's still not reproducible...
Maybe we can support a hook point for beforeTest and afterTest, which will help us restore the scene without affecting other cases. |
I think it does not matter. We are setting up the seed used by |
Are you sure? |
But |
Do we need that? It seem like overkill for this purpose. I'd suggest we just remove all random seeding in each test suite and only do it once by the test framework. And print it in the beginning. It's nice that this test framework is extremely simple, without scaffolding like beforeSuite, beforeTestCase. |
@rjd15372 I see now that getRandomBytes only reads The test framework could can re-seed using the same seed before each test suite, maybe.... |
Correct. It's only reproducible if you run the test with the same CLI arguments plus the seed arg. If you use the Yeah, maybe re-seeding before each test run would allow us to run a single test. I'll update the PR. |
Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
@zuiderkwast what do you think of doing something similar to this PR for TCL tests? |
That's be great but it seems much harder. It would need to involve some server config or debug command to set the seed, right? And Lua's and TCL's internal seeds too? A fixed hashtable seed per slot that's transferred on failover and slot migrations is something we've been thinking about in #4. It's a different purpose but it seems to be related and somewhat overlapping in parts of implementation I guess. |
I was thinking about something simpler. Just set the seed on the TCL side. The server would still be random but it would be better than nothing. |
Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
In this commit, we add a new parameter to the unit tests binary, called
--seed
, that allows to specify the seed used by the several random numbers generators used in the Valkey server code.We also now print the seed information right before starting the unit tests execution, so that someone that needs to reproduce an error, can use the same seed to re-run the failed tests.