From: Jason Dillaman Date: Tue, 25 Aug 2015 14:12:43 +0000 (-0400) Subject: tests: new ImageWatcher tests for snap protect/unprotect and rename X-Git-Tag: v10.0.2~193^2~19 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8a15fa648cf74b0d3597ff2108e167a648297d9e;p=ceph.git tests: new ImageWatcher tests for snap protect/unprotect and rename Signed-off-by: Jason Dillaman --- diff --git a/src/test/librbd/test_ImageWatcher.cc b/src/test/librbd/test_ImageWatcher.cc index e8ad76ed37c..0bba8109d6a 100644 --- a/src/test/librbd/test_ImageWatcher.cc +++ b/src/test/librbd/test_ImageWatcher.cc @@ -1061,6 +1061,66 @@ TEST_F(TestImageWatcher, NotifySnapRemove) { ASSERT_EQ(expected_notify_ops, m_notifies); } +TEST_F(TestImageWatcher, NotifySnapProtect) { + REQUIRE_FEATURE(RBD_FEATURE_EXCLUSIVE_LOCK); + + librbd::ImageCtx *ictx; + ASSERT_EQ(0, open_image(m_image_name, &ictx)); + + ASSERT_EQ(0, register_image_watch(*ictx)); + ASSERT_EQ(0, lock_image(*ictx, LOCK_EXCLUSIVE, + "auto " + stringify(m_watch_ctx->get_handle()))); + + m_notify_acks = {{NOTIFY_OP_SNAP_PROTECT, create_response_message(0)}}; + + RWLock::RLocker l(ictx->owner_lock); + ASSERT_EQ(0, ictx->image_watcher->notify_snap_protect("snap")); + + NotifyOps expected_notify_ops; + expected_notify_ops += NOTIFY_OP_SNAP_PROTECT; + ASSERT_EQ(expected_notify_ops, m_notifies); +} + +TEST_F(TestImageWatcher, NotifySnapUnprotect) { + REQUIRE_FEATURE(RBD_FEATURE_EXCLUSIVE_LOCK); + + librbd::ImageCtx *ictx; + ASSERT_EQ(0, open_image(m_image_name, &ictx)); + + ASSERT_EQ(0, register_image_watch(*ictx)); + ASSERT_EQ(0, lock_image(*ictx, LOCK_EXCLUSIVE, + "auto " + stringify(m_watch_ctx->get_handle()))); + + m_notify_acks = {{NOTIFY_OP_SNAP_UNPROTECT, create_response_message(0)}}; + + RWLock::RLocker l(ictx->owner_lock); + ASSERT_EQ(0, ictx->image_watcher->notify_snap_unprotect("snap")); + + NotifyOps expected_notify_ops; + expected_notify_ops += NOTIFY_OP_SNAP_UNPROTECT; + ASSERT_EQ(expected_notify_ops, m_notifies); +} + +TEST_F(TestImageWatcher, NotifyRename) { + REQUIRE_FEATURE(RBD_FEATURE_EXCLUSIVE_LOCK); + + librbd::ImageCtx *ictx; + ASSERT_EQ(0, open_image(m_image_name, &ictx)); + + ASSERT_EQ(0, register_image_watch(*ictx)); + ASSERT_EQ(0, lock_image(*ictx, LOCK_EXCLUSIVE, + "auto " + stringify(m_watch_ctx->get_handle()))); + + m_notify_acks = {{NOTIFY_OP_RENAME, create_response_message(0)}}; + + RWLock::RLocker l(ictx->owner_lock); + ASSERT_EQ(0, ictx->image_watcher->notify_rename("new_name")); + + NotifyOps expected_notify_ops; + expected_notify_ops += NOTIFY_OP_RENAME; + ASSERT_EQ(expected_notify_ops, m_notifies); +} + TEST_F(TestImageWatcher, NotifyAsyncTimedOut) { REQUIRE_FEATURE(RBD_FEATURE_EXCLUSIVE_LOCK);