Skip to content

Commit 8e21369

Browse files
committed
Working on fixing replace-before-active test
1 parent ac5c71a commit 8e21369

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

crutest/src/main.rs

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,7 +2517,8 @@ async fn replace_before_active(
25172517
// generation numbers.
25182518
fill_workload(volume, di, true).await?;
25192519
let ds_total = targets.len() - 1;
2520-
let mut old_ds = 0;
2520+
let mut old_ds_a = 0;
2521+
let mut old_ds_b = 1;
25212522
let mut new_ds = targets.len() - 1;
25222523
for c in 1.. {
25232524
info!(log, "[{c}] Touch every extent");
@@ -2533,41 +2534,44 @@ async fn replace_before_active(
25332534
tokio::time::sleep(tokio::time::Duration::from_secs(4)).await;
25342535
}
25352536

2536-
// Stop a downstairs, wait for dsc to confirm it is stopped.
2537-
dsc_client.dsc_stop(old_ds).await.unwrap();
2538-
loop {
2539-
let res = dsc_client.dsc_get_ds_state(old_ds).await.unwrap();
2540-
let state = res.into_inner();
2541-
if state == DownstairsState::Exit {
2542-
break;
2537+
// Stop two downstairs, wait for dsc to confirm they are stopped.
2538+
for old_ds in [old_ds_a, old_ds_b] {
2539+
dsc_client.dsc_stop(old_ds).await.unwrap();
2540+
loop {
2541+
let res = dsc_client.dsc_get_ds_state(old_ds).await.unwrap();
2542+
let state = res.into_inner();
2543+
if state == DownstairsState::Exit {
2544+
break;
2545+
}
2546+
tokio::time::sleep(tokio::time::Duration::from_secs(4)).await;
25432547
}
2544-
tokio::time::sleep(tokio::time::Duration::from_secs(4)).await;
25452548
}
25462549

25472550
info!(log, "[{c}] Request the upstairs activate");
2548-
// Spawn a task to re-activate, this will not finish till all three
2549-
// downstairs respond.
2551+
// Spawn a task to re-activate, this will not finish until 2-3
2552+
// downstairs respond (and we have disabled all but 1)
25502553
gen += 1;
25512554
let gc = volume.clone();
25522555
let handle =
25532556
tokio::spawn(async move { gc.activate_with_gen(gen).await });
25542557

2555-
// Give the activation request time to percolate in the upstairs.
2558+
// Give the activation request time to percolate in the upstairs; it
2559+
// shouldn't get anywhere because we don't have enough downstairs
25562560
tokio::time::sleep(tokio::time::Duration::from_secs(4)).await;
25572561
let is_active = volume.query_is_active().await.unwrap();
25582562
info!(log, "[{c}] activate should now be waiting {:?}", is_active);
25592563
assert!(!is_active);
25602564

25612565
info!(
25622566
log,
2563-
"[{c}] Replacing DS {old_ds}:{} with {new_ds}:{}",
2564-
targets[old_ds as usize],
2567+
"[{c}] Replacing DS {old_ds_a}:{} with {new_ds}:{}",
2568+
targets[old_ds_a as usize],
25652569
targets[new_ds],
25662570
);
25672571
match volume
25682572
.replace_downstairs(
25692573
Uuid::new_v4(),
2570-
targets[old_ds as usize],
2574+
targets[old_ds_a as usize],
25712575
targets[new_ds],
25722576
)
25732577
.await
@@ -2578,6 +2582,9 @@ async fn replace_before_active(
25782582
}
25792583
}
25802584

2585+
// At this point, we've got two Downstairs (one of which was provided
2586+
// initially, and one of which has just been replaced), so activation
2587+
// should happen!
25812588
info!(log, "[{c}] Wait for activation after replacement");
25822589
loop {
25832590
let is_active = volume.query_is_active().await.unwrap();
@@ -2602,8 +2609,10 @@ async fn replace_before_active(
26022609
}
26032610

26042611
// Start up the old downstairs so it is ready for the next loop.
2605-
let res = dsc_client.dsc_start(old_ds).await;
2606-
info!(log, "[{c}] Replay: started {old_ds}, returned:{:?}", res);
2612+
for old_ds in [old_ds_a, old_ds_b] {
2613+
let res = dsc_client.dsc_start(old_ds).await;
2614+
info!(log, "[{c}] Replay: started {old_ds}, returned:{:?}", res);
2615+
}
26072616

26082617
// Wait for all IO to finish before we continue
26092618
loop {
@@ -2622,12 +2631,13 @@ async fn replace_before_active(
26222631
tokio::time::sleep(tokio::time::Duration::from_secs(4)).await;
26232632
}
26242633

2625-
old_ds = (old_ds + 1) % (ds_total as u32 + 1);
2634+
old_ds_a = (old_ds_a + 1) % (ds_total as u32 + 1);
2635+
old_ds_b = (old_ds_b + 1) % (ds_total as u32 + 1);
26262636
new_ds = (new_ds + 1) % (ds_total + 1);
26272637

26282638
match wtq {
26292639
WhenToQuit::Count { count } => {
2630-
if c > count {
2640+
if c >= count {
26312641
break;
26322642
}
26332643
}

0 commit comments

Comments
 (0)