From 5db7a8815f933bf276ecff17cbf091e436d0e1e7 Mon Sep 17 00:00:00 2001 From: themanforfree Date: Fri, 24 Nov 2023 10:31:53 +0800 Subject: [PATCH] fix: fix madsim tests Signed-off-by: themanforfree --- curp-test-utils/src/test_cmd.rs | 6 +++--- curp/src/server/cmd_worker/mod.rs | 20 ++++++++++---------- curp/tests/it/common/curp_group.rs | 14 ++------------ simulation/src/curp_group.rs | 8 ++++---- 4 files changed, 19 insertions(+), 29 deletions(-) diff --git a/curp-test-utils/src/test_cmd.rs b/curp-test-utils/src/test_cmd.rs index f86ea89ec..a15d766fe 100644 --- a/curp-test-utils/src/test_cmd.rs +++ b/curp-test-utils/src/test_cmd.rs @@ -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}; @@ -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"), diff --git a/curp/src/server/cmd_worker/mod.rs b/curp/src/server/cmd_worker/mod.rs index b97706d72..bee732c82 100644 --- a/curp/src/server/cmd_worker/mod.rs +++ b/curp/src/server/cmd_worker/mod.rs @@ -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; @@ -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) = @@ -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) = @@ -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) = @@ -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) = @@ -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) = @@ -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) = @@ -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) = @@ -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()); @@ -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()); diff --git a/curp/tests/it/common/curp_group.rs b/curp/tests/it/common/curp_group.rs index 4dea7812d..246d973d1 100644 --- a/curp/tests/it/common/curp_group.rs +++ b/curp/tests/it/common/curp_group.rs @@ -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 @@ -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(); diff --git a/simulation/src/curp_group.rs b/simulation/src/curp_group.rs index f4f1866b9..9af8b7582 100644 --- a/simulation/src/curp_group.rs +++ b/simulation/src/curp_group.rs @@ -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, }; @@ -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(); @@ -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. @@ -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(),