Add workload logging

This commit is contained in:
andrussal 2025-12-11 08:03:49 +01:00
parent f31aa99c0e
commit 75541abaa2
2 changed files with 35 additions and 11 deletions

View File

@ -7,6 +7,7 @@ use tokio::time::{Instant, sleep};
use tracing::info; use tracing::info;
/// Randomly restarts validators and executors during a run to introduce chaos. /// Randomly restarts validators and executors during a run to introduce chaos.
#[derive(Debug)]
pub struct RandomRestartWorkload { pub struct RandomRestartWorkload {
min_delay: Duration, min_delay: Duration,
max_delay: Duration, max_delay: Duration,
@ -137,6 +138,14 @@ impl Workload for RandomRestartWorkload {
return Err("chaos restart workload has no eligible targets".into()); return Err("chaos restart workload has no eligible targets".into());
} }
tracing::info!(
config = ?self,
validators = ctx.descriptors().validators().len(),
executors = ctx.descriptors().executors().len(),
target_count = targets.len(),
"starting chaos restart workload"
);
let mut cooldowns = self.initialize_cooldowns(&targets); let mut cooldowns = self.initialize_cooldowns(&targets);
loop { loop {
@ -144,14 +153,20 @@ impl Workload for RandomRestartWorkload {
let target = self.pick_target(&targets, &cooldowns).await; let target = self.pick_target(&targets, &cooldowns).await;
match target { match target {
Target::Validator(index) => handle Target::Validator(index) => {
.restart_validator(index) tracing::info!(index, "chaos restarting validator");
.await handle
.map_err(|err| format!("validator restart failed: {err}"))?, .restart_validator(index)
Target::Executor(index) => handle .await
.restart_executor(index) .map_err(|err| format!("validator restart failed: {err}"))?
.await }
.map_err(|err| format!("executor restart failed: {err}"))?, Target::Executor(index) => {
tracing::info!(index, "chaos restarting executor");
handle
.restart_executor(index)
.await
.map_err(|err| format!("executor restart failed: {err}"))?
}
} }
cooldowns.insert(target, Instant::now() + self.target_cooldown); cooldowns.insert(target, Instant::now() + self.target_cooldown);

View File

@ -3,11 +3,12 @@ use std::sync::Arc;
use nomos_core::{ use nomos_core::{
block::Block, block::Block,
mantle::{ mantle::{
AuthenticatedMantleTx as _, SignedMantleTx, AuthenticatedMantleTx as _, SignedMantleTx, Transaction as MantleTx,
ops::{Op, channel::MsgId}, ops::{Op, channel::MsgId},
}, },
}; };
use testing_framework_core::scenario::{DynError, RunContext}; use testing_framework_core::scenario::{DynError, RunContext};
use tracing::debug;
/// Scans a block and invokes the matcher for every operation until it returns /// Scans a block and invokes the matcher for every operation until it returns
/// `Some(...)`. Returns `None` when no matching operation is found. /// `Some(...)`. Returns `None` when no matching operation is found.
@ -32,14 +33,22 @@ pub async fn submit_transaction_via_cluster(
ctx: &RunContext, ctx: &RunContext,
tx: Arc<SignedMantleTx>, tx: Arc<SignedMantleTx>,
) -> Result<(), DynError> { ) -> Result<(), DynError> {
let tx_hash = tx.hash();
debug!(?tx_hash, "submitting transaction via cluster");
ctx.cluster_client() ctx.cluster_client()
.try_all_clients(|client| { .try_all_clients(|client| {
let tx = Arc::clone(&tx); let tx = Arc::clone(&tx);
Box::pin(async move { Box::pin(async move {
client let url = client.base_url().clone();
debug!(?tx_hash, %url, "submitting transaction to client");
let res = client
.submit_transaction(&tx) .submit_transaction(&tx)
.await .await
.map_err(|err| -> DynError { err.into() }) .map_err(|err| -> DynError { err.into() });
if res.is_err() {
debug!(?tx_hash, %url, "transaction submission failed");
}
res
}) })
}) })
.await .await