diff options
author | Sage Weil <sage@redhat.com> | 2017-04-17 21:48:23 +0200 |
---|---|---|
committer | Sage Weil <sage@redhat.com> | 2017-05-05 19:39:13 +0200 |
commit | 434351ba590897cc9e441a3b63184cb6107e2978 (patch) | |
tree | 97da356de57244828ae1be8ab8285a1adde7435e /src/test/librados | |
parent | ceph_test_rados_api_list: update check_list (diff) | |
download | ceph-434351ba590897cc9e441a3b63184cb6107e2978.tar.xz ceph-434351ba590897cc9e441a3b63184cb6107e2978.zip |
ceph_test_rados_api_*: do not clean up objects (usually)
First, this is pointless--each test runs in a namespace so they don't
step on each other. Second, leaving objects in place is an opportunity
for scrub to notice any issues we created. Third, the cleanup asserts
that delete succeeds but if clones exist pgls will show whiteouts and then
delete will return ENOENT. We could disable the assert, but why bother
even attempting a sloppy cleanup?
We need to preserve cleanup behavior for a few tests (notably the object
listing ones).
Signed-off-by: Sage Weil <sage@redhat.com>
Diffstat (limited to 'src/test/librados')
-rw-r--r-- | src/test/librados/TestCase.cc | 45 | ||||
-rw-r--r-- | src/test/librados/TestCase.h | 46 | ||||
-rw-r--r-- | src/test/librados/list.cc | 10 |
3 files changed, 72 insertions, 29 deletions
diff --git a/src/test/librados/TestCase.cc b/src/test/librados/TestCase.cc index b9ae9b79e0e..9df0cce9f53 100644 --- a/src/test/librados/TestCase.cc +++ b/src/test/librados/TestCase.cc @@ -47,7 +47,8 @@ void RadosTestNS::SetUp() void RadosTestNS::TearDown() { - cleanup_all_objects(ioctx); + if (cleanup) + cleanup_all_objects(ioctx); rados_ioctx_destroy(ioctx); } @@ -97,7 +98,8 @@ void RadosTestPPNS::SetUp() void RadosTestPPNS::TearDown() { - cleanup_all_objects(ioctx); + if (cleanup) + cleanup_all_objects(ioctx); ioctx.close(); } @@ -179,7 +181,8 @@ void RadosTestParamPPNS::SetUp() void RadosTestParamPPNS::TearDown() { - cleanup_all_objects(ioctx); + if (cleanup) + cleanup_all_objects(ioctx); ioctx.close(); } @@ -223,7 +226,8 @@ void RadosTestECNS::SetUp() void RadosTestECNS::TearDown() { - cleanup_all_objects(ioctx); + if (cleanup) + cleanup_all_objects(ioctx); rados_ioctx_destroy(ioctx); } @@ -253,7 +257,8 @@ void RadosTestECPPNS::SetUp() void RadosTestECPPNS::TearDown() { - cleanup_all_objects(ioctx); + if (cleanup) + cleanup_all_objects(ioctx); ioctx.close(); } @@ -284,8 +289,10 @@ void RadosTest::SetUp() void RadosTest::TearDown() { - cleanup_default_namespace(ioctx); - cleanup_namespace(ioctx, nspace); + if (cleanup) { + cleanup_default_namespace(ioctx); + cleanup_namespace(ioctx, nspace); + } rados_ioctx_destroy(ioctx); } @@ -343,8 +350,10 @@ void RadosTestPP::SetUp() void RadosTestPP::TearDown() { - cleanup_default_namespace(ioctx); - cleanup_namespace(ioctx, nspace); + if (cleanup) { + cleanup_default_namespace(ioctx); + cleanup_namespace(ioctx, nspace); + } ioctx.close(); } @@ -442,8 +451,10 @@ void RadosTestParamPP::SetUp() void RadosTestParamPP::TearDown() { - cleanup_default_namespace(ioctx); - cleanup_namespace(ioctx, nspace); + if (cleanup) { + cleanup_default_namespace(ioctx); + cleanup_namespace(ioctx, nspace); + } ioctx.close(); } @@ -494,8 +505,10 @@ void RadosTestEC::SetUp() void RadosTestEC::TearDown() { - cleanup_default_namespace(ioctx); - cleanup_namespace(ioctx, nspace); + if (cleanup) { + cleanup_default_namespace(ioctx); + cleanup_namespace(ioctx, nspace); + } rados_ioctx_destroy(ioctx); } @@ -527,8 +540,10 @@ void RadosTestECPP::SetUp() void RadosTestECPP::TearDown() { - cleanup_default_namespace(ioctx); - cleanup_namespace(ioctx, nspace); + if (cleanup) { + cleanup_default_namespace(ioctx); + cleanup_namespace(ioctx, nspace); + } ioctx.close(); } diff --git a/src/test/librados/TestCase.h b/src/test/librados/TestCase.h index 2bb1f1f4aa9..ac84bba0864 100644 --- a/src/test/librados/TestCase.h +++ b/src/test/librados/TestCase.h @@ -21,7 +21,7 @@ */ class RadosTestNS : public ::testing::Test { public: - RadosTestNS() {} + RadosTestNS(bool c=false) : cleanup(c) {} ~RadosTestNS() override {} protected: static void SetUpTestCase(); @@ -34,11 +34,16 @@ protected: void TearDown() override; rados_t cluster; rados_ioctx_t ioctx; + bool cleanup; +}; + +struct RadosTestNSCleanup : public RadosTestNS { + RadosTestNSCleanup() : RadosTestNS(true) {} }; class RadosTestPPNS : public ::testing::Test { public: - RadosTestPPNS() : cluster(s_cluster) {} + RadosTestPPNS(bool c=false) : cluster(s_cluster), cleanup(c) {} ~RadosTestPPNS() override {} protected: static void SetUpTestCase(); @@ -51,11 +56,16 @@ protected: void TearDown() override; librados::Rados &cluster; librados::IoCtx ioctx; + bool cleanup; +}; + +struct RadosTestPPNSCleanup : public RadosTestPPNS { + RadosTestPPNSCleanup() : RadosTestPPNS(true) {} }; class RadosTestParamPPNS : public ::testing::TestWithParam<const char*> { public: - RadosTestParamPPNS() : cluster(s_cluster) {} + RadosTestParamPPNS(bool c=false) : cluster(s_cluster), cleanup(c) {} ~RadosTestParamPPNS() override {} static void SetUpTestCase(); static void TearDownTestCase(); @@ -69,11 +79,12 @@ protected: void TearDown() override; librados::Rados &cluster; librados::IoCtx ioctx; + bool cleanup; }; class RadosTestECNS : public RadosTestNS { public: - RadosTestECNS() {} + RadosTestECNS(bool c=false) : cleanup(c) {} ~RadosTestECNS() override {} protected: static void SetUpTestCase(); @@ -86,11 +97,16 @@ protected: rados_t cluster; rados_ioctx_t ioctx; uint64_t alignment; + bool cleanup; +}; + +struct RadosTestECNSCleanup : public RadosTestECNS { + RadosTestECNSCleanup() : RadosTestECNS(true) {} }; class RadosTestECPPNS : public RadosTestPPNS { public: - RadosTestECPPNS() : cluster(s_cluster) {} + RadosTestECPPNS(bool c=false) : cluster(s_cluster), cleanup(c) {} ~RadosTestECPPNS() override {} protected: static void SetUpTestCase(); @@ -103,6 +119,11 @@ protected: librados::Rados &cluster; librados::IoCtx ioctx; uint64_t alignment; + bool cleanup; +}; + +struct RadosTestECPPNSCleanup : public RadosTestECPPNS { + RadosTestECPPNSCleanup() : RadosTestECPPNS(true) {} }; /** @@ -115,7 +136,7 @@ protected: */ class RadosTest : public ::testing::Test { public: - RadosTest() {} + RadosTest(bool c=false) : cleanup(c) {} ~RadosTest() override {} protected: static void SetUpTestCase(); @@ -130,11 +151,12 @@ protected: rados_t cluster; rados_ioctx_t ioctx; std::string nspace; + bool cleanup; }; class RadosTestPP : public ::testing::Test { public: - RadosTestPP() : cluster(s_cluster) {} + RadosTestPP(bool c=false) : cluster(s_cluster), cleanup(c) {} ~RadosTestPP() override {} protected: static void SetUpTestCase(); @@ -148,12 +170,13 @@ protected: void TearDown() override; librados::Rados &cluster; librados::IoCtx ioctx; + bool cleanup; std::string nspace; }; class RadosTestParamPP : public ::testing::TestWithParam<const char*> { public: - RadosTestParamPP() : cluster(s_cluster) {} + RadosTestParamPP(bool c=false) : cluster(s_cluster), cleanup(c) {} ~RadosTestParamPP() override {} static void SetUpTestCase(); static void TearDownTestCase(); @@ -168,12 +191,13 @@ protected: void TearDown() override; librados::Rados &cluster; librados::IoCtx ioctx; + bool cleanup; std::string nspace; }; class RadosTestEC : public RadosTest { public: - RadosTestEC() {} + RadosTestEC(bool c=false) : cleanup(c) {} ~RadosTestEC() override {} protected: static void SetUpTestCase(); @@ -185,13 +209,14 @@ protected: void TearDown() override; rados_t cluster; rados_ioctx_t ioctx; + bool cleanup; std::string nspace; uint64_t alignment; }; class RadosTestECPP : public RadosTestPP { public: - RadosTestECPP() : cluster(s_cluster) {} + RadosTestECPP(bool c=false) : cluster(s_cluster), cleanup(c) {} ~RadosTestECPP() override {} protected: static void SetUpTestCase(); @@ -203,6 +228,7 @@ protected: void TearDown() override; librados::Rados &cluster; librados::IoCtx ioctx; + bool cleanup; std::string nspace; uint64_t alignment; }; diff --git a/src/test/librados/list.cc b/src/test/librados/list.cc index 77f5f54fed3..948063b58ed 100644 --- a/src/test/librados/list.cc +++ b/src/test/librados/list.cc @@ -16,10 +16,10 @@ using namespace librados; -typedef RadosTestNS LibRadosList; -typedef RadosTestPPNS LibRadosListPP; -typedef RadosTestECNS LibRadosListEC; -typedef RadosTestECPPNS LibRadosListECPP; +typedef RadosTestNSCleanup LibRadosList; +typedef RadosTestPPNSCleanup LibRadosListPP; +typedef RadosTestECNSCleanup LibRadosListEC; +typedef RadosTestECPPNSCleanup LibRadosListECPP; typedef RadosTestNP LibRadosListNP; @@ -144,6 +144,7 @@ static void check_list( std::string check_nspace) { const char *entry, *nspace; + cout << "myset " << myset << std::endl; // we should see every item exactly once. int ret; while ((ret = rados_nobjects_list_next(ctx, &entry, NULL, &nspace)) == 0) { @@ -154,6 +155,7 @@ static void check_list( ASSERT_TRUE(std::string(nspace) == check_nspace); test_name = std::string(entry); } + cout << test_name << std::endl; ASSERT_TRUE(myset.end() != myset.find(test_name)); myset.erase(test_name); |