Browse Source

Minor changes

Hamilton Turner 10 years ago
parent
commit
44ea3d6bb9

+ 4 - 2
toolset/benchmark/framework_test.py

@@ -302,6 +302,7 @@ class FrameworkTest:
     def verify_type(test_type):
     def verify_type(test_type):
       
       
       test = self.runTests[test_type]
       test = self.runTests[test_type]
+      test.setup_out_err(out, err)
       out.write(header("VERIFYING %s" % test_type.upper()))
       out.write(header("VERIFYING %s" % test_type.upper()))
       
       
       base_url = "http://%s:%s" % (self.benchmarker.server_host, self.port)
       base_url = "http://%s:%s" % (self.benchmarker.server_host, self.port)
@@ -532,6 +533,7 @@ class FrameworkTest:
       out.write("BENCHMARKING %s ... " % test_type.upper())
       out.write("BENCHMARKING %s ... " % test_type.upper())
 
 
       test = self.runTests[test_type]
       test = self.runTests[test_type]
+      test.setup_out_err(out, err)
       output_file = self.benchmarker.output_file(self.name, test_type)
       output_file = self.benchmarker.output_file(self.name, test_type)
       if not os.path.exists(output_file):
       if not os.path.exists(output_file):
         # Open to create the empty file
         # Open to create the empty file
@@ -949,8 +951,8 @@ class FrameworkTest:
   # Starts a thread to monitor the resource usage, to be synced with the client's time
   # Starts a thread to monitor the resource usage, to be synced with the client's time
   # TODO: MySQL and InnoDB are possible. Figure out how to implement them.
   # TODO: MySQL and InnoDB are possible. Figure out how to implement them.
   ############################################################
   ############################################################
-  def __begin_logging(self, test_name):
-    output_file = "{file_name}".format(file_name=self.benchmarker.get_stats_file(self.name, test_name))
+  def __begin_logging(self, test_type):
+    output_file = "{file_name}".format(file_name=self.benchmarker.get_stats_file(self.name, test_type))
     dstat_string = "dstat -afilmprsT --aio --fs --ipc --lock --raw --socket --tcp \
     dstat_string = "dstat -afilmprsT --aio --fs --ipc --lock --raw --socket --tcp \
                                       --raw --socket --tcp --udp --unix --vm --disk-util \
                                       --raw --socket --tcp --udp --unix --vm --disk-util \
                                       --rpc --rpcd --output {output_file}".format(output_file=output_file)
                                       --rpc --rpcd --output {output_file}".format(output_file=output_file)

+ 9 - 7
toolset/benchmark/test_types/framework_test_type.py

@@ -1,4 +1,5 @@
 import copy
 import copy
+import sys
 import subprocess
 import subprocess
 from subprocess import PIPE
 from subprocess import PIPE
 
 
@@ -22,8 +23,8 @@ class FrameworkTestType:
     self.name = name
     self.name = name
     self.requires_db = requires_db
     self.requires_db = requires_db
     self.args = args
     self.args = args
-    self.out = [] # You can use [sys.stdout] to tee
-    self.err = [] # [sys.stderr]
+    self.out = sys.stdout
+    self.err = sys.stderr
     self.accept_header = accept_header
     self.accept_header = accept_header
     if accept_header is None:
     if accept_header is None:
       self.accept_header = self.accept_plaintext
       self.accept_header = self.accept_plaintext
@@ -41,8 +42,8 @@ class FrameworkTestType:
     NOTE: I detest this. It would be much better to use
     NOTE: I detest this. It would be much better to use
     logging like it's intended
     logging like it's intended
     '''
     '''
-    self.out.append(out)
-    self.err.append(err)
+    self.out = out
+    self.err = err
   
   
   def parse(self, test_keys):
   def parse(self, test_keys):
     '''Takes the dict of key/value pairs describing a FrameworkTest 
     '''Takes the dict of key/value pairs describing a FrameworkTest 
@@ -64,14 +65,15 @@ class FrameworkTestType:
     # Use -sS to hide progress bar, but show errors.
     # Use -sS to hide progress bar, but show errors.
     p = subprocess.Popen(["curl", "-m", "15", "-i", "-sS", url], stderr=PIPE, stdout=PIPE)
     p = subprocess.Popen(["curl", "-m", "15", "-i", "-sS", url], stderr=PIPE, stdout=PIPE)
     (out, err) = p.communicate()
     (out, err) = p.communicate()
-    [item.write(err+'\n') for item in self.err]
-    [item.write(out+'\n') for item in self.out]
+    self.err.write(err+'\n')
+    self.out.write(out+'\n')
     if p.returncode != 0:
     if p.returncode != 0:
       return None
       return None
     # Get response body
     # Get response body
     p = subprocess.Popen(["curl", "-m", "15", "-s", url], stdout=PIPE, stderr=PIPE)
     p = subprocess.Popen(["curl", "-m", "15", "-s", url], stdout=PIPE, stderr=PIPE)
     (out, err) = p.communicate()
     (out, err) = p.communicate()
-    [item.write(err+'\n') for item in self.err]
+    self.err.write(err+'\n')
+    self.out.write(out+'\n')
     return out
     return out
   
   
   def verify(self, base_url):
   def verify(self, base_url):