diff --git a/raft/raft_api.nim b/raft/raft_api.nim index 253325d..56bca9c 100644 --- a/raft/raft_api.nim +++ b/raft/raft_api.nim @@ -118,7 +118,7 @@ template RaftTimerCreate(timerInterval: int, timerCallback: RaftTimerCallback): # Timers scheduling stuff etc. proc RaftNodeScheduleHeartBeat*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) = - node.heartBeatTimer = RaftTimerCreate(130, proc() = asyncSpawn RaftNodeSendHeartBeat(node)) + node.heartBeatTimer = RaftTimerCreate(150, proc() = asyncSpawn RaftNodeSendHeartBeat(node)) proc RaftNodeSendHeartBeat*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) {.async.} = debug "Raft Node sending Heart-Beat to peers", node_id=node.id @@ -142,11 +142,11 @@ proc RaftNodeScheduleElectionTimeout*[SmCommandType, SmStateType](node: RaftNode proc RaftNodeCancelAllTimers*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) = withRLock(node.raftStateMutex): if node.heartBeatTimer != nil: - waitFor cancelAndWait(node.heartBeatTimer) + asyncSpawn cancelAndWait(node.heartBeatTimer) if node.electionTimeoutTimer != nil: - waitFor cancelAndWait(node.electionTimeoutTimer ) + asyncSpawn cancelAndWait(node.electionTimeoutTimer ) if node.appendEntriesTimer != nil: - waitFor cancelAndWait(node.appendEntriesTimer) + asyncSpawn cancelAndWait(node.appendEntriesTimer) proc RaftNodeStop*[SmCommandType, SmStateType](node: RaftNode[SmCommandType, SmStateType]) = # Try to stop gracefully diff --git a/tests/test_basic_cluster.nim b/tests/test_basic_cluster.nim index 3e42c18..92fa97c 100644 --- a/tests/test_basic_cluster.nim +++ b/tests/test_basic_cluster.nim @@ -26,9 +26,9 @@ proc basicClusterMain*() = test "Generate Random Client SmCommands Queue": discard - test "Start Basic Raft Cluster And wait it to converge (Elect a Leader)": + test "Start Basic Raft Cluster And wait it to converge 10s (Elect a Leader)": BasicRaftClusterStart(cluster) - let dur = seconds(60) + let dur = seconds(10) waitFor sleepAsync(dur) test "Simulate Basic Raft Cluster Client SmCommands Execution / Log Replication":