From 73070284c0b01aa425f4f7fb9c7bdf8d68480ebc Mon Sep 17 00:00:00 2001 From: andrussal Date: Tue, 16 Dec 2025 06:23:49 +0100 Subject: [PATCH] docs(gitbook): fix API snippets to match current code --- book/src/annotated-tree.md | 2 +- book/src/architecture-overview.md | 4 ++-- book/src/custom-workload-example.md | 33 +++++++++++++---------------- book/src/node-control.md | 8 ++++--- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/book/src/annotated-tree.md b/book/src/annotated-tree.md index a3772bb..a23ee6f 100644 --- a/book/src/annotated-tree.md +++ b/book/src/annotated-tree.md @@ -81,7 +81,7 @@ Helper utilities: **Compose runner** includes: - **Prometheus** at `http://localhost:9090` (metrics scraping) - Node metrics exposed per validator/executor -- Access in expectations: `ctx.telemetry().prometheus_endpoint()` +- Access in expectations: `ctx.telemetry().prometheus().map(|p| p.base_url())` **Logging** controlled by: - `NOMOS_LOG_DIR` — Write per-node log files diff --git a/book/src/architecture-overview.md b/book/src/architecture-overview.md index 0869bfb..963855d 100644 --- a/book/src/architecture-overview.md +++ b/book/src/architecture-overview.md @@ -140,11 +140,11 @@ Templates and configs in `testing-framework/runners/compose/assets/`: **Prometheus (Compose only):** - Exposed at `http://localhost:9090` (configurable) - Scrapes all validator and executor metrics -- Accessible in expectations: `ctx.telemetry().prometheus_endpoint()` +- Accessible in expectations: `ctx.telemetry().prometheus().map(|p| p.base_url())` **Node APIs:** - HTTP endpoints per node for consensus info, network status, DA membership -- Accessible in expectations: `ctx.node_clients().validators().get(0)` +- Accessible in expectations: `ctx.node_clients().validator_clients().get(0)` **OTLP (optional):** - Trace endpoint: `NOMOS_OTLP_ENDPOINT=http://localhost:4317` diff --git a/book/src/custom-workload-example.md b/book/src/custom-workload-example.md index 65aeff9..72a29c7 100644 --- a/book/src/custom-workload-example.md +++ b/book/src/custom-workload-example.md @@ -13,35 +13,30 @@ Key ideas: - **start**: drive async activity using the shared `RunContext`. ```rust -use std::sync::Arc; use async_trait::async_trait; use testing_framework_core::scenario::{ - DynError, Expectation, RunContext, RunMetrics, Workload, + DynError, Expectation, RunContext, Workload, runtime::context::RunMetrics, }; use testing_framework_core::topology::generation::GeneratedTopology; pub struct ReachabilityWorkload { target_idx: usize, - bundled: Vec>, } impl ReachabilityWorkload { pub fn new(target_idx: usize) -> Self { - Self { - target_idx, - bundled: vec![Box::new(ReachabilityExpectation::new(target_idx))], - } + Self { target_idx } } } #[async_trait] impl Workload for ReachabilityWorkload { - fn name(&self) -> &'static str { + fn name(&self) -> &str { "reachability_workload" } fn expectations(&self) -> Vec> { - self.bundled.clone() + vec![Box::new(ReachabilityExpectation::new(self.target_idx))] } fn init( @@ -57,13 +52,13 @@ impl Workload for ReachabilityWorkload { async fn start(&self, ctx: &RunContext) -> Result<(), DynError> { let client = ctx - .clients() - .validators() + .node_clients() + .validator_clients() .get(self.target_idx) .ok_or("missing target client")?; - // Pseudo-action: issue a lightweight RPC to prove reachability. - client.health_check().await.map_err(|e| e.into()) + // Lightweight API call to prove reachability. + client.consensus_info().await.map(|_| ()).map_err(|e| e.into()) } } ``` @@ -96,14 +91,16 @@ impl Expectation for ReachabilityExpectation { async fn evaluate(&mut self, ctx: &RunContext) -> Result<(), DynError> { let client = ctx - .clients() - .validators() + .node_clients() + .validator_clients() .get(self.target_idx) .ok_or("missing target client")?; - client.health_check().await.map_err(|e| { - format!("target became unreachable during run: {e}").into() - }) + client + .consensus_info() + .await + .map(|_| ()) + .map_err(|e| format!("target became unreachable during run: {e}").into()) } } ``` diff --git a/book/src/node-control.md b/book/src/node-control.md index 9cf953e..25aca79 100644 --- a/book/src/node-control.md +++ b/book/src/node-control.md @@ -32,14 +32,16 @@ which describes the proposed `block_peer`/`unblock_peer` API (not yet implemente Check for control support and use it conditionally: ```rust -use testing_framework_core::scenario::{Expectation, RunContext, Workload}; +use async_trait::async_trait; +use testing_framework_core::scenario::{DynError, RunContext, Workload}; struct RestartWorkload; +#[async_trait] impl Workload for RestartWorkload { - fn name(&self) -> &'static str { "restart_workload" } + fn name(&self) -> &str { "restart_workload" } - async fn start(&self, ctx: &RunContext) -> Result<(), Box> { + async fn start(&self, ctx: &RunContext) -> Result<(), DynError> { if let Some(control) = ctx.node_control() { // Restart the first validator (index 0) if supported. control.restart_validator(0).await?;