Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): Address a port conflict issue in the non-blocking logger test #8658

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions zebrad/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
parameters::Network::{self, *},
};
use zebra_consensus::ParameterCheckpoint;
use zebra_network::constants::PORT_IN_USE_ERROR;

Check warning on line 170 in zebrad/tests/acceptance.rs

View workflow job for this annotation

GitHub Actions / Test stable on windows-latest

unused import: `zebra_network::constants::PORT_IN_USE_ERROR`
use zebra_node_services::rpc_client::RpcRequestClient;
use zebra_rpc::server::OPENED_RPC_ENDPOINT_MSG;
use zebra_state::{constants::LOCK_FILE_ERROR, state_database_format_version_in_code};
Expand All @@ -175,7 +175,7 @@
use zebra_test::{
args,
command::{to_regex::CollectRegexSet, ContextFrom},
net::random_known_port,

Check warning on line 178 in zebrad/tests/acceptance.rs

View workflow job for this annotation

GitHub Actions / Test stable on windows-latest

unused import: `net::random_known_port`
prelude::*,
};

Expand Down Expand Up @@ -1711,25 +1711,20 @@
let test_task_handle: tokio::task::JoinHandle<Result<()>> = rt.spawn(async move {
let _init_guard = zebra_test::init();

// Write a configuration that has RPC listen_addr set
// [Note on port conflict](#Note on port conflict)
let mut config = random_known_rpc_port_config(false, &Mainnet)?;
let mut config = os_assigned_rpc_port_config(false, &Mainnet)?;
config.tracing.filter = Some("trace".to_string());
config.tracing.buffer_limit = 100;
let zebra_rpc_address = config.rpc.listen_addr.unwrap();

let dir = testdir()?.with_config(&mut config)?;
let mut child = dir
.spawn_child(args!["start"])?
.with_timeout(TINY_CHECKPOINT_TIMEOUT);

// Wait until port is open.
child.expect_stdout_line_matches(
format!("Opened RPC endpoint at {}", config.rpc.listen_addr.unwrap()).as_str(),
)?;
let rpc_address = read_listen_addr_from_logs(&mut child, OPENED_RPC_ENDPOINT_MSG)?;

// Create an http client
let client = RpcRequestClient::new(zebra_rpc_address);
let client = RpcRequestClient::new(rpc_address);

// Most of Zebra's lines are 100-200 characters long, so 500 requests should print enough to fill the unix pipe,
// fill the channel that tracing logs are queued onto, and drop logs rather than block execution.
Expand Down
Loading