mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-02 13:23:13 +00:00
docs(gitbook): fix API snippets to match current code
This commit is contained in:
parent
0210e857f0
commit
73070284c0
@ -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
|
||||
|
||||
@ -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`
|
||||
|
||||
@ -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<Box<dyn Expectation>>,
|
||||
}
|
||||
|
||||
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<Box<dyn Expectation>> {
|
||||
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())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -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<dyn std::error::Error + Send + Sync>> {
|
||||
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?;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user