mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-02-17 03:33:08 +00:00
* Add node config overrides (#14) * chore: merge master into dev and update configs after merge (#17) * Sdp config structs from logos blockchain (#15) * Update configs after main repo merge --------- Co-authored-by: gusto <bacv@users.noreply.github.com> * Local deployer allows to stop and restart nodes (#16) * Unify local node control and restart support * Add local stop-node support * Use node names for restart/stop control * merge --------- Co-authored-by: hansieodendaal <hansie.odendaal@gmail.com> * Add orphan manual cluster test utilities * Update node rev and align consensus/wallet config * Update node rev and align wallet/KMS configs * Update main repo ref (#23) * Fix genesis utxos and scale leader stake * Document leader stake constants * feat: add custom persistent dir option for working files (#26) * chore: config and naming updates (#27) * Update config and crate naming - Updated configs to the lates main repo configs. - Updated all main repo crate namings to be same as the main repo. - Added `create_dir_all` to `pub(crate) fn create_tempdir(custom_work_dir: Option<PathBuf>) -> std::io::Result<TempDir> {`. - Wired in optional `persist_dir` when using the local deployer. - Update `time` vulnerability **Note:** Unsure about the `service_params` mapping in `pub(crate) fn cryptarchia_deployment(config: &GeneralConfig) -> CryptarchiaDeploymentSettings {` * fix ntp server config --------- Co-authored-by: Andrus Salumets <andrus@status.im> Co-authored-by: gusto <bacv@users.noreply.github.com> Co-authored-by: andrussal <salumets.andrus@gmail.com>
85 lines
2.3 KiB
Rust
85 lines
2.3 KiB
Rust
use std::{path::Path, process::Command as StdCommand};
|
|
|
|
use lb_tracing::metrics::otlp::OtlpMetricsConfig;
|
|
use lb_tracing_service::MetricsLayer;
|
|
use reqwest::Url;
|
|
use testing_framework_core::{
|
|
scenario::cfgsync::{apply_topology_overrides, load_cfgsync_template, write_cfgsync_template},
|
|
topology::generation::GeneratedTopology,
|
|
};
|
|
use tracing::{debug, info, warn};
|
|
|
|
/// Handle that tracks a cfgsync server started for compose runs.
|
|
#[derive(Debug)]
|
|
pub enum CfgsyncServerHandle {
|
|
Container { name: String, stopped: bool },
|
|
}
|
|
|
|
impl CfgsyncServerHandle {
|
|
/// Stop the backing container if still running.
|
|
pub fn shutdown(&mut self) {
|
|
match self {
|
|
Self::Container { name, stopped } if !*stopped => {
|
|
info!(container = name, "stopping cfgsync container");
|
|
remove_container(name);
|
|
*stopped = true;
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|
|
}
|
|
|
|
fn remove_container(name: &str) {
|
|
match StdCommand::new("docker")
|
|
.arg("rm")
|
|
.arg("-f")
|
|
.arg(name)
|
|
.status()
|
|
{
|
|
Ok(status) if status.success() => {
|
|
debug!(container = name, "removed cfgsync container");
|
|
}
|
|
Ok(status) => {
|
|
warn!(container = name, status = ?status, "failed to remove cfgsync container");
|
|
}
|
|
Err(_) => {
|
|
warn!(
|
|
container = name,
|
|
"failed to spawn docker rm for cfgsync container"
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Drop for CfgsyncServerHandle {
|
|
fn drop(&mut self) {
|
|
self.shutdown();
|
|
}
|
|
}
|
|
|
|
/// Updates the cfgsync template on disk with topology-driven overrides.
|
|
pub fn update_cfgsync_config(
|
|
path: &Path,
|
|
topology: &GeneratedTopology,
|
|
port: u16,
|
|
metrics_otlp_ingest_url: Option<&Url>,
|
|
) -> anyhow::Result<()> {
|
|
debug!(
|
|
path = %path.display(),
|
|
port,
|
|
nodes = topology.nodes().len(),
|
|
"updating cfgsync template"
|
|
);
|
|
let mut cfg = load_cfgsync_template(path)?;
|
|
cfg.port = port;
|
|
apply_topology_overrides(&mut cfg, topology);
|
|
if let Some(endpoint) = metrics_otlp_ingest_url.cloned() {
|
|
cfg.tracing_settings.metrics = MetricsLayer::Otlp(OtlpMetricsConfig {
|
|
endpoint,
|
|
host_identifier: "node".into(),
|
|
});
|
|
}
|
|
write_cfgsync_template(path, &cfg)?;
|
|
Ok(())
|
|
}
|