Browse Source

First pass on bringing the hostile server into automated testing.

Brian Aker 12 years ago
parent
commit
686357f3e1
4 changed files with 35 additions and 5 deletions
  1. 12 5
      libtest/gearmand.cc
  2. 2 0
      libtest/gearmand.h
  3. 10 0
      libtest/server_container.cc
  4. 11 0
      tests/stress_worker.cc

+ 12 - 5
libtest/gearmand.cc

@@ -69,11 +69,7 @@ class Gearmand : public libtest::Server
 {
 private:
 public:
-  Gearmand(const std::string& host_arg, in_port_t port_arg) :
-    libtest::Server(host_arg, port_arg, GEARMAND_BINARY, true)
-  {
-    set_pid_file();
-  }
+  Gearmand(const std::string& host_arg, in_port_t port_arg, const char* binary= GEARMAND_BINARY);
 
   bool ping()
   {
@@ -149,6 +145,12 @@ public:
   bool build(size_t argc, const char *argv[]);
 };
 
+Gearmand::Gearmand(const std::string& host_arg, in_port_t port_arg, const char* binary_arg) :
+  libtest::Server(host_arg, port_arg, binary_arg, true)
+{
+  set_pid_file();
+}
+
 bool Gearmand::build(size_t argc, const char *argv[])
 {
   if (getuid() == 0 or geteuid() == 0)
@@ -173,4 +175,9 @@ libtest::Server *build_gearmand(const char *hostname, in_port_t try_port)
   return new Gearmand(hostname, try_port);
 }
 
+libtest::Server *build_gearmand(const char *hostname, in_port_t try_port, const char* binary)
+{
+  return new Gearmand(hostname, try_port, binary);
+}
+
 }

+ 2 - 0
libtest/gearmand.h

@@ -44,4 +44,6 @@ namespace libtest {
 
 libtest::Server *build_gearmand(const char *hostname, in_port_t try_port);
 
+libtest::Server *build_gearmand(const char *hostname, in_port_t try_port, const char* binary);
+
 }

+ 10 - 0
libtest/server_container.cc

@@ -196,6 +196,16 @@ bool server_startup(server_startup_st& construct, const std::string& server_type
         }
       }
     }
+    else if (server_type.compare("hostile-gearmand") == 0)
+    {
+      if (GEARMAND_BINARY)
+      {
+        if (HAVE_LIBGEARMAN)
+        {
+          server= build_gearmand("localhost", try_port, "gearmand/hostile_gearmand");
+        }
+      }
+    }
     else if (server_type.compare("drizzled") == 0)
     {
       if (DRIZZLED_BINARY)

+ 11 - 0
tests/stress_worker.cc

@@ -59,6 +59,8 @@ using namespace libtest;
 
 #define WORKER_FUNCTION_NAME "foo"
 
+static in_port_t hostile_server= 0;
+
 struct client_thread_context_st
 {
   size_t count;
@@ -405,6 +407,15 @@ static void *world_create(server_startup_st& servers, test_return_t& error)
     return NULL;
   }
 
+#if defined(HAVE_LIBHOSTILE) && HAVE_LIBHOSTILE
+  hostile_server= libtest::get_free_port();
+  if (server_startup(servers, "gearmand", hostile_server, 0, NULL) == false)
+  {
+    error= TEST_FAILURE;
+    return NULL;
+  }
+#endif
+
   return new worker_handles_st;
 }