Bug 1342828 - Support chunks in mozmill tests. r=philipp
authorTom Prince <tom.prince@ualberta.net>
Sat, 10 Jun 2017 23:17:00 +0200
changeset 28335 aa78e5d5dc26d9cda6e983589ccb98a7a94054be
parent 28334 abde13d46a5275e1f1b20eb156de7833a1f9d69e
child 28336 36e37076b1b36bb009b6f64a36e77a74e2ee1387
push id1986
push userclokep@gmail.com
push dateWed, 02 Aug 2017 14:43:31 +0000
treeherdercomm-beta@b51c9adf2c9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp
bugs1342828
Bug 1342828 - Support chunks in mozmill tests. r=philipp
mail/test/mozmill/runtestlist.py
--- a/mail/test/mozmill/runtestlist.py
+++ b/mail/test/mozmill/runtestlist.py
@@ -33,16 +33,25 @@ class RunTestListOptions(optparse.Option
                         help = "Directory of the tests, leave blank for current directory")
         defaults["dir"] = ""
 
         self.add_option("--symbols-path",
                         action = "store", type = "string", dest = "symbols",
                         help = "The path to the symbol files from build_symbols")
         defaults["symbols"] = ""
 
+        self.add_option("--total-chunks",
+                        action = "store", type = "int", dest = "total_chunks",
+                        help="how many chunks to split the tests up into")
+        defaults["total_chunks"] = 1
+        self.add_option("--this-chunk",
+                        action = "store", type = "int", dest = "this_chunk",
+                        help="which chunk to run between 1 and --total-chunks")
+        defaults["this_chunk"] = 1
+
         self.add_option("--plugins-path",
                         action = "store", type = "string", dest = "plugins",
                         help = "The path to the plugins folder for the test profiles")
 
         self.add_option("--testing-modules-dir",
                         action="store", type="string", dest="testingmodules",
                         help="The path to the testing modules directory")
         defaults["testingmodules"] = ""
@@ -65,18 +74,27 @@ options, args = parser.parse_args()
 if options.binary == "" or options.list == "":
     parser.print_help()
     sys.exit(1)
 
 totalTestErrors = 0
 totalTestPasses = 0
 totalDirectories = 0
 
-f = open(options.list, 'rt')
-for directory in f:
+tests = open(options.list, "rt").readlines()
+
+if options.total_chunks > 1:
+    tests_per_chunk = float(len(tests)) / options.total_chunks
+    start = int(round((options.this_chunk - 1) * tests_per_chunk))
+    end = int(round(options.this_chunk * tests_per_chunk))
+
+    tests = (t for t in tests[start:end])
+
+
+for directory in tests:
     log.info("INFO | (runtestlist.py) | Running directory: %s",
              directory.rstrip())
     if options.dir != "":
         testDirectory = os.path.join(options.dir, directory.rstrip())
     else:
         testDirectory = directory.rstrip()
     args = [sys.executable, "runtest.py", "-t", testDirectory,
             "--binary", os.path.abspath(options.binary), "--symbols-path", options.symbols]