aboutsummaryrefslogtreecommitdiff
path: root/src/net/test.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-02-13 13:54:37 +0100
committerAlex Auvolat <alex@adnab.me>2024-02-15 12:15:33 +0100
commit5766befb245efba7d9241e2e2c68bcf4ed28d7a4 (patch)
tree64d8cc62a6fc6363a0263dc3609b9aae61115c22 /src/net/test.rs
parent5ea24254a91c3794ceb69e68c940b13f5447f40c (diff)
downloadgarage-5766befb245efba7d9241e2e2c68bcf4ed28d7a4.tar.gz
garage-5766befb245efba7d9241e2e2c68bcf4ed28d7a4.zip
[import-netapp] fix tests
Diffstat (limited to 'src/net/test.rs')
-rw-r--r--src/net/test.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/net/test.rs b/src/net/test.rs
index 19759ccf..d4da6f23 100644
--- a/src/net/test.rs
+++ b/src/net/test.rs
@@ -14,32 +14,32 @@ use crate::NodeID;
#[tokio::test(flavor = "current_thread")]
async fn test_with_basic_scheduler() {
- env_logger::init();
- run_test().await
+ pretty_env_logger::init();
+ run_test(19980).await
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_with_threaded_scheduler() {
- run_test().await
+ run_test(19990).await
}
-async fn run_test() {
+async fn run_test(port_base: u16) {
select! {
- _ = run_test_inner() => (),
+ _ = run_test_inner(port_base) => (),
_ = tokio::time::sleep(Duration::from_secs(20)) => panic!("timeout"),
}
}
-async fn run_test_inner() {
+async fn run_test_inner(port_base: u16) {
let netid = auth::gen_key();
let (pk1, sk1) = ed25519::gen_keypair();
let (pk2, sk2) = ed25519::gen_keypair();
let (pk3, sk3) = ed25519::gen_keypair();
- let addr1: SocketAddr = "127.0.0.1:19991".parse().unwrap();
- let addr2: SocketAddr = "127.0.0.1:19992".parse().unwrap();
- let addr3: SocketAddr = "127.0.0.1:19993".parse().unwrap();
+ let addr1: SocketAddr = SocketAddr::new("127.0.0.1".parse().unwrap(), port_base);
+ let addr2: SocketAddr = SocketAddr::new("127.0.0.1".parse().unwrap(), port_base + 1);
+ let addr3: SocketAddr = SocketAddr::new("127.0.0.1".parse().unwrap(), port_base + 2);
let (stop_tx, stop_rx) = watch::channel(false);
@@ -56,7 +56,7 @@ async fn run_test_inner() {
vec![(pk1, addr1)],
stop_rx.clone(),
);
- tokio::time::sleep(Duration::from_secs(5)).await;
+ tokio::time::sleep(Duration::from_secs(3)).await;
let pl1 = peering1.get_peer_list();
println!("A pl1: {:?}", pl1);
@@ -69,7 +69,7 @@ async fn run_test_inner() {
// Connect third ndoe and check it peers with everyone
let (thread3, _netapp3, peering3) =
run_netapp(netid, pk3, sk3, addr3, vec![(pk2, addr2)], stop_rx.clone());
- tokio::time::sleep(Duration::from_secs(5)).await;
+ tokio::time::sleep(Duration::from_secs(3)).await;
let pl1 = peering1.get_peer_list();
println!("B pl1: {:?}", pl1);