Use deterministic randomness in ExampleGenerator. #5068
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR checklist
./bin/to update Petstore sample so that CIs can verify the change.→ bin/nodejs-petstore-google-cloud-functions.sh && bin/nodejs-petstore-server.sh (twice: before and after the update.)
Description of the PR
This changes the randomness introduced into ExampleGenerator in #4797 to be deterministic.
This way, in each run of the generator the same output is produced when using the same input.
Previously, you got random changes each time you updated the NodeJS sample, which made it tedious to find out what actually changed. See ccc117c for an example commit containing just those changes. When merging different branches, this leads to unnecessary conflicts.
With this PR the randomness generator is totally deterministic, generating the sequence 0,6,1 for all integer values without min/max. I guess we could use the input for the example generator as a seed to the Random object, to have the result a bit more random-looking? Opinions?
(The last commit of this PR applies this on the nodejs samples, the first commit updates the samples with the old code.)
/cc @bartkummel @wing328