]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
test/rbd-mirror: eliminate a race in ResyncRequestedRemoteNotPrimary
authorVinayBhaskar-V <vvarada@redhat.com>
Wed, 30 Jul 2025 10:10:27 +0000 (10:10 +0000)
committerIlya Dryomov <idryomov@gmail.com>
Fri, 1 Aug 2025 10:47:16 +0000 (12:47 +0200)
Adjust the wait_for_notification call in TestMockImageReplayerSnapshotReplayer.ResyncRequestedRemoteNotPrimary
to expect 2 notifications instead of 1. This allows the test to correctly wait for both expected events
i.e for finish_sync() and handle_replay_complete(locker, -EREMOTEIO, "remote image demoted"), ensuring the
replayer transitions to STATE_COMPLETE and is_replaying() returns false as intended.

Fixes: https://tracker.ceph.com/issues/72325
Signed-off-by: VinayBhaskar-V <vvarada@redhat.com>
(cherry picked from commit b5a013f6170bb4445da8f5469243e4869b760a81)

src/test/rbd_mirror/image_replayer/snapshot/test_mock_Replayer.cc

index dff9cd4b65cf4360ddd9e0293c51b3d448c3172c..21afa6d52bb552100d8b0c8f856d38e46205bea8 100644 (file)
@@ -1787,6 +1787,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, ResyncRequested) {
                                    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{
@@ -1803,6 +1804,7 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, ResyncRequested) {
 
   // wait for sync to complete and expect replay complete
   ASSERT_EQ(0, wait_for_notification(1));
+  ASSERT_TRUE(mock_replayer.is_resync_requested());
   ASSERT_FALSE(mock_replayer.is_replaying());
 
   ASSERT_EQ(0, shut_down_entry_replayer(mock_replayer, mock_threads,
@@ -1876,6 +1878,8 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, ResyncRequestedRemoteNotPrimary) {
     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);
+
+  // idle
   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);
@@ -1890,7 +1894,8 @@ TEST_F(TestMockImageReplayerSnapshotReplayer, ResyncRequestedRemoteNotPrimary) {
   // wake-up replayer
   update_watch_ctx->handle_notify();
 
-  ASSERT_EQ(0, wait_for_notification(1));
+  ASSERT_EQ(0, wait_for_notification(2));
+  ASSERT_FALSE(mock_replayer.is_resync_requested());
   ASSERT_FALSE(mock_replayer.is_replaying());
 
   ASSERT_EQ(0, shut_down_entry_replayer(mock_replayer, mock_threads,