]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/store_test: use 'threadsafe' style for death tests. 37738/head
authorIgor Fedotov <ifedotov@suse.com>
Wed, 21 Oct 2020 13:24:30 +0000 (16:24 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Wed, 21 Oct 2020 13:24:30 +0000 (16:24 +0300)
Hopefully Fixes: https://tracker.ceph.com/issues/47328
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/test/objectstore/store_test.cc
src/test/objectstore/store_test_fixture.cc
src/test/objectstore/store_test_fixture.h

index c382c3ac1f8a9f58c8afaa54304ad0574ca4fb9d..0c970f2658523d294e39bc767b31b82597d00f0b 100644 (file)
@@ -3021,6 +3021,9 @@ TEST_P(StoreTest, MultipoolListTest) {
 TEST_P(StoreTest, SimpleCloneTest) {
   int r;
   coll_t cid;
+
+  SetDeathTestStyle("threadsafe");
+
   auto ch = store->create_new_collection(cid);
   {
     ObjectStore::Transaction t;
@@ -3293,13 +3296,7 @@ TEST_P(StoreTest, SimpleCloneTest) {
     ASSERT_TRUE(bl_eq(rl, final));
   }
 
-  //Unfortunately we need a workaround for filestore since EXPECT_DEATH
-  // macro has potential issues when using /in multithread environments. 
-  //It works well for all stores but filestore for now. 
-  //A fix setting gtest_death_test_style = "threadsafe" doesn't help as well - 
-  //  test app clone asserts on store folder presence.
-  //
-  if (string(GetParam()) != "filestore") { 
+  {
     //verify if non-empty collection is properly handled after store reload
     ch.reset();
     r = store->umount();
@@ -3320,8 +3317,7 @@ TEST_P(StoreTest, SimpleCloneTest) {
     r = queue_transaction(store, ch, std::move(t));
     ASSERT_EQ(r, 0);
   }
-  //See comment above for "filestore" check explanation.
-  if (string(GetParam()) != "filestore") {
+  {
     ObjectStore::Transaction t;
     //verify if non-empty collection is properly handled when there are some pending removes and live records in db
     cerr << "Invalid rm coll again" << std::endl;
index 6b7a652f8fc66f9ca61e55c11a8ff0aa8eba5c59..e343f96156da7d272d995a5a31aead064eb228ac 100644 (file)
@@ -70,6 +70,10 @@ void StoreTestFixture::TearDown()
   // config settings. Hence setting it to 'unsafe' here as test case is closing.
   g_conf()._clear_safe_to_start_threads();
   PopSettings(0);
+  if (!orig_death_test_style.empty()) {
+    ::testing::FLAGS_gtest_death_test_style = orig_death_test_style;
+    orig_death_test_style.clear();
+  }
   if (store) {
     int r = store->umount();
     EXPECT_EQ(0, r);
index f3baa66d9bdf9ae997ef38a1f79aa6ebff77b41f..3b7971d7cdee57f210eb40fd7c77599d31706bd5 100644 (file)
@@ -13,6 +13,8 @@ class StoreTestFixture : virtual public ::testing::Test {
   std::stack<std::pair<std::string, std::string>> saved_settings;
   ConfigProxy* conf = nullptr;
 
+  std::string orig_death_test_style;
+
 public:
   boost::scoped_ptr<ObjectStore> store;
   ObjectStore::CollectionHandle ch;
@@ -23,6 +25,13 @@ public:
 
   void SetUp() override;
   void TearDown() override;
+  void SetDeathTestStyle(const char* new_style) {
+    if (orig_death_test_style.empty()) {
+      orig_death_test_style = ::testing::FLAGS_gtest_death_test_style;
+    }
+    ::testing::FLAGS_gtest_death_test_style = new_style;
+  }
+
   void SetVal(ConfigProxy& conf, const char* key, const char* val);
   struct SettingsBookmark {
     StoreTestFixture& s;