Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11190 from tchaikov/wip-memstore-clone-fixture
tests: use a fixture for memstore clone testing Reviewed-by: Casey Bodley <cbodley@redhat.com>
- Loading branch information
Showing
5 changed files
with
125 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <stdlib.h> | ||
#include <string> | ||
#include <iostream> | ||
#include <gtest/gtest.h> | ||
|
||
#include "common/errno.h" | ||
#include "os/ObjectStore.h" | ||
#include "store_test_fixture.h" | ||
|
||
static void rm_r(const string& path) { | ||
string cmd = string("rm -r ") + path; | ||
cout << "==> " << cmd << std::endl; | ||
int r = ::system(cmd.c_str()); | ||
if (r) { | ||
cerr << "failed with exit code " << r | ||
<< ", continuing anyway" << std::endl; | ||
} | ||
} | ||
|
||
void StoreTestFixture::SetUp() { | ||
int r = ::mkdir(data_dir.c_str(), 0777); | ||
if (r < 0) { | ||
r = -errno; | ||
cerr << __func__ << ": unable to create " << data_dir << ": " << cpp_strerror(r) << std::endl; | ||
} | ||
ASSERT_EQ(0, r); | ||
|
||
store.reset(ObjectStore::create(g_ceph_context, | ||
type, | ||
data_dir, | ||
string("store_test_temp_journal"))); | ||
if (!store) { | ||
cerr << __func__ << ": objectstore type " << type << " doesn't exist yet!" << std::endl; | ||
} | ||
ASSERT_TRUE(store); | ||
ASSERT_EQ(0, store->mkfs()); | ||
ASSERT_EQ(0, store->mount()); | ||
} | ||
|
||
void StoreTestFixture::TearDown() { | ||
if (store) { | ||
int r = store->umount(); | ||
EXPECT_EQ(0, r); | ||
rm_r(data_dir); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <string> | ||
#include <boost/scoped_ptr.hpp> | ||
#include <gtest/gtest.h> | ||
|
||
class ObjectStore; | ||
|
||
class StoreTestFixture : public ::testing::Test { | ||
const std::string type; | ||
const std::string data_dir; | ||
|
||
public: | ||
boost::scoped_ptr<ObjectStore> store; | ||
|
||
StoreTestFixture(const std::string& type) | ||
: type(type), data_dir(type + ".test_temp_dir") | ||
{} | ||
void SetUp() override; | ||
void TearDown() override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters