Bug 1352054 - Support mach awsy-test on Windows. r=erahm, r=jmaher, a=test-only
authorBob Clary <bclary@bclary.com>
Tue, 02 May 2017 20:49:57 -0400
changeset 396116 174b7b906a7cabc03c8856a6f44261437c0a7698
parent 396115 17b4e2a0ed3fe3e09e847cebe8d9f951d1d90443
child 396117 4bbb2460a2f506d0640ed919dbfd47422b95691d
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm, jmaher, test-only
bugs1352054
milestone54.0
Bug 1352054 - Support mach awsy-test on Windows. r=erahm, r=jmaher, a=test-only
testing/awsy/mach_commands.py
--- a/testing/awsy/mach_commands.py
+++ b/testing/awsy/mach_commands.py
@@ -3,18 +3,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, unicode_literals
 
 import argparse
 import os
 import sys
 
-import mozfile
-
 from mozbuild.base import (
     MachCommandBase,
     MachCommandConditions as conditions,
 )
 
 from mach.decorators import (
     CommandArgument,
     CommandArgumentGroup,
@@ -45,19 +43,21 @@ class MachCommands(MachCommandBase):
 
         from marionette_harness.runtests import (
             MarionetteTestRunner,
             MarionetteHarness
         )
 
         parser = setup_awsy_argument_parser()
 
+        awsy_source_dir = os.path.join(self.topsrcdir, 'testing', 'awsy')
         if not tests:
-            tests = [os.path.join(self.topsrcdir,
-                                  'testing/awsy/awsy/test_memory_usage.py')]
+            tests = [os.path.join(awsy_source_dir,
+                                  'awsy',
+                                  'test_memory_usage.py')]
 
         args = argparse.Namespace(tests=tests)
 
         args.binary = binary
 
         if kwargs['quick']:
             kwargs['entities'] = 3
             kwargs['iterations'] = 1
@@ -80,57 +80,63 @@ class MachCommands(MachCommandBase):
 
         if 'resultsDir' not in runtime_testvars:
             runtime_testvars['resultsDir'] = os.path.join(awsy_tests_dir,
                                                           'results')
         page_load_test_dir = os.path.join(web_root_dir, 'page_load_test')
         if not os.path.isdir(page_load_test_dir):
             os.makedirs(page_load_test_dir)
 
-        if not os.path.isdir(runtime_testvars["resultsDir"]):
-            os.makedirs(runtime_testvars["resultsDir"])
+        if not os.path.isdir(runtime_testvars['resultsDir']):
+            os.makedirs(runtime_testvars['resultsDir'])
 
         runtime_testvars_path = os.path.join(awsy_tests_dir, 'runtime-testvars.json')
         if kwargs['testvars']:
             kwargs['testvars'].append(runtime_testvars_path)
         else:
             kwargs['testvars'] = [runtime_testvars_path]
 
         runtime_testvars_file = open(runtime_testvars_path, 'wb')
         runtime_testvars_file.write(json.dumps(runtime_testvars, indent=2))
         runtime_testvars_file.close()
 
-        if not kwargs['webRootDir']:
-            # Populate the Awsy webroot if not specified by the user.
-            manifest_file = os.path.join(self.topsrcdir,
-                                         'testing',
-                                         'awsy',
-                                         'tp5n-pageset.manifest')
-            tooltool_args = {"args": [
-                os.path.join(self.topsrcdir, "taskcluster/docker/recipes/tooltool.py"),
-                "--manifest=%s" % manifest_file,
-                "--unpack",
-                "--cache-folder=%s" % os.path.join(self.topsrcdir, "tooltool-cache"),
-                "fetch"
-            ]}
-
-            self.run_process(cwd=page_load_test_dir, **tooltool_args)
-            tp5nzip = os.path.join(page_load_test_dir, 'tp5n.zip')
-            tp5nmanifest = os.path.join(page_load_test_dir, 'tp5n', 'tp5n.manifest')
-            if not os.path.exists(tp5nmanifest):
-                files = mozfile.extract_zip(tp5nzip, page_load_test_dir)
+        manifest_file = os.path.join(awsy_source_dir,
+                                     'tp5n-pageset.manifest')
+        tooltool_args = {'args': [
+            sys.executable,
+            os.path.join(self.topsrcdir,
+                         'taskcluster',
+                         'docker',
+                         'recipes',
+                         'tooltool.py'),
+            '--manifest=%s' % manifest_file,
+            '--cache-folder=%s' % os.path.join(self.topsrcdir, 'tooltool-cache'),
+            'fetch'
+        ]}
+        self.run_process(cwd=page_load_test_dir, **tooltool_args)
+        tp5nzip = os.path.join(page_load_test_dir, 'tp5n.zip')
+        tp5nmanifest = os.path.join(page_load_test_dir, 'tp5n', 'tp5n.manifest')
+        if not os.path.exists(tp5nmanifest):
+            unzip_args = {'args': [
+                'unzip',
+                '-q',
+                '-o',
+                tp5nzip,
+                '-d',
+                page_load_test_dir]}
+            self.run_process(**unzip_args)
 
         for k, v in kwargs.iteritems():
             setattr(args, k, v)
 
         parser.verify_usage(args)
 
-        args.logger = commandline.setup_logging("Are We Slim Yet Tests",
+        args.logger = commandline.setup_logging('Are We Slim Yet Tests',
                                                 args,
-                                                {"mach": sys.stdout})
+                                                {'mach': sys.stdout})
         failed = MarionetteHarness(MarionetteTestRunner, args=vars(args)).run()
         if failed > 0:
             return 1
         else:
             return 0
 
     @Command('awsy-test', category='testing',
         description='Run Are We Slim Yet (AWSY) memory usage testing using marionette.',
@@ -140,17 +146,17 @@ class MachCommands(MachCommandBase):
     @CommandArgument('--web-root', group='AWSY', action='store', type=str,
                      dest='webRootDir',
                      help='Path to web server root directory. If not specified, '
                      'defaults to topobjdir/_tests/awsy/html.')
     @CommandArgument('--page-manifest', group='AWSY', action='store', type=str,
                      dest='pageManifest',
                      help='Path to page manifest text file containing a list '
                      'of urls to test. The urls must be served from localhost. If not '
-                     'specified, defaults to page_load_test/tp5b/tp5n.manifest under '
+                     'specified, defaults to page_load_test/tp5n/tp5n.manifest under '
                      'the web root.')
     @CommandArgument('--results', group='AWSY', action='store', type=str,
                      dest='resultsDir',
                      help='Path to results directory. If not specified, defaults '
                      'to the parent directory of the web root.')
     @CommandArgument('--quick', group='AWSY', action='store_true',
                      dest='quick', default=False,
                      help='Set --entities=3, --iterations=1, --per-tab-pause=1, '
@@ -190,16 +196,26 @@ class MachCommands(MachCommandBase):
         awsy-test will automatically download the tp5n.zip talos
         pageset from tooltool and install it under
         topobjdir/_tests/awsy/html. You can specify your own page set
         by specifying --web-root and --page-manifest.
 
         The results of the test will be placed in the results
         directory specified by the --results argument.
 
+        On Windows, you may experience problems due to path length
+        errors when extracting the tp5n.zip file containing the
+        test pages or when attempting to write checkpoints to the
+        results directory. In that case, you should specify both
+        the --web-root and --results arguments pointing to a location
+        with a short path. For example:
+
+        --web-root=c:\\\\tmp\\\\html --results=c:\\\\tmp\\\\results
+
+        Note that the double backslashes are required.
         """
         kwargs['logger_name'] = 'Awsy Tests'
         if 'test_objects' in kwargs:
             tests = []
             for obj in kwargs['test_objects']:
                 tests.append(obj['file_relpath'])
             del kwargs['test_objects']