Skip to content

Commit 209fcd3

Browse files
committed
test_default_policy_is_tablet_aware: Retry in case of migrations
If there are migrations during driver info population, an attempt may fail. A solution to improve the test implemented here is to check if there was migration, and if so retry a few times.
1 parent fe96179 commit 209fcd3

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

scylla/tests/integration/load_balancing/tablets.rs

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct SelectedTablet {
2929
replicas: Vec<(Uuid, i32)>,
3030
}
3131

32+
#[derive(Eq, PartialEq)]
3233
struct Tablet {
3334
first_token: i64,
3435
last_token: i64,
@@ -348,18 +349,36 @@ async fn test_default_policy_is_tablet_aware() {
348349
)]));
349350
}
350351

351-
let tablets = get_tablets(&session, &ks, "t").await;
352-
let value_per_tablet = calculate_key_per_tablet(&tablets, &prepared);
353-
run_test_default_policy_is_tablet_aware_attempt(
354-
&session,
355-
&prepared,
356-
&value_per_tablet,
357-
&mut feedback_rxs,
358-
)
359-
.await
360-
.unwrap();
361-
362-
running_proxy
352+
// Test attempt can fail because of tablet migrations.
353+
// Let's try a few times if there are migrations.
354+
let mut last_error = None;
355+
for _ in 0..5 {
356+
let tablets = get_tablets(&session, &ks, "t").await;
357+
let value_per_tablet = calculate_key_per_tablet(&tablets, &prepared);
358+
match run_test_default_policy_is_tablet_aware_attempt(
359+
&session,
360+
&prepared,
361+
&value_per_tablet,
362+
&mut feedback_rxs,
363+
)
364+
.await
365+
{
366+
Ok(_) => return running_proxy, // Test succeeded
367+
Err(e) => {
368+
let new_tablets = get_tablets(&session, &ks, "t").await;
369+
if tablets == new_tablets {
370+
// We failed, but there was no migration.
371+
panic!("Test attempt failed despite no migration. Error: {e}");
372+
}
373+
last_error = Some(e);
374+
// There was a migration, let's try again
375+
}
376+
}
377+
}
378+
panic!(
379+
"There was a tablet migration during each attempt! Last error: {}",
380+
last_error.unwrap()
381+
);
363382
},
364383
)
365384
.await;

0 commit comments

Comments
 (0)