From 160ed78196626eae0cb493afed24ab8208458a3f Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Fri, 6 Oct 2023 09:33:39 -0400 Subject: [PATCH 01/10] chore: flaky test updates --- Cargo.lock | 10 ++++++++++ homestar-runtime/Cargo.toml | 1 + homestar-runtime/tests/metrics.rs | 11 +++++++++++ homestar-runtime/tests/utils.rs | 1 + 4 files changed, 23 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 886af4cd..d35ec5af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2383,6 +2383,7 @@ dependencies = [ "rand", "reqwest", "retry", + "rm_rf", "sec1", "semver", "serde", @@ -5043,6 +5044,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "rm_rf" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3443b7a35aa12ed2e99edfc0ecbefe6a53b4848305cc83e29981dfa1aea1f71e" +dependencies = [ + "stacker", +] + [[package]] name = "rmp" version = "0.8.12" diff --git a/homestar-runtime/Cargo.toml b/homestar-runtime/Cargo.toml index 7fd4c12b..775eafda 100644 --- a/homestar-runtime/Cargo.toml +++ b/homestar-runtime/Cargo.toml @@ -179,6 +179,7 @@ predicates = { version = "3.0", default-features = false } prometheus-parse = "0.2.4" rand = { workspace = true } retry = { version = "2.0", default-features = false } +rm_rf = "0.6" serial_test = { version = "2.0", default-features = false, features = [ "file_locks", ] } diff --git a/homestar-runtime/tests/metrics.rs b/homestar-runtime/tests/metrics.rs index 7c70209f..704c30ef 100644 --- a/homestar-runtime/tests/metrics.rs +++ b/homestar-runtime/tests/metrics.rs @@ -5,6 +5,7 @@ use reqwest::StatusCode; use retry::{delay::Fixed, retry, OperationResult}; use serial_test::file_serial; use std::{ + net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpStream}, path::PathBuf, process::{Command, Stdio}, time::Duration, @@ -56,6 +57,16 @@ fn test_metrics_serial() -> Result<()> { .spawn() .unwrap(); + let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 4000); + let result = retry(Fixed::from_millis(500), || { + TcpStream::connect(socket).map(|stream| stream.shutdown(Shutdown::Both)) + }); + + if result.is_err() { + homestar_proc.kill().unwrap(); + panic!("Homestar server/runtime failed to start in time"); + } + let sample1 = sample_metrics(); let sample2 = retry(Fixed::from_millis(500).take(5), || { diff --git a/homestar-runtime/tests/utils.rs b/homestar-runtime/tests/utils.rs index 43d94452..74cf7855 100644 --- a/homestar-runtime/tests/utils.rs +++ b/homestar-runtime/tests/utils.rs @@ -67,6 +67,7 @@ pub(crate) fn stop_ipfs() -> Result<()> { .stderr(Stdio::null()) .status() .context("failed to stop IPFS daemon")?; + rm_rf::ensure_removed(path).unwrap(); Ok(()) } From 6d088d63b27449d30aa410e934d47e2cbd6c4a55 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Fri, 6 Oct 2023 10:08:00 -0400 Subject: [PATCH 02/10] chore: bring in some bgins work --- homestar-runtime/tests/cli.rs | 32 +++++++++---------- .../metrics_node/config/settings.toml | 12 +++++++ .../network_node1/config/settings.toml | 16 ++++++++++ .../network_node2/config/settings.toml | 16 ++++++++++ homestar-runtime/tests/metrics.rs | 21 ++++++------ .../tests/test_node1/config/settings.toml | 13 -------- .../tests/test_node2/config/settings.toml | 12 ------- 7 files changed, 69 insertions(+), 53 deletions(-) create mode 100644 homestar-runtime/tests/fixtures/metrics_node/config/settings.toml create mode 100644 homestar-runtime/tests/fixtures/network_node1/config/settings.toml create mode 100644 homestar-runtime/tests/fixtures/network_node2/config/settings.toml delete mode 100644 homestar-runtime/tests/test_node1/config/settings.toml delete mode 100644 homestar-runtime/tests/test_node2/config/settings.toml diff --git a/homestar-runtime/tests/cli.rs b/homestar-runtime/tests/cli.rs index aaba16a9..64ac43a9 100644 --- a/homestar-runtime/tests/cli.rs +++ b/homestar-runtime/tests/cli.rs @@ -6,7 +6,7 @@ use assert_cmd::prelude::*; use once_cell::sync::Lazy; use predicates::prelude::*; use retry::{delay::Fixed, retry}; -use serial_test::file_serial; +use serial_test::serial; use std::{ net::{IpAddr, Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, TcpStream}, path::PathBuf, @@ -18,7 +18,7 @@ use wait_timeout::ChildExt; static BIN: Lazy = Lazy::new(|| assert_cmd::cargo::cargo_bin(BIN_NAME)); #[test] -#[file_serial] +#[serial] fn test_help_serial() -> Result<()> { let _ = stop_all_bins(); @@ -53,7 +53,7 @@ fn test_help_serial() -> Result<()> { } #[test] -#[file_serial] +#[serial] fn test_version_serial() -> Result<()> { let _ = stop_all_bins(); @@ -76,7 +76,7 @@ fn test_version_serial() -> Result<()> { } #[test] -#[file_serial] +#[serial] fn test_server_not_running_serial() -> Result<()> { let _ = stop_all_bins(); @@ -119,7 +119,7 @@ fn test_server_not_running_serial() -> Result<()> { } #[test] -#[file_serial] +#[serial] fn test_server_serial() -> Result<()> { let _ = stop_all_bins(); @@ -142,7 +142,7 @@ fn test_server_serial() -> Result<()> { .unwrap(); let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), 3030); - let result = retry(Fixed::from_millis(500), || { + let result = retry(Fixed::from_millis(1000).take(10), || { TcpStream::connect(socket).map(|stream| stream.shutdown(Shutdown::Both)) }); @@ -188,7 +188,7 @@ fn test_server_serial() -> Result<()> { #[cfg(feature = "test-utils")] #[test] -#[file_serial] +#[serial] fn test_workflow_run_serial() -> Result<()> { let _ = stop_all_bins(); @@ -204,7 +204,7 @@ fn test_workflow_run_serial() -> Result<()> { .unwrap(); let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), 3030); - let result = retry(Fixed::from_millis(500), || { + let result = retry(Fixed::from_millis(1000).take(30), || { TcpStream::connect(socket).map(|stream| stream.shutdown(Shutdown::Both)) }); @@ -262,7 +262,7 @@ fn test_workflow_run_serial() -> Result<()> { } #[test] -#[file_serial] +#[serial] #[cfg(not(windows))] fn test_daemon_serial() -> Result<()> { let _ = stop_all_bins(); @@ -279,7 +279,7 @@ fn test_daemon_serial() -> Result<()> { .success(); let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), 3030); - let result = retry(Fixed::from_millis(500), || { + let result = retry(Fixed::from_millis(1000).take(10), || { TcpStream::connect(socket).map(|stream| stream.shutdown(Shutdown::Both)) }); @@ -301,7 +301,7 @@ fn test_daemon_serial() -> Result<()> { } #[test] -#[file_serial] +#[serial] #[cfg(windows)] fn test_signal_kill_serial() -> Result<()> { let _ = stop_all_bins(); @@ -318,7 +318,7 @@ fn test_signal_kill_serial() -> Result<()> { .unwrap(); let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), 3030); - let result = retry(Fixed::from_millis(500), || { + let result = retry(Fixed::from_millis(1000).take(10), || { TcpStream::connect(socket).map(|stream| stream.shutdown(Shutdown::Both)) }); @@ -353,7 +353,7 @@ fn test_signal_kill_serial() -> Result<()> { } #[test] -#[file_serial] +#[serial] #[cfg(windows)] fn test_server_v4_serial() -> Result<()> { let _ = stop_all_bins(); @@ -372,7 +372,7 @@ fn test_server_v4_serial() -> Result<()> { .unwrap(); let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 9999); - let result = retry(Fixed::from_millis(500), || { + let result = retry(Fixed::from_millis(1000).take(30), || { TcpStream::connect(socket).map(|stream| stream.shutdown(Shutdown::Both)) }); @@ -410,7 +410,7 @@ fn test_server_v4_serial() -> Result<()> { } #[test] -#[file_serial] +#[serial] #[cfg(not(windows))] fn test_daemon_v4_serial() -> Result<()> { let _ = stop_all_bins(); @@ -429,7 +429,7 @@ fn test_daemon_v4_serial() -> Result<()> { .success(); let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 9999); - let result = retry(Fixed::from_millis(500), || { + let result = retry(Fixed::from_millis(1000).take(30), || { TcpStream::connect(socket).map(|stream| stream.shutdown(Shutdown::Both)) }); diff --git a/homestar-runtime/tests/fixtures/metrics_node/config/settings.toml b/homestar-runtime/tests/fixtures/metrics_node/config/settings.toml new file mode 100644 index 00000000..dd4521f2 --- /dev/null +++ b/homestar-runtime/tests/fixtures/metrics_node/config/settings.toml @@ -0,0 +1,12 @@ +[monitoring] +process_collector_interval = 10 +metrics_port = 4004 + +[node] + +[node.network] +rpc_port = 3031 +websocket_port = 9090 + +[node.network.keypair_config] +existing = { key_type = "ed25519", path = "./fixtures/__testkey_ed25519.pem" } diff --git a/homestar-runtime/tests/fixtures/network_node1/config/settings.toml b/homestar-runtime/tests/fixtures/network_node1/config/settings.toml new file mode 100644 index 00000000..33090934 --- /dev/null +++ b/homestar-runtime/tests/fixtures/network_node1/config/settings.toml @@ -0,0 +1,16 @@ +[monitoring] +process_collector_interval = 500 +metrics_port = 4002 + +[node] + +[node.network] +rpc_port = 3032 +websocket_port = 9092 +listen_address = "/ip4/127.0.0.1/tcp/7000" +node_addresses = [ + "/ip4/127.0.0.1/tcp/7001/p2p/16Uiu2HAm3g9AomQNeEctL2hPwLapap7AtPSNt8ZrBny4rLx1W5Dc", +] + +[node.network.keypair_config] +existing = { key_type = "ed25519", path = "./fixtures/__testkey_ed25519.pem" } diff --git a/homestar-runtime/tests/fixtures/network_node2/config/settings.toml b/homestar-runtime/tests/fixtures/network_node2/config/settings.toml new file mode 100644 index 00000000..b1cf1e0a --- /dev/null +++ b/homestar-runtime/tests/fixtures/network_node2/config/settings.toml @@ -0,0 +1,16 @@ +[monitoring] +process_collector_interval = 500 +metrics_port = 4003 + +[node] + +[node.network] +rpc_port = 3033 +websocket_port = 9093 +listen_address = "/ip4/127.0.0.1/tcp/7001" +node_addresses = [ + "/ip4/127.0.0.1/tcp/7000/p2p/12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN", +] + +[node.network.keypair_config] +existing = { key_type = "secp256k1", path = "./fixtures/__testkey_secp256k1.der" } diff --git a/homestar-runtime/tests/metrics.rs b/homestar-runtime/tests/metrics.rs index 704c30ef..53bdcfa0 100644 --- a/homestar-runtime/tests/metrics.rs +++ b/homestar-runtime/tests/metrics.rs @@ -3,7 +3,6 @@ use anyhow::Result; use once_cell::sync::Lazy; use reqwest::StatusCode; use retry::{delay::Fixed, retry, OperationResult}; -use serial_test::file_serial; use std::{ net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpStream}, path::PathBuf, @@ -13,14 +12,13 @@ use std::{ use wait_timeout::ChildExt; static BIN: Lazy = Lazy::new(|| assert_cmd::cargo::cargo_bin(BIN_NAME)); -const METRICS_URL: &str = "http://localhost:4000"; +const METRICS_URL: &str = "http://localhost:4004"; #[test] -#[file_serial] -fn test_metrics_serial() -> Result<()> { +fn test_metrics() -> Result<()> { fn sample_metrics() -> prometheus_parse::Value { let body = retry( - Fixed::from_millis(500).take(2), + Fixed::from_millis(1000).take(10), || match reqwest::blocking::get(METRICS_URL) { Ok(response) => match response.status() { StatusCode::OK => OperationResult::Ok(response.text()), @@ -29,10 +27,9 @@ fn test_metrics_serial() -> Result<()> { Err(_) => OperationResult::Retry("Metrics server not available"), }, ) - .unwrap() - .expect("Metrics server failed to serve metrics"); + .unwrap(); - let lines: Vec<_> = body.lines().map(|s| Ok(s.to_owned())).collect(); + let lines: Vec<_> = body.unwrap().lines().map(|s| Ok(s.to_owned())).collect(); let metrics = prometheus_parse::Scrape::parse(lines.into_iter()).expect("Unable to parse metrics"); @@ -50,15 +47,15 @@ fn test_metrics_serial() -> Result<()> { let mut homestar_proc = Command::new(BIN.as_os_str()) .arg("start") .arg("-c") - .arg("tests/test_node2/config/settings.toml") + .arg("tests/fixtures/metrics_node/config/settings.toml") .arg("--db") .arg("homestar.db") .stdout(Stdio::piped()) .spawn() .unwrap(); - let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 4000); - let result = retry(Fixed::from_millis(500), || { + let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 4004); + let result = retry(Fixed::from_millis(1000).take(10), || { TcpStream::connect(socket).map(|stream| stream.shutdown(Shutdown::Both)) }); @@ -69,7 +66,7 @@ fn test_metrics_serial() -> Result<()> { let sample1 = sample_metrics(); - let sample2 = retry(Fixed::from_millis(500).take(5), || { + let sample2 = retry(Fixed::from_millis(500).take(3), || { let sample2 = sample_metrics(); if sample1 != sample2 { OperationResult::Ok(sample2) diff --git a/homestar-runtime/tests/test_node1/config/settings.toml b/homestar-runtime/tests/test_node1/config/settings.toml deleted file mode 100644 index 305694c9..00000000 --- a/homestar-runtime/tests/test_node1/config/settings.toml +++ /dev/null @@ -1,13 +0,0 @@ -[monitoring] -process_collector_interval = 500 -metrics_port = 4000 - -[node] - -[node.network] -rpc_port = 3031 -websocket_port = 9091 -node_addresses = ["/ip4/127.0.0.1/tcp/9092/ws"] - -[node.network.keypair_config] -existing = { key_type = "ed25519", path = "../../fixtures/__testkey_ed25519.pem" } diff --git a/homestar-runtime/tests/test_node2/config/settings.toml b/homestar-runtime/tests/test_node2/config/settings.toml deleted file mode 100644 index 92570f77..00000000 --- a/homestar-runtime/tests/test_node2/config/settings.toml +++ /dev/null @@ -1,12 +0,0 @@ -[monitoring] -process_collector_interval = 500 -metrics_port = 4000 - -[node] - -[node.network] -rpc_port = 3032 -websocket_port = 9092 -node_addresses = [ - "/ip4/127.0.0.1/tcp/9091/ws/p2p/12D3KooWDpJ7As7BWAwRMfu1VU2WCqNjvq387JEYKDBj4kx6nXTN", -] From 0df866212473780170883d1753f71f6e2a6fca70 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Fri, 6 Oct 2023 12:27:42 -0400 Subject: [PATCH 03/10] chore: fixture cleanup --- homestar-runtime/fixtures/test_v4.toml | 6 ------ homestar-runtime/tests/cli.rs | 16 ++++++++++++---- .../fixtures/metrics_node/config/settings.toml | 2 +- .../fixtures/test-workflow-add-one.json | 0 4 files changed, 13 insertions(+), 11 deletions(-) delete mode 100644 homestar-runtime/fixtures/test_v4.toml rename homestar-runtime/{ => tests}/fixtures/test-workflow-add-one.json (100%) diff --git a/homestar-runtime/fixtures/test_v4.toml b/homestar-runtime/fixtures/test_v4.toml deleted file mode 100644 index 37bdce12..00000000 --- a/homestar-runtime/fixtures/test_v4.toml +++ /dev/null @@ -1,6 +0,0 @@ -[node] - -[node.network] -events_buffer_len = 1000 -rpc_port = 9999 -rpc_host = "127.0.0.1" diff --git a/homestar-runtime/tests/cli.rs b/homestar-runtime/tests/cli.rs index 64ac43a9..def32897 100644 --- a/homestar-runtime/tests/cli.rs +++ b/homestar-runtime/tests/cli.rs @@ -135,13 +135,15 @@ fn test_server_serial() -> Result<()> { let mut homestar_proc = Command::new(BIN.as_os_str()) .arg("start") + .arg("-c") + .arg("tests/fixtures/test_v6.toml") .arg("--db") .arg("homestar.db") .stdout(Stdio::piped()) .spawn() .unwrap(); - let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), 3030); + let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), 9998); let result = retry(Fixed::from_millis(1000).take(10), || { TcpStream::connect(socket).map(|stream| stream.shutdown(Shutdown::Both)) }); @@ -153,6 +155,10 @@ fn test_server_serial() -> Result<()> { Command::new(BIN.as_os_str()) .arg("ping") + .arg("--host") + .arg("::1") + .arg("-p") + .arg("9998") .assert() .success() .stdout(predicate::str::contains("::1")) @@ -160,6 +166,8 @@ fn test_server_serial() -> Result<()> { Command::new(BIN.as_os_str()) .arg("ping") + .arg("--host") + .arg("::1") .arg("-p") .arg("9999") .assert() @@ -216,7 +224,7 @@ fn test_workflow_run_serial() -> Result<()> { Command::new(BIN.as_os_str()) .arg("run") .arg("-w") - .arg("./fixtures/test-workflow-add-one.json") + .arg("tests/fixtures/test-workflow-add-one.json") .assert() .success() .stdout(predicate::str::contains( @@ -364,7 +372,7 @@ fn test_server_v4_serial() -> Result<()> { let mut homestar_proc = Command::new(BIN.as_os_str()) .arg("start") .arg("-c") - .arg("fixtures/test_v4.toml") + .arg("tests/fixtures/test_v4.toml") .arg("--db") .arg("homestar.db") .stdout(Stdio::piped()) @@ -421,7 +429,7 @@ fn test_daemon_v4_serial() -> Result<()> { Command::new(BIN.as_os_str()) .arg("start") .arg("-c") - .arg("fixtures/test_v4.toml") + .arg("tests/fixtures/test_v4.toml") .arg("-d") .env("DATABASE_URL", "homestar.db") .stdout(Stdio::piped()) diff --git a/homestar-runtime/tests/fixtures/metrics_node/config/settings.toml b/homestar-runtime/tests/fixtures/metrics_node/config/settings.toml index dd4521f2..c8f2f4b4 100644 --- a/homestar-runtime/tests/fixtures/metrics_node/config/settings.toml +++ b/homestar-runtime/tests/fixtures/metrics_node/config/settings.toml @@ -1,5 +1,5 @@ [monitoring] -process_collector_interval = 10 +process_collector_interval = 500 metrics_port = 4004 [node] diff --git a/homestar-runtime/fixtures/test-workflow-add-one.json b/homestar-runtime/tests/fixtures/test-workflow-add-one.json similarity index 100% rename from homestar-runtime/fixtures/test-workflow-add-one.json rename to homestar-runtime/tests/fixtures/test-workflow-add-one.json From 8efbfd3ec5c5827d61c162944379d28a67808c09 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Fri, 6 Oct 2023 12:39:15 -0400 Subject: [PATCH 04/10] chore: fixture cleanup --- homestar-runtime/tests/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-runtime/tests/cli.rs b/homestar-runtime/tests/cli.rs index def32897..797ab2e9 100644 --- a/homestar-runtime/tests/cli.rs +++ b/homestar-runtime/tests/cli.rs @@ -240,7 +240,7 @@ fn test_workflow_run_serial() -> Result<()> { Command::new(BIN.as_os_str()) .arg("run") .arg("-w") - .arg("./fixtures/test-workflow-add-one.json") + .arg("tests/fixtures/test-workflow-add-one.json") .assert() .success() .stdout(predicate::str::contains( From 98c45d0fad90abc29efd0abebcc97f75988c93a2 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Fri, 6 Oct 2023 12:54:12 -0400 Subject: [PATCH 05/10] chore: files gotta file --- homestar-runtime/tests/fixtures/test_v4.toml | 6 ++++++ homestar-runtime/tests/fixtures/test_v6.toml | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 homestar-runtime/tests/fixtures/test_v4.toml create mode 100644 homestar-runtime/tests/fixtures/test_v6.toml diff --git a/homestar-runtime/tests/fixtures/test_v4.toml b/homestar-runtime/tests/fixtures/test_v4.toml new file mode 100644 index 00000000..37bdce12 --- /dev/null +++ b/homestar-runtime/tests/fixtures/test_v4.toml @@ -0,0 +1,6 @@ +[node] + +[node.network] +events_buffer_len = 1000 +rpc_port = 9999 +rpc_host = "127.0.0.1" diff --git a/homestar-runtime/tests/fixtures/test_v6.toml b/homestar-runtime/tests/fixtures/test_v6.toml new file mode 100644 index 00000000..2e35703f --- /dev/null +++ b/homestar-runtime/tests/fixtures/test_v6.toml @@ -0,0 +1,10 @@ +[monitoring] +process_collector_interval = 500 +metrics_port = 4006 + +[node] + +[node.network] +events_buffer_len = 1000 +rpc_port = 9998 +rpc_host = "::1" From 28de66dce17e73ae2ad9c37d4805daf608424401 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Fri, 6 Oct 2023 13:15:50 -0400 Subject: [PATCH 06/10] chore: serial --- homestar-runtime/tests/metrics.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homestar-runtime/tests/metrics.rs b/homestar-runtime/tests/metrics.rs index 53bdcfa0..2b50c401 100644 --- a/homestar-runtime/tests/metrics.rs +++ b/homestar-runtime/tests/metrics.rs @@ -3,6 +3,7 @@ use anyhow::Result; use once_cell::sync::Lazy; use reqwest::StatusCode; use retry::{delay::Fixed, retry, OperationResult}; +use serial_test::{file_serial, serial}; use std::{ net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpStream}, path::PathBuf, @@ -15,7 +16,8 @@ static BIN: Lazy = Lazy::new(|| assert_cmd::cargo::cargo_bin(BIN_NAME)) const METRICS_URL: &str = "http://localhost:4004"; #[test] -fn test_metrics() -> Result<()> { +#[serial] +fn test_metrics_serial() -> Result<()> { fn sample_metrics() -> prometheus_parse::Value { let body = retry( Fixed::from_millis(1000).take(10), From 4457d0cb2e8d11cc613ec24e4d39b531fccc8d2c Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Fri, 6 Oct 2023 13:21:55 -0400 Subject: [PATCH 07/10] chore: .. --- homestar-runtime/tests/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-runtime/tests/utils.rs b/homestar-runtime/tests/utils.rs index 74cf7855..afedace7 100644 --- a/homestar-runtime/tests/utils.rs +++ b/homestar-runtime/tests/utils.rs @@ -98,7 +98,7 @@ pub(crate) fn kill_homestar_process() -> Result<()> { ); let _result = signal::kill(Pid::from_raw(pid.try_into().unwrap()), Signal::SIGTERM); - let _result = retry(Fixed::from_millis(500), || { + let _result = retry(Fixed::from_millis(1000).take(5), || { Command::new(BIN.as_os_str()) .arg("ping") .assert() From 2b24e751322078390babbb98909b3899b9d22bc1 Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Fri, 6 Oct 2023 13:41:04 -0400 Subject: [PATCH 08/10] chore: .. --- homestar-runtime/tests/cli.rs | 30 ++++++++++++++++++------------ homestar-runtime/tests/metrics.rs | 4 ++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/homestar-runtime/tests/cli.rs b/homestar-runtime/tests/cli.rs index 797ab2e9..343df306 100644 --- a/homestar-runtime/tests/cli.rs +++ b/homestar-runtime/tests/cli.rs @@ -6,7 +6,7 @@ use assert_cmd::prelude::*; use once_cell::sync::Lazy; use predicates::prelude::*; use retry::{delay::Fixed, retry}; -use serial_test::serial; +use serial_test::file_serial; use std::{ net::{IpAddr, Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, TcpStream}, path::PathBuf, @@ -18,7 +18,7 @@ use wait_timeout::ChildExt; static BIN: Lazy = Lazy::new(|| assert_cmd::cargo::cargo_bin(BIN_NAME)); #[test] -#[serial] +#[file_serial] fn test_help_serial() -> Result<()> { let _ = stop_all_bins(); @@ -53,7 +53,7 @@ fn test_help_serial() -> Result<()> { } #[test] -#[serial] +#[file_serial] fn test_version_serial() -> Result<()> { let _ = stop_all_bins(); @@ -76,7 +76,7 @@ fn test_version_serial() -> Result<()> { } #[test] -#[serial] +#[file_serial] fn test_server_not_running_serial() -> Result<()> { let _ = stop_all_bins(); @@ -119,7 +119,7 @@ fn test_server_not_running_serial() -> Result<()> { } #[test] -#[serial] +#[file_serial] fn test_server_serial() -> Result<()> { let _ = stop_all_bins(); @@ -196,7 +196,7 @@ fn test_server_serial() -> Result<()> { #[cfg(feature = "test-utils")] #[test] -#[serial] +#[file_serial] fn test_workflow_run_serial() -> Result<()> { let _ = stop_all_bins(); @@ -270,7 +270,7 @@ fn test_workflow_run_serial() -> Result<()> { } #[test] -#[serial] +#[file_serial] #[cfg(not(windows))] fn test_daemon_serial() -> Result<()> { let _ = stop_all_bins(); @@ -280,13 +280,15 @@ fn test_daemon_serial() -> Result<()> { Command::new(BIN.as_os_str()) .arg("start") + .arg("-c") + .arg("tests/fixtures/test_v4_alt.toml") .arg("-d") .env("DATABASE_URL", "homestar.db") .stdout(Stdio::piped()) .assert() .success(); - let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), 3030); + let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), 9997); let result = retry(Fixed::from_millis(1000).take(10), || { TcpStream::connect(socket).map(|stream| stream.shutdown(Shutdown::Both)) }); @@ -297,9 +299,13 @@ fn test_daemon_serial() -> Result<()> { Command::new(BIN.as_os_str()) .arg("ping") + .arg("--host") + .arg("127.0.0.1") + .arg("-p") + .arg("9997") .assert() .success() - .stdout(predicate::str::contains("::1")) + .stdout(predicate::str::contains("127.0.0.1")) .stdout(predicate::str::contains("pong")); let _ = stop_all_bins(); @@ -309,7 +315,7 @@ fn test_daemon_serial() -> Result<()> { } #[test] -#[serial] +#[file_serial] #[cfg(windows)] fn test_signal_kill_serial() -> Result<()> { let _ = stop_all_bins(); @@ -361,7 +367,7 @@ fn test_signal_kill_serial() -> Result<()> { } #[test] -#[serial] +#[file_serial] #[cfg(windows)] fn test_server_v4_serial() -> Result<()> { let _ = stop_all_bins(); @@ -418,7 +424,7 @@ fn test_server_v4_serial() -> Result<()> { } #[test] -#[serial] +#[file_serial] #[cfg(not(windows))] fn test_daemon_v4_serial() -> Result<()> { let _ = stop_all_bins(); diff --git a/homestar-runtime/tests/metrics.rs b/homestar-runtime/tests/metrics.rs index 2b50c401..889b5dc1 100644 --- a/homestar-runtime/tests/metrics.rs +++ b/homestar-runtime/tests/metrics.rs @@ -3,7 +3,7 @@ use anyhow::Result; use once_cell::sync::Lazy; use reqwest::StatusCode; use retry::{delay::Fixed, retry, OperationResult}; -use serial_test::{file_serial, serial}; +use serial_test::file_serial; use std::{ net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, TcpStream}, path::PathBuf, @@ -16,7 +16,7 @@ static BIN: Lazy = Lazy::new(|| assert_cmd::cargo::cargo_bin(BIN_NAME)) const METRICS_URL: &str = "http://localhost:4004"; #[test] -#[serial] +#[file_serial] fn test_metrics_serial() -> Result<()> { fn sample_metrics() -> prometheus_parse::Value { let body = retry( From 8d7c88608d3be60574e695c471e02edec2359f0a Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Fri, 6 Oct 2023 13:53:00 -0400 Subject: [PATCH 09/10] chore: .. --- homestar-runtime/tests/fixtures/test_v4_alt.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 homestar-runtime/tests/fixtures/test_v4_alt.toml diff --git a/homestar-runtime/tests/fixtures/test_v4_alt.toml b/homestar-runtime/tests/fixtures/test_v4_alt.toml new file mode 100644 index 00000000..11a3c23f --- /dev/null +++ b/homestar-runtime/tests/fixtures/test_v4_alt.toml @@ -0,0 +1,10 @@ +[monitoring] +process_collector_interval = 500 +metrics_port = 4007 + +[node] + +[node.network] +events_buffer_len = 1000 +rpc_port = 9997 +rpc_host = "127.0.0.1" From ad7bdd4c00eafa8e481892ad61447c73221f360e Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Fri, 6 Oct 2023 14:02:50 -0400 Subject: [PATCH 10/10] chore: .. --- homestar-runtime/tests/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homestar-runtime/tests/cli.rs b/homestar-runtime/tests/cli.rs index 343df306..dc0c6c6b 100644 --- a/homestar-runtime/tests/cli.rs +++ b/homestar-runtime/tests/cli.rs @@ -288,7 +288,7 @@ fn test_daemon_serial() -> Result<()> { .assert() .success(); - let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::LOCALHOST), 9997); + let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 9997); let result = retry(Fixed::from_millis(1000).take(10), || { TcpStream::connect(socket).map(|stream| stream.shutdown(Shutdown::Both)) });