diff --git a/mozilla/testing/performance/talos/PerfConfigurator.py b/mozilla/testing/performance/talos/PerfConfigurator.py index ddb65f1731a..3644b6e0823 100644 --- a/mozilla/testing/performance/talos/PerfConfigurator.py +++ b/mozilla/testing/performance/talos/PerfConfigurator.py @@ -26,7 +26,7 @@ defaultTitle = "qm-pxp01" help_message = ''' This is the buildbot performance runner's YAML configurator.bean -USAGE: python PerfConfigurator.py --title title --executablePath path --configFilePath cpath --buildid id --branch branch --testDate date --resultsServer server --resultsLink link --activeTests testlist --branchName branchFullName --fast --symbolsPath path --sampleConfig cfile --browserWait seconds --remoteDevice ip_of_device --remotePort port_on_device --webServer webserver_ipaddr --deviceRoot rootdir_on_device +USAGE: python PerfConfigurator.py --title title --executablePath path --configFilePath cpath --buildid id --branch branch --testDate date --resultsServer server --resultsLink link --activeTests testlist --branchName branchFullName --fast --symbolsPath path --sampleConfig cfile --browserWait seconds --remoteDevice ip_of_device --remotePort port_on_device --webServer webserver_ipaddr --deviceRoot rootdir_on_device --testPrefix prefix --extension addon example testlist: tp:tsspider:tdhtml:twinopen ''' @@ -50,11 +50,13 @@ class PerfConfigurator: activeTests = '' noChrome = False fast = False + testPrefix = '' remoteDevice = '' webServer = '' deviceRoot = '' _remote = False port = '' + extension = '' def _setupRemote(self, host, port = 20701): import devicemanager @@ -78,6 +80,8 @@ class PerfConfigurator: print " - resultsServer = " + self.resultsServer print " - resultsLink = " + self.resultsLink print " - activeTests = " + self.activeTests + print " - extension = " + self.extension + print " - testPrefix = " + self.testPrefix if (self._remote == True): print " - deviceIP = " + self.remoteDevice print " - devicePort = " + self.port @@ -180,6 +184,8 @@ class PerfConfigurator: newline = 'deviceroot: %s\n' % self.deviceRoot if 'deviceport:' in line: newline = 'deviceport: %s\n' % self.port + if self.extension and ('extensions : {}' in line): + newline = 'extensions: ' + '\n- ' + self.extension if 'remote:' in line: newline = 'remote: %s\n' % self._remote if 'buildid:' in line: @@ -217,6 +223,8 @@ class PerfConfigurator: printMe = True if (test == 'tp') and self.fast: #only affects the tp test name newline = newline.replace('tp', 'tp_fast') + if self.testPrefix: + newline = newline.replace(test, self.testPrefix + '_' + test) if self.noChrome: #if noChrome is True remove --tpchrome option newline = line.replace('-tpchrome ','') @@ -272,6 +280,10 @@ class PerfConfigurator: self.webServer = kwargs['webServer'] if 'deviceRoot' in kwargs: self.deviceRoot = kwargs['deviceRoot'] + if 'testPrefix' in kwargs: + self.testPrefix = kwargs['testPrefix'] + if 'extension' in kwargs: + self.extension = kwargs['extension'] if 'remotePort' in kwargs: self.port = kwargs['remotePort'] @@ -315,6 +327,8 @@ def main(argv=None): remotePort = '' webServer = 'localhost' deviceRoot = '' + testPrefix = '' + extension = '' if argv is None: argv = sys.argv @@ -325,7 +339,7 @@ def main(argv=None): "configFilePath=", "sampleConfig=", "title=", "branch=", "output=", "id=", "testDate=", "browserWait=", "resultsServer=", "resultsLink=", "activeTests=", - "noChrome", "branchName=", "fast", "symbolsPath=", + "noChrome", "testPrefix=", "extension=", "branchName=", "fast", "symbolsPath=", "remoteDevice=", "remotePort=", "webServer=", "deviceRoot="]) except getopt.error, msg: raise Usage(msg) @@ -366,6 +380,10 @@ def main(argv=None): activeTests = value if option in ("-n", "--noChrome"): noChrome = True + if option in ("--testPrefix",): + testPrefix = value + if option in ("--extension",): + extension = value if option in ("-r", "--remoteDevice"): remoteDevice = value if option in ("-p", "--remotePort"): @@ -409,6 +427,8 @@ def main(argv=None): activeTests=activeTests, noChrome=noChrome, fast=fast, + testPrefix=testPrefix, + extension=extension, symbolsPath=symbolsPath, remoteDevice=remoteDevice, remotePort=remotePort, diff --git a/mozilla/testing/performance/talos/ffsetup.py b/mozilla/testing/performance/talos/ffsetup.py index 78d9e7ab0e3..d944be7a24b 100644 --- a/mozilla/testing/performance/talos/ffsetup.py +++ b/mozilla/testing/performance/talos/ffsetup.py @@ -51,6 +51,9 @@ import shutil import tempfile import time import glob +import zipfile +from xml.dom import minidom +import shutil import utils from utils import talosError @@ -97,6 +100,51 @@ class FFSetup(object): out_value = '"%s"' % value return 'user_pref("%s", %s);%s' % (name, out_value, newline) + def install_addon(self, profile_path, addon): + """Installs the given addon in the profile. + most of this borrowed from mozrunner, except downgraded to work on python 2.4 + # Contributor(s) for mozrunner: + # Mikeal Rogers + # Clint Talbert + # Henrik Skupin + """ + tmpdir = None + addon_id = '' + tmpdir = tempfile.mkdtemp(suffix = "." + os.path.split(addon)[-1]) + compressed_file = zipfile.ZipFile(addon, "r") + #in python2.6 can use extractall, currently limited to python2.4 + for name in compressed_file.namelist(): + if name.endswith('/'): + os.makedirs(os.path.join(tmpdir, name)) + else: + if not os.path.isdir(os.path.dirname(os.path.join(tmpdir, name))): + os.makedirs(os.path.dirname(os.path.join(tmpdir, name))) + data = compressed_file.read(name) + f = open(os.path.join(tmpdir, name), 'w') + f.write(data) ; f.close() + addon = tmpdir + + doc = minidom.parse(os.path.join(addon, 'install.rdf')) + # description_element = + # tree.find('.//{http://www.w3.org/1999/02/22-rdf-syntax-ns#}Description/') + + desc = doc.getElementsByTagName('Description') + for elem in desc: + apps = elem.getElementsByTagName('em:targetApplication') + if apps: + for app in apps: + #remove targetApplication nodes, they contain id's we aren't interested in + elem.removeChild(app) + addon_id = str(elem.getElementsByTagName('em:id')[0].firstChild.data) + + if not addon_id: #bail out, we don't have an addon id + raise talosError("no addon_id found for extension") + + addon_path = os.path.join(profile_path, 'extensions', addon_id) + #if an old copy is already installed, remove it + if os.path.isdir(addon_path): + shutil.rmtree(addon_path, ignore_errors=True) + shutil.move(addon, addon_path) def CreateTempProfileDir(self, source_profile, prefs, extensions): """Creates a temporary profile directory from the source profile directory @@ -107,8 +155,7 @@ class FFSetup(object): directory to copy from. prefs: Preferences to set in the prefs.js file of the new profile. Format: {"PrefName1" : "PrefValue1", "PrefName2" : "PrefValue2"} - extensions: Guids and paths of extensions to link to. Format: - {"{GUID1}" : "c:\\Path\\to\\ext1", "{GUID2}", "c:\\Path\\to\\ext2"} + extensions: list of paths to .xpi files to be installed Returns: String containing the absolute path of the profile directory. @@ -136,10 +183,8 @@ class FFSetup(object): extension_dir = os.path.join(profile_dir, "extensions") if not os.path.exists(extension_dir): os.makedirs(extension_dir) - for extension in extensions: - link_file = open(os.path.join(extension_dir, extension), 'w') - link_file.write(extensions[extension]) - link_file.close() + for addon in extensions: + self.install_addon(profile_dir, addon) if (self._remoteWebServer <> 'localhost'): remote_dir = self.ffprocess.copyDirToDevice(profile_dir)