Skip to content

Commit 1e22c11

Browse files
committed
test/crimson/test_backfill: more detailed backfill cancellation tests
Emulate all backfill cancellation scenarios Signed-off-by: Xuehan Xu <[email protected]>
1 parent a34b0ce commit 1e22c11

File tree

1 file changed

+134
-5
lines changed

1 file changed

+134
-5
lines changed

src/test/crimson/test_backfill.cc

Lines changed: 134 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ class BackfillFixture : public crimson::osd::BackfillState::BackfillListener {
119119
events_to_dispatch.emplace_back(event.intrusive_from_this());
120120
}
121121

122+
template <class EventT>
123+
void schedule_event_immediate(const EventT& event) {
124+
events_to_dispatch.emplace_front(event.intrusive_from_this());
125+
}
126+
122127
// BackfillListener {
123128
void request_replica_scan(
124129
const pg_shard_t& target,
@@ -188,12 +193,11 @@ class BackfillFixture : public crimson::osd::BackfillState::BackfillListener {
188193
struct PGFacade;
189194

190195
void cancel() {
191-
events_to_dispatch.clear();
192-
schedule_event(crimson::osd::BackfillState::CancelBackfill{});
196+
schedule_event_immediate(crimson::osd::BackfillState::CancelBackfill{});
193197
}
194198

195199
void resume() {
196-
schedule_event(crimson::osd::BackfillState::Triggered{});
200+
schedule_event_immediate(crimson::osd::BackfillState::Triggered{});
197201
}
198202
};
199203

@@ -455,7 +459,38 @@ TEST(backfill, two_empty_replicas)
455459
EXPECT_TRUE(cluster_fixture.all_stores_look_like(reference_store));
456460
}
457461

458-
TEST(backfill, cancel_resume)
462+
TEST(backfill, cancel_resume_middle_of_primaryscan)
463+
{
464+
const auto reference_store = FakeStore{ {
465+
{ "1:00058bcc:::rbd_data.1018ac3e755.00000000000000d5:head", {10, 234} },
466+
{ "1:00ed7f8e:::rbd_data.1018ac3e755.00000000000000af:head", {10, 196} },
467+
{ "1:01483aea:::rbd_data.1018ac3e755.0000000000000095:head", {10, 169} },
468+
}};
469+
auto cluster_fixture = BackfillFixtureBuilder::add_source(
470+
reference_store.objs
471+
).add_target(
472+
{ /* nothing 1 */ }
473+
).add_target(
474+
{ /* nothing 2 */ }
475+
).get_result();
476+
477+
EXPECT_CALL(cluster_fixture, backfilled);
478+
cluster_fixture.cancel();
479+
cluster_fixture.next_round2<crimson::osd::BackfillState::CancelBackfill>();
480+
cluster_fixture.next_round2<crimson::osd::BackfillState::PrimaryScanned>();
481+
cluster_fixture.resume();
482+
cluster_fixture.next_round2<crimson::osd::BackfillState::Triggered>();
483+
cluster_fixture.next_round2<crimson::osd::BackfillState::ReplicaScanned>();
484+
cluster_fixture.next_round2<crimson::osd::BackfillState::ReplicaScanned>();
485+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
486+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
487+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
488+
cluster_fixture.next_till_done();
489+
490+
EXPECT_TRUE(cluster_fixture.all_stores_look_like(reference_store));
491+
}
492+
493+
TEST(backfill, cancel_resume_middle_of_replicascan1)
459494
{
460495
const auto reference_store = FakeStore{ {
461496
{ "1:00058bcc:::rbd_data.1018ac3e755.00000000000000d5:head", {10, 234} },
@@ -486,7 +521,7 @@ TEST(backfill, cancel_resume)
486521
EXPECT_TRUE(cluster_fixture.all_stores_look_like(reference_store));
487522
}
488523

489-
TEST(backfill, cancel_resume_middle_of_scan)
524+
TEST(backfill, cancel_resume_middle_of_replicascan2)
490525
{
491526
const auto reference_store = FakeStore{ {
492527
{ "1:00058bcc:::rbd_data.1018ac3e755.00000000000000d5:head", {10, 234} },
@@ -517,6 +552,100 @@ TEST(backfill, cancel_resume_middle_of_scan)
517552
EXPECT_TRUE(cluster_fixture.all_stores_look_like(reference_store));
518553
}
519554

555+
TEST(backfill, cancel_resume_middle_of_push1)
556+
{
557+
const auto reference_store = FakeStore{ {
558+
{ "1:00058bcc:::rbd_data.1018ac3e755.00000000000000d5:head", {10, 234} },
559+
{ "1:00ed7f8e:::rbd_data.1018ac3e755.00000000000000af:head", {10, 196} },
560+
{ "1:01483aea:::rbd_data.1018ac3e755.0000000000000095:head", {10, 169} },
561+
}};
562+
auto cluster_fixture = BackfillFixtureBuilder::add_source(
563+
reference_store.objs
564+
).add_target(
565+
{ /* nothing 1 */ }
566+
).add_target(
567+
{ /* nothing 2 */ }
568+
).get_result();
569+
570+
EXPECT_CALL(cluster_fixture, backfilled);
571+
cluster_fixture.next_round2<crimson::osd::BackfillState::PrimaryScanned>();
572+
cluster_fixture.next_round2<crimson::osd::BackfillState::ReplicaScanned>();
573+
cluster_fixture.next_round2<crimson::osd::BackfillState::ReplicaScanned>();
574+
cluster_fixture.cancel();
575+
cluster_fixture.next_round2<crimson::osd::BackfillState::CancelBackfill>();
576+
cluster_fixture.resume();
577+
cluster_fixture.next_round2<crimson::osd::BackfillState::Triggered>();
578+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
579+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
580+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
581+
cluster_fixture.next_till_done();
582+
583+
EXPECT_TRUE(cluster_fixture.all_stores_look_like(reference_store));
584+
}
585+
586+
TEST(backfill, cancel_resume_middle_of_push2)
587+
{
588+
const auto reference_store = FakeStore{ {
589+
{ "1:00058bcc:::rbd_data.1018ac3e755.00000000000000d5:head", {10, 234} },
590+
{ "1:00ed7f8e:::rbd_data.1018ac3e755.00000000000000af:head", {10, 196} },
591+
{ "1:01483aea:::rbd_data.1018ac3e755.0000000000000095:head", {10, 169} },
592+
}};
593+
auto cluster_fixture = BackfillFixtureBuilder::add_source(
594+
reference_store.objs
595+
).add_target(
596+
{ /* nothing 1 */ }
597+
).add_target(
598+
{ /* nothing 2 */ }
599+
).get_result();
600+
601+
EXPECT_CALL(cluster_fixture, backfilled);
602+
cluster_fixture.next_round2<crimson::osd::BackfillState::PrimaryScanned>();
603+
cluster_fixture.next_round2<crimson::osd::BackfillState::ReplicaScanned>();
604+
cluster_fixture.next_round2<crimson::osd::BackfillState::ReplicaScanned>();
605+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
606+
cluster_fixture.cancel();
607+
cluster_fixture.next_round2<crimson::osd::BackfillState::CancelBackfill>();
608+
cluster_fixture.resume();
609+
cluster_fixture.next_round2<crimson::osd::BackfillState::Triggered>();
610+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
611+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
612+
cluster_fixture.next_till_done();
613+
614+
EXPECT_TRUE(cluster_fixture.all_stores_look_like(reference_store));
615+
}
616+
617+
TEST(backfill, cancel_resume_middle_of_push3)
618+
{
619+
const auto reference_store = FakeStore{ {
620+
{ "1:00058bcc:::rbd_data.1018ac3e755.00000000000000d5:head", {10, 234} },
621+
{ "1:00ed7f8e:::rbd_data.1018ac3e755.00000000000000af:head", {10, 196} },
622+
{ "1:01483aea:::rbd_data.1018ac3e755.0000000000000095:head", {10, 169} },
623+
}};
624+
auto cluster_fixture = BackfillFixtureBuilder::add_source(
625+
reference_store.objs
626+
).add_target(
627+
{ /* nothing 1 */ }
628+
).add_target(
629+
{ /* nothing 2 */ }
630+
).get_result();
631+
632+
EXPECT_CALL(cluster_fixture, backfilled);
633+
cluster_fixture.next_round2<crimson::osd::BackfillState::PrimaryScanned>();
634+
cluster_fixture.next_round2<crimson::osd::BackfillState::ReplicaScanned>();
635+
cluster_fixture.next_round2<crimson::osd::BackfillState::ReplicaScanned>();
636+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
637+
cluster_fixture.cancel();
638+
cluster_fixture.next_round2<crimson::osd::BackfillState::CancelBackfill>();
639+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
640+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
641+
cluster_fixture.resume();
642+
cluster_fixture.next_round2<crimson::osd::BackfillState::Triggered>();
643+
cluster_fixture.next_round2<crimson::osd::BackfillState::RequestDone>();
644+
cluster_fixture.next_till_done();
645+
646+
EXPECT_TRUE(cluster_fixture.all_stores_look_like(reference_store));
647+
}
648+
520649
namespace StoreRandomizer {
521650
// FIXME: copied & pasted from test/test_snap_mapper.cc. We need to
522651
// find a way to avoid code duplication in test. A static library?

0 commit comments

Comments
 (0)