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

feat: replace TryCP with Nomad for running scenarios #136

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ logs/**/*.log
scenarios/*/logs
run_summary.jsonl
summariser-report-*.json

# A symlink to the output directory of nix builds
result
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://localhost:4646/ui> 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 <http://localhost:4646/ui/jobs/app_install_scenario@default> 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

Expand Down
5 changes: 4 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Expand All @@ -81,6 +83,7 @@
pkgs.taplo
pkgs.yamlfmt
pkgs.perl
unfreePkgs.nomad
config.rustHelper.rust
inputs'.holonix.packages.holochain
inputs'.holonix.packages.lair-keystore
Expand Down
73 changes: 73 additions & 0 deletions nomad/run_scenario_local.nomad.hcl
Original file line number Diff line number Diff line change
@@ -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}"
])
}
}
}
}
2 changes: 2 additions & 0 deletions nomad/var_files/app_install_large.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scenario-name = "app_install"
behaviours = { large = 1 }
2 changes: 2 additions & 0 deletions nomad/var_files/app_install_minimal.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scenario-name = "app_install"
behaviours = { minimal = 1 }
6 changes: 6 additions & 0 deletions nomad/var_files/dht_sync_lag.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
scenario-name = "dht_sync_lag"
agents = 2
behaviours = {
write = 1,
record_lag = 1,
}
2 changes: 2 additions & 0 deletions nomad/var_files/first_call.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scenario-name = "first_call"
behaviours = { local = 1 }
1 change: 1 addition & 0 deletions nomad/var_files/local_signals.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scenario-name = "local_signals"
1 change: 1 addition & 0 deletions nomad/var_files/single_write_many_read.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scenario-name = "single_write_many_read"
1 change: 1 addition & 0 deletions nomad/var_files/write_query.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scenario-name = "write_query"
1 change: 1 addition & 0 deletions nomad/var_files/write_read.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scenario-name = "write_read"
1 change: 1 addition & 0 deletions nomad/var_files/write_validated.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scenario-name = "write_validated"
1 change: 1 addition & 0 deletions nomad/var_files/zome_call_single_value.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scenario-name = "zome_call_single_value"
Loading