Browse Source

Merge branch 'selective_db_restart' of https://github.com/hamiltont/FrameworkBenchmarks into PR616

Conflicts:
	toolset/benchmark/benchmarker.py
	toolset/benchmark/framework_test.py
Mike Smith 11 years ago
parent
commit
0f6d254c17
2 changed files with 21 additions and 13 deletions
  1. 8 7
      toolset/benchmark/benchmarker.py
  2. 13 6
      toolset/benchmark/framework_test.py

+ 8 - 7
toolset/benchmark/benchmarker.py

@@ -566,13 +566,14 @@ class Benchmarker:
       """.format(name=test.name)) )
       out.flush()
       try:
-        p = subprocess.Popen(self.database_ssh_string, stdin=subprocess.PIPE, stdout=out, stderr=err, shell=True)
-        p.communicate("""
-          sudo restart mysql
-          sudo restart mongodb
-		      sudo /etc/init.d/postgresql restart
-        """)
-        time.sleep(10)
+        if test.requires_database():
+          p = subprocess.Popen(self.database_ssh_string, stdin=subprocess.PIPE, stdout=out, stderr=err, shell=True)
+          p.communicate("""
+            sudo restart mysql
+            sudo restart mongodb
+  		      sudo /etc/init.d/postgresql restart
+          """)
+          time.sleep(10)
 
         if self.__is_port_bound(test.port):
           self.__write_intermediate_results(test.name, "port " + str(test.port) + " is not available before start")

+ 13 - 6
toolset/benchmark/framework_test.py

@@ -535,17 +535,17 @@ class FrameworkTest:
   ############################################################
   def contains_type(self, type):
     try:
-      if type == self.JSON and self.json_url != None:
+      if type == self.JSON and self.json_url is not None:
         return True
-      if type == self.DB and self.db_url != None:
+      if type == self.DB and self.db_url is not None:
         return True
-      if type == self.QUERY and self.query_url != None:
+      if type == self.QUERY and self.query_url is not None:
         return True
-      if type == self.FORTUNE and self.fortune_url != None:
+      if type == self.FORTUNE and self.fortune_url is not None:
         return True
-      if type == self.UPDATE and self.update_url != None:
+      if type == self.UPDATE and self.update_url is not None:
         return True
-      if type == self.PLAINTEXT and self.plaintext_url != None:
+      if type == self.PLAINTEXT and self.plaintext_url is not None:
         return True
     except AttributeError:
       pass
@@ -925,6 +925,13 @@ class FrameworkTest:
   # End __curl_url
   ##############################################################
 
+  def requires_database(self):
+      """Returns True/False if this test requires a database"""
+      return (self.contains_type(self.FORTUNE) or 
+              self.contains_type(self.DATABASE) or 
+              self.contains_type(self.QUERY) or
+              self.contains_type(self.UPDATE))
+
   ##########################################################################################
   # Constructor
   ##########################################################################################