mirror of
https://github.com/ceph/ceph
synced 2025-01-03 09:32:43 +00:00
Merge pull request #1864 from dachary/wip-filestore
unit tests for #1860
This commit is contained in:
commit
49ac0c0e2c
@ -637,6 +637,7 @@ private:
|
||||
int read_superblock();
|
||||
|
||||
friend class FileStoreBackend;
|
||||
friend class TestFileStore;
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream& out, const FileStore::OpSequencer& s);
|
||||
|
@ -789,6 +789,11 @@ ceph_test_objectstore_SOURCES = test/objectstore/store_test.cc
|
||||
ceph_test_objectstore_LDADD = $(LIBOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
|
||||
ceph_test_objectstore_CXXFLAGS = $(UNITTEST_CXXFLAGS)
|
||||
bin_DEBUGPROGRAMS += ceph_test_objectstore
|
||||
|
||||
ceph_test_filestore_SOURCES = test/filestore/TestFileStore.cc
|
||||
ceph_test_filestore_LDADD = $(LIBOS) $(UNITTEST_LDADD) $(CEPH_GLOBAL)
|
||||
ceph_test_filestore_CXXFLAGS = $(UNITTEST_CXXFLAGS)
|
||||
bin_DEBUGPROGRAMS += ceph_test_filestore
|
||||
endif
|
||||
|
||||
ceph_test_objectstore_workloadgen_SOURCES = \
|
||||
|
87
src/test/filestore/TestFileStore.cc
Normal file
87
src/test/filestore/TestFileStore.cc
Normal file
@ -0,0 +1,87 @@
|
||||
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
|
||||
// vim: ts=8 sw=2 smarttab
|
||||
/*
|
||||
* Ceph - scalable distributed file system
|
||||
*
|
||||
* Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
|
||||
*
|
||||
* Author: Loic Dachary <loic@dachary.org>
|
||||
*
|
||||
* This is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software
|
||||
* Foundation. See file COPYING.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/ceph_argparse.h"
|
||||
#include "global/global_init.h"
|
||||
#include "os/FileStore.h"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
class TestFileStore {
|
||||
public:
|
||||
static void create_backend(FileStore &fs, long f_type) {
|
||||
fs.create_backend(f_type);
|
||||
}
|
||||
};
|
||||
|
||||
TEST(FileStore, create)
|
||||
{
|
||||
{
|
||||
map<string,string> pm;
|
||||
FileStore fs("a", "b");
|
||||
TestFileStore::create_backend(fs, 0);
|
||||
fs.collect_metadata(&pm);
|
||||
ASSERT_EQ(pm["filestore_backend"], "generic");
|
||||
}
|
||||
#if defined(__linux__)
|
||||
{
|
||||
map<string,string> pm;
|
||||
FileStore fs("a", "b");
|
||||
TestFileStore::create_backend(fs, BTRFS_SUPER_MAGIC);
|
||||
fs.collect_metadata(&pm);
|
||||
ASSERT_EQ(pm["filestore_backend"], "btrfs");
|
||||
}
|
||||
# ifdef HAVE_LIBXFS
|
||||
{
|
||||
map<string,string> pm;
|
||||
FileStore fs("a", "b");
|
||||
TestFileStore::create_backend(fs, XFS_SUPER_MAGIC);
|
||||
fs.collect_metadata(&pm);
|
||||
ASSERT_EQ(pm["filestore_backend"], "xfs");
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
#ifdef HAVE_LIBZFS
|
||||
{
|
||||
map<string,string> pm;
|
||||
FileStore fs("a", "b");
|
||||
TestFileStore::create_backend(fs, ZFS_SUPER_MAGIC);
|
||||
fs.collect_metadata(&pm);
|
||||
ASSERT_EQ(pm["filestore_backend"], "zfs");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
vector<const char*> args;
|
||||
argv_to_vec(argc, (const char **)argv, args);
|
||||
|
||||
global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
|
||||
common_init_finish(g_ceph_context);
|
||||
g_ceph_context->_conf->set_val("osd_journal_size", "100");
|
||||
g_ceph_context->_conf->apply_changes(NULL);
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* compile-command: "cd ../.. ; make ceph_test_filestore &&
|
||||
* ./ceph_test_filestore \
|
||||
* --gtest_filter=*.* --log-to-stderr=true --debug-filestore=20
|
||||
* "
|
||||
* End:
|
||||
*/
|
@ -75,6 +75,15 @@ bool sorted(const vector<ghobject_t> &in) {
|
||||
return true;
|
||||
}
|
||||
|
||||
TEST_P(StoreTest, collect_metadata) {
|
||||
map<string,string> pm;
|
||||
store->collect_metadata(&pm);
|
||||
if (GetParam() == string("filestore")) {
|
||||
ASSERT_NE(pm.count("filestore_backend"), 0);
|
||||
ASSERT_NE(pm.count("filestore_f_type"), 0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(StoreTest, SimpleColTest) {
|
||||
coll_t cid = coll_t("initial");
|
||||
int r = 0;
|
||||
@ -1265,6 +1274,11 @@ int main(int argc, char **argv) {
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// compile-command: "cd ../.. ; make ceph_test_objectstore ; ./ceph_test_objectstore --gtest_filter=StoreTest.* --log-to-stderr=true --debug-filestore=20"
|
||||
// End:
|
||||
/*
|
||||
* Local Variables:
|
||||
* compile-command: "cd ../.. ; make ceph_test_objectstore &&
|
||||
* ./ceph_test_objectstore \
|
||||
* --gtest_filter=*.collect_metadata* --log-to-stderr=true --debug-filestore=20
|
||||
* "
|
||||
* End:
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user