Skip to content

Commit

Permalink
fix: fix madsim tests
Browse files Browse the repository at this point in the history
Signed-off-by: themanforfree <[email protected]>
  • Loading branch information
themanforfree committed Nov 24, 2023
1 parent 8b8a20d commit 5db7a88
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 29 deletions.
6 changes: 3 additions & 3 deletions curp-test-utils/src/test_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
use thiserror::Error;
use tokio::{sync::mpsc, time::sleep};
use tracing::debug;
use utils::config::{EngineConfig, StorageConfig};
use utils::config::EngineConfig;

use crate::{META_TABLE, REVISION_TABLE, TEST_TABLE};

Expand Down Expand Up @@ -435,9 +435,9 @@ impl TestCE {
server_name: String,
exe_sender: mpsc::UnboundedSender<(TestCommand, TestCommandResult)>,
after_sync_sender: mpsc::UnboundedSender<(TestCommand, LogIndex)>,
storage_cfg: StorageConfig,
engine_cfg: EngineConfig,
) -> Self {
let engine_type = match storage_cfg.engine {
let engine_type = match engine_cfg {
EngineConfig::Memory => EngineType::Memory,
EngineConfig::RocksDB(path) => EngineType::Rocks(path),
_ => unreachable!("Not supported storage type"),
Expand Down
20 changes: 10 additions & 10 deletions curp/src/server/cmd_worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ mod tests {
use test_macros::abort_on_panic;
use tokio::{sync::mpsc, time::Instant};
use tracing_test::traced_test;
use utils::config::{default_quota, EngineConfig, StorageConfig};
use utils::config::EngineConfig;

use super::*;
use crate::log_entry::LogEntry;
Expand All @@ -401,7 +401,7 @@ mod tests {
"S1".to_owned(),
er_tx,
as_tx,
StorageConfig::new(EngineConfig::Memory, default_quota()),
EngineConfig::Memory,
));
let (t, l) = shutdown::channel();
let (ce_event_tx, task_rx, done_tx) =
Expand Down Expand Up @@ -439,7 +439,7 @@ mod tests {
"S1".to_owned(),
er_tx,
as_tx,
StorageConfig::new(EngineConfig::Memory, default_quota()),
EngineConfig::Memory,
));
let (t, l) = shutdown::channel();
let (ce_event_tx, task_rx, done_tx) =
Expand Down Expand Up @@ -486,7 +486,7 @@ mod tests {
"S1".to_owned(),
er_tx,
as_tx,
StorageConfig::new(EngineConfig::Memory, default_quota()),
EngineConfig::Memory,
));
let (t, l) = shutdown::channel();
let (ce_event_tx, task_rx, done_tx) =
Expand Down Expand Up @@ -537,7 +537,7 @@ mod tests {
"S1".to_owned(),
er_tx,
as_tx,
StorageConfig::new(EngineConfig::Memory, default_quota()),
EngineConfig::Memory,
));
let (t, l) = shutdown::channel();
let (ce_event_tx, task_rx, done_tx) =
Expand Down Expand Up @@ -574,7 +574,7 @@ mod tests {
"S1".to_owned(),
er_tx,
as_tx,
StorageConfig::new(EngineConfig::Memory, default_quota()),
EngineConfig::Memory,
));
let (t, l) = shutdown::channel();
let (ce_event_tx, task_rx, done_tx) =
Expand Down Expand Up @@ -618,7 +618,7 @@ mod tests {
"S1".to_owned(),
er_tx,
as_tx,
StorageConfig::new(EngineConfig::Memory, default_quota()),
EngineConfig::Memory,
));
let (t, l) = shutdown::channel();
let (ce_event_tx, task_rx, done_tx) =
Expand Down Expand Up @@ -674,7 +674,7 @@ mod tests {
"S1".to_owned(),
er_tx,
as_tx,
StorageConfig::new(EngineConfig::Memory, default_quota()),
EngineConfig::Memory,
));
let (t, l) = shutdown::channel();
let (ce_event_tx, task_rx, done_tx) =
Expand Down Expand Up @@ -729,7 +729,7 @@ mod tests {
"S1".to_owned(),
er_tx,
as_tx,
StorageConfig::new(EngineConfig::Memory, default_quota()),
EngineConfig::Memory,
));
let (ce_event_tx, task_rx, done_tx) =
conflict_checked_mpmc::channel(Arc::clone(&ce1), t.clone());
Expand Down Expand Up @@ -775,7 +775,7 @@ mod tests {
"S1".to_owned(),
er_tx,
as_tx,
StorageConfig::new(EngineConfig::Memory, default_quota()),
EngineConfig::Memory,
));
let (ce_event_tx, task_rx, done_tx) =
conflict_checked_mpmc::channel(Arc::clone(&ce2), t.clone());
Expand Down
14 changes: 2 additions & 12 deletions curp/tests/it/common/curp_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ impl CurpGroup {

let (exe_tx, exe_rx) = mpsc::unbounded_channel();
let (as_tx, as_rx) = mpsc::unbounded_channel();
let ce = TestCE::new(
name.clone(),
exe_tx,
as_tx,
StorageConfig::new(xline_storage_config, default_quota()),
);
let ce = TestCE::new(name.clone(), exe_tx, as_tx, xline_storage_config);

let cluster_info = Arc::new(ClusterInfo::new(
all_members
Expand Down Expand Up @@ -199,12 +194,7 @@ impl CurpGroup {

let (exe_tx, exe_rx) = mpsc::unbounded_channel();
let (as_tx, as_rx) = mpsc::unbounded_channel();
let ce = TestCE::new(
name.clone(),
exe_tx,
as_tx,
StorageConfig::new(xline_storage_config, default_quota()),
);
let ce = TestCE::new(name.clone(), exe_tx, as_tx, xline_storage_config);

let id = cluster_info.self_id();
let role_change_cb = TestRoleChange::default();
Expand Down
8 changes: 4 additions & 4 deletions simulation/src/curp_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use parking_lot::Mutex;
use tokio::sync::mpsc;
use tracing::debug;
use utils::{
config::{ClientConfig, CurpConfigBuilder, StorageConfig},
config::{ClientConfig, CurpConfigBuilder, EngineConfig},
shutdown,
};

Expand Down Expand Up @@ -82,7 +82,7 @@ impl CurpGroup {
.map(|(k, mut v)| (k, v.pop().unwrap()))
.collect();
let id = cluster_info.self_id();
let storage_cfg = StorageConfig::RocksDB(storage_path.clone());
let engine_cfg = EngineConfig::RocksDB(storage_path.clone());
let store_c = Arc::clone(&store);
let role_change_cb = TestRoleChange::default();
let role_change_arc = role_change_cb.get_inner_arc();
Expand All @@ -97,7 +97,7 @@ impl CurpGroup {
name.clone(),
exe_tx.clone(),
as_tx.clone(),
StorageConfig::Memory,
EngineConfig::Memory,
);
store_c.lock().replace(Arc::clone(&ce.store));
// we will restart the old leader.
Expand All @@ -115,7 +115,7 @@ impl CurpGroup {
},
Arc::new(
CurpConfigBuilder::default()
.storage_cfg(storage_cfg.clone())
.engine_cfg(engine_cfg.clone())
.log_entries_cap(10)
.build()
.unwrap(),
Expand Down

0 comments on commit 5db7a88

Please sign in to comment.