Skip to content

Commit

Permalink
Try to fix CI (Fix harness test's leader node-id to 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Feb 1, 2024
1 parent 32ac6f4 commit 3b3a48a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion harness/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ pub async fn load_peers(example_filename: &str) -> Result<Peers, Box<dyn std::er

for peer_info in raft_config.raft.peers {
let addr = SocketAddr::new(peer_info.host.parse().unwrap(), peer_info.port);
peers.add_peer(peer_info.node_id, addr, Some(InitialRole::Voter));

if peer_info.node_id == 1 {
peers.add_peer(peer_info.node_id, addr, Some(InitialRole::Leader));
} else {
peers.add_peer(peer_info.node_id, addr, Some(InitialRole::Voter));
}
}

Ok(peers)
Expand Down
2 changes: 1 addition & 1 deletion harness/tests/data_replication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use harness::{
pub async fn test_data_replication() {
let peers = load_peers(THREE_NODE_EXAMPLE).await.unwrap();
let _raft_tasks = tokio::spawn(build_raft_cluster(peers.clone()));
sleep(Duration::from_secs(5)).await;
sleep(Duration::from_secs(1)).await;

{
let mut rafts = RAFTS.lock().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion harness/tests/leader_election.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use harness::{
pub async fn test_leader_election_in_three_node_example() {
let peers = load_peers(THREE_NODE_EXAMPLE).await.unwrap();
let _raft_tasks = tokio::spawn(build_raft_cluster(peers.clone()));
sleep(Duration::from_secs(5)).await;
sleep(Duration::from_secs(1)).await;

let mut rafts = RAFTS.lock().unwrap();
let raft_1 = rafts.get_mut(&1).unwrap();
Expand Down

0 comments on commit 3b3a48a

Please sign in to comment.