]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: create librbd API-only integration test suite
authorJason Dillaman <dillaman@redhat.com>
Tue, 5 May 2015 14:27:38 +0000 (10:27 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 5 May 2015 17:21:08 +0000 (13:21 -0400)
The QA client-upgrade test suite requires a librbd test
that is dynamically linked to librbd.  Since the current
ceph_test_librbd includes tests against the non-public API,
it is statically linked against librbd and thus cannot be
used to test a client upgrade scenario.

Backport: hammer
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/Makefile-client.am
src/test/Makefile.am
src/test/librbd/test_ImageWatcher.cc
src/test/librbd/test_fixture.cc
src/test/librbd/test_fixture.h
src/test/librbd/test_internal.cc
src/test/librbd/test_librbd.cc
src/test/librbd/test_main.cc
src/test/librbd/test_support.cc [new file with mode: 0644]
src/test/librbd/test_support.h [new file with mode: 0644]

index 963c26f0ed8fcecdfc1b352ce557ac3ae8b434ed..c3aaacc460c4b0e92c123df9f7b7976142d57467 100644 (file)
@@ -300,15 +300,16 @@ check_TESTPROGRAMS += unittest_rbd_replay
 
 librbd_test_la_SOURCES = \
        test/librbd/test_fixture.cc \
+       test/librbd/test_support.cc \
        test/librbd/test_librbd.cc \
        test/librbd/test_ImageWatcher.cc \
-       test/librbd/test_internal.cc \
-       test/librbd/test_main.cc
+       test/librbd/test_internal.cc
 librbd_test_la_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 noinst_LTLIBRARIES += librbd_test.la
 
-unittest_librbd_SOURCES =
-nodist_EXTRA_unittest_librbd_SOURCES = dummy.cc
+unittest_librbd_SOURCES = \
+        test/librbd/test_main.cc
+unittest_librbd_CXXFLAGS = $(UNITTEST_CXXFLAGS) -DTEST_LIBRBD_INTERNALS
 unittest_librbd_LDADD = \
        librbd_test.la librbd_api.la librbd_internal.la $(LIBRBD_TYPES) \
        libcls_rbd_client.la libcls_lock_client.la \
@@ -322,19 +323,30 @@ if VALGRIND_ENABLED
 check_SCRIPTS += test/run-rbd-valgrind-unit-tests.sh
 endif
 
-ceph_test_librbd_SOURCES =
-nodist_EXTRA_ceph_test_librbd_SOURCES = dummy.cc
+ceph_test_librbd_SOURCES = \
+        test/librbd/test_main.cc
+ceph_test_librbd_CXXFLAGS = $(UNITTEST_CXXFLAGS) -DTEST_LIBRBD_INTERNALS
 ceph_test_librbd_LDADD = \
        librbd_test.la librbd_api.la librbd_internal.la $(LIBRBD_TYPES) \
        libcls_rbd_client.la libcls_lock_client.la \
        librados_api.la $(LIBRADOS_DEPS) $(UNITTEST_LDADD) \
        $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
-ceph_test_librbd_CXXFLAGS = $(UNITTEST_CXXFLAGS)
 bin_DEBUGPROGRAMS += ceph_test_librbd
 
+ceph_test_librbd_api_SOURCES = \
+       test/librbd/test_support.cc \
+       test/librbd/test_librbd.cc \
+       test/librbd/test_main.cc
+ceph_test_librbd_api_CXXFLAGS = $(UNITTEST_CXXFLAGS)
+ceph_test_librbd_api_LDADD = \
+       $(LIBRBD) $(LIBRADOS) $(UNITTEST_LDADD) \
+       $(CEPH_GLOBAL) $(RADOS_TEST_LDADD)
+bin_DEBUGPROGRAMS += ceph_test_librbd_api
+
 if WITH_LTTNG
 unittest_librbd_LDADD += $(LIBRBD_TP)
 ceph_test_librbd_LDADD += $(LIBRBD_TP)
+ceph_test_librbd_api_LDADD += $(LIBRBD_TP)
 endif
 
 if LINUX
index 4b4440d57cd588ee4c50d1f09986924b92e8d0fd..ad72ee90169088ddcbdd35fca7e61fcf4f236cdc 100644 (file)
@@ -454,6 +454,7 @@ noinst_HEADERS += \
        test/librados/TestCase.h \
        test/libradosstriper/TestCase.h \
        test/librbd/test_fixture.h \
+       test/librbd/test_support.h \
        test/ObjectMap/KeyValueDBMemory.h \
        test/omap_bench.h \
        test/osdc/FakeWriteback.h \
index ae1db8a511ff8b004b3738aff3f8192abbbf0c8d..496ab58cbd83aa3a742a74fc3194877d33991c7d 100644 (file)
@@ -1,6 +1,7 @@
 // -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 #include "test/librbd/test_fixture.h"
+#include "test/librbd/test_support.h"
 #include "include/int_types.h"
 #include "include/stringify.h"
 #include "include/rados/librados.h"
index 9e47125489971a662b1ed8674b2964388b47aa48..e3db5c9f8496ad884a7210d2683b6af455fb0a09 100644 (file)
@@ -1,6 +1,7 @@
 // -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 #include "test/librbd/test_fixture.h"
+#include "test/librbd/test_support.h"
 #include "include/stringify.h"
 #include "cls/lock/cls_lock_client.h"
 #include "cls/lock/cls_lock_types.h"
 #include <sstream>
 #include <stdlib.h>
 
-bool get_features(uint64_t *features) {
-  const char *c = getenv("RBD_FEATURES");
-  if (c == NULL) {
-    return false;
-  }
-
-  std::stringstream ss(c);
-  if (!(ss >> *features)) {
-    return false;
-  }
-  return true;
-}
-
-bool is_feature_enabled(uint64_t feature) {
-  uint64_t features;
-  return (get_features(&features) && (features & feature) == feature);
-}
-
-int create_image_pp(librbd::RBD &rbd, librados::IoCtx &ioctx,
-                    const std::string &name, uint64_t size) {
-  uint64_t features = 0;
-  get_features(&features);
-  int order = 0;
-  return rbd.create2(ioctx, name.c_str(), size, features, &order);
-}
-
 std::string TestFixture::_pool_name;
 librados::Rados TestFixture::_rados;
 uint64_t TestFixture::_image_number = 0;
index d3246a7808d6745d650d036b2e9d237452c45472..7e3fff81ca875038f8dbdc8fd5cde60fff3976ec 100644 (file)
 
 using namespace ceph;
 
-bool get_features(uint64_t *features);
-bool is_feature_enabled(uint64_t feature);
-int create_image_pp(librbd::RBD &rbd, librados::IoCtx &ioctx,
-                    const std::string &name, uint64_t size);
-
-#define REQUIRE_FEATURE(feature) {       \
-  if (!is_feature_enabled(feature)) {    \
-    std::cout << "SKIPPING" << std::endl; \
-    return SUCCEED();                    \
-  }                                      \
-}
-
 class TestFixture : public ::testing::Test {
 public:
 
index 1b6f6a902e03c1529d8f2243108b38d5d3dfdca1..e11762b7f5e2808d638bfeb90d6473bc7071f88e 100644 (file)
@@ -1,6 +1,7 @@
 // -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 #include "test/librbd/test_fixture.h"
+#include "test/librbd/test_support.h"
 #include "librbd/AioCompletion.h"
 #include "librbd/ImageWatcher.h"
 #include "librbd/internal.h"
index 34754771f54e7eda838d4250b2cbb55865a8ae0a..c4238477bd358b083ff4eb8af586f62fdf867807 100644 (file)
@@ -22,6 +22,7 @@
 #include "global/global_init.h"
 #include "common/ceph_argparse.h"
 #include "common/config.h"
+#include "common/Thread.h"
 
 #include "gtest/gtest.h"
 
@@ -39,7 +40,7 @@
 #include <vector>
 
 #include "test/librados/test.h"
-#include "test/librbd/test_fixture.h"
+#include "test/librbd/test_support.h"
 #include "common/errno.h"
 #include "include/interval_set.h"
 #include "include/stringify.h"
index 52c1c46a22629712984b6e01edd716b842aac03a..7937e76c50ef1b654c144bcd8d5ee3af143ee330 100644 (file)
@@ -8,15 +8,19 @@
 #include "global/global_init.h"
 #include <vector>
 
+extern void register_test_librbd();
+#ifdef TEST_LIBRBD_INTERNALS
 extern void register_test_image_watcher();
 extern void register_test_internal();
-extern void register_test_librbd();
+#endif // TEST_LIBRBD_INTERNALS
 
 int main(int argc, char **argv)
 {
+  register_test_librbd();
+#ifdef TEST_LIBRBD_INTERNALS
   register_test_image_watcher();
   register_test_internal();
-  register_test_librbd();
+#endif // TEST_LIBRBD_INTERNALS
 
   ::testing::InitGoogleTest(&argc, argv);
 
diff --git a/src/test/librbd/test_support.cc b/src/test/librbd/test_support.cc
new file mode 100644 (file)
index 0000000..318b5be
--- /dev/null
@@ -0,0 +1,30 @@
+// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#include "test/librbd/test_support.h"
+#include <sstream>
+
+bool get_features(uint64_t *features) {
+  const char *c = getenv("RBD_FEATURES");
+  if (c == NULL) {
+    return false;
+  }
+
+  std::stringstream ss(c);
+  if (!(ss >> *features)) {
+    return false;
+  }
+  return true;
+}
+
+bool is_feature_enabled(uint64_t feature) {
+  uint64_t features;
+  return (get_features(&features) && (features & feature) == feature);
+}
+
+int create_image_pp(librbd::RBD &rbd, librados::IoCtx &ioctx,
+                    const std::string &name, uint64_t size) {
+  uint64_t features = 0;
+  get_features(&features);
+  int order = 0;
+  return rbd.create2(ioctx, name.c_str(), size, features, &order);
+}
diff --git a/src/test/librbd/test_support.h b/src/test/librbd/test_support.h
new file mode 100644 (file)
index 0000000..5bdd958
--- /dev/null
@@ -0,0 +1,19 @@
+// -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#include "include/int_types.h"
+#include "include/rados/librados.h"
+#include "include/rbd/librbd.hpp"
+#include <string>
+
+bool get_features(uint64_t *features);
+bool is_feature_enabled(uint64_t feature);
+int create_image_pp(librbd::RBD &rbd, librados::IoCtx &ioctx,
+                    const std::string &name, uint64_t size);
+
+#define REQUIRE_FEATURE(feature) {       \
+  if (!is_feature_enabled(feature)) {    \
+    std::cout << "SKIPPING" << std::endl; \
+    return SUCCEED();                    \
+  }                                      \
+}
+