diff --git a/.gitignore b/.gitignore index 22e0f69..c6f2db8 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ logs/**/*.log scenarios/*/logs run_summary.jsonl summariser-report-*.json + +# A symlink to the output directory of nix builds +result diff --git a/README.md b/README.md index 3a9fa97..81f367a 100644 --- a/README.md +++ b/README.md @@ -354,6 +354,51 @@ You can then start a second terminal and run one of the scenarios in the `scenar ```bash RUST_LOG=info CONDUCTOR_CONFIG="CI" TRYCP_RUST_LOG="info" MIN_PEERS=2 cargo run --package trycp_write_validated -- --targets targets-ci.yaml --instances-per-target 2 --duration 60 ``` +#### Running Wind Tunnel Scenarios with Nomad + +> [!Warning] +> This is a work in progress and currently only works running the scenarios locally. + +##### Running Locally + +You can easily test the Wind Tunnel scenarios with [Nomad](https://www.nomadproject.io) by running them locally, this requires running a Nomad agent locally +as both a client and a server. + +First, enter the Nix `devShell` with `nix develop` to make sure you have all the packages install. +Alternatively, [install Nomad](https://developer.hashicorp.com/nomad/install) and Holochain locally so that both `nomad` and `hc` are in your `PATH`. + +Once Nomad is installed, run the agent in `dev` mode to spin up both a server and client, do this with: +```shell +nomad agent -dev +``` + +Now navigate to to view the Nomad dashboard. + +Next, in a new terminal window, build the scenario you want to run with: +```shell +nix build .#app_install +``` +where `app_install` is the name of the scenario. + +Once the scenario is built you can run the Nomad job with: +```shell +nomad job run -var-file=nomad/var_files/app_install_minimal.vars nomad/run_scenario_local.nomad.hcl +``` +where the `-var-file` path should point to the var file in `nomad/var_files` with the matching scenario name. + +You can also override existing and omitted variables with the `-var` flag. For example, to set the duration (omitted) and reporter (override) use: + +```shell +nomad job run -var-file=nomad/var_files/app_install_minimal.vars -var duration=5 -var reporter=in-memory nomad/run_scenario_local.nomad.hcl +``` +> [!Note] +> Make sure the `var` options are after the `var-file` option otherwise the values in the file will take precedence. + +Then, navigate to where you should see one allocation (the Nomad name for an instance of the job) +this allocation should have two tasks: the `start_holochain` task and the `run_scenario` task. You can view the logs of these tasks to see the results. +The allocation should be marked as "Completed" after the duration specified. + +Once you've finished testing you can kill the Nomad agent with `^C` in the first terminal running the agent. ### Published crates diff --git a/flake.nix b/flake.nix index 09d8df2..98d422d 100644 --- a/flake.nix +++ b/flake.nix @@ -54,6 +54,7 @@ systems = builtins.attrNames inputs.holonix.devShells; perSystem = { inputs', pkgs, system, config, ... }: let + unfreePkgs = import nixpkgs { inherit system; config.allowUnfree = true; }; rustMod = flake-parts-lib.importApply ./nix/modules/rust.nix { inherit crane rust-overlay nixpkgs; }; in { @@ -68,8 +69,9 @@ ./nix/modules/zomes.nix ]; + devShells.default = pkgs.mkShell { - packages = with pkgs; [ + packages = [ pkgs.influxdb2-cli pkgs.influxdb2-server # TODO https://docs.influxdata.com/telegraf/v1/install/#ntp @@ -81,6 +83,7 @@ pkgs.taplo pkgs.yamlfmt pkgs.perl + unfreePkgs.nomad config.rustHelper.rust inputs'.holonix.packages.holochain inputs'.holonix.packages.lair-keystore diff --git a/nomad/run_scenario_local.nomad.hcl b/nomad/run_scenario_local.nomad.hcl new file mode 100644 index 0000000..8a67583 --- /dev/null +++ b/nomad/run_scenario_local.nomad.hcl @@ -0,0 +1,73 @@ +variable "scenario-name" { + type = string + description = "The name of the scenario to run" +} + +variable "connection-string" { + type = string + description = "The URL to be used to connect to the service being tested" + default = "ws://localhost:8888" +} + +variable "agents" { + type = number + description = "The number of agents to create" + default = null +} + +variable "duration" { + type = number + description = "The maximum duration of the scenario run" + default = null +} + +variable "reporter" { + type = string + description = "The method used to report the logs" + default = "influx-file" +} + +variable "behaviours" { + type = map(string) + description = "Custom behaviours defined and used by the scenarios" + default = {} +} + +job "run_scenario" { + type = "batch" + + group "scenario_runnner" { + task "start_holochain" { + lifecycle { + hook = "prestart" + sidecar = true + } + + driver = "raw_exec" + config { + command = "bash" + args = ["-c", "hc s clean && echo 1234 | hc s --piped create && echo 1234 | hc s --piped -f 8888 run"] + } + } + + task "run_scenario" { + driver = "raw_exec" + env { + RUST_LOG = "info" + } + config { + command = abspath("result/bin/${var.scenario-name}") + // The `compact` function removes empty strings and `null` items from the list. + args = concat(compact([ + "--connection-string=${var.connection-string}", + var.agents != null ? "--agents=${var.agents}" : null, + var.duration != null ? "--duration=${var.duration}" : null, + var.reporter != null ? "--reporter=${var.reporter}" : null, + "--no-progress" + ]), [ + for k, v in var.behaviours : "--behaviour=${k}:${v}" + ]) + } + } + } +} diff --git a/nomad/var_files/app_install_large.vars b/nomad/var_files/app_install_large.vars new file mode 100644 index 0000000..3a57523 --- /dev/null +++ b/nomad/var_files/app_install_large.vars @@ -0,0 +1,2 @@ +scenario-name = "app_install" +behaviours = { large = 1 } diff --git a/nomad/var_files/app_install_minimal.vars b/nomad/var_files/app_install_minimal.vars new file mode 100644 index 0000000..f712705 --- /dev/null +++ b/nomad/var_files/app_install_minimal.vars @@ -0,0 +1,2 @@ +scenario-name = "app_install" +behaviours = { minimal = 1 } diff --git a/nomad/var_files/dht_sync_lag.vars b/nomad/var_files/dht_sync_lag.vars new file mode 100644 index 0000000..4ffb0ff --- /dev/null +++ b/nomad/var_files/dht_sync_lag.vars @@ -0,0 +1,6 @@ +scenario-name = "dht_sync_lag" +agents = 2 +behaviours = { + write = 1, + record_lag = 1, +} diff --git a/nomad/var_files/first_call.vars b/nomad/var_files/first_call.vars new file mode 100644 index 0000000..bceb3cb --- /dev/null +++ b/nomad/var_files/first_call.vars @@ -0,0 +1,2 @@ +scenario-name = "first_call" +behaviours = { local = 1 } diff --git a/nomad/var_files/local_signals.vars b/nomad/var_files/local_signals.vars new file mode 100644 index 0000000..c635b2f --- /dev/null +++ b/nomad/var_files/local_signals.vars @@ -0,0 +1 @@ +scenario-name = "local_signals" diff --git a/nomad/var_files/single_write_many_read.vars b/nomad/var_files/single_write_many_read.vars new file mode 100644 index 0000000..236bf2d --- /dev/null +++ b/nomad/var_files/single_write_many_read.vars @@ -0,0 +1 @@ +scenario-name = "single_write_many_read" diff --git a/nomad/var_files/write_query.vars b/nomad/var_files/write_query.vars new file mode 100644 index 0000000..4b8035c --- /dev/null +++ b/nomad/var_files/write_query.vars @@ -0,0 +1 @@ +scenario-name = "write_query" diff --git a/nomad/var_files/write_read.vars b/nomad/var_files/write_read.vars new file mode 100644 index 0000000..a64e993 --- /dev/null +++ b/nomad/var_files/write_read.vars @@ -0,0 +1 @@ +scenario-name = "write_read" diff --git a/nomad/var_files/write_validated.vars b/nomad/var_files/write_validated.vars new file mode 100644 index 0000000..e026c27 --- /dev/null +++ b/nomad/var_files/write_validated.vars @@ -0,0 +1 @@ +scenario-name = "write_validated" diff --git a/nomad/var_files/zome_call_single_value.vars b/nomad/var_files/zome_call_single_value.vars new file mode 100644 index 0000000..188bb42 --- /dev/null +++ b/nomad/var_files/zome_call_single_value.vars @@ -0,0 +1 @@ +scenario-name = "zome_call_single_value"