-
Notifications
You must be signed in to change notification settings - Fork 4
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
Testing multiple zebrads #80
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ use std::path::PathBuf; | |
use zcash_protocol::{PoolType, ShieldedProtocol}; | ||
|
||
use testvectors::REG_O_ADDR_FROM_ABANDONART; | ||
use tokio::task::{AbortHandle, JoinSet}; | ||
use zingolib::testutils::lightclient::{from_inputs, get_base_address}; | ||
|
||
use zingo_infra_testutils::client; | ||
|
@@ -79,6 +80,99 @@ async fn launch_zebrad_with_cache() { | |
assert_eq!(zebrad.get_chain_height().await, 52.into()); | ||
} | ||
|
||
#[ignore = "added to test multiple zebrad instances"] | ||
#[tokio::test] | ||
async fn launch_zebrad_with_cache_again() { | ||
tracing_subscriber::fmt().init(); | ||
|
||
let zebrad = Zebrad::launch(ZebradConfig { | ||
zebrad_bin: ZEBRAD_BIN, | ||
network_listen_port: None, | ||
rpc_listen_port: None, | ||
activation_heights: network::ActivationHeights::default(), | ||
miner_address: ZEBRAD_DEFAULT_MINER, | ||
chain_cache: Some(utils::chain_cache_dir().join("client_rpc_tests_large")), | ||
network: network::Network::Regtest, | ||
}) | ||
.await | ||
.unwrap(); | ||
zebrad.print_stdout(); | ||
zebrad.print_stderr(); | ||
|
||
assert_eq!(zebrad.get_chain_height().await, 52.into()); | ||
} | ||
|
||
#[ignore = "added to test multiple zebrad instances"] | ||
#[tokio::test] | ||
async fn launch_zebrad_multiple_times_with_cache() { | ||
tracing_subscriber::fmt().init(); | ||
|
||
let zebrad1 = Zebrad::launch(ZebradConfig { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
zebrad_bin: ZEBRAD_BIN, | ||
network_listen_port: None, | ||
rpc_listen_port: None, | ||
activation_heights: network::ActivationHeights::default(), | ||
miner_address: ZEBRAD_DEFAULT_MINER, | ||
chain_cache: Some(utils::chain_cache_dir().join("client_rpc_tests_large")), | ||
network: network::Network::Regtest, | ||
}) | ||
.await | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awaited here... |
||
.unwrap(); | ||
zebrad1.print_stdout(); | ||
zebrad1.print_stderr(); | ||
|
||
let zebrad2 = Zebrad::launch(ZebradConfig { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stops because this |
||
zebrad_bin: ZEBRAD_BIN, | ||
network_listen_port: None, | ||
rpc_listen_port: None, | ||
activation_heights: network::ActivationHeights::default(), | ||
miner_address: ZEBRAD_DEFAULT_MINER, | ||
chain_cache: Some(utils::chain_cache_dir().join("client_rpc_tests_large")), | ||
network: network::Network::Regtest, | ||
}) | ||
.await | ||
.unwrap(); | ||
zebrad2.print_stdout(); | ||
zebrad2.print_stderr(); | ||
|
||
// Don't stop either zebrad | ||
assert_eq!(zebrad1.get_chain_height().await, 52.into()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and means this test running |
||
assert_eq!(zebrad2.get_chain_height().await, 52.into()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or this one, is corrupted because the launches are being awaited? I get the error though I have not completely isolated the chain_cache dir yet, I think your fix will make all of these pass. We can also write a test that will spawn multiple tasks, but I think these tests are useful. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The key aspect is that they only raco for the lock if they are both running at the same time.
I agree that it's an useful test. Could be made into 2 distinct ones:
BUT this test isn't yet running 2 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think, in this test, against current |
||
} | ||
|
||
#[ignore = "added to test multiple zebrad instances"] | ||
#[tokio::test] | ||
async fn launch_zebrad_multiple_times_in_tokio_tasks_with_cache() { | ||
tracing_subscriber::fmt().init(); | ||
|
||
let mut tests_set: JoinSet<()> = JoinSet::new(); | ||
// spawn 3 tests as tasks | ||
for _ in 0..=2 { | ||
tests_set.spawn(async { | ||
let zebrad = Zebrad::launch(ZebradConfig { | ||
zebrad_bin: ZEBRAD_BIN, | ||
network_listen_port: None, | ||
rpc_listen_port: None, | ||
activation_heights: network::ActivationHeights::default(), | ||
miner_address: ZEBRAD_DEFAULT_MINER, | ||
chain_cache: Some(utils::chain_cache_dir().join("client_rpc_tests_large")), | ||
network: network::Network::Regtest, | ||
}) | ||
.await | ||
.expect("future inside task to unwrap"); | ||
zebrad.print_stdout(); | ||
zebrad.print_stderr(); | ||
// assert within task | ||
assert_eq!(zebrad.get_chain_height().await, 52.into()); | ||
}); | ||
|
||
// Don't stop either zebrad | ||
} | ||
// will only be joined when all tasks have completed launch and asserted a chain height. | ||
tests_set.join_all().await; | ||
// returns pass | ||
} | ||
|
||
#[tokio::test] | ||
async fn launch_localnet_zainod_zcashd() { | ||
tracing_subscriber::fmt().init(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a sequential launch of
zebrad
's. Notice how there are being awaited.We need a single test to launch 2+ instances in parallel. In as comparable as possible of a way as how
nextest run
launches 2 tests and each test launches azebrad
process.Only then will they be really competing for the cache dir lock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. Are you saying that...