Skip to content

feat: migrate validation_receipts scenario away from TryCP #172

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

Merged
merged 12 commits into from
May 1, 2025
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
3 changes: 3 additions & 0 deletions .github/workflows/nomad.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:

- scenario-name: dht_sync_lag
required-nodes: 2

- scenario-name: validation_receipts
required-nodes: 2
steps:
- uses: actions/checkout@v4

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/performance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:

- scenario: first_call
extra-args: "--agents 1 --behaviour local:1"

- scenario: validation_receipts
extra-args: "--agents 2"
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -91,7 +94,7 @@ jobs:
fail-fast: false
matrix:
# To run a test with TryCP and default configuration, add the scenario name to this array.
scenario: [trycp_write_validated, remote_call_rate, validation_receipts, remote_signals]
scenario: [trycp_write_validated, remote_call_rate, remote_signals]
# To run a test with TryCP and additional configuration, add the scenario name and `extra-args` as an `include` item.
include:
- scenario: two_party_countersigning
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,15 @@ jobs:
run: |
set -x

# Start local network services
nix develop .#ci -c bash -c "hc-run-local-services --bootstrap-port 4422 --signal-port 4423 &"
# Start a TryCP instance
nix develop .#ci -c bash -c "source ./scripts/trycp.sh && start_trycp &"
# Start a sandbox conductor and run it in the background
nix develop .#ci -c bash -c "hc s clean && echo "1234" | hc s --piped create && echo "1234" | hc s --piped -f 8888 run &"

nix develop .#ci --command bash ./scripts/wait-for-hc.sh

# Run the scenario
RUST_LOG=warn CONDUCTOR_CONFIG="CI" MIN_PEERS=2 nix run .#validation_receipts -- --targets targets-ci.yaml --instances-per-target 2 --duration 45 --no-progress
RUST_LOG=warn CONDUCTOR_CONFIG="CI" MIN_AGENTS=2 nix run .#validation_receipts -- --connection-string ws://localhost:8888 --duration 45 --no-progress

# Stop the TryCP instance
nix develop .#ci -c bash -c "source ./scripts/trycp.sh && stop_trycp"
# Stop local network services
pkill hc-run-local
pkill hc && pkill holochain && pkill lair-keystore

- name: Smoke test - remote_signals
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Increased TryCP test scenario duration to 30s in CI [Test Workflow](.github/workflows/test.yaml).
- Use the new `AppBundleSource::Bytes` variant to bundle scenarios [#152](https://github.com/holochain/wind-tunnel/pull/152)
- Test workflow uses kitsune dev shell for kitsune scenario.
- Converted `validation_receipts` scenario to non-TryCP scenario to be run on the Nomad cluster. [#172](https://github.com/holochain/wind-tunnel/pull/172)

### Deprecated
### Removed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion nomad/run_scenario.nomad.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ variable "run-id" {
default = null
}

variable "agents-per-node" {
type = number
description = "The number of agents to run per client node that is running the scenario"
default = 1
}

variable "min-agents" {
type = number
description = "The minimum number of agents to wait for in the scenario"
default = 2
}

job "run_scenario" {
type = "batch"
all_at_once = true // Try to run all groups at once
Expand All @@ -52,7 +64,7 @@ job "run_scenario" {

dynamic "group" {
for_each = var.behaviours
labels = ["${var.scenario-name}-${group.value}"]
labels = ["${var.scenario-name}-${group.key}-${group.value}"]

content {
task "start_holochain" {
Expand Down Expand Up @@ -104,6 +116,7 @@ job "run_scenario" {
RUST_LOG = "info"
HOME = "${NOMAD_TASK_DIR}"
WT_METRICS_DIR = "${NOMAD_ALLOC_DIR}/data/telegraf/metrics"
MIN_AGENTS = "${var.min-agents}"
}

config {
Expand All @@ -116,6 +129,7 @@ job "run_scenario" {
var.reporter != null ? "--reporter=${var.reporter}" : null,
group.value != "" ? "--behaviour=${group.value}:1" : null,
var.run-id != null ? "--run-id=${var.run-id}" : null,
"--agents=${var.agents-per-node}",
"--no-progress"
])
}
Expand Down
4 changes: 4 additions & 0 deletions nomad/var_files/validation_receipts.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
scenario-name = "validation_receipts"
behaviours = [ "", "" ] # Run two nodes both with the default behaviour
agents-per-node = 5
min-agents = 10
2 changes: 1 addition & 1 deletion scenarios/validation_receipts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rand = { workspace = true }
log = { workspace = true }

holochain_types = { workspace = true }
trycp_wind_tunnel_runner = { workspace = true }
holochain_wind_tunnel_runner = { workspace = true }

[build-dependencies]
happ_builder = { workspace = true }
Expand Down
28 changes: 9 additions & 19 deletions scenarios/validation_receipts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,22 @@

Creates an entry, wait for required validation receipts, then repeat.

Records `wt.custom.validation_receipts_complete_time` which is the time taken from after the zome call that created the
Records `wt.custom.validation_receipts_complete_time` which is the time taken from after the zome call that created the
data returns, to when we have enough validation receipts. This is measured to the nearest 20ms so that we don't keep the
agent too busy checking for receipts.

**warning** This is a TryCP-based scenario and needs to be run differently to other scenarios.

### Waiting for peer discovery

This scenario reads the environment variable `MIN_PEERS` and waits for at least that many peers to be available before
This scenario reads the environment variable `MIN_AGENTS` and waits for at least that many agents to be available before
starting the agent behaviour. It will wait up to two minutes then proceed regardless.

The scenario is not able to check that you have configured more peers than the minimum you have set, so you should
ensure that you have configured enough peers to meet the minimum.
The scenario is not able to check that you have configured more agents than the minimum you have set, so you should
ensure that you have configured enough agents to meet the minimum.

Note that the number of peers seen by each node includes itself. So having two nodes means that each node will
immediately see one peer after app installation.
Note that the number of agents seen by each node includes itself. So setting `MIN_AGENTS` to 2 means that each agent
will immediately see one agent after app installation.

You need around at least 10 peers, or the nodes will never get the required number of validation receipts.
You need around 10 agents, or they will never get the required number of validation receipts.

### NO_VALIDATION_COMPLETE

Expand All @@ -30,21 +28,13 @@ By default, this scenario will wait for a complete set of validation receipts be
Example:

```bash
NO_VALIDATION_COMPLETE=1 RUST_LOG=info CONDUCTOR_CONFIG="CI" TRYCP_RUST_LOG="info" MIN_PEERS=10 cargo run --package validation_receipts -- --targets targets-ci.yaml --instances-per-target 10 --duration 300
NO_VALIDATION_COMPLETE=1 RUST_LOG=info MIN_AGENTS=10 cargo run --package validation_receipts -- --connection-string ws://localhost:8888 --agents 10 --duration 300
```

### Suggested command

You can run the scenario locally with the following command:

```bash
RUST_LOG=info CONDUCTOR_CONFIG="CI" TRYCP_RUST_LOG="info" MIN_PEERS=10 cargo run --package validation_receipts -- --targets targets-ci.yaml --instances-per-target 10 --duration 300
```

This assumes that `trycp_server` is running. See the script `scripts/trycp.sh` and run with `start_trycp`.

To run the scenario against the current target list, you can run:

```bash
RUST_LOG=info MIN_PEERS=40 cargo run --package validation_receipts -- --targets targets.yaml --duration 500
RUST_LOG=info MIN_AGENTS=10 cargo run --package validation_receipts -- --connection-string ws://localhost:8888 --agents 10 --duration 300
```
66 changes: 18 additions & 48 deletions scenarios/validation_receipts/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use holochain_types::prelude::*;
use holochain_wind_tunnel_runner::prelude::*;
use holochain_wind_tunnel_runner::scenario_happ_path;
use std::collections::HashMap;
use std::time::{Duration, Instant};
use trycp_wind_tunnel_runner::embed_conductor_config;
use trycp_wind_tunnel_runner::prelude::*;

embed_conductor_config!();

type OpType = String;
type ReceiptsComplete = bool;
Expand Down Expand Up @@ -50,35 +48,22 @@ impl ScenarioValues {

impl UserValuesConstraint for ScenarioValues {}

fn setup(ctx: &mut RunnerContext<HolochainRunnerContext>) -> HookResult {
configure_app_ws_url(ctx)?;
Ok(())
}

fn agent_setup(
ctx: &mut AgentContext<TryCPRunnerContext, TryCPAgentContext<ScenarioValues>>,
ctx: &mut AgentContext<HolochainRunnerContext, HolochainAgentContext<ScenarioValues>>,
) -> HookResult {
connect_trycp_client(ctx)?;
reset_trycp_remote(ctx)?;

let client = ctx.get().trycp_client();
let agent_name = ctx.agent_name().to_string();

ctx.runner_context()
.executor()
.execute_in_place(async move {
client
.configure_player(agent_name.clone(), conductor_config().to_string(), None)
.await?;

client.startup(agent_name.clone(), None).await?;

Ok(())
})?;

install_app(ctx, scenario_happ_path!("crud"), &"crud".to_string())?;
try_wait_for_min_peers(ctx, Duration::from_secs(120))?;
try_wait_for_min_agents(ctx, Duration::from_secs(120))?;

Ok(())
}

fn agent_behaviour(
ctx: &mut AgentContext<TryCPRunnerContext, TryCPAgentContext<ScenarioValues>>,
ctx: &mut AgentContext<HolochainRunnerContext, HolochainAgentContext<ScenarioValues>>,
) -> HookResult {
let reporter = ctx.runner_context().reporter();
let agent = ctx.get().cell_id().agent_pubkey().clone().to_string();
Expand All @@ -88,7 +73,6 @@ fn agent_behaviour(
"crud",
"create_sample_entry",
"this is a test entry value",
Some(Duration::from_secs(80)),
)?;

ctx.get_mut()
Expand Down Expand Up @@ -123,7 +107,6 @@ fn agent_behaviour(
"crud",
"get_sample_entry_validation_receipts",
action_hash.clone(),
Some(Duration::from_secs(80)),
)?;

for set in response.iter() {
Expand Down Expand Up @@ -164,37 +147,24 @@ fn agent_behaviour(
}

fn agent_teardown(
ctx: &mut AgentContext<TryCPRunnerContext, TryCPAgentContext<ScenarioValues>>,
ctx: &mut AgentContext<HolochainRunnerContext, HolochainAgentContext<ScenarioValues>>,
) -> HookResult {
if let Err(e) = dump_logs(ctx) {
log::warn!("Failed to dump logs: {:?}", e);
}

// Best effort to remove data and cleanup.
// You should comment out this line if you want to examine the result of the scenario run!
let _ = reset_trycp_remote(ctx);

// Alternatively, you can just shut down the remote conductor instead of shutting it down and removing data.
// shutdown_remote(ctx)?;

disconnect_trycp_client(ctx)?;

Ok(())
uninstall_app(ctx, None)
}

fn main() -> WindTunnelResult<()> {
let builder = TryCPScenarioDefinitionBuilder::<
TryCPRunnerContext,
TryCPAgentContext<ScenarioValues>,
>::new_with_init(env!("CARGO_PKG_NAME"))?
.into_std()
let builder = ScenarioDefinitionBuilder::<
HolochainRunnerContext,
HolochainAgentContext<ScenarioValues>,
>::new_with_init(env!("CARGO_PKG_NAME"))
.with_default_duration_s(300)
.add_capture_env("NO_VALIDATION_COMPLETE")
.use_setup(setup)
.use_agent_setup(agent_setup)
.use_agent_behaviour(agent_behaviour)
.use_agent_teardown(agent_teardown);

run_with_required_agents(builder, 1)?;
run(builder)?;

Ok(())
}