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

cmd/hive: Add --sim.randomseed #943

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/commandline.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ This sets the default value of `HIVE_LOGLEVEL` in client containers.
interpreted by simulators. It sets the `HIVE_PARALLELISM` environment variable. Defaults
to 1.

`--sim.randomseed <number>`: Sets a fixed number as the randomness seed to be used by all
simulators. It sets the `HIVE_RANDOM_SEED` environment variable. Defaults to zero, which
translates being unset and the simulators decide the source of randomness.

## Viewing simulation results (hiveview)

The results of hive simulation runs are stored in JSON files containing test results, and
Expand Down
1 change: 1 addition & 0 deletions docs/simulators.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ This is the list of all environment variables that hive sets when launching simu
| `HIVE_SIMULATOR` | URL of the API server | |
| `HIVE_TEST_PATTERN` | Regular expression, selects suites/tests | `--sim.limit` |
| `HIVE_PARALLELISM` | Integer, sets test concurrency | `--sim.parallelism` |
| `HIVE_RANDOM_SEED` | Integer, sets simulator random seed number | `--sim.randomseed` |
| `HIVE_LOGLEVEL` | Decimal 0-5, configures simulator log levels | `--sim.loglevel` |

## Writing Simulators in Go
Expand Down
2 changes: 2 additions & 0 deletions hive.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func main() {
simPattern = flag.String("sim", "", "Regular `expression` selecting the simulators to run.")
simTestPattern = flag.String("sim.limit", "", "Regular `expression` selecting tests/suites (interpreted by simulators).")
simParallelism = flag.Int("sim.parallelism", 1, "Max `number` of parallel clients/containers (interpreted by simulators).")
simRandomSeed = flag.Int("sim.randomseed", 0, "Randomness seed number (interpreted by simulators).")
simTestLimit = flag.Int("sim.testlimit", 0, "[DEPRECATED] Max `number` of tests to execute per client (interpreted by simulators).")
simTimeLimit = flag.Duration("sim.timelimit", 0, "Simulation `timeout`. Hive aborts the simulator if it exceeds this time.")
simLogLevel = flag.Int("sim.loglevel", 3, "Selects log `level` of client instances. Supports values 0-5.")
Expand Down Expand Up @@ -110,6 +111,7 @@ func main() {
SimLogLevel: *simLogLevel,
SimTestPattern: *simTestPattern,
SimParallelism: *simParallelism,
SimRandomSeed: *simRandomSeed,
SimDurationLimit: *simTimeLimit,
ClientStartTimeout: *clientTimeout,
}
Expand Down
1 change: 1 addition & 0 deletions internal/libhive/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ func (r *Runner) run(ctx context.Context, sim string, env SimEnv) (SimResult, er
"HIVE_PARALLELISM": strconv.Itoa(env.SimParallelism),
"HIVE_LOGLEVEL": strconv.Itoa(env.SimLogLevel),
"HIVE_TEST_PATTERN": env.SimTestPattern,
"HIVE_RANDOM_SEED": strconv.Itoa(env.SimRandomSeed),
},
}
containerID, err := r.container.CreateContainer(ctx, r.simImages[sim], opts)
Expand Down
1 change: 1 addition & 0 deletions internal/libhive/testmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type SimEnv struct {
// Parameters of simulation.
SimLogLevel int
SimParallelism int
SimRandomSeed int
SimTestPattern string

// This is the time limit for the simulation run.
Expand Down