def __init__(self, os_name, browser_name, profiles, cmd, args_tuple=()): self.os_name = os_name self.browser_name = browser_name self.profiles = [] if type(profiles) != list: profiles = [profiles] for p in profiles: if type(p) == str: self.profiles.append({'path': p}) else: self.profiles.append(p) self.cmd = cmd self.cmd_args = tuple() self.args_tuple = args_tuple self.proc = None self.launch_time = None try: self.cmd = config.cfg.get(os_name, browser_name) except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): pass args = config.get_str(os_name, browser_name + "_args") if args is not None: self.cmd_args = tuple(args.split()) self.NameExtra = config.get_str(os_name, browser_name + "_suffix")
def __init__(self, os_name, browser_name, package='org.mozilla.fennec', activity='.App'): super(AndroidBrowserController, self).__init__(os_name, browser_name, "default", None) self.browserPackage = config.get_str('android', browser_name + '_package', package) self.browserActivity = config.get_str('android', browser_name + '_activity', activity) self.dm = createDeviceManager(packageName=package) self.remoteProfile = "%s/profile" % self.dm.getDeviceRoot() #TODO: pull this in from the conf file, we might want to specify something custom self.localProfile = "android_profile"
def __init__(self, os_name, browser_name, package='org.mozilla.fennec', activity='.App'): super(AndroidBrowserController, self).__init__(os_name, browser_name, "default", None) self.browserPackage = config.get_str('android', browser_name + '_package', package) self.browserActivity = config.get_str('android', browser_name + '_activity', activity) self.dm = createDeviceManager(packageName=package)
def main(): from optparse import OptionParser parser = OptionParser() parser.add_option('-f', '--config', dest='config_file', type='string', action='store', default=None, help='config file (default speedtests.conf)') parser.add_option('-t', '--test', dest='tests', action='append', default=[]) parser.add_option('-n', '--noresults', dest='noresults', action='store_true') parser.add_option('-v', '--verbose', dest='verbose', action='count') parser.add_option('--ignore', dest='ignore', action='store_true', help='instruct server to ignore results') parser.add_option('--client', dest='client', type='string', action='store', help='override client name reported to server') parser.add_option('--platform', dest='platform', type='string', action='store', help='override detected platform') parser.add_option('--port', dest='local_port', type='int', action='store', help='override local_port') parser.add_option('--cycles', dest='cycles', type='int', default=1, action='store', help='number of cycles to run, default 1, -1 to run forever') parser.add_option('--forever', dest='cycles', const=-1, action='store_const', help='run forever') parser.add_option('--nap-after', dest='nap_after', type='int', action='store', help='take a break after this many cycles (0=never)') parser.add_option('--nap-time', dest='nap_time', type='int', action='store', help='duration of nap, in seconds') parser.add_option('--reboot-after', dest='reboot_after', type='int', action='store', help='reboot device after this many cycles (0=never)') parser.add_option('--include-dev-builds', dest='include_dev_builds', action='store_true', help='Include developer builds in browsers lists (specifically for Android Firefox)') (options, args) = parser.parse_args() config.read(options.noresults, options.ignore, options.config_file) if options.client: config.client = options.client if options.local_port: config.local_port = options.local_port if options.verbose: config.verbose = options.verbose if options.include_dev_builds: config.include_dev_builds = True if not options.client and not config.get_str('speedtests', 'client'): print "--client must be specified on command line or in config (we don't support ip-based clients here)" sys.exit(errno.EINVAL) if options.platform: config.platform = options.platform config.nap_after = config.get_int(config.platform, 'nap_after', 0) config.nap_time = config.get_int(config.platform, 'nap_time', 0) config.reboot_after = config.get_int(config.platform, 'reboot_after', 0) config.reboot_sleep = config.get_int(config.platform, 'reboot_sleep', 180) # Allow override from platform subsections if config.get_str(config.platform, 'test_base_url'): config.test_base_url = config.get_str(config.platform, 'test_base_url') if options.nap_after: config.nap_after = options.nap_after if options.nap_time: config.nap_time = options.nap_time if options.reboot_after: config.reboot_after = options.reboot_after def get_browser_arg(): try: browser = args[1] except IndexError: print 'Specify a browser.' sys.exit(errno.EINVAL) return browser evt = threading.Event() if len(args) >= 1 and args[0] == 'archive': browser = get_browser_arg() BrowserRunner(evt).archive_current_profiles(browser) sys.exit(0) # start tests in specified browsers. if none given, run all. # create a configuration object to pass to the tests testconfig = dict() testconfig["clientName"] = config.client testconfig["runnerServer"] = "http://%s:%d/submit-result" % (config.local_ip, config.local_port) testconfig["platform"] = config.platform if not options.noresults: testconfig["resultServer"] = config.results_server testconfig["cubeServer"] = config.cube_results_server if not options.tests: print 'Getting test list from server...' try: # pass the config to testpaths, so that it can do potentially useful things with that info test_extra_params = "?_benchconfig=" + base64.b64encode(json.dumps(testconfig)) tests_url = config.test_base_url + '/testpaths' print 'Getting test list from %s...' % tests_url options.tests = json.loads(urllib2.urlopen(tests_url + test_extra_params).read()) except urllib2.HTTPError, e: sys.stderr.write('Could not get test list: %s\n' % e) sys.exit(errno.EPERM) except urllib2.URLError, e: sys.stderr.write('Could not get test list: %s\n' % e.reason) sys.exit(e.reason.errno)
try: # pass the config to testpaths, so that it can do potentially useful things with that info test_extra_params = "?_benchconfig=" + base64.b64encode(json.dumps(testconfig)) tests_url = config.test_base_url + '/testpaths' print 'Getting test list from %s...' % tests_url options.tests = json.loads(urllib2.urlopen(tests_url + test_extra_params).read()) except urllib2.HTTPError, e: sys.stderr.write('Could not get test list: %s\n' % e) sys.exit(errno.EPERM) except urllib2.URLError, e: sys.stderr.write('Could not get test list: %s\n' % e.reason) sys.exit(e.reason.errno) browsers = args conf_browsers = config.get_str(config.platform, "browsers") if browsers is None or len(browsers) == 0 and conf_browsers is not None: browsers = conf_browsers.split() global runner runner = BrowserRunner(evt, browsers, options.tests, testconfig) print 'Starting HTTP server...' trs = TestRunnerHTTPServer(('', config.local_port), runner) server_thread = threading.Thread(target=trs.serve_forever) server_thread.daemon = True server_thread.start() cycle_count = 0 global report report = TestReport()