]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/system/*: use dynamically generated pool name 8318/head
authorKefu Chai <kchai@redhat.com>
Sun, 27 Mar 2016 13:21:54 +0000 (21:21 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 27 Mar 2016 13:21:55 +0000 (21:21 +0800)
was using "foo" for the pool name. this works if we are performing
tests in serial. but if we do it in parallel, the tests interfere
with each other.

Fixes: #15240
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/test/system/rados_delete_pools_parallel.cc
src/test/system/rados_list_parallel.cc
src/test/system/rados_open_pools_parallel.cc
src/test/system/st_rados_create_pool.cc
src/test/system/st_rados_create_pool.h
src/test/system/st_rados_list_objects.cc
src/test/system/systest_runnable.h

index 5347c53c296ced33ca68f5760e0f86946be6a1b7..47d878c7cb3fe2b127e1bd65b6518892098a100f 100644 (file)
@@ -57,7 +57,7 @@ const char *get_id_str()
 int main(int argc, const char **argv)
 {
   const char *num_objects = getenv("NUM_OBJECTS");
-  std::string pool = "foo";
+  const std::string pool = get_temp_pool_name(argv[0]);
   if (num_objects) {
     g_num_objects = atoi(num_objects); 
     if (g_num_objects == 0)
index fb4540d218ba52ed03db0d559fb74348b7160081..ff1cfaeee6e39420fdfdd6a349e59bd2d0f848de 100644 (file)
@@ -221,7 +221,7 @@ const char *get_id_str()
 int main(int argc, const char **argv)
 {
   const char *num_objects = getenv("NUM_OBJECTS");
-  std::string pool = "foo." + stringify(getpid());
+  const std::string pool = get_temp_pool_name(argv[0]);
   if (num_objects) {
     g_num_objects = atoi(num_objects); 
     if (g_num_objects == 0)
index 82c712077f272c458abf098192340d0dd1ff7d23..fbaaf2a6e5e46175353c928670bf9e65b6f1dc73 100644 (file)
@@ -49,9 +49,13 @@ class StRadosOpenPool : public SysTestRunnable
 {
 public:
   StRadosOpenPool(int argc, const char **argv,
-                 CrossProcessSem *pool_setup_sem, CrossProcessSem *open_pool_sem)
+                  CrossProcessSem *pool_setup_sem,
+                  CrossProcessSem *open_pool_sem,
+                  const std::string& pool_name)
     : SysTestRunnable(argc, argv),
-      m_pool_setup_sem(pool_setup_sem), m_open_pool_sem(open_pool_sem)
+      m_pool_setup_sem(pool_setup_sem),
+      m_open_pool_sem(open_pool_sem),
+      m_pool_name(pool_name)
   {
   }
 
@@ -74,10 +78,10 @@ public:
       m_pool_setup_sem->wait();
 
     printf("%s: rados_pool_create.\n", get_id_str());
-    rados_pool_create(cl, "foo");
+    rados_pool_create(cl, m_pool_name.c_str());
     rados_ioctx_t io_ctx;
     printf("%s: rados_ioctx_create.\n", get_id_str());
-    RETURN1_IF_NOT_VAL(0, rados_ioctx_create(cl, "foo", &io_ctx));
+    RETURN1_IF_NOT_VAL(0, rados_ioctx_create(cl, m_pool_name.c_str(), &io_ctx));
     if (m_open_pool_sem)
       m_open_pool_sem->post();
     rados_ioctx_destroy(io_ctx);
@@ -88,6 +92,7 @@ public:
 private:
   CrossProcessSem *m_pool_setup_sem;
   CrossProcessSem *m_open_pool_sem;
+  std::string m_pool_name;
 };
 
 const char *get_id_str()
@@ -97,13 +102,14 @@ const char *get_id_str()
 
 int main(int argc, const char **argv)
 {
+  const std::string pool = get_temp_pool_name(argv[0]);
   // first test: create a pool, shut down the client, access that 
   // pool in a different process.
   CrossProcessSem *pool_setup_sem = NULL;
   RETURN1_IF_NONZERO(CrossProcessSem::create(0, &pool_setup_sem));
   StRadosCreatePool r1(argc, argv, NULL, pool_setup_sem, NULL,
-                                          "foo", 50, ".obj");
-  StRadosOpenPool r2(argc, argv, pool_setup_sem, NULL);
+                                          pool, 50, ".obj");
+  StRadosOpenPool r2(argc, argv, pool_setup_sem, NULL, pool);
   vector < SysTestRunnable* > vec;
   vec.push_back(&r1);
   vec.push_back(&r2);
@@ -120,8 +126,8 @@ int main(int argc, const char **argv)
   CrossProcessSem *open_pool_sem2 = NULL;
   RETURN1_IF_NONZERO(CrossProcessSem::create(0, &open_pool_sem2));
   StRadosCreatePool r3(argc, argv, NULL, pool_setup_sem2, open_pool_sem2,
-                                          "foo", 50, ".obj");
-  StRadosOpenPool r4(argc, argv, pool_setup_sem2, open_pool_sem2);
+                                          pool, 50, ".obj");
+  StRadosOpenPool r4(argc, argv, pool_setup_sem2, open_pool_sem2, pool);
   vector < SysTestRunnable* > vec2;
   vec2.push_back(&r3);
   vec2.push_back(&r4);
index 512f3fe1cda75cbcf0c65fc25e356bd32b2432c1..b027860f51724245f388c237ff81b0bf8179b5c4 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <sstream>
 #include <string>
 
@@ -113,3 +114,17 @@ out:
   rados_shutdown(cl);
   return ret_val;
 }
+
+std::string get_temp_pool_name(const char* prefix)
+{
+  assert(prefix);
+  char hostname[80];
+  int ret = 0;
+  ret = gethostname(hostname, sizeof(hostname));
+  assert(!ret);
+  char poolname[256];
+  ret = snprintf(poolname, sizeof(poolname),
+                 "%s.%s-%d", prefix, hostname, getpid());
+  assert(ret < sizeof(poolname));
+  return poolname;
+}
index f0f8a3bc0f877098522ffa17d9853423b414b6bd..5554f3eec98c4476dcada9a1508eda7e730c6fda 100644 (file)
@@ -48,4 +48,6 @@ private:
   std::string m_suffix;
 };
 
+std::string get_temp_pool_name(const char* prefix);
+
 #endif
index c53ab17ccb1b7e37ae04b3858ddf878d6254f0a0..514dafe65701e830c976c4af7992f6f989ec4a6b 100644 (file)
@@ -36,6 +36,7 @@ StRadosListObjects(int argc, const char **argv,
                   CrossProcessSem *midway_sem_wait,
                   CrossProcessSem *midway_sem_post)
   : SysTestRunnable(argc, argv),
+    m_pool_name(pool_name),
     m_accept_list_errors(accept_list_errors),
     m_midway_cnt(midway_cnt),
     m_pool_setup_sem(pool_setup_sem),
@@ -63,8 +64,8 @@ run()
   m_pool_setup_sem->post();
 
   rados_ioctx_t io_ctx;
-  rados_pool_create(cl, "foo");
-  RETURN1_IF_NONZERO(rados_ioctx_create(cl, "foo", &io_ctx));
+  rados_pool_create(cl, m_pool_name.c_str());
+  RETURN1_IF_NONZERO(rados_ioctx_create(cl, m_pool_name.c_str(), &io_ctx));
 
   int saw = 0;
   const char *obj_name;
index bd7d2586bc31c180b35305af0c767527f40afdfb..c19441c25de13ac9bff5a19bbc852035bf4cecab 100644 (file)
@@ -36,7 +36,7 @@
   RETURN1_IF_NOT_VAL(0, expr)
 
 extern void* systest_runnable_pthread_helper(void *arg);
-
+std::string get_temp_pool_name(const char* prefix);
 /* Represents a single test thread / process.
  *
  * Inherit from this class and implement the test body in run().