-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test: add an AsyncRuntime test suite
- Loading branch information
Showing
13 changed files
with
461 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//! Testing utilities used by all kinds of tests. | ||
use std::collections::BTreeSet; | ||
|
||
use crate::entry::RaftEntry; | ||
use crate::CommittedLeaderId; | ||
use crate::LogId; | ||
use crate::RaftTypeConfig; | ||
|
||
/// Builds a log id, for testing purposes. | ||
pub fn log_id<NID: crate::NodeId>(term: u64, node_id: NID, index: u64) -> LogId<NID> { | ||
LogId::<NID> { | ||
leader_id: CommittedLeaderId::new(term, node_id), | ||
index, | ||
} | ||
} | ||
|
||
/// Create a blank log entry for test. | ||
pub fn blank_ent<C: RaftTypeConfig>(term: u64, node_id: C::NodeId, index: u64) -> crate::Entry<C> { | ||
crate::Entry::<C>::new_blank(LogId::new(CommittedLeaderId::new(term, node_id), index)) | ||
} | ||
|
||
/// Create a membership log entry without learner config for test. | ||
pub fn membership_ent<C: RaftTypeConfig>( | ||
term: u64, | ||
node_id: C::NodeId, | ||
index: u64, | ||
config: Vec<BTreeSet<C::NodeId>>, | ||
) -> crate::Entry<C> { | ||
crate::Entry::new_membership( | ||
LogId::new(CommittedLeaderId::new(term, node_id), index), | ||
crate::Membership::new(config, None), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//! Suite for testing implementations of [`RaftLogStorage`] and [`RaftStateMachine`]. | ||
//! | ||
//! [`RaftLogStorage`]: crate::storage::RaftLogStorage | ||
//! [`RaftStateMachine`]: crate::storage::RaftStateMachine | ||
mod store_builder; | ||
mod suite; | ||
|
||
pub use store_builder::StoreBuilder; | ||
pub use suite::Suite; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,7 @@ | ||
//! Testing utilities for OpenRaft. | ||
mod store_builder; | ||
mod suite; | ||
pub mod common; | ||
pub mod log; | ||
pub mod runtime; | ||
|
||
use std::collections::BTreeSet; | ||
|
||
pub use store_builder::StoreBuilder; | ||
pub use suite::Suite; | ||
|
||
use crate::entry::RaftEntry; | ||
use crate::CommittedLeaderId; | ||
use crate::LogId; | ||
use crate::RaftTypeConfig; | ||
|
||
/// Builds a log id, for testing purposes. | ||
pub fn log_id<NID: crate::NodeId>(term: u64, node_id: NID, index: u64) -> LogId<NID> { | ||
LogId::<NID> { | ||
leader_id: CommittedLeaderId::new(term, node_id), | ||
index, | ||
} | ||
} | ||
|
||
/// Create a blank log entry for test. | ||
pub fn blank_ent<C: RaftTypeConfig>(term: u64, node_id: C::NodeId, index: u64) -> crate::Entry<C> { | ||
crate::Entry::<C>::new_blank(LogId::new(CommittedLeaderId::new(term, node_id), index)) | ||
} | ||
|
||
/// Create a membership log entry without learner config for test. | ||
pub fn membership_ent<C: RaftTypeConfig>( | ||
term: u64, | ||
node_id: C::NodeId, | ||
index: u64, | ||
config: Vec<BTreeSet<C::NodeId>>, | ||
) -> crate::Entry<C> { | ||
crate::Entry::new_membership( | ||
LogId::new(CommittedLeaderId::new(term, node_id), index), | ||
crate::Membership::new(config, None), | ||
) | ||
} | ||
pub use common::*; |
Oops, something went wrong.