Skip to content

Commit

Permalink
fix: CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Sep 30, 2024
1 parent dc89235 commit be7049b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion harness/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use raftify::{Config, RaftConfig};

pub fn build_config() -> Config {
pub fn build_config(node_id: u64) -> Config {
let raft_config = RaftConfig {
id: node_id,
election_tick: 10,
heartbeat_tick: 3,
omit_heartbeat_log: true,
Expand Down
23 changes: 16 additions & 7 deletions harness/src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn run_raft(
should_be_leader: bool,
) -> Result<JoinHandle<Result<()>>> {
let peer = peers.get(node_id).unwrap();
let mut cfg = build_config();
let mut cfg = build_config(*node_id);
cfg.initial_peers = if should_be_leader {
None
} else {
Expand Down Expand Up @@ -141,7 +141,7 @@ pub async fn spawn_extra_node(
slog: build_logger(),
});

let cfg = build_config();
let cfg = build_config(node_id);
let store = HashStore::new();
let storage_pth = get_storage_path(cfg.log_dir.as_str(), 1);
ensure_directory_exist(storage_pth.as_str())?;
Expand Down Expand Up @@ -172,7 +172,7 @@ pub async fn spawn_and_join_extra_node(
.unwrap();

let node_id = join_ticket.reserved_id;
let mut cfg = build_config();
let mut cfg = build_config(node_id);
cfg.initial_peers = Some(join_ticket.peers.clone().into());
let store = HashStore::new();

Expand All @@ -189,8 +189,12 @@ pub async fn spawn_and_join_extra_node(

let raft_handle = tokio::spawn(raft.clone().run());

raft.add_peers(join_ticket.peers.clone()).await;
raft.join_cluster(vec![join_ticket]).await;
raft.add_peers(join_ticket.peers.clone())
.await
.expect("Failed to add peers");
raft.join_cluster(vec![join_ticket])
.await
.expect("Failed to join cluster");

Ok(raft_handle)
}
Expand All @@ -202,9 +206,14 @@ pub async fn join_nodes(rafts: Vec<&Raft>, raft_addrs: Vec<&str>, peer_addr: &st
.await
.unwrap();

raft.add_peers(join_ticket.peers.clone()).await;
raft.add_peers(join_ticket.peers.clone())
.await
.expect("Failed to add peers");
tickets.push(join_ticket);
}

rafts[0].join_cluster(tickets).await;
rafts[0]
.join_cluster(tickets)
.await
.expect("Failed to join cluster");
}

0 comments on commit be7049b

Please sign in to comment.