From 596ff10824a3fc059f9081164f996997e83e3d11 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Wed, 21 Oct 2020 16:24:30 +0300 Subject: [PATCH] test/store_test: use 'threadsafe' style for death tests. Hopefully Fixes: https://tracker.ceph.com/issues/47328 Signed-off-by: Igor Fedotov (cherry picked from commit 99ac34cbfeb98c36ffcc3e1b5b65174930273c4c) --- src/test/objectstore/store_test.cc | 14 +++++--------- src/test/objectstore/store_test_fixture.cc | 4 ++++ src/test/objectstore/store_test_fixture.h | 9 +++++++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index db1ff9d7dc854..70dbec35caa10 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -2914,6 +2914,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; @@ -3186,13 +3189,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(); @@ -3213,8 +3210,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; diff --git a/src/test/objectstore/store_test_fixture.cc b/src/test/objectstore/store_test_fixture.cc index 33d4618a31b00..7e233102f3fc4 100644 --- a/src/test/objectstore/store_test_fixture.cc +++ b/src/test/objectstore/store_test_fixture.cc @@ -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); diff --git a/src/test/objectstore/store_test_fixture.h b/src/test/objectstore/store_test_fixture.h index d816dbdf49de7..40e62778cdb5c 100644 --- a/src/test/objectstore/store_test_fixture.h +++ b/src/test/objectstore/store_test_fixture.h @@ -13,6 +13,8 @@ class StoreTestFixture : virtual public ::testing::Test { std::stack> saved_settings; ConfigProxy* conf = nullptr; + std::string orig_death_test_style; + public: boost::scoped_ptr 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; -- 2.39.5