Skip to content

Commit d7e6896

Browse files
rzarzynskixxhdx1985126
authored andcommitted
test/crimson: verify the backfill cancellation & resumption
Signed-off-by: Radoslaw Zarzynski <[email protected]>
1 parent ae7469a commit d7e6896

File tree

1 file changed

+76
-1
lines changed

1 file changed

+76
-1
lines changed

src/test/crimson/test_backfill.cc

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ class BackfillFixture : public crimson::osd::BackfillState::BackfillListener {
157157
template <class EventT>
158158
void next_round2() {
159159
ceph_assert(events_to_dispatch.size());
160-
ceph_assert(typeid(*events_to_dispatch.front()) == typeid(EventT));
160+
// workaround for Clang's `-Wpotentially-evaluated-expression`. See:
161+
// * https://gitlab.cern.ch/gaudi/Gaudi/-/merge_requests/970
162+
// * https://stackoverflow.com/q/46494928
163+
const auto& front_event = *events_to_dispatch.front();
164+
ceph_assert(typeid(front_event) == typeid(EventT));
161165
backfill_state.process_event(std::move(events_to_dispatch.front()));
162166
events_to_dispatch.pop_front();
163167
}
@@ -179,6 +183,15 @@ class BackfillFixture : public crimson::osd::BackfillState::BackfillListener {
179183

180184
struct PeeringFacade;
181185
struct PGFacade;
186+
187+
void cancel() {
188+
events_to_dispatch.clear();
189+
schedule_event(crimson::osd::BackfillState::CancelBackfill{});
190+
}
191+
192+
void resume() {
193+
schedule_event(crimson::osd::BackfillState::Triggered{});
194+
}
182195
};
183196

184197
struct BackfillFixture::PeeringFacade
@@ -419,6 +432,68 @@ TEST(backfill, two_empty_replicas)
419432
EXPECT_TRUE(cluster_fixture.all_stores_look_like(reference_store));
420433
}
421434

435+
TEST(backfill, cancel_resume)
436+
{
437+
const auto reference_store = FakeStore{ {
438+
{ "1:00058bcc:::rbd_data.1018ac3e755.00000000000000d5:head", {10, 234} },
439+
{ "1:00ed7f8e:::rbd_data.1018ac3e755.00000000000000af:head", {10, 196} },
440+
{ "1:01483aea:::rbd_data.1018ac3e755.0000000000000095:head", {10, 169} },
441+
}};
442+
auto cluster_fixture = BackfillFixtureBuilder::add_source(
443+
reference_store.objs
444+
).add_target(
445+
{ /* nothing 1 */ }
446+
).add_target(
447+
{ /* nothing 2 */ }
448+
).get_result();
449+
450+
EXPECT_CALL(cluster_fixture, backfilled);
451+
cluster_fixture.next_round2<crimson::osd::BackfillState::PrimaryScanned>();
452+
cluster_fixture.cancel();
453+
cluster_fixture.next_round2<crimson::osd::BackfillState::CancelBackfill>();
454+
cluster_fixture.resume();
455+
cluster_fixture.next_round2<crimson::osd::BackfillState::Triggered>();
456+
cluster_fixture.next_round2<crimson::osd::BackfillState::ReplicaScanned>();
457+
cluster_fixture.next_round2<crimson::osd::BackfillState::ReplicaScanned>();
458+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
459+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
460+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
461+
cluster_fixture.next_till_done();
462+
463+
EXPECT_TRUE(cluster_fixture.all_stores_look_like(reference_store));
464+
}
465+
466+
TEST(backfill, cancel_resume_middle_of_scan)
467+
{
468+
const auto reference_store = FakeStore{ {
469+
{ "1:00058bcc:::rbd_data.1018ac3e755.00000000000000d5:head", {10, 234} },
470+
{ "1:00ed7f8e:::rbd_data.1018ac3e755.00000000000000af:head", {10, 196} },
471+
{ "1:01483aea:::rbd_data.1018ac3e755.0000000000000095:head", {10, 169} },
472+
}};
473+
auto cluster_fixture = BackfillFixtureBuilder::add_source(
474+
reference_store.objs
475+
).add_target(
476+
{ /* nothing 1 */ }
477+
).add_target(
478+
{ /* nothing 2 */ }
479+
).get_result();
480+
481+
EXPECT_CALL(cluster_fixture, backfilled);
482+
cluster_fixture.next_round2<crimson::osd::BackfillState::PrimaryScanned>();
483+
cluster_fixture.next_round2<crimson::osd::BackfillState::ReplicaScanned>();
484+
cluster_fixture.cancel();
485+
cluster_fixture.next_round2<crimson::osd::BackfillState::CancelBackfill>();
486+
cluster_fixture.resume();
487+
cluster_fixture.next_round2<crimson::osd::BackfillState::Triggered>();
488+
cluster_fixture.next_round2<crimson::osd::BackfillState::ReplicaScanned>();
489+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
490+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
491+
cluster_fixture.next_round2<crimson::osd::BackfillState::ObjectPushed>();
492+
cluster_fixture.next_till_done();
493+
494+
EXPECT_TRUE(cluster_fixture.all_stores_look_like(reference_store));
495+
}
496+
422497
namespace StoreRandomizer {
423498
// FIXME: copied & pasted from test/test_snap_mapper.cc. We need to
424499
// find a way to avoid code duplication in test. A static library?

0 commit comments

Comments
 (0)