Skip to content

Commit

Permalink
fix(test): sleep before verifying routing table
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin committed Nov 24, 2023
1 parent acaa862 commit 7a16131
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/memcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ jobs:

- name: Verify the routing tables of the nodes
run: cargo test --release -p sn_node --test verify_routing_table -- --nocapture
timeout-minutes: 5
env:
SLEEP_BEFORE_VERIFICATION: 300
timeout-minutes: 10

- name: Create and fund a wallet to pay for files storage
run: |
Expand Down Expand Up @@ -118,7 +120,9 @@ jobs:

- name: Verify the routing tables of the nodes
run: cargo test --release -p sn_node --test verify_routing_table -- --nocapture
timeout-minutes: 5
env:
SLEEP_BEFORE_VERIFICATION: 300
timeout-minutes: 10

- name: Verify restart of nodes using rg
shell: bash
Expand Down
16 changes: 16 additions & 0 deletions sn_node/tests/verify_routing_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,29 @@ use sn_protocol::safenode_proto::{safe_node_client::SafeNodeClient, KBucketsRequ
use std::{
collections::{HashMap, HashSet},
net::{IpAddr, Ipv4Addr, SocketAddr},
time::Duration,
};
use tonic::Request;

/// Sleep for sometime for the nodes for discover each other before verification
/// Also can be set through the env variable of the same name.
const SLEEP_BEFORE_VERIFICATION: Duration = Duration::from_secs(5);

#[tokio::test(flavor = "multi_thread")]
async fn verify_routing_table() -> Result<()> {
let _log_appender_guard = LogBuilder::init_multi_threaded_tokio_test("verify_routing_table");

let sleep_duration = std::env::var("SLEEP_BEFORE_VERIFICATION")
.map(|value| {
value
.parse::<u64>()
.expect("Failed to prase sleep value into u64")
})
.map(Duration::from_secs)
.unwrap_or(SLEEP_BEFORE_VERIFICATION);
println!("Sleeping for {sleep_duration:?} before verification");
tokio::time::sleep(sleep_duration).await;

let all_peers = get_all_peer_ids().await?;
let mut all_failed_list = HashMap::new();

Expand Down

0 comments on commit 7a16131

Please sign in to comment.