expect_register_update_watcher(mock_remote_image_ctx, update_watch_ctx, 234,
0);
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
C_SaferCond init_ctx;
mock_replayer.init(&init_ctx);
// sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0, {{1, CEPH_NOSNAP}},
0);
// sync snap4
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, true);
- expect_refresh(
- mock_local_image_ctx, {
- {11U, librbd::SnapInfo{"snap1", cls::rbd::MirrorSnapshotNamespace{
- cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY, {}, "remote mirror uuid",
- 1, true, 0, {{1, CEPH_NOSNAP}}},
- 0, {}, 0, 0, {}}},
- }, 0);
expect_is_refresh_required(mock_remote_image_ctx, true);
expect_refresh(
mock_remote_image_ctx, {
"", CEPH_NOSNAP, true, 0, {}},
0, {}, 0, 0, {}}}
}, 0);
+ expect_is_refresh_required(mock_local_image_ctx, true);
+ expect_refresh(
+ mock_local_image_ctx, {
+ {11U, librbd::SnapInfo{"snap1", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY, {}, "remote mirror uuid",
+ 1, true, 0, {{1, CEPH_NOSNAP}}},
+ 0, {}, 0, 0, {}}},
+ }, 0);
expect_snapshot_copy(mock_snapshot_copy_request, 1, 4, 11,
{{1, 11}, {2, 12}, {4, CEPH_NOSNAP}}, 0);
expect_get_image_state(mock_get_image_state_request, 4, 0);
// prune non-primary snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, true);
- expect_refresh(
- mock_local_image_ctx, {
- {11U, librbd::SnapInfo{"snap1", cls::rbd::MirrorSnapshotNamespace{
- cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY, {}, "remote mirror uuid",
- 1, true, 0, {}},
- 0, {}, 0, 0, {}}},
- {12U, librbd::SnapInfo{"snap2", cls::rbd::UserSnapshotNamespace{},
- 0, {}, 0, 0, {}}},
- {14U, librbd::SnapInfo{"snap4", cls::rbd::MirrorSnapshotNamespace{
- cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY, {}, "remote mirror uuid",
- 4, true, 0, {}},
- 0, {}, 0, 0, {}}},
- }, 0);
expect_is_refresh_required(mock_remote_image_ctx, true);
expect_refresh(
mock_remote_image_ctx, {
"", CEPH_NOSNAP, true, 0, {}},
0, {}, 0, 0, {}}}
}, 0);
- expect_prune_non_primary_snapshot(mock_local_image_ctx, 11, 0);
-
- // idle
- expect_load_image_meta(mock_image_meta, false, 0);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
+ {11U, librbd::SnapInfo{"snap1", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY, {}, "remote mirror uuid",
+ 1, true, 0, {}},
+ 0, {}, 0, 0, {}}},
+ {12U, librbd::SnapInfo{"snap2", cls::rbd::UserSnapshotNamespace{},
+ 0, {}, 0, 0, {}}},
{14U, librbd::SnapInfo{"snap4", cls::rbd::MirrorSnapshotNamespace{
cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY, {}, "remote mirror uuid",
4, true, 0, {}},
0, {}, 0, 0, {}}},
}, 0);
+ expect_prune_non_primary_snapshot(mock_local_image_ctx, 11, 0);
+
+ // idle
+ expect_load_image_meta(mock_image_meta, false, 0);
expect_is_refresh_required(mock_remote_image_ctx, true);
expect_refresh(
mock_remote_image_ctx, {
"", CEPH_NOSNAP, true, 0, {}},
0, {}, 0, 0, {}}}
}, 0);
+ expect_is_refresh_required(mock_local_image_ctx, true);
+ expect_refresh(
+ mock_local_image_ctx, {
+ {14U, librbd::SnapInfo{"snap4", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY, {}, "remote mirror uuid",
+ 4, true, 0, {}},
+ 0, {}, 0, 0, {}}},
+ }, 0);
// fire init
C_SaferCond init_ctx;
// re-sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockGetImageStateRequest mock_get_image_state_request;
expect_get_image_state(mock_get_image_state_request, 11, 0);
expect_notify_sync_request(mock_instance_watcher, mock_local_image_ctx.id, 0);
// idle
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
1, true, 0, {}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, false);
// wake-up replayer
update_watch_ctx->handle_notify();
// re-sync snap2
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockGetImageStateRequest mock_get_image_state_request;
expect_get_image_state(mock_get_image_state_request, 12, 0);
expect_notify_sync_request(mock_instance_watcher, mock_local_image_ctx.id, 0);
// prune non-primary snap1
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, true);
+ expect_refresh(
+ mock_remote_image_ctx, {
+ {2U, librbd::SnapInfo{"snap2", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {"remote mirror peer uuid"},
+ "", CEPH_NOSNAP, true, 0, {}},
+ 0, {}, 0, 0, {}}},
+ }, 0);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
2, true, 0, {}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, true);
- expect_refresh(
- mock_remote_image_ctx, {
- {2U, librbd::SnapInfo{"snap2", cls::rbd::MirrorSnapshotNamespace{
- cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {"remote mirror peer uuid"},
- "", CEPH_NOSNAP, true, 0, {}},
- 0, {}, 0, 0, {}}},
- }, 0);
expect_prune_non_primary_snapshot(mock_local_image_ctx, 11, 0);
// idle
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
2, true, 0, {}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, false);
// wake-up replayer
update_watch_ctx->handle_notify();
// re-sync snap2
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockGetImageStateRequest mock_get_image_state_request;
expect_get_image_state(mock_get_image_state_request, 12, 0);
expect_notify_sync_request(mock_instance_watcher, mock_local_image_ctx.id, 0);
// idle
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, true);
+ expect_refresh(
+ mock_remote_image_ctx, {
+ {2U, librbd::SnapInfo{"snap2", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {"remote mirror peer uuid"},
+ "", CEPH_NOSNAP, true, 0, {}},
+ 0, {}, 0, 0, {}}},
+ }, 0);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
2, true, 0, {}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, true);
- expect_refresh(
- mock_remote_image_ctx, {
- {2U, librbd::SnapInfo{"snap2", cls::rbd::MirrorSnapshotNamespace{
- cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {"remote mirror peer uuid"},
- "", CEPH_NOSNAP, true, 0, {}},
- 0, {}, 0, 0, {}}},
- }, 0);
// wake-up replayer
update_watch_ctx->handle_notify();
// re-sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockGetImageStateRequest mock_get_image_state_request;
expect_get_image_state(mock_get_image_state_request, 11, 0);
expect_notify_sync_request(mock_instance_watcher, mock_local_image_ctx.id, 0);
// idle
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
1, true, 0, {}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, false);
// wake-up replayer
update_watch_ctx->handle_notify();
// prune non-primary snap2
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
expect_prune_non_primary_snapshot(mock_local_image_ctx, 12, 0);
// sync snap2
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
1, true, 0, {{1, CEPH_NOSNAP}}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 1, 2, 11,
{{2, CEPH_NOSNAP}}, 0);
// prune non-primary snap1
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, true);
+ expect_refresh(
+ mock_remote_image_ctx, {
+ {2U, librbd::SnapInfo{"snap2", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {"remote mirror peer uuid"},
+ "", CEPH_NOSNAP, true, 0, {}},
+ 0, {}, 0, 0, {}}},
+ }, 0);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
2, true, 0, {}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, true);
- expect_refresh(
- mock_remote_image_ctx, {
- {2U, librbd::SnapInfo{"snap2", cls::rbd::MirrorSnapshotNamespace{
- cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {"remote mirror peer uuid"},
- "", CEPH_NOSNAP, true, 0, {}},
- 0, {}, 0, 0, {}}},
- }, 0);
expect_prune_non_primary_snapshot(mock_local_image_ctx, 11, 0);
// idle
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
2, true, 0, {}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, false);
// wake-up replayer
update_watch_ctx->handle_notify();
// prune non-primary snap2
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
expect_prune_non_primary_snapshot(mock_local_image_ctx, 12, 0);
// sync snap2
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
{"remote mirror peer uuid"}, "", CEPH_NOSNAP, true, 0, {}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 1, 2, 11,
{{2, CEPH_NOSNAP}}, 0);
// idle
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, true);
+ expect_refresh(
+ mock_remote_image_ctx, {
+ {2U, librbd::SnapInfo{"snap2", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {"remote mirror peer uuid"},
+ "", CEPH_NOSNAP, true, 0, {}},
+ 0, {}, 0, 0, {}}},
+ }, 0);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
2, true, 0, {}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, true);
- expect_refresh(
- mock_remote_image_ctx, {
- {2U, librbd::SnapInfo{"snap2", cls::rbd::MirrorSnapshotNamespace{
- cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {"remote mirror peer uuid"},
- "", CEPH_NOSNAP, true, 0, {}},
- 0, {}, 0, 0, {}}},
- }, 0);
// wake-up replayer
update_watch_ctx->handle_notify();
// sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0, {{1, CEPH_NOSNAP}},
0);
// idle
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
1, true, 0, {}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, false);
// wake-up replayer
update_watch_ctx->handle_notify();
// idle
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
// wake-up replayer
update_watch_ctx->handle_notify();
mock_replayer_listener,
mock_image_meta,
&update_watch_ctx));
+ // inject a primary snapshot
+ mock_remote_image_ctx.snap_info = {
+ {1U, librbd::SnapInfo{"snap1", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {"remote mirror peer uuid"},
+ "", CEPH_NOSNAP, true, 0, {}},
+ 0, {}, 0, 0, {}}}};
// idle
expect_load_image_meta(mock_image_meta, true, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
// wake-up replayer
update_watch_ctx->handle_notify();
mock_remote_image_ctx));
}
+TEST_F(TestMockImageReplayerSnapshotReplayer, ResyncRequestedRemoteNotPrimary) {
+ librbd::MockTestImageCtx mock_local_image_ctx{*m_local_image_ctx};
+ librbd::MockTestImageCtx mock_remote_image_ctx{*m_remote_image_ctx};
+
+ MockThreads mock_threads(m_threads);
+ expect_work_queue_repeatedly(mock_threads);
+
+ MockReplayerListener mock_replayer_listener;
+ expect_notification(mock_threads, mock_replayer_listener);
+
+ InSequence seq;
+
+ MockInstanceWatcher mock_instance_watcher;
+ MockImageMeta mock_image_meta;
+ MockStateBuilder mock_state_builder(mock_local_image_ctx,
+ mock_remote_image_ctx,
+ mock_image_meta);
+ MockReplayer mock_replayer{&mock_threads, &mock_instance_watcher,
+ "local mirror uuid", &m_pool_meta_cache,
+ &mock_state_builder, &mock_replayer_listener};
+ m_pool_meta_cache.set_remote_pool_meta(
+ m_remote_io_ctx.get_id(),
+ {"remote mirror uuid", "remote mirror peer uuid"});
+
+ librbd::UpdateWatchCtx* update_watch_ctx = nullptr;
+ ASSERT_EQ(0, init_entry_replayer(mock_replayer, mock_threads,
+ mock_local_image_ctx,
+ mock_remote_image_ctx,
+ mock_replayer_listener,
+ mock_image_meta,
+ &update_watch_ctx));
+
+ // inject a demotion snapshot
+ mock_remote_image_ctx.snap_info = {
+ {1U, librbd::SnapInfo{"snap1", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY_DEMOTED,
+ {"remote mirror peer uuid"}, "", CEPH_NOSNAP, true, 0, {}},
+ 0, {}, 0, 0, {}}}};
+
+ // resync requested
+ expect_load_image_meta(mock_image_meta, true, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
+
+ // remote is not primary so no resync should occur
+ expect_is_refresh_required(mock_local_image_ctx, false);
+ MockSnapshotCopyRequest mock_snapshot_copy_request;
+ expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0,
+ {{1, CEPH_NOSNAP}}, 0);
+ MockGetImageStateRequest mock_get_image_state_request;
+ expect_get_image_state(mock_get_image_state_request, 1, 0);
+ MockCreateNonPrimaryRequest mock_create_non_primary_request;
+ expect_create_non_primary_request(mock_create_non_primary_request,
+ true, "remote mirror uuid", 1,
+ {{1, CEPH_NOSNAP}}, 11, 0);
+ MockImageStateUpdateRequest mock_image_state_update_request;
+ expect_update_mirror_image_state(mock_image_state_update_request, 0);
+ expect_notify_sync_request(mock_instance_watcher, mock_local_image_ctx.id, 0);
+ MockImageCopyRequest mock_image_copy_request;
+ expect_image_copy(mock_image_copy_request, 0, 1, 0, {},
+ {{1, CEPH_NOSNAP}}, 0);
+ MockApplyImageStateRequest mock_apply_state_request;
+ expect_apply_image_state(mock_apply_state_request, 0);
+ expect_mirror_image_snapshot_set_copy_progress(
+ mock_local_image_ctx, 11, true, 0, 0);
+ expect_notify_update(mock_local_image_ctx);
+ expect_notify_sync_complete(mock_instance_watcher, mock_local_image_ctx.id);
+ expect_load_image_meta(mock_image_meta, true, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, true);
+ expect_refresh(
+ mock_local_image_ctx, {
+ {11U, librbd::SnapInfo{"snap1", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY_DEMOTED, {"uuid"},
+ "remote mirror uuid", 1, true, 0, {{1, CEPH_NOSNAP}}},
+ 0, {}, 0, 0, {}}},
+ }, 0);
+
+ // wake-up replayer
+ update_watch_ctx->handle_notify();
+
+ ASSERT_EQ(0, wait_for_notification(1));
+ ASSERT_FALSE(mock_replayer.is_replaying());
+
+ ASSERT_EQ(0, shut_down_entry_replayer(mock_replayer, mock_threads,
+ mock_local_image_ctx,
+ mock_remote_image_ctx));
+}
+
TEST_F(TestMockImageReplayerSnapshotReplayer, RegisterLocalUpdateWatcherError) {
librbd::MockTestImageCtx mock_local_image_ctx{*m_local_image_ctx};
librbd::MockTestImageCtx mock_remote_image_ctx{*m_remote_image_ctx};
// sync
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(mock_local_image_ctx, {}, -EINVAL);
// sync
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, true);
expect_refresh(mock_remote_image_ctx, {}, -EINVAL);
// sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0, {{1, CEPH_NOSNAP}},
-EINVAL);
// sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0, {{1, CEPH_NOSNAP}},
0);
// sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0, {{1, CEPH_NOSNAP}},
0);
// sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0, {{1, CEPH_NOSNAP}},
0);
// sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0, {{1, CEPH_NOSNAP}},
0);
// sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0, {{1, CEPH_NOSNAP}},
0);
// sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0, {{1, CEPH_NOSNAP}},
0);
// sync snap2
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 1, 2, 11, {{2, CEPH_NOSNAP}},
0);
// detect split-brain
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
// wake-up replayer
update_watch_ctx->handle_notify();
// split-brain due to missing snapshot 1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
// wake-up replayer
update_watch_ctx->handle_notify();
// attach to promoted remote image
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 2, 3, 12,
{{2, 12}, {3, CEPH_NOSNAP}}, 0);
// idle
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, true);
+ expect_refresh(
+ mock_remote_image_ctx, {
+ {1U, librbd::SnapInfo{"snap1", cls::rbd::UserSnapshotNamespace{},
+ 0, {}, 0, 0, {}}},
+ {2U, librbd::SnapInfo{"snap2", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY_DEMOTED,
+ {"remote mirror peer uuid"}, "local mirror uuid", 12U, true, 0, {}},
+ 0, {}, 0, 0, {}}},
+ {3U, librbd::SnapInfo{"snap3", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {}, "", CEPH_NOSNAP, true, 0,
+ {}},
+ 0, {}, 0, 0, {}}}
+ }, 0);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
{{1, 11}, {2, 12}, {3, CEPH_NOSNAP}}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, true);
- expect_refresh(
- mock_remote_image_ctx, {
- {1U, librbd::SnapInfo{"snap1", cls::rbd::UserSnapshotNamespace{},
- 0, {}, 0, 0, {}}},
- {2U, librbd::SnapInfo{"snap2", cls::rbd::MirrorSnapshotNamespace{
- cls::rbd::MIRROR_SNAPSHOT_STATE_NON_PRIMARY_DEMOTED,
- {"remote mirror peer uuid"}, "local mirror uuid", 12U, true, 0, {}},
- 0, {}, 0, 0, {}}},
- {3U, librbd::SnapInfo{"snap3", cls::rbd::MirrorSnapshotNamespace{
- cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {}, "", CEPH_NOSNAP, true, 0,
- {}},
- 0, {}, 0, 0, {}}}
- }, 0);
// wake-up replayer
update_watch_ctx->handle_notify();
// unlink snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockUnlinkPeerRequest mock_unlink_peer_request;
expect_unlink_peer(mock_unlink_peer_request, 1, "remote mirror peer uuid",
false, 0);
// idle
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, true);
expect_refresh(
mock_remote_image_ctx, {
"", CEPH_NOSNAP, true, 0, {}},
0, {}, 0, 0, {}}}
}, 0);
+ expect_is_refresh_required(mock_local_image_ctx, false);
// fire init
C_SaferCond init_ctx;
// sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0, {{1, CEPH_NOSNAP}},
0);
// idle
expect_load_image_meta(mock_image_meta, false, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
expect_is_refresh_required(mock_local_image_ctx, true);
expect_refresh(
mock_local_image_ctx, {
1, true, 0, {{1, CEPH_NOSNAP}}},
0, {}, 0, 0, {}}},
}, 0);
- expect_is_refresh_required(mock_remote_image_ctx, false);
// fire init
C_SaferCond init_ctx;
mock_image_meta,
&update_watch_ctx));
+ // inject a primary snapshot
+ mock_remote_image_ctx.snap_info = {
+ {1U, librbd::SnapInfo{"snap1", cls::rbd::MirrorSnapshotNamespace{
+ cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {"remote mirror peer uuid"},
+ "", CEPH_NOSNAP, true, 0, {}},
+ 0, {}, 0, 0, {}}}};
+
// change the name of the image
mock_local_image_ctx.name = "NEW NAME";
// idle
expect_load_image_meta(mock_image_meta, true, 0);
+ expect_is_refresh_required(mock_remote_image_ctx, false);
// wake-up replayer
update_watch_ctx->handle_notify();
// sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0, {{1, CEPH_NOSNAP}},
0);
// sync snap1
expect_load_image_meta(mock_image_meta, false, 0);
- expect_is_refresh_required(mock_local_image_ctx, false);
expect_is_refresh_required(mock_remote_image_ctx, false);
+ expect_is_refresh_required(mock_local_image_ctx, false);
MockSnapshotCopyRequest mock_snapshot_copy_request;
expect_snapshot_copy(mock_snapshot_copy_request, 0, 1, 0, {{1, CEPH_NOSNAP}},
0);