diff --git a/src/boot_fake_node/mod.rs b/src/boot_fake_node/mod.rs index c8ebffc0..335bb5ff 100644 --- a/src/boot_fake_node/mod.rs +++ b/src/boot_fake_node/mod.rs @@ -330,12 +330,15 @@ pub fn run_runtime( args: &[&str], verbose: bool, detached: bool, + verbosity: u8, ) -> anyhow::Result<(Child, OwnedFd)> { let port = format!("{}", port); let network_router_port = format!("{}", network_router_port); + let verbosity = format!("{}", verbosity); let mut full_args = vec![ home.to_str().unwrap(), "--port", port.as_str(), "--network-router-port", network_router_port.as_str(), + "--verbosity", verbosity.as_str(), ]; if !args.is_empty() { @@ -367,6 +370,7 @@ pub async fn execute( password: &str, is_persist: bool, release: bool, + verbosity: u8, mut args: Vec<&str>, ) -> anyhow::Result<()> { let detached = false; // TODO: to argument? @@ -454,6 +458,7 @@ pub async fn execute( &args[..], true, detached, + verbosity, )?; let mut node_cleanup_infos = node_cleanup_infos.lock().await; diff --git a/src/inject_message/mod.rs b/src/inject_message/mod.rs index cfe1316b..0ae5ab1d 100644 --- a/src/inject_message/mod.rs +++ b/src/inject_message/mod.rs @@ -12,6 +12,8 @@ pub struct Response { pub lazy_load_blob: Option>, } +const ENDPOINT: &str = "/rpc:distro:sys/message"; + impl std::fmt::Display for Response { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if let Some(Some(ref s)) = self.lazy_load_blob_utf8 { @@ -76,16 +78,25 @@ pub async fn send_request( url: &str, json_data: Value, ) -> anyhow::Result { - let endpoint = "/rpc:distro:sys/message"; + send_request_inner(url, json_data).await +} + +/// send_request_inner() allows failure without logging; +/// used for run_tests where nodes are pinged until they +/// respond with a 200 to determine when they are online +pub async fn send_request_inner( + url: &str, + json_data: Value, +) -> anyhow::Result { let mut url = url.to_string(); let url = - if url.ends_with(endpoint) { + if url.ends_with(ENDPOINT) { url } else { if url.ends_with('/') { url.pop(); } - format!("{}{}", url, endpoint) + format!("{}{}", url, ENDPOINT) }; let client = reqwest::Client::new(); let response = client.post(&url) diff --git a/src/main.rs b/src/main.rs index f161012c..bc4f0238 100644 --- a/src/main.rs +++ b/src/main.rs @@ -131,6 +131,7 @@ async fn execute( let password = boot_matches.get_one::("PASSWORD").unwrap(); let is_persist = boot_matches.get_one::("PERSIST").unwrap(); let release = boot_matches.get_one::("RELEASE").unwrap(); + let verbosity = boot_matches.get_one::("VERBOSITY").unwrap(); boot_fake_node::execute( runtime_path, @@ -144,6 +145,7 @@ async fn execute( password, *is_persist, *release, + *verbosity, vec![], ).await }, @@ -398,6 +400,13 @@ async fn make_app(current_dir: &std::ffi::OsString) -> anyhow::Result { .help("If set and given --runtime-path, compile release build [default: debug build]") .required(false) ) + .arg(Arg::new("VERBOSITY") + .action(ArgAction::Set) + .long("verbosity") + .help("Verbosity of node: higher is more verbose") + .default_value("0") + .value_parser(value_parser!(u8)) + ) .arg(Arg::new("help") .long("help") .action(ArgAction::Help) diff --git a/src/run_tests/mod.rs b/src/run_tests/mod.rs index 0160a703..e01bf251 100644 --- a/src/run_tests/mod.rs +++ b/src/run_tests/mod.rs @@ -107,7 +107,7 @@ async fn wait_until_booted( None, )?; - match inject_message::send_request( + match inject_message::send_request_inner( &format!("http://localhost:{}", port), request, ).await { @@ -288,10 +288,10 @@ async fn run_tests( #[instrument(level = "trace", err, skip_all)] async fn handle_test(detached: bool, runtime_path: &Path, test: Test) -> anyhow::Result<()> { for setup_package_path in &test.setup_package_paths { - build::execute(&setup_package_path, false, false, test.package_build_verbose, false).await?; + build::execute(&setup_package_path, false, false, !test.mute_package_build, false).await?; } for TestPackage { ref path, .. } in &test.test_packages { - build::execute(path, false, false, test.package_build_verbose, false).await?; + build::execute(path, false, false, !test.mute_package_build, false).await?; } // Initialize variables for master node and nodes list @@ -355,7 +355,7 @@ async fn handle_test(detached: bool, runtime_path: &Path, test: Test) -> anyhow: args.extend_from_slice(&["--password", password]); }; if node.is_testnet { - args.extend_from_slice(&["--testnet"]); + args.push("--testnet"); } let (runtime_process, master_fd) = run_runtime( @@ -364,8 +364,9 @@ async fn handle_test(detached: bool, runtime_path: &Path, test: Test) -> anyhow: node.port, test.network_router.port, &args[..], - node.runtime_verbose, + !node.mute_runtime, detached, + node.runtime_verbosity.unwrap_or_else(|| 0u8), )?; let mut node_cleanup_infos = node_cleanup_infos.lock().await; @@ -439,7 +440,7 @@ pub async fn execute(config_path: &str) -> anyhow::Result<()> { // Compile the runtime binary compile_runtime( &runtime_path, - config.runtime_build_verbose, + !config.mute_runtime_build, config.runtime_build_release, )?; runtime_path.join("target") diff --git a/src/run_tests/types.rs b/src/run_tests/types.rs index b56c1332..776b9fd5 100644 --- a/src/run_tests/types.rs +++ b/src/run_tests/types.rs @@ -10,7 +10,7 @@ use serde::{Serialize, Deserialize}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Config { pub runtime: Runtime, - pub runtime_build_verbose: bool, + pub mute_runtime_build: bool, pub runtime_build_release: bool, pub tests: Vec, } @@ -25,7 +25,7 @@ pub enum Runtime { pub struct Test { pub setup_package_paths: Vec, pub test_packages: Vec, - pub package_build_verbose: bool, + pub mute_package_build: bool, pub timeout_secs: u64, pub network_router: NetworkRouter, pub nodes: Vec, @@ -56,8 +56,9 @@ pub struct Node { pub fake_node_name: String, pub password: Option, pub rpc: Option, - pub runtime_verbose: bool, + pub mute_runtime: bool, pub is_testnet: bool, + pub runtime_verbosity: Option, } pub type NodeHandles = Arc>>;