Skip to content

Commit

Permalink
fix fap test
Browse files Browse the repository at this point in the history
Signed-off-by: CalvinNeo <[email protected]>
  • Loading branch information
CalvinNeo committed Nov 3, 2023
1 parent 8f01ecb commit 13e7c10
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
17 changes: 14 additions & 3 deletions proxy_components/mock-engine-store/src/mock_store/mock_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,29 @@ pub fn copy_data_from(
// kv data in memory
for cf in 0..3 {
for (k, v) in &source.data[cf] {
if k.as_slice() >= source.region.get_start_key()
&& k.as_slice() < source.region.get_end_key()
if (k.as_slice() >= source.region.get_start_key()
|| source.region.get_start_key().is_empty())
&& (k.as_slice() < source.region.get_end_key()
|| source.region.get_end_key().is_empty())
{
debug!(
"copy_data_from region {} {:?} {:?} S {:?} E {:?}",
"copy_data_from write to region {} {:?} {:?} S {:?} E {:?}",
region_id,
k,
v,
source.region.get_start_key(),
source.region.get_end_key()
);
write_kv_in_mem(target, cf, k.as_slice(), v.as_slice());
} else {
debug!(
"copy_data_from skip write to region {} {:?} {:?} S {:?} E {:?}",
region_id,
k,
v,
source.region.get_start_key(),
source.region.get_end_key()
);
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion proxy_tests/proxy/shared/fast_add_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::utils::v1::*;
enum SourceType {
Leader,
Learner,
// The learner coesn't catch up with Leader.
DelayedLearner,
InvalidSource,
}
Expand Down Expand Up @@ -328,6 +329,9 @@ fn test_overlap_apply_legacy_in_the_middle() {
cluster.shutdown();
}

// `block_wait`: whether we block wait in a MsgAppend handling, or return with
// WaitForData. `pause`: pause in some core procedures.
// `check_timeout`: mock and check if FAP timeouts.
fn simple_fast_add_peer(
source_type: SourceType,
block_wait: bool,
Expand Down Expand Up @@ -421,7 +425,7 @@ fn simple_fast_add_peer(
_ => (),
}

// Add peer 3
// Add peer 3 by FAP
pd_client.must_add_peer(1, new_learner_peer(3, 3));
cluster.must_put(b"k2", b"v2");

Expand Down Expand Up @@ -649,6 +653,7 @@ mod simple_blocked_nopause {}
mod simple_blocked_pause {
use super::*;
// Delay when fetch and build data

#[test]
fn test_simpleb_from_learner_paused_build() {
fail::cfg("fap_core_no_fallback", "panic").unwrap();
Expand Down

0 comments on commit 13e7c10

Please sign in to comment.