Skip to content

Commit

Permalink
teuthology/suite: initialize lua prng using run's seed
Browse files Browse the repository at this point in the history
When a script may use Lua's prng, we want it to produce the same sequence
during a rerun.

Signed-off-by: Patrick Donnelly <[email protected]>
  • Loading branch information
batrick committed Mar 19, 2024
1 parent e691533 commit cddd8b7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions teuthology/describe_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ def output_summary(path, limit=0,
filter_in=filter_in,
filter_out=filter_out,
filter_all=filter_all,
filter_fragments=filter_fragments)
filter_fragments=filter_fragments,
seed=seed)
for c in configs:
if limit and count >= limit:
break
Expand Down Expand Up @@ -185,7 +186,8 @@ def get_combinations(suite_dir,
filter_in=filter_in,
filter_out=filter_out,
filter_all=filter_all,
filter_fragments=filter_fragments)
filter_fragments=filter_fragments,
seed=seed)
for _, fragment_paths, __ in configs:
if limit > 0 and num_listed >= limit:
break
Expand Down
3 changes: 3 additions & 0 deletions teuthology/suite/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ def config_merge(configs, suite_name=None, **kwargs):
the entire job (config) from the list.
"""

seed = kwargs.get('seed', 1)
log.debug("configuring Lua randomseed to %d", seed)
L.eval(f'local math = require"math"; math.randomseed({seed});')
new_script = L.eval('new_script')
yaml_cache = {}
for desc, paths in configs:
Expand Down
1 change: 1 addition & 0 deletions teuthology/suite/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ def schedule_suite(self):
filter_out=self.args.filter_out,
filter_all=self.args.filter_all,
filter_fragments=self.args.filter_fragments,
seed=self.args.seed,
suite_name=suite_name))

if self.args.dry_run:
Expand Down

0 comments on commit cddd8b7

Please sign in to comment.