From: Jason Dillaman Date: Fri, 6 Feb 2015 08:58:33 +0000 (-0500) Subject: tests: update librbd tests to handle blacklisting X-Git-Tag: v0.93~54^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7ecf8641b2d6b8df22aed509bfb26736152cf2b8;p=ceph.git tests: update librbd tests to handle blacklisting The break lock unit test was updated to use a different librados client to prevent blacklisting itself when breaking the lock of a "dead" client. Signed-off-by: Jason Dillaman --- diff --git a/src/test/librbd/test_ImageWatcher.cc b/src/test/librbd/test_ImageWatcher.cc index 3354fa87b774..265b15f7baa8 100644 --- a/src/test/librbd/test_ImageWatcher.cc +++ b/src/test/librbd/test_ImageWatcher.cc @@ -282,15 +282,26 @@ TEST_F(TestImageWatcher, TryLockNotifyAnnounceLocked) { TEST_F(TestImageWatcher, TryLockWithTimedOutOwner) { REQUIRE_FEATURE(RBD_FEATURE_EXCLUSIVE_LOCK); - librbd::ImageCtx *ictx; - ASSERT_EQ(0, open_image(m_image_name, &ictx)); - + // use new Rados connection due to blacklisting + librados::Rados rados; + ASSERT_EQ("", connect_cluster_pp(rados)); + + librados::IoCtx io_ctx; + ASSERT_EQ(0, rados.ioctx_create(_pool_name.c_str(), io_ctx)); + librbd::ImageCtx *ictx = new librbd::ImageCtx(m_image_name.c_str(), "", NULL, + io_ctx, false); + ASSERT_EQ(0, librbd::open_image(ictx)); ASSERT_EQ(0, lock_image(*ictx, LOCK_EXCLUSIVE, "auto 1234")); + librbd::close_image(ictx); + io_ctx.close(); // no watcher on the locked image means we can break the lock + ASSERT_EQ(0, open_image(m_image_name, &ictx)); RWLock::WLocker l(ictx->owner_lock); ASSERT_EQ(0, ictx->image_watcher->try_lock()); ASSERT_TRUE(ictx->image_watcher->is_lock_owner()); + + rados.test_blacklist_self(false); } TEST_F(TestImageWatcher, TryLockWithUserExclusiveLock) { diff --git a/src/test/librbd/test_fixture.cc b/src/test/librbd/test_fixture.cc index 0c584b0e230f..9e4712548997 100644 --- a/src/test/librbd/test_fixture.cc +++ b/src/test/librbd/test_fixture.cc @@ -89,7 +89,7 @@ void TestFixture::close_image(librbd::ImageCtx *ictx) { int TestFixture::lock_image(librbd::ImageCtx &ictx, ClsLockType lock_type, const std::string &cookie) { - int r = rados::cls::lock::lock(&m_ioctx, ictx.header_oid, RBD_LOCK_NAME, + int r = rados::cls::lock::lock(&ictx.md_ctx, ictx.header_oid, RBD_LOCK_NAME, lock_type, cookie, "internal", "", utime_t(), 0); if (r == 0) {