refactor cucumber

This commit is contained in:
hansieodendaal 2026-01-14 17:59:44 +02:00
parent 416ec051a5
commit 2f67919b7b
No known key found for this signature in database
GPG Key ID: D341DA7FC6098627
35 changed files with 118 additions and 89 deletions

6
Cargo.lock generated
View File

@ -1012,7 +1012,7 @@ dependencies = [
]
[[package]]
name = "cfgsync"
name = "cfgsync_tf"
version = "0.1.0"
dependencies = [
"anyhow",
@ -7312,7 +7312,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"async-trait",
"cfgsync",
"cfgsync_tf",
"groth16",
"key-management-system-service",
"nomos-core",
@ -7323,6 +7323,7 @@ dependencies = [
"serde",
"tempfile",
"tera",
"testing-framework-config",
"testing-framework-core",
"testing-framework-env",
"tests",
@ -7348,6 +7349,7 @@ dependencies = [
"serde",
"serde_yaml",
"tempfile",
"testing-framework-config",
"testing-framework-core",
"testing-framework-env",
"thiserror 2.0.17",

View File

@ -9,7 +9,7 @@ members = [
"testing-framework/deployers/k8s",
"testing-framework/deployers/local",
"testing-framework/env",
"testing-framework/tools/cfgsync",
"testing-framework/tools/cfgsync_tf",
"testing-framework/workflows",
]
resolver = "2"
@ -42,7 +42,7 @@ testing-framework-workflows = { default-features = false, path = "testing-f
# Logos git dependencies (pinned to latest master)
broadcast-service = { default-features = false, git = "https://github.com/logos-co/nomos-node.git", rev = "1fce2dc3f482c16361316eb2a1b6ccd1206aa917" }
cfgsync = { default-features = false, path = "testing-framework/tools/cfgsync" }
cfgsync_tf = { default-features = false, path = "testing-framework/tools/cfgsync_tf" }
chain-leader = { default-features = false, git = "https://github.com/logos-co/nomos-node.git", rev = "1fce2dc3f482c16361316eb2a1b6ccd1206aa917", features = [
"pol-dev-mode",
] }

View File

@ -5,12 +5,6 @@ use testing_framework_env as tf_env;
/// Default cfgsync port used across runners.
pub const DEFAULT_CFGSYNC_PORT: u16 = 4400;
/// Default container path for KZG parameters (compose/k8s mount point).
pub const DEFAULT_KZG_CONTAINER_PATH: &str = "/kzgrs_test_params/kzgrs_test_params";
/// Default host-relative directory for KZG assets.
pub const DEFAULT_KZG_HOST_DIR: &str = "testing-framework/assets/stack/kzgrs_test_params";
/// Default HTTP probe interval used across readiness checks.
pub const DEFAULT_HTTP_POLL_INTERVAL: Duration = Duration::from_secs(1);
@ -36,15 +30,25 @@ pub const DEFAULT_LIBP2P_NETWORK_PORT: u16 = 3000;
pub const DEFAULT_DA_NETWORK_PORT: u16 = 3300;
/// Default blend network port.
pub const DEFAULT_BLEND_NETWORK_PORT: u16 = 4401;
pub const DEFAULT_BLEND_NETWORK_PORT: u16 = 3400; //4401;
/// Resolve cfgsync port from `NOMOS_CFGSYNC_PORT`, falling back to the default.
pub fn cfgsync_port() -> u16 {
tf_env::nomos_cfgsync_port().unwrap_or(DEFAULT_CFGSYNC_PORT)
}
/// Default KZG parameters file name.
pub const KZG_PARAMS_FILENAME: &str = "kzgrs_test_params";
/// Default container path for KZG parameters (compose/k8s mount point).
pub const DEFAULT_KZG_CONTAINER_PATH: &str = "/kzgrs_test_params/kzgrs_test_params";
/// Resolve container KZG path from `NOMOS_KZG_CONTAINER_PATH`, falling back to
/// the default.
pub fn kzg_container_path() -> String {
tf_env::nomos_kzg_container_path().unwrap_or_else(|| DEFAULT_KZG_CONTAINER_PATH.to_string())
}
/// Default stack assets directory.
pub const DEFAULT_ASSETS_STACK_DIR: &str = "testing-framework/assets/stack";
/// Default host-relative directory for KZG assets.
pub const DEFAULT_KZG_HOST_DIR: &str = "testing-framework/assets/stack/kzgrs_test_params";

View File

@ -4,6 +4,7 @@ use nomos_core::sdp::ProviderId;
use nomos_libp2p::{Multiaddr, PeerId, multiaddr};
use testing_framework_env as tf_env;
pub mod constants;
pub mod nodes;
pub mod timeouts;
pub mod topology;

View File

@ -32,7 +32,7 @@ use nomos_node::{
use nomos_utils::math::NonNegativeF64;
use nomos_wallet::WalletServiceSettings;
use crate::{timeouts, topology::configs::GeneralConfig};
use crate::{constants::KZG_PARAMS_FILENAME, timeouts, topology::configs::GeneralConfig};
// Configuration constants
const CRYPTARCHIA_GOSSIPSUB_PROTOCOL: &str = "/cryptarchia/proto";
@ -45,7 +45,6 @@ const API_RATE_LIMIT_PER_SECOND: u64 = 10000;
const API_RATE_LIMIT_BURST: u32 = 10000;
const API_MAX_CONCURRENT_REQUESTS: usize = 1000;
const BLOB_STORAGE_DIR: &str = "./";
const KZG_PARAMS_FILENAME: &str = "kzgrs_test_params";
pub(crate) fn cryptarchia_deployment(config: &GeneralConfig) -> CryptarchiaDeploymentSettings {
CryptarchiaDeploymentSettings {

View File

@ -22,7 +22,7 @@ use testing_framework_env as tf_env;
use thiserror::Error;
use tracing::warn;
use crate::secret_key_to_peer_id;
use crate::{constants::DEFAULT_KZG_HOST_DIR, secret_key_to_peer_id};
pub static GLOBAL_PARAMS_PATH: LazyLock<String> = LazyLock::new(resolve_global_params_path);
@ -69,7 +69,10 @@ fn resolve_global_params_path() -> String {
.unwrap_or_else(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")));
let params_path = canonicalize_params_path(
workspace_root.join("testing-framework/assets/stack/kzgrs_test_params"),
workspace_root.join(
testing_framework_env::nomos_kzg_dir_rel()
.unwrap_or_else(|| DEFAULT_KZG_HOST_DIR.to_string()),
),
);
match params_path.canonicalize() {
Ok(path) => path.to_string_lossy().to_string(),

View File

@ -1,9 +1,8 @@
use std::path::{Path, PathBuf};
use testing_framework_config::constants::{DEFAULT_KZG_CONTAINER_PATH, DEFAULT_KZG_HOST_DIR};
use testing_framework_env as tf_env;
use crate::constants::{DEFAULT_KZG_CONTAINER_PATH, DEFAULT_KZG_HOST_DIR};
/// Default in-image path for KZG params used by testnet images.
pub const DEFAULT_IN_IMAGE_KZG_PARAMS_PATH: &str = "/opt/nomos/kzg-params/kzgrs_test_params";

View File

@ -1,4 +1,3 @@
pub mod constants;
pub mod kzg;
pub mod nodes;
pub mod scenario;

View File

@ -6,12 +6,10 @@ use nomos_tracing_service::TracingSettings;
use nomos_utils::bounded_duration::{MinimalBoundedDuration, SECOND};
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use testing_framework_config::constants::kzg_container_path;
use tracing::debug;
use crate::{
constants::kzg_container_path,
topology::{configs::wallet::WalletConfig, generation::GeneratedTopology},
};
use crate::topology::{configs::wallet::WalletConfig, generation::GeneratedTopology};
#[serde_as]
#[derive(Debug, Clone, Serialize, Deserialize)]

View File

@ -252,7 +252,9 @@ impl TestingFrameworkWorld {
if !(node_ok && exec_ok) {
return Err(StepError::Preflight {
message: "Missing Logos host binaries. Set NOMOS_NODE_BIN (and NOMOS_EXECUTOR_BIN if your scenario uses executors), or run `scripts/run/run-examples.sh host` to restore them into `testing-framework/assets/stack/bin`.".to_owned(),
message: "Missing Logos host binaries. Set NOMOS_NODE_BIN (and NOMOS_EXECUTOR_BIN if your scenario \
uses executors), or run `scripts/run/run-examples.sh host` to restore them into \
`testing-framework/assets/stack/bin`.".to_owned(),
});
}
}

View File

@ -13,22 +13,23 @@ version = "0.1.0"
workspace = true
[dependencies]
anyhow = "1"
async-trait = { workspace = true }
cfgsync = { workspace = true }
nomos-tracing = { workspace = true }
nomos-tracing-service = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
serde = { workspace = true, features = ["derive"] }
tempfile = { workspace = true }
tera = "1.19"
testing-framework-core = { path = "../../core" }
testing-framework-env = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["macros", "net", "process", "rt-multi-thread", "sync", "time"] }
tracing = { workspace = true }
url = { version = "2" }
uuid = { version = "1", features = ["v4"] }
anyhow = "1"
async-trait = { workspace = true }
cfgsync_tf = { workspace = true }
nomos-tracing = { workspace = true }
nomos-tracing-service = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
serde = { workspace = true, features = ["derive"] }
tempfile = { workspace = true }
tera = "1.19"
testing-framework-config = { workspace = true }
testing-framework-core = { path = "../../core" }
testing-framework-env = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["macros", "net", "process", "rt-multi-thread", "sync", "time"] }
tracing = { workspace = true }
url = { version = "2" }
uuid = { version = "1", features = ["v4"] }
[dev-dependencies]
groth16 = { workspace = true }

View File

@ -87,7 +87,7 @@ pub(super) fn make_cleanup_guard(
mod tests {
use std::{collections::HashMap, net::Ipv4Addr};
use cfgsync::{
use cfgsync_tf::{
config::builder::create_node_configs,
host::{Host, PortOverrides},
};

View File

@ -5,7 +5,6 @@ use std::{
use serde::Serialize;
use testing_framework_core::{
constants::DEFAULT_CFGSYNC_PORT,
kzg::KzgParamsSpec,
topology::generation::{GeneratedNodeConfig, GeneratedTopology},
};
@ -16,6 +15,7 @@ use crate::docker::platform::{host_gateway_entry, resolve_image};
mod node;
pub use node::{EnvEntry, NodeDescriptor};
use testing_framework_config::constants::DEFAULT_CFGSYNC_PORT;
/// Top-level docker-compose descriptor built from a GeneratedTopology.
#[derive(Clone, Debug, Serialize)]

View File

@ -5,6 +5,7 @@ pub mod workspace;
use std::{env, process::Stdio, time::Duration};
use testing_framework_config::constants::DEFAULT_ASSETS_STACK_DIR;
use tokio::{process::Command, time::timeout};
use tracing::{debug, info, warn};
@ -104,7 +105,9 @@ pub async fn build_local_image(
) -> Result<(), ComposeRunnerError> {
let repo_root =
repository_root().map_err(|source| ComposeRunnerError::ImageBuild { source })?;
let runtime_dockerfile = repo_root.join("testing-framework/assets/stack/Dockerfile.runtime");
let runtime_dockerfile = repo_root
.join(DEFAULT_ASSETS_STACK_DIR)
.join("Dockerfile.runtime");
tracing::info!(
image,

View File

@ -5,6 +5,10 @@ use std::{
use anyhow::{Context as _, Result};
use tempfile::TempDir;
use testing_framework_config::constants::{
DEFAULT_ASSETS_STACK_DIR, DEFAULT_KZG_HOST_DIR, KZG_PARAMS_FILENAME,
};
use testing_framework_env;
use tracing::{debug, info};
/// Copy the repository stack assets into a scenario-specific temp dir.
@ -16,7 +20,8 @@ pub struct ComposeWorkspace {
impl ComposeWorkspace {
/// Clone the stack assets into a temporary directory.
pub fn create() -> Result<Self> {
let repo_root = env::var("CARGO_WORKSPACE_DIR")
let repo_root = env::var("REPO_ROOT_OVERRIDE_DIR")
.or_else(|_| env::var("CARGO_WORKSPACE_DIR"))
.map(PathBuf::from)
.or_else(|_| {
Path::new(env!("CARGO_MANIFEST_DIR"))
@ -49,8 +54,11 @@ impl ComposeWorkspace {
copy_dir_recursive(&scripts_source, &temp.path().join("stack/scripts"))?;
}
let kzg_source = repo_root.join("testing-framework/assets/stack/kzgrs_test_params");
let target = temp.path().join("kzgrs_test_params");
let kzg_source = repo_root.join(
testing_framework_env::nomos_kzg_dir_rel()
.unwrap_or_else(|| DEFAULT_KZG_HOST_DIR.to_string()),
);
let target = temp.path().join(KZG_PARAMS_FILENAME);
if kzg_source.exists() {
if kzg_source.is_dir() {
copy_dir_recursive(&kzg_source, &target)?;
@ -69,8 +77,14 @@ impl ComposeWorkspace {
.unwrap_or(true)
{
anyhow::bail!(
"KZG params missing in stack assets (expected files in {})",
kzg_source.display()
"\nKZG params missing in stack assets (expected files in {})\
\nrepo_root: {}\
\ntarget: {}\
\nnomos_kzg_dir_rel(): {:?}\n",
kzg_source.display(),
repo_root.display(),
target.display(),
testing_framework_env::nomos_kzg_dir_rel(),
);
}
@ -98,7 +112,11 @@ impl ComposeWorkspace {
}
fn stack_assets_root(repo_root: &Path) -> PathBuf {
let new_layout = repo_root.join("testing-framework/assets/stack");
let new_layout = if let Some(rel_stack_dir) = env::var("REL_ASSETS_STACK_DIR").ok() {
repo_root.join(rel_stack_dir)
} else {
repo_root.join(DEFAULT_ASSETS_STACK_DIR)
};
if new_layout.exists() {
new_layout
} else {
@ -107,7 +125,7 @@ fn stack_assets_root(repo_root: &Path) -> PathBuf {
}
fn stack_scripts_root(repo_root: &Path) -> PathBuf {
let new_layout = repo_root.join("testing-framework/assets/stack/scripts");
let new_layout = repo_root.join(DEFAULT_ASSETS_STACK_DIR).join("scripts");
if new_layout.exists() {
new_layout
} else {

View File

@ -6,6 +6,7 @@ use std::{
use anyhow::anyhow;
use reqwest::Url;
use testing_framework_config::constants::KZG_PARAMS_FILENAME;
use testing_framework_core::{
adjust_timeout, scenario::CleanupGuard, topology::generation::GeneratedTopology,
};
@ -151,7 +152,7 @@ pub fn prepare_workspace_state() -> Result<WorkspaceState, WorkspaceError> {
let workspace = ComposeWorkspace::create().map_err(WorkspaceError::new)?;
let root = workspace.root_path().to_path_buf();
let cfgsync_path = workspace.stack_dir().join("cfgsync.yaml");
let use_kzg = workspace.root_path().join("kzgrs_test_params").exists();
let use_kzg = workspace.root_path().join(KZG_PARAMS_FILENAME).exists();
let state = WorkspaceState {
workspace,

View File

@ -13,20 +13,21 @@ version = "0.1.0"
workspace = true
[dependencies]
anyhow = "1"
async-trait = { workspace = true }
k8s-openapi = { version = "0.20", features = ["latest"] }
kube = { version = "0.87", default-features = false, features = ["client", "runtime", "rustls-tls"] }
nomos-tracing = { workspace = true }
nomos-tracing-service = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
serde = { version = "1", features = ["derive"] }
serde_yaml = { workspace = true }
tempfile = { workspace = true }
testing-framework-core = { path = "../../core" }
testing-framework-env = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["macros", "net", "process", "rt-multi-thread", "sync", "time"] }
tracing = { workspace = true }
url = { version = "2" }
uuid = { version = "1", features = ["v4"] }
anyhow = "1"
async-trait = { workspace = true }
k8s-openapi = { version = "0.20", features = ["latest"] }
kube = { version = "0.87", default-features = false, features = ["client", "runtime", "rustls-tls"] }
nomos-tracing = { workspace = true }
nomos-tracing-service = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
serde = { version = "1", features = ["derive"] }
serde_yaml = { workspace = true }
tempfile = { workspace = true }
testing-framework-config = { workspace = true }
testing-framework-core = { path = "../../core" }
testing-framework-env = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["macros", "net", "process", "rt-multi-thread", "sync", "time"] }
tracing = { workspace = true }
url = { version = "2" }
uuid = { version = "1", features = ["v4"] }

View File

@ -10,9 +10,9 @@ use nomos_tracing_service::MetricsLayer;
use reqwest::Url;
use serde::Serialize;
use tempfile::TempDir;
use testing_framework_config::constants::{DEFAULT_ASSETS_STACK_DIR, cfgsync_port};
pub use testing_framework_core::kzg::KzgMode;
use testing_framework_core::{
constants::cfgsync_port,
kzg::KzgParamsSpec,
scenario::cfgsync::{apply_topology_overrides, load_cfgsync_template, render_cfgsync_yaml},
topology::generation::GeneratedTopology,
@ -242,7 +242,7 @@ fn validate_scripts(root: &Path) -> Result<ScriptPaths, AssetsError> {
fn validate_kzg_params(root: &Path, spec: &KzgParamsSpec) -> Result<PathBuf, AssetsError> {
let Some(path) = spec.host_params_dir.clone() else {
return Err(AssetsError::MissingKzg {
path: root.join(testing_framework_core::constants::DEFAULT_KZG_HOST_DIR),
path: root.join(testing_framework_config::constants::DEFAULT_KZG_HOST_DIR),
});
};
if path.exists() {
@ -294,7 +294,7 @@ pub fn workspace_root() -> AnyResult<PathBuf> {
}
fn stack_assets_root(root: &Path) -> PathBuf {
let new_layout = root.join("testing-framework/assets/stack");
let new_layout = root.join(DEFAULT_ASSETS_STACK_DIR);
if new_layout.exists() {
new_layout
} else {
@ -303,7 +303,7 @@ fn stack_assets_root(root: &Path) -> PathBuf {
}
fn stack_scripts_root(root: &Path) -> PathBuf {
let new_layout = root.join("testing-framework/assets/stack/scripts");
let new_layout = root.join(DEFAULT_ASSETS_STACK_DIR).join("scripts");
if new_layout.exists() {
new_layout
} else {

View File

@ -1,13 +1,7 @@
use std::{env, sync::LazyLock, time::Duration};
use kube::Error as KubeError;
use testing_framework_core::{
constants::{
DEFAULT_HTTP_POLL_INTERVAL, DEFAULT_K8S_DEPLOYMENT_TIMEOUT,
DEFAULT_NODE_HTTP_PROBE_TIMEOUT, DEFAULT_NODE_HTTP_TIMEOUT,
},
scenario::http_probe::NodeRole,
};
use testing_framework_core::scenario::http_probe::NodeRole;
use thiserror::Error;
mod deployment;
@ -18,6 +12,10 @@ mod ports;
pub use forwarding::PortForwardHandle;
pub use orchestrator::wait_for_cluster_ready;
use testing_framework_config::constants::{
DEFAULT_HTTP_POLL_INTERVAL, DEFAULT_K8S_DEPLOYMENT_TIMEOUT, DEFAULT_NODE_HTTP_PROBE_TIMEOUT,
DEFAULT_NODE_HTTP_TIMEOUT,
};
/// Container and host-side HTTP ports for a node in the Helm chart values.
#[derive(Clone, Copy, Debug)]

View File

@ -4,7 +4,7 @@ description = { workspace = true }
edition = { workspace = true }
keywords = { workspace = true }
license = { workspace = true }
name = "cfgsync"
name = "cfgsync_tf"
readme = { workspace = true }
repository = { workspace = true }
version = { workspace = true }

View File

@ -6,7 +6,7 @@ use std::{
str::FromStr,
};
use cfgsync::{
use cfgsync_tf::{
client::{FetchedConfig, get_config},
server::ClientIp,
};
@ -15,9 +15,9 @@ use nomos_libp2p::PeerId;
use nomos_node::Config as ValidatorConfig;
use serde::{Serialize, de::DeserializeOwned};
use subnetworks_assignations::{MembershipCreator, MembershipHandler, SubnetworkId};
use testing_framework_core::{
constants::cfgsync_port as default_cfgsync_port,
nodes::common::config::injection::{inject_ibd_into_cryptarchia, normalize_ed25519_sigs},
use testing_framework_config::constants::cfgsync_port as default_cfgsync_port;
use testing_framework_core::nodes::common::config::injection::{
inject_ibd_into_cryptarchia, normalize_ed25519_sigs,
};
fn parse_ip(ip_str: &str) -> Ipv4Addr {

View File

@ -1,7 +1,7 @@
use std::path::PathBuf;
use anyhow::Context as _;
use cfgsync::server::{CfgSyncConfig, cfgsync_app};
use cfgsync_tf::server::{CfgSyncConfig, cfgsync_app};
use clap::Parser;
use tokio::net::TcpListener;

View File

@ -1,9 +1,9 @@
use std::net::Ipv4Addr;
pub const DEFAULT_LIBP2P_NETWORK_PORT: u16 = 3000;
pub const DEFAULT_DA_NETWORK_PORT: u16 = 3300;
pub const DEFAULT_BLEND_PORT: u16 = 3400;
pub const DEFAULT_API_PORT: u16 = 18080;
use testing_framework_config::constants::{
DEFAULT_API_PORT, DEFAULT_BLEND_NETWORK_PORT, DEFAULT_DA_NETWORK_PORT,
DEFAULT_LIBP2P_NETWORK_PORT,
};
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub enum HostKind {
@ -40,7 +40,7 @@ impl Host {
identifier,
network_port: ports.network_port.unwrap_or(DEFAULT_LIBP2P_NETWORK_PORT),
da_network_port: ports.da_network_port.unwrap_or(DEFAULT_DA_NETWORK_PORT),
blend_port: ports.blend_port.unwrap_or(DEFAULT_BLEND_PORT),
blend_port: ports.blend_port.unwrap_or(DEFAULT_BLEND_NETWORK_PORT),
api_port: ports.api_port.unwrap_or(DEFAULT_API_PORT),
testing_http_port: ports.testing_http_port.unwrap_or(DEFAULT_API_PORT + 1),
}