Browse Source

Merge pull request #1883 from nbrady-techempower/toolset-clean-option

Added the --clean results option to the toolset
Mike Smith 9 years ago
parent
commit
7ab01e72d7

+ 2 - 0
benchmark.cfg.example

@@ -28,3 +28,5 @@ sleep=60
 test=None
 test=None
 type=all
 type=all
 verbose=True
 verbose=True
+clean=False
+clean_all=False

+ 9 - 0
toolset/benchmark/benchmarker.py

@@ -9,6 +9,7 @@ from utils import gather_frameworks
 from utils import verify_database_connections
 from utils import verify_database_connections
 
 
 import os
 import os
+import shutil
 import stat
 import stat
 import json
 import json
 import subprocess
 import subprocess
@@ -963,8 +964,16 @@ class Benchmarker:
 
 
     # setup results and latest_results directories 
     # setup results and latest_results directories 
     self.result_directory = os.path.join("results", self.name)
     self.result_directory = os.path.join("results", self.name)
+    if args['clean'] or args['clean_all']:
+        shutil.rmtree(os.path.join(self.fwroot, "results"))
     self.latest_results_directory = self.latest_results_directory()
     self.latest_results_directory = self.latest_results_directory()
   
   
+    # remove installs directories if --clean-all provided
+    self.install_root = "%s/%s" % (self.fwroot, "installs")
+    if args['clean_all']:
+        os.system("rm -rf " + self.install_root)
+        os.mkdir(self.install_root)
+
     if hasattr(self, 'parse') and self.parse != None:
     if hasattr(self, 'parse') and self.parse != None:
       self.timestamp = self.parse
       self.timestamp = self.parse
     else:
     else:

+ 2 - 0
toolset/benchmark/framework_test.py

@@ -188,6 +188,8 @@ class FrameworkTest:
                 max(self.benchmarker.concurrency_levels)))
                 max(self.benchmarker.concurrency_levels)))
 
 
     # Always ensure that IROOT belongs to the runner_user
     # Always ensure that IROOT belongs to the runner_user
+    if not os.path.exists(self.install_root):
+      os.mkdir(self.install_root)
     chown = "sudo chown -R %s:%s %s" % (self.benchmarker.runner_user,
     chown = "sudo chown -R %s:%s %s" % (self.benchmarker.runner_user,
       self.benchmarker.runner_user, os.path.join(self.fwroot, self.install_root))
       self.benchmarker.runner_user, os.path.join(self.fwroot, self.install_root))
     subprocess.check_call(chown, shell=True, cwd=self.fwroot, executable='/bin/bash')
     subprocess.check_call(chown, shell=True, cwd=self.fwroot, executable='/bin/bash')

+ 2 - 0
toolset/run-tests.py

@@ -146,6 +146,8 @@ def main(argv=None):
         help='''Affects : With unified, all server software is installed into a single directory. 
         help='''Affects : With unified, all server software is installed into a single directory. 
         With pertest each test gets its own installs directory, but installation takes longer''')
         With pertest each test gets its own installs directory, but installation takes longer''')
     parser.add_argument('--install-only', action='store_true', default=False, help='Do not run benchmark or verification, just install and exit')
     parser.add_argument('--install-only', action='store_true', default=False, help='Do not run benchmark or verification, just install and exit')
+    parser.add_argument('--clean', action='store_true', default=False, help='Removes the results directory')
+    parser.add_argument('--clean-all', action='store_true', dest='clean_all', default=False, help='Removes the results and installs directories')
 
 
     # Test options
     # Test options
     parser.add_argument('--test', nargs='+', help='names of tests to run')
     parser.add_argument('--test', nargs='+', help='names of tests to run')