From 836ab7ad95fd652d736e9fe2ab3a769d73758176 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 28 Jun 2017 12:56:46 -0400 Subject: [PATCH] test: skip pool application metadata tests if OSDs not at min luminous Signed-off-by: Jason Dillaman --- qa/tasks/ceph_manager.py | 4 ++ qa/tasks/reg11184.py | 3 ++ qa/workunits/rbd/verify_pool.sh | 2 +- src/test/librados/aio.cc | 1 + src/test/librados/misc.cc | 53 ++++++++++++++++---- src/test/librados/test.cc | 22 ++++++++ src/test/librados/tier.cc | 7 +++ src/test/librbd/fsx.cc | 2 + src/test/librbd/test_support.cc | 7 +++ src/test/multi_stress_watch.cc | 6 +++ src/test/pybind/test_rados.py | 10 ++++ src/test/rbd_mirror/test_ClusterWatcher.cc | 7 ++- src/test/rbd_mirror/test_ImageReplayer.cc | 3 ++ src/test/rbd_mirror/test_PoolWatcher.cc | 1 + src/test/rbd_mirror/test_fixture.cc | 8 +++ src/test/system/rados_open_pools_parallel.cc | 1 + src/test/test_mutate.cc | 2 + 17 files changed, 127 insertions(+), 12 deletions(-) diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index 964dc73440f..d541aeacccc 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -1620,6 +1620,10 @@ class CephManager: 'osd', 'pool', 'set', pool_name, 'allow_ec_overwrites', 'true') + self.raw_cluster_cmd( + 'osd', 'pool', 'application', 'enable', + pool_name, 'rados', '--yes-i-really-mean-it', + run.Raw('||'), 'true') self.pools[pool_name] = pg_num time.sleep(1) diff --git a/qa/tasks/reg11184.py b/qa/tasks/reg11184.py index b0c6dc11a17..89edf33ae9b 100644 --- a/qa/tasks/reg11184.py +++ b/qa/tasks/reg11184.py @@ -55,6 +55,9 @@ def task(ctx, config): # create 1 pg pool log.info('creating foo') manager.raw_cluster_cmd('osd', 'pool', 'create', 'foo', '1') + manager.raw_cluster_cmd( + 'osd', 'pool', 'application', 'enable', + pool_name, 'rados', run.Raw('||'), 'true') # Remove extra pool to simlify log output manager.raw_cluster_cmd('osd', 'pool', 'delete', 'rbd', 'rbd', '--yes-i-really-really-mean-it') diff --git a/qa/workunits/rbd/verify_pool.sh b/qa/workunits/rbd/verify_pool.sh index 48d069160d3..f008fb6b3cf 100755 --- a/qa/workunits/rbd/verify_pool.sh +++ b/qa/workunits/rbd/verify_pool.sh @@ -11,7 +11,7 @@ set_up () { tear_down ceph osd pool create $POOL_NAME $PG_NUM ceph osd pool mksnap $POOL_NAME snap - rbd pool init images + rbd pool init $POOL_NAME } trap tear_down EXIT HUP INT diff --git a/src/test/librados/aio.cc b/src/test/librados/aio.cc index 22ed976995e..ff5064ba353 100644 --- a/src/test/librados/aio.cc +++ b/src/test/librados/aio.cc @@ -205,6 +205,7 @@ TEST(LibRadosAio, PoolQuotaPP) { ASSERT_EQ(0, test_data.m_cluster.pool_create(p.c_str())); IoCtx ioctx; ASSERT_EQ(0, test_data.m_cluster.ioctx_create(p.c_str(), ioctx)); + ioctx.application_enable("rados", true); bufferlist inbl; ASSERT_EQ(0, test_data.m_cluster.mon_command( diff --git a/src/test/librados/misc.cc b/src/test/librados/misc.cc index 290829d8796..ea4d3e713e7 100644 --- a/src/test/librados/misc.cc +++ b/src/test/librados/misc.cc @@ -19,7 +19,7 @@ #include #include #include - +#include using namespace librados; using std::map; @@ -856,6 +856,14 @@ protected: ASSERT_EQ("", create_one_ec_pool_pp(pool_name, s_cluster)); src_pool_name = get_temp_pool_name(); ASSERT_EQ(0, s_cluster.pool_create(src_pool_name.c_str())); + + librados::IoCtx ioctx; + ASSERT_EQ(0, s_cluster.ioctx_create(pool_name.c_str(), ioctx)); + ioctx.application_enable("rados", true); + + librados::IoCtx src_ioctx; + ASSERT_EQ(0, s_cluster.ioctx_create(src_pool_name.c_str(), src_ioctx)); + src_ioctx.application_enable("rados", true); } static void TearDownTestCase() { ASSERT_EQ(0, s_cluster.pool_delete(src_pool_name.c_str())); @@ -1231,22 +1239,37 @@ TEST_F(LibRadosMisc, CmpExt) { } TEST_F(LibRadosMisc, Applications) { + const char *cmd[] = {"{\"prefix\":\"osd dump\"}", nullptr}; + char *buf, *st; + size_t buflen, stlen; + ASSERT_EQ(0, rados_mon_command(cluster, (const char **)cmd, 1, "", 0, &buf, + &buflen, &st, &stlen)); + ASSERT_LT(0u, buflen); + string result(buf); + rados_buffer_free(buf); + rados_buffer_free(st); + if (!boost::regex_search(result, boost::regex("require_osd_release [l-z]"))) { + std::cout << "SKIPPING"; + return; + } + char apps[128]; size_t app_len; app_len = sizeof(apps); ASSERT_EQ(0, rados_application_list(ioctx, apps, &app_len)); - ASSERT_EQ(0U, app_len); + ASSERT_EQ(6U, app_len); + ASSERT_EQ(0, memcmp("rados\0", apps, app_len)); - ASSERT_EQ(0, rados_application_enable(ioctx, "app1", 0)); + ASSERT_EQ(0, rados_application_enable(ioctx, "app1", 1)); ASSERT_EQ(-EPERM, rados_application_enable(ioctx, "app2", 0)); ASSERT_EQ(0, rados_application_enable(ioctx, "app2", 1)); ASSERT_EQ(-ERANGE, rados_application_list(ioctx, apps, &app_len)); - ASSERT_EQ(10U, app_len); + ASSERT_EQ(16U, app_len); ASSERT_EQ(0, rados_application_list(ioctx, apps, &app_len)); - ASSERT_EQ(10U, app_len); - ASSERT_EQ(0, memcmp("app1\0app2\0", apps, app_len)); + ASSERT_EQ(16U, app_len); + ASSERT_EQ(0, memcmp("app1\0app2\0rados\0", apps, app_len)); char keys[128]; char vals[128]; @@ -1288,16 +1311,28 @@ TEST_F(LibRadosMisc, Applications) { } TEST_F(LibRadosMiscPP, Applications) { - std::set expected_apps; + bufferlist inbl, outbl; + string outs; + ASSERT_EQ(0, cluster.mon_command("{\"prefix\": \"osd dump\"}", + inbl, &outbl, &outs)); + ASSERT_LT(0u, outbl.length()); + ASSERT_LE(0u, outs.length()); + if (!boost::regex_search(outbl.to_str(), + boost::regex("require_osd_release [l-z]"))) { + std::cout << "SKIPPING"; + return; + } + + std::set expected_apps = {"rados"}; std::set apps; ASSERT_EQ(0, ioctx.application_list(&apps)); ASSERT_EQ(expected_apps, apps); - ASSERT_EQ(0, ioctx.application_enable("app1", false)); + ASSERT_EQ(0, ioctx.application_enable("app1", true)); ASSERT_EQ(-EPERM, ioctx.application_enable("app2", false)); ASSERT_EQ(0, ioctx.application_enable("app2", true)); - expected_apps = {"app1", "app2"}; + expected_apps = {"app1", "app2", "rados"}; ASSERT_EQ(0, ioctx.application_list(&apps)); ASSERT_EQ(expected_apps, apps); diff --git a/src/test/librados/test.cc b/src/test/librados/test.cc index 7c9ee59b3ac..42269b074bf 100644 --- a/src/test/librados/test.cc +++ b/src/test/librados/test.cc @@ -49,6 +49,17 @@ std::string create_one_pool( return oss.str(); } + rados_ioctx_t ioctx; + ret = rados_ioctx_create(*cluster, pool_name.c_str(), &ioctx); + if (ret < 0) { + rados_shutdown(*cluster); + std::ostringstream oss; + oss << "rados_ioctx_create(" << pool_name << ") failed with error " << ret; + return oss.str(); + } + + rados_application_enable(ioctx, "rados", 1); + rados_ioctx_destroy(ioctx); return ""; } @@ -155,6 +166,17 @@ std::string create_one_pool_pp(const std::string &pool_name, Rados &cluster, oss << "cluster.pool_create(" << pool_name << ") failed with error " << ret; return oss.str(); } + + IoCtx ioctx; + ret = cluster.ioctx_create(pool_name.c_str(), ioctx); + if (ret < 0) { + cluster.shutdown(); + std::ostringstream oss; + oss << "cluster.ioctx_create(" << pool_name << ") failed with error " + << ret; + return oss.str(); + } + ioctx.application_enable("rados", true); return ""; } diff --git a/src/test/librados/tier.cc b/src/test/librados/tier.cc index 1296acd0b75..ec30b1dd340 100755 --- a/src/test/librados/tier.cc +++ b/src/test/librados/tier.cc @@ -82,7 +82,9 @@ protected: cache_pool_name = get_temp_pool_name(); ASSERT_EQ(0, s_cluster.pool_create(cache_pool_name.c_str())); RadosTestPP::SetUp(); + ASSERT_EQ(0, cluster.ioctx_create(cache_pool_name.c_str(), cache_ioctx)); + cache_ioctx.application_enable("rados", true); cache_ioctx.set_namespace(nspace); } void TearDown() override { @@ -1761,6 +1763,7 @@ TEST_F(LibRadosTierPP, FlushWriteRaces) { ASSERT_EQ(0, cluster.pool_create(cache_pool_name.c_str())); IoCtx cache_ioctx; ASSERT_EQ(0, cluster.ioctx_create(cache_pool_name.c_str(), cache_ioctx)); + cache_ioctx.application_enable("rados", true); IoCtx ioctx; ASSERT_EQ(0, cluster.ioctx_create(pool_name.c_str(), ioctx)); @@ -2830,7 +2833,9 @@ protected: cache_pool_name = get_temp_pool_name(); ASSERT_EQ(0, s_cluster.pool_create(cache_pool_name.c_str())); RadosTestECPP::SetUp(); + ASSERT_EQ(0, cluster.ioctx_create(cache_pool_name.c_str(), cache_ioctx)); + cache_ioctx.application_enable("rados", true); cache_ioctx.set_namespace(nspace); } void TearDown() override { @@ -4426,6 +4431,7 @@ TEST_F(LibRadosTierECPP, FlushWriteRaces) { ASSERT_EQ(0, cluster.pool_create(cache_pool_name.c_str())); IoCtx cache_ioctx; ASSERT_EQ(0, cluster.ioctx_create(cache_pool_name.c_str(), cache_ioctx)); + cache_ioctx.application_enable("rados", true); IoCtx ioctx; ASSERT_EQ(0, cluster.ioctx_create(pool_name.c_str(), ioctx)); @@ -4772,6 +4778,7 @@ TEST_F(LibRadosTierECPP, CallForcesPromote) { ASSERT_EQ(0, cluster.pool_create(cache_pool_name.c_str())); IoCtx cache_ioctx; ASSERT_EQ(0, cluster.ioctx_create(cache_pool_name.c_str(), cache_ioctx)); + cache_ioctx.application_enable("rados", true); IoCtx ioctx; ASSERT_EQ(0, cluster.ioctx_create(pool_name.c_str(), ioctx)); diff --git a/src/test/librbd/fsx.cc b/src/test/librbd/fsx.cc index 444fdbefd59..12e1eaddde4 100644 --- a/src/test/librbd/fsx.cc +++ b/src/test/librbd/fsx.cc @@ -1522,6 +1522,8 @@ create_image() simple_err("Error creating ioctx", r); goto failed_krbd; } + rados_application_enable(ioctx, "rbd", 1); + if (clone_calls || journal_replay) { uint64_t features = 0; if (clone_calls) { diff --git a/src/test/librbd/test_support.cc b/src/test/librbd/test_support.cc index fa8e25194a7..55ebe03dce3 100644 --- a/src/test/librbd/test_support.cc +++ b/src/test/librbd/test_support.cc @@ -109,5 +109,12 @@ int create_image_data_pool(librados::Rados &rados, std::string &data_pool, bool return 0; } + librados::IoCtx ioctx; + r = rados.ioctx_create(pool.c_str(), ioctx); + if (r < 0) { + return r; + } + ioctx.application_enable("rbd", true); + return r; } diff --git a/src/test/multi_stress_watch.cc b/src/test/multi_stress_watch.cc index 9b1b715f348..f105c46e9b0 100644 --- a/src/test/multi_stress_watch.cc +++ b/src/test/multi_stress_watch.cc @@ -42,6 +42,7 @@ test_loop(Rados &cluster, std::string pool_name, std::string obj_name) std::cerr << "ioctx_create " << pool_name << " failed with " << ret << std::endl; exit(1); } + ioctx.application_enable("rados", true); ret = ioctx.create(obj_name, false); if (ret < 0) { @@ -64,6 +65,11 @@ test_loop(Rados &cluster, std::string pool_name, std::string obj_name) } ioctx.close(); + ret = cluster.pool_delete(pool_name.c_str()); + if (ret < 0) { + std::cerr << "pool_delete failed with " << ret << std::endl; + exit(1); + } } #pragma GCC diagnostic pop diff --git a/src/test/pybind/test_rados.py b/src/test/pybind/test_rados.py index ca496528df8..88b8d2a92c8 100644 --- a/src/test/pybind/test_rados.py +++ b/src/test/pybind/test_rados.py @@ -1,4 +1,5 @@ from __future__ import print_function +from nose import SkipTest from nose.tools import eq_ as eq, ok_ as ok, assert_raises from rados import (Rados, Error, RadosStateError, Object, ObjectExists, ObjectNotFound, ObjectBusy, requires, opt, @@ -860,6 +861,15 @@ class TestIoctx(object): [i.remove() for i in self.ioctx.list_objects()] def test_applications(self): + cmd = {"prefix":"osd dump", "format":"json"} + ret, buf, errs = self.rados.mon_command(json.dumps(cmd), b'') + eq(ret, 0) + assert len(buf) > 0 + release = json.loads(buf.decode("utf-8")).get("require_osd_release", + None) + if not release or release[0] < 'l': + raise SkipTest + eq([], self.ioctx.application_list()) self.ioctx.application_enable("app1") diff --git a/src/test/rbd_mirror/test_ClusterWatcher.cc b/src/test/rbd_mirror/test_ClusterWatcher.cc index 2fd894c702e..11080b7a70f 100644 --- a/src/test/rbd_mirror/test_ClusterWatcher.cc +++ b/src/test/rbd_mirror/test_ClusterWatcher.cc @@ -51,10 +51,13 @@ public: int64_t pool_id = m_cluster->pool_lookup(pool_name.c_str()); ASSERT_GE(pool_id, 0); + + librados::IoCtx ioctx; + ASSERT_EQ(0, m_cluster->ioctx_create2(pool_id, ioctx)); + ioctx.application_enable("rbd", true); + m_pools.insert(pool_name); if (enable_mirroring) { - librados::IoCtx ioctx; - ASSERT_EQ(0, m_cluster->ioctx_create2(pool_id, ioctx)); ASSERT_EQ(0, librbd::api::Mirror<>::mode_set(ioctx, RBD_MIRROR_MODE_POOL)); diff --git a/src/test/rbd_mirror/test_ImageReplayer.cc b/src/test/rbd_mirror/test_ImageReplayer.cc index 04259e4d12b..8a7766948c5 100644 --- a/src/test/rbd_mirror/test_ImageReplayer.cc +++ b/src/test/rbd_mirror/test_ImageReplayer.cc @@ -90,6 +90,7 @@ public: EXPECT_EQ(0, m_local_cluster->pool_create(m_local_pool_name.c_str())); EXPECT_EQ(0, m_local_cluster->ioctx_create(m_local_pool_name.c_str(), m_local_ioctx)); + m_local_ioctx.application_enable("rbd", true); EXPECT_EQ("", connect_cluster_pp(m_remote_cluster)); EXPECT_EQ(0, m_remote_cluster.conf_set("rbd_cache", "false")); @@ -101,6 +102,8 @@ public: EXPECT_EQ(0, m_remote_cluster.ioctx_create(m_remote_pool_name.c_str(), m_remote_ioctx)); + m_remote_ioctx.application_enable("rbd", true); + EXPECT_EQ(0, librbd::api::Mirror<>::mode_set(m_remote_ioctx, RBD_MIRROR_MODE_POOL)); diff --git a/src/test/rbd_mirror/test_PoolWatcher.cc b/src/test/rbd_mirror/test_PoolWatcher.cc index c1272466933..06dcd570b32 100644 --- a/src/test/rbd_mirror/test_PoolWatcher.cc +++ b/src/test/rbd_mirror/test_PoolWatcher.cc @@ -97,6 +97,7 @@ public: librados::IoCtx ioctx; ASSERT_EQ(0, m_cluster->ioctx_create2(pool_id, ioctx)); + ioctx.application_enable("rbd", true); m_pool_watcher.reset(new PoolWatcher<>(m_threads, ioctx, m_pool_watcher_listener)); diff --git a/src/test/rbd_mirror/test_fixture.cc b/src/test/rbd_mirror/test_fixture.cc index b095f7372ca..221d618d492 100644 --- a/src/test/rbd_mirror/test_fixture.cc +++ b/src/test/rbd_mirror/test_fixture.cc @@ -31,9 +31,17 @@ void TestFixture::SetUpTestCase() { _local_pool_name = get_temp_pool_name("test-rbd-mirror-"); ASSERT_EQ(0, _rados->pool_create(_local_pool_name.c_str())); + librados::IoCtx local_ioctx; + ASSERT_EQ(0, _rados->ioctx_create(_local_pool_name.c_str(), local_ioctx)); + local_ioctx.application_enable("rbd", true); + _remote_pool_name = get_temp_pool_name("test-rbd-mirror-"); ASSERT_EQ(0, _rados->pool_create(_remote_pool_name.c_str())); + librados::IoCtx remote_ioctx; + ASSERT_EQ(0, _rados->ioctx_create(_remote_pool_name.c_str(), remote_ioctx)); + remote_ioctx.application_enable("rbd", true); + ASSERT_EQ(0, create_image_data_pool(_data_pool)); if (!_data_pool.empty()) { printf("using image data pool: %s\n", _data_pool.c_str()); diff --git a/src/test/system/rados_open_pools_parallel.cc b/src/test/system/rados_open_pools_parallel.cc index 0181e2b8825..04a144264ac 100644 --- a/src/test/system/rados_open_pools_parallel.cc +++ b/src/test/system/rados_open_pools_parallel.cc @@ -85,6 +85,7 @@ public: if (m_open_pool_sem) m_open_pool_sem->post(); rados_ioctx_destroy(io_ctx); + rados_pool_delete(cl, m_pool_name.c_str()); rados_shutdown(cl); return 0; } diff --git a/src/test/test_mutate.cc b/src/test/test_mutate.cc index a8d83d5708c..023b4f2d515 100644 --- a/src/test/test_mutate.cc +++ b/src/test/test_mutate.cc @@ -99,6 +99,8 @@ int main(int argc, const char **argv) << "': error " << ret << std::endl; return 1; } + ioctx.application_enable("rados", true); + librados::ObjectWriteOperation op; op.create(true); ret = ioctx.operate(oid, &op); -- 2.39.5