Skip to content

Control uses of rand() in test scripts #301

@plbossart

Description

@plbossart

The test scripts use random number generator to e.g. change the sleep times.

This is wonderful for stress tests, but a really bad idea for CI and daily tests, since by definition these tests cannot be reproduced UNLESS the seed is known.

We should add one option to tests that use random numbers, so that by default we shall use the same seed - 42
https://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy#Answer_to_the_Ultimate_Question_of_Life,_the_Universe,_and_Everything_(42)

When the user wishes more randomness, the seed shall be saved in the logs so that we can reproduce failures.

This can be done in bash with the RANDOM variable

Normal case:

$ T=42
$ RANDOM=$T; echo $RANDOM; echo $RANDOM; echo $RANDOM
17766
11151
23481
$ RANDOM=$T; echo $RANDOM; echo $RANDOM; echo $RANDOM
17766
11151
23481

stress-test:

$ T=$(date +%s)
$ echo $T
1596129567
$ RANDOM=$T; echo $RANDOM; echo $RANDOM;
19204
11943
$ RANDOM=$T; echo $RANDOM; echo $RANDOM;
19204
11943
$ RANDOM=$T; echo $RANDOM; echo $RANDOM;
19204
11943

cc:

Metadata

Metadata

Assignees

Labels

P2Critical bugs or normal featurestype:enhancementNew framework feature or requesttype:test coverage gapThis requires a new test case, not just fixing one

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions