Bug 1068989 - Allow specifying custom talos options in talos.json;r=kmoir
authorWilliam Lachance <wlachance@mozilla.com>
Tue, 23 Sep 2014 14:08:06 -0400
changeset 3203 2f7dc3cdef1d
parent 3201 f12caf1970aa
child 3204 1fc39400ae85
push id2447
push userwlachance@mozilla.com
push dateTue, 23 Sep 2014 18:08:19 +0000
reviewerskmoir
bugs1068989
Bug 1068989 - Allow specifying custom talos options in talos.json;r=kmoir
scripts/android_panda_talos.py
--- a/scripts/android_panda_talos.py
+++ b/scripts/android_panda_talos.py
@@ -3,24 +3,26 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 # ***** END LICENSE BLOCK *****
 
 import copy
 import getpass
 import os
+import pprint
 import sys
 import time
 import socket
 
 # load modules from parent dir
 sys.path.insert(1, os.path.dirname(sys.path[0]))
 
 from mozharness.mozilla.buildbot import BuildbotMixin
+from mozharness.base.config import parse_config_file
 from mozharness.base.log import INFO, FATAL
 from mozharness.base.vcs.vcsbase import MercurialScript
 from mozharness.mozilla.blob_upload import BlobUploadMixin, blobupload_config_options
 from mozharness.mozilla.testing.mozpool import MozpoolMixin
 from mozharness.mozilla.testing.device import SUTDeviceMozdeviceMixin
 from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options
 from mozharness.mozilla.testing.talos import TalosOutputParser, TalosErrorList
 
@@ -110,28 +112,49 @@ class PandaTalosTest(TestingMixin, Mercu
             config={'virtualenv_modules': self.virtualenv_modules})
 
         self.mozpool_assignee = self.config.get('mozpool_assignee', getpass.getuser())
         self.request_url = None
         self.test_url = self.config.get("test_url")
         self.mozpool_device = self.config.get("mozpool_device")
         self.talos_branch = self.config.get("talos_branch")
 
+        self.read_buildbot_config()
+        self.revision = self.config.get('revision',
+                                        self.buildbot_config.get('properties')["revision"])
+        self.repo_path = self.config.get('repo_path',
+                                         self.buildbot_config.get('properties')["repo_path"])
+        self.talos_json_url = (self.config.get("talos_json_url") % (self.repo_path, self.revision))
+        self.talos_json_config = None
+
     def postflight_read_buildbot_config(self):
         super(PandaTalosTest, self).postflight_read_buildbot_config()
         self.mozpool_device = self.config.get('mozpool_device', self.buildbot_config.get('properties')["slavename"])
         dirs = self.query_abs_dirs()
         #touch the shutdown file
         shutdown_file = os.path.join(dirs['shutdown_dir'], 'shutdown.stamp')
         try:
             self.info("*** Touching the shutdown file **")
             open(shutdown_file, 'w').close()
         except Exception, e:
             self.warning("We failed to create the shutdown file: str(%s)" % str(e))
 
+    def query_talos_json_config(self):
+        if self.talos_json_config:
+            return self.talos_json_config
+
+        dirs = self.query_abs_dirs()
+        self.talos_json = self.download_file(self.talos_json_url,
+                                             parent_dir=dirs['abs_talosdata_dir'],
+                                             error_level=FATAL)
+        self.talos_json_config = parse_config_file(self.talos_json)
+        self.info(pprint.pformat(self.talos_json_config))
+
+        return self.talos_json_config
+
     def request_device(self):
         self.retrieve_android_device(b2gbase="")
         env = self.query_env()
         cmd = [self.query_exe('python'), self.config.get("verify_path")]
         if self.run_command(cmd, env=env):
             self.critical("Preparing to abort run due to failed verify check.")
             self.close_request()
             self.fatal("Dying due to failing verification")
@@ -296,34 +319,30 @@ class PandaTalosTest(TestingMixin, Mercu
         self.symbols_url = self.query_symbols_url()
 
         self._download_unzip(self.symbols_url,
                              dirs['abs_symbols_dir'])
 
         self._download_unzip(self.config['retry_url'],
                              dirs['abs_talosdata_dir'])
 
-        revision = self.config.get('revision', self.buildbot_config.get('properties')["revision"])
-        repo_path = self.config.get('repo_path', self.buildbot_config.get('properties')["repo_path"])
         taloscode = self.config.get("talos_from_code_url")
-        talosjson = self.config.get("talos_json_url")
 
-        talos_from_code_url = (taloscode % (repo_path, revision))
-        talos_json_url = (talosjson % (repo_path, revision))
+        talos_from_code_url = (taloscode % (self.repo_path, self.revision))
 
         self.download_file(talos_from_code_url, file_name='talos_from_code.py',
                            parent_dir=dirs['abs_talosdata_dir'],
                            error_level=FATAL)
 
         talos_base_cmd = ['python']
         talos_code_path = (os.path.join(dirs['abs_talosdata_dir'], "talos_from_code.py"))
         talos_zip_path = (os.path.join(dirs['abs_talosdata_dir'], "talos.zip"))
         talos_base_cmd.append(talos_code_path)
         talos_base_cmd.append("--talos-json-url")
-        talos_base_cmd.append(talos_json_url)
+        talos_base_cmd.append(self.talos_json_url)
         env = self.query_env()
         self.run_command(talos_base_cmd, dirs['abs_talosdata_dir'], env=env, halt_on_failure=True, fatal_exit_code=3)
         unzip = self.query_exe("unzip")
         unzip_cmd = [unzip, '-q', '-o',  talos_zip_path]
         self.run_command(unzip_cmd, cwd=dirs['abs_talosdata_dir'], halt_on_failure=True, fatal_exit_code=3)
 
     def _query_abs_base_cmd(self, suite_category):
         dirs = self.query_abs_dirs()
@@ -349,16 +368,23 @@ class PandaTalosTest(TestingMixin, Mercu
         str_format_values = {
             'device_ip': self.device_ip,
             'hostname': self.mozpool_device,
             'http_port': http_port,
             'ssl_port':  ssl_port,
             'app_name':  self.app_name,
             'talos_branch':  self.talos_branch,
         }
+        talos_json_config = self.query_talos_json_config()
+        if talos_json_config.get('extra_options') and \
+           talos_json_config['extra_options'].get('android'):
+            for option in self.talos_json_config['extra_options']['android']:
+                options.append(option % {
+                    'apk_path': self.apk_path })
+
         if self.config['%s_options' % suite_category]:
             for option in self.config['%s_options' % suite_category]:
                 options.append(option % str_format_values)
             for url in self.config.get('datazilla_urls', []):
                 options.extend(['--datazilla-url', url])
             # add datazilla authfile
             authfile = self.config.get('datazilla_authfile')
             if authfile: