Bug 1068989 - Make talos use mozversion;r=jmaher
authorWilliam Lachance <wlachance@mozilla.com>
Tue, 21 Oct 2014 13:27:04 -0400
changeset 812 e2ca7449db07
parent 811 a2a867ca69ab
child 813 ae356cdd2e37
push id535
push userwlachance@mozilla.com
push dateTue, 21 Oct 2014 20:23:39 +0000
reviewersjmaher
bugs1068989
Bug 1068989 - Make talos use mozversion;r=jmaher
create_talos_zip.py
setup.py
talos/PerfConfigurator.py
talos/ffsetup.py
talos/getInfo.html
talos/run_tests.py
--- a/create_talos_zip.py
+++ b/create_talos_zip.py
@@ -16,23 +16,24 @@ import tempfile
 import urllib2
 import zipfile
 
 # globals
 here = os.path.dirname(os.path.abspath(__file__))
 dest = os.path.join(here, 'talos')
 
 mozbase_packages = [ ('mozcrash', '0.13'),
-                     ('mozdevice', '0.26'),
+                     ('mozdevice', '0.40'),
                      ('mozfile', '1.1'),
                      ('mozhttpd', '0.5'),
                      ('mozinfo', '0.7'),
                      ('mozlog', '2.6'),
                      ('moznetwork', '0.24'),
-                     ('mozprocess', '0.13') ]
+                     ('mozprocess', '0.21'),
+                     ('mozversion', '0.8') ]
 
 # datazilla client dependency
 datazilla_client = [('https://raw.github.com/mozilla/datazilla_client/master/dzclient/client.py',
                      'dzclient.py')]
 
 # PyYAML dependency
 yaml_src = 'http://pyyaml.org/export/360/pyyaml/trunk/lib/yaml/'
 yaml_files = ['composer.py',
--- a/setup.py
+++ b/setup.py
@@ -5,26 +5,27 @@ try:
     here = os.path.dirname(os.path.abspath(__file__))
     description = file(os.path.join(here, 'README.txt')).read()
 except IOError, OSError:
     description = ''
 
 version = "0.0"
 
 dependencies = ['PyYAML',
-                'mozlog == 1.5',
-                'mozcrash == 0.9',
-                'mozdevice == 0.26',
+                'mozlog == 2.6',
+                'mozcrash == 0.13',
+                'mozdevice == 0.40',
                 'mozfile == 1.1',
                 'mozhttpd == 0.5',
                 'mozinfo == 0.7',
                 'datazilla == 1.4',
                 'moznetwork == 0.24',
-                'mozprocess == 0.13',
+                'mozprocess == 0.21',
                 'mozinstall == 1.6',
+                'mozversion == 0.8',
                 'httplib2',
                 'oauth2',
                 'cache_flusher == 1.0.4'
                 ]
 dependency_links = []
 
 setup(name='talos',
       version=version,
--- a/talos/PerfConfigurator.py
+++ b/talos/PerfConfigurator.py
@@ -421,16 +421,21 @@ the highest value.
         return Configuration.__call__(self, *args)
 
     def validate(self):
         """validate and finalize configuration"""
 
         self.config['remote'] = self.remote
 
         if self.remote:
+            if not self.config.get('develop') and \
+               not self.config.get('apk_path'):
+                raise ConfigurationError("Must specify --apkPath on remote "
+                                         "if not in development mode")
+
             # setup remote
             deviceip = self.config.get('deviceip')
             deviceport = self.config['deviceport']
             if deviceip or deviceport == -1:
                 self._setupRemote(deviceip, deviceport)
 
             # fix webserver for --develop mode
             if self.config.get('develop'):
@@ -901,17 +906,18 @@ the highest value.
                     'fennecIDs': '',
                     'repository': None,
                     'sourcestamp': None,
                     'symbols_path': None,
                     'test_name_extension': '',
                     'test_timeout': 1200,
                     'webserver': '',
                     'xperf_path': None,
-                    'error_filename': None
+                    'error_filename': None,
+                    'apk_path': None
                     }
         browser_config = dict(title=title)
         browser_config.update(dict([(i, self.config[i]) for i in required]))
         browser_config.update(dict([(i, self.config.get(i, j)) for i, j in optional.items()]))
         return browser_config
 
     def _setupRemote(self, deviceip, deviceport):
 
--- a/talos/ffsetup.py
+++ b/talos/ffsetup.py
@@ -3,16 +3,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 """A set of functions to set up a browser with the correct
    preferences and extensions in the given directory.
 
 """
 
 import mozfile
+import mozversion
 import os
 import os.path
 import re
 import shutil
 import tempfile
 import time
 import glob
 import zipfile
@@ -227,17 +228,16 @@ class FFSetup(object):
             is run with a new profile.
             Returns 1 (success) if PROFILE_REGEX is found,
             and 0 (failure) otherwise
 
         Args:
             browser_config: object containing all the browser_config options
             profile_dir: The full path to the profile directory to load
         """
-        INFO_REGEX = re.compile('__browserInfo(.*)__browserInfo', re.DOTALL|re.MULTILINE)
         PROFILE_REGEX = re.compile('__metrics(.*)__metrics', re.DOTALL|re.MULTILINE)
 
         command_args = utils.GenerateBrowserCommandLine(browser_config["browser_path"],
                                                         browser_config["extra_args"],
                                                         browser_config["deviceroot"],
                                                         profile_dir,
                                                         browser_config["init_url"])
 
@@ -251,28 +251,28 @@ class FFSetup(object):
             self.ffprocess.runProgram(browser_config, command_args, timeout=1200)
 
         res = 0
         if not os.path.isfile(browser_config['browser_log']):
             raise TalosError("initalization has no output from browser")
         results_file = open(browser_config['browser_log'], "r")
         results_raw = results_file.read()
         results_file.close()
+
         match = PROFILE_REGEX.search(results_raw)
         if match:
             res = 1
         else:
             utils.info("Could not find %s in browser_log: %s", PROFILE_REGEX.pattern, browser_config['browser_log'])
             utils.info("Raw results:%s", results_raw)
             utils.info("Initialization of new profile failed")
-        match = INFO_REGEX.search(results_raw)
-        if match:
-            binfo = match.group(1)
-            print binfo
-            for line in binfo.split('\n'):
-                if line.strip().startswith('browser_name'):
-                    browser_config['browser_name'] = line.split(':')[1]
-                if line.strip().startswith('browser_version'):
-                    browser_config['browser_version'] = line.split(':')[1]
-                if line.strip().startswith('buildID'):
-                    browser_config['buildid'] = line.split(':')[1]
+
+        binary = browser_config.get("apk_path")
+        if not binary:
+            binary = browser_config["browser_path"]
+        version_info = mozversion.get_version(binary=binary)
+        browser_config['browser_name'] = version_info['application_name']
+        browser_config['browser_version'] = version_info['application_version']
+        browser_config['buildid'] = version_info['application_buildid']
+        browser_config['repository'] = version_info['application_repository']
+        browser_config['sourcestamp'] = version_info['application_changeset']
 
         return res
--- a/talos/getInfo.html
+++ b/talos/getInfo.html
@@ -2,69 +2,20 @@
    - 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/.  -->
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
   <meta charset="utf-8">
   <head>
     <script language="Javascript" type="text/javascript" src="scripts/MozillaFileLogger.js"></script>
     <script language="Javascript" type="text/javascript" src="page_load_test/quit.js"></script>
-    <script>
-
-  function setup() {
-    var id;
-    var version;
-    var buildid;
-
-    if (!useSpecialPowers) {
-      try {
-        netscape.security.PrivilegeManager.enablePrivilege('UniversalPreferencesRead UniversalPreferencesWrite UniversalXPConnect');
-        var appInfo = Components.classes['@mozilla.org/xre/app-info;1']
-                                .getService(Components.interfaces.nsIXULAppInfo);
-
-        //NOTE: version and buildid work fine, but appInfo.ID throws an exception on XUL Fennec, so we need to do that last.
-        version = appInfo.version;
-        buildid = appInfo.appBuildID;
-        id = appInfo.ID;
-      } catch(err) {
-          dumpLog('exception getting privileged access, defaulting to XUL_FENNEC');
-          id = '{a23983c0-fd0e-11dc-95ff-0800200c9a66}';
-      }
-    } else {
-      id = SpecialPowers.ID;
-      if (id == null) {
-          id = '{a23983c0-fd0e-11dc-95ff-0800200c9a66}';
-      }
-      version = SpecialPowers.Version;
-      buildid = SpecialPowers.BuildID;
-    }
-    return [id, version, buildid]
-  }
-    </script>
     <title>shutdown script</title>
   </head>
 
   <body onload="
-    var appinfo = setup();
-    var id = appinfo[0];
-    var version = appinfo[1];
-    var buildid = appinfo[2];
-
-    var productid = [];
-    productid['{ec8030f7-c20a-464f-9b0e-13a3a9e97384}'] = 'Firefox';
-    productid['{99bceaaa-e3c6-48c1-b981-ef9b46b67d60}'] = 'Firefox';
-    productid['{3550f703-e582-4d05-9a08-453d09bdfdc6}'] = 'Thunderbird';
-    productid['{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}'] = 'SeaMonkey';
-    productid['{aa3c5121-dab2-40e2-81ca-7ea25febc110}'] = 'Fennec';
-    productid['{a23983c0-fd0e-11dc-95ff-0800200c9a66}'] = 'Fennec';
-
-    var product = productid[id];
-
-    dumpLog('__browserInfo\nbrowser_name:' + product + '\nbrowser_version:' + version + '\nbuildID:' + buildid + '\n__browserInfo');
-
     dumpLog('__metrics\tScreen width/height:' + screen.width + '/' + screen.height + '\n\tcolorDepth:' + screen.colorDepth + '\n');
     dumpLog('\tBrowser inner width/height: ' + window.innerWidth + '/' + window.innerHeight + '\n');
 //JMAHER: this is temporarily commented out because this hangs the fennec browser
 //  dumpLog('\tBrowser outer width/height: ' + window.outerWidth + '/' + window.outerHeight);
     dumpLog('__metrics\n');
     goQuitApplication();
     window.close();
 ">
--- a/talos/run_tests.py
+++ b/talos/run_tests.py
@@ -1,15 +1,14 @@
 #!/usr/bin/env python
 
 # 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/.
 
-import ConfigParser
 import filter
 import os
 import PerfConfigurator
 import sys
 import time
 import traceback
 import urllib
 import urlparse
@@ -17,68 +16,16 @@ import utils
 
 from results import TalosResults
 from ttest import TTest
 from utils import TalosError, TalosCrash, TalosRegression
 
 # directory of this file
 here = os.path.dirname(os.path.realpath(__file__))
 
-def browserInfo(browser_config, devicemanager=None):
-    """Get the buildid and sourcestamp from the application.ini (if it exists)"""
-    # XXX this should probably be moved to PerfConfigurator.py
-
-    config = ConfigParser.RawConfigParser()
-    appIniFileName = "application.ini"
-    bpath = os.path.dirname(browser_config['browser_path'])
-    if bpath.endswith('MacOS'):
-        # OSX bundle structure changed in bug 1053820
-        if not os.path.exists(os.path.join(bpath, appIniFileName)):
-            bpath = os.path.join(os.path.dirname(bpath), 'Resources')
-    appIniPath = os.path.join(bpath, appIniFileName)
-
-    # keys for various browser info
-    keys = {'buildid': ('App', 'BuildID'),
-            'repository': ('App', 'SourceRepository'),
-            'sourcestamp': ('App', 'SourceStamp'),
-            'browser_name': ('App', 'Name'),
-            'browser_version': ('App', 'Version')}
-
-    # fetch application.ini from remote
-    if devicemanager:
-        if not os.path.isfile('remoteapp.ini'):
-            if browser_config['browser_path'].startswith('org.mozilla.f'): # mobile Firefox/fennec
-                remoteAppIni = '/data/data/%s/%s' % (browser_config['browser_path'], appIniFileName)
-            else:
-                remoteAppIni = '/%s/%s' % (browser_config['deviceroot'], appIniFileName)
-            devicemanager.getFile(remoteAppIni, 'remoteapp.ini')
-        appIniPath = 'remoteapp.ini'
-
-    if not os.path.isfile(appIniPath):
-        raise TalosError("Could not read application information from file "
-                         "'%s'" % appIniPath)
-
-    # read from application.ini
-    config.read(appIniPath)
-
-    # fill out browser_config data
-    for key in keys:
-        value = browser_config.get(key)
-        if not value:
-            browser_config[key] = config.get(*keys[key])
-            utils.info("Reading '%s' from %s => %s", key, appIniPath,
-                       browser_config[key])
-        # we should have a value that is not None or a blank string for
-        # the key at this point
-        if not browser_config[key]:
-            raise TalosError("Key '%s' should be specified in browser_config, "
-                             "was not" % browser_config[key])
-
-    return browser_config
-
 def useBaseTestDefaults(base, tests):
     for test in tests:
         for item in base:
             if not item in test:
                 test[item] = base[item]
                 if test[item] is None:
                     test[item] = ''
     return tests
@@ -237,23 +184,16 @@ def run_tests(configurator):
     # get test date in seconds since epoch
     if testdate:
         date = int(time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT')))
     else:
         date = int(time.time())
     utils.debug("using testdate: %d", date)
     utils.debug("actual date: %d", int(time.time()))
 
-    # pull buildid & sourcestamp from browser
-    try:
-        browser_config = browserInfo(browser_config, devicemanager=dm)
-    except:
-        if not browser_config['develop']:
-            raise
-
     if browser_config['remote']:
         procName = browser_config['browser_path'].split('/')[-1]
         if dm.processExist(procName):
             dm.killProcess(procName)
 
     # results container
     talos_results = TalosResults(title=title,
                                  date=date,