예제 #1
0
파일: run_tests.py 프로젝트: wlach/talos
def test_file(filename, to_screen, amo):
  """Runs the talos tests on the given config file and generates a report.
  
  Args:
    filename: the name of the file to run the tests on
    to_screen: boolean, determine if all results should be outputed directly to stdout
  """
  
  browser_config = []
  tests = []
  title = ''
  testdate = ''
  csv_dir = ''
  results_server = ''
  results_link = ''
  results = {}
  
  # Read in the profile info from the YAML config file
  config_file = open(filename, 'r')
  yaml_config = yaml.load(config_file)
  config_file.close()
  for item in yaml_config:
    if item == 'title':
      title = yaml_config[item]
    elif item == 'testdate':
      testdate = yaml_config[item]
    elif item == 'csv_dir':
       csv_dir = os.path.normpath(yaml_config[item])
       if not os.path.exists(csv_dir):
         print "FAIL: path \"" + csv_dir + "\" does not exist"
         sys.exit(0)
    elif item == 'results_server':
       results_server = yaml_config[item]
    elif item == 'results_link' :
       results_link = yaml_config[item]
  if (results_link != results_server != ''):
    if not post_file.link_exists(results_server, results_link):
      print 'WARNING: graph server link does not exist'
  browser_config = {'preferences'  : yaml_config['preferences'],
                    'extensions'   : yaml_config['extensions'],
                    'browser_path' : yaml_config['browser_path'],
                    'browser_log'  : yaml_config['browser_log'],
                    'symbols_path' : yaml_config.get('symbols_path', None),
                    'browser_wait' : yaml_config['browser_wait'],
                    'process'      : yaml_config['process'],
                    'extra_args'   : yaml_config['extra_args'],
                    'branch'       : yaml_config['branch'],
                    'title'        : yaml_config.get('title', ''),
                    'buildid'      : yaml_config['buildid'],
                    'env'          : yaml_config['env'],
                    'dirs'         : yaml_config.get('dirs', {}),
                    'bundles'      : yaml_config.get('bundles', {}),
                    'init_url'     : yaml_config['init_url'],
                    'child_process'      : yaml_config.get('child_process', 'plugin-container'),
                    'branch_name'        : yaml_config.get('branch_name', ''),
                    'test_name_extension': yaml_config.get('test_name_extension', ''),
                    'sourcestamp'        : yaml_config.get('sourcestamp', 'NULL'),
                    'repository'         : yaml_config.get('repository', 'NULL'),
                    'host'               : yaml_config.get('deviceip', ''),
                    'port'               : yaml_config.get('deviceport', ''),
                    'webserver'          : yaml_config.get('webserver', ''),
                    'deviceroot'         : yaml_config.get('deviceroot', ''),
                    'remote'             : yaml_config.get('remote', False),
                    'test_timeout'       : yaml_config.get('test_timeout', 1200),
                    'addon_id'           : yaml_config.get('addon_id', 'NULL'),
                    'bcontroller_config' : yaml_config.get('bcontroller_config', 'bcontroller.yml'),
                    'xperf_path'         : yaml_config.get('xperf_path', None)}

  #normalize paths to work accross platforms
  dm = None
  if (browser_config['remote'] == True):
    import devicemanager
    if (browser_config['port'] == -1):
        import devicemanagerADB
        dm = devicemanagerADB.DeviceManagerADB(browser_config['host'], browser_config['port'])
    else:
        import devicemanagerSUT
        dm = devicemanagerSUT.DeviceManagerSUT(browser_config['host'], browser_config['port'])

  browser_config['browser_path'] = os.path.normpath(browser_config['browser_path'])
  for dir in browser_config['dirs']:
    browser_config['dirs'][dir] = os.path.normpath(browser_config['dirs'][dir])
  for bname in browser_config['bundles']:
    browser_config['bundles'][bname] = os.path.normpath(browser_config['bundles'][bname])
  tests = yaml_config['tests']
  config_file.close()
  if (testdate != ''):
    date = int(time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT')))
  else:
    date = int(time.time()) #TODO get this into own file
  utils.debug("using testdate: %d" % date)
  utils.debug("actual date: %d" % int(time.time()))
  print 'RETURN:s: %s' % title
  #pull buildid & sourcestamp from browser
  browser_config = browserInfo(browser_config, devicemanager = dm)

  if (browser_config['remote'] == True):
    procName = browser_config['browser_path'].split('/')[-1]
    if (dm.processExist(procName)):
      dm.killProcess(procName)

  utils.startTimer()
  utils.stamped_msg(title, "Started")
  for test in tests:
    testname = test['name']
    utils.stamped_msg("Running test " + testname, "Started")
    try:
      mytest = TTest(browser_config['remote'])
      browser_dump, counter_dump, print_format = mytest.runTest(browser_config, test)
      utils.debug("Received test results: " + " ".join(browser_dump))
      results[testname] = [browser_dump, counter_dump, print_format]
      # If we're doing CSV, write this test immediately (bug 419367)
      if csv_dir != '':
        send_to_csv(csv_dir, {testname : results[testname]})
      if to_screen or amo:
        send_to_csv(None, {testname : results[testname]})
    except talosError, e:
      utils.stamped_msg("Failed " + testname, "Stopped")
      print 'FAIL: Busted: ' + testname
      print 'FAIL: ' + e.msg.replace('\n','\nRETURN:')
    utils.stamped_msg("Completed test " + testname, "Stopped")
예제 #2
0
def test_file(filename):
  """Runs the Ts and Tp tests on the given config file and generates a report.
  
  Args:
    filename: the name of the file to run the tests on
  """
  
  browser_config = []
  tests = []
  title = ''
  testdate = ''
  csv_dir = ''
  results_server = ''
  results_link = ''
  results = {}
  
  # Read in the profile info from the YAML config file
  config_file = open(filename, 'r')
  yaml_config = yaml.load(config_file)
  config_file.close()
  for item in yaml_config:
    if item == 'title':
      title = yaml_config[item]
    elif item == 'testdate':
      testdate = yaml_config[item]
    elif item == 'csv_dir':
       csv_dir = os.path.normpath(yaml_config[item])
       if not os.path.exists(csv_dir):
         print "FAIL: path \"" + csv_dir + "\" does not exist"
         sys.exit(0)
    elif item == 'results_server':
       results_server = yaml_config[item]
    elif item == 'results_link' :
       results_link = yaml_config[item]
  if (results_link != results_server != ''):
    if not post_file.link_exists(results_server, results_link):
      sys.exit(0)
  browser_config = {'preferences'  : yaml_config['preferences'],
                    'extensions'   : yaml_config['extensions'],
                    'firefox'      : yaml_config['firefox'],
                    'branch'       : yaml_config['branch'],
                    'buildid'      : yaml_config['buildid'],
                    'profile_path' : yaml_config['profile_path'],
                    'env'          : yaml_config['env'],
                    'dirs'         : yaml_config['dirs'],
                    'init_url'     : yaml_config['init_url']}
  #normalize paths to work accross platforms
  browser_config['firefox'] = os.path.normpath(browser_config['firefox'])
  if browser_config['profile_path'] != {}:
    browser_config['profile_path'] = os.path.normpath(browser_config['profile_path'])
  for dir in browser_config['dirs']:
    browser_config['dirs'][dir] = os.path.normpath(browser_config['dirs'][dir])
  tests = yaml_config['tests']
  config_file.close()
  if (testdate != ''):
    date = int(time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT')))
  else:
    date = int(time.time()) #TODO get this into own file
  utils.debug("using testdate: %d" % date)
  utils.debug("actual date: %d" % int(time.time()))

  utils.stamped_msg(title, "Started")
  for test in tests:
    utils.stamped_msg("Running test " + test, "Started")
    try:
      browser_dump, counter_dump = ttest.runTest(browser_config, tests[test])
    except talosError, e:
      utils.stamped_msg("Failed " + test, "Stopped")
      print 'FAIL: Busted: ' + test
      print 'FAIL: ' + e.msg
      sys.exit(0)
    utils.debug("Received test results: " + " ".join(browser_dump))
    results[test] = [browser_dump, counter_dump]
    utils.stamped_msg("Completed test " + test, "Stopped")
예제 #3
0
def test_file(filename):
    """Runs the Ts and Tp tests on the given config file and generates a report.
  
  Args:
    filename: the name of the file to run the tests on
  """

    browser_config = []
    tests = []
    title = ''
    testdate = ''
    csv_dir = ''
    results_server = ''
    results_link = ''
    results = {}

    # Read in the profile info from the YAML config file
    config_file = open(filename, 'r')
    yaml_config = yaml.load(config_file)
    config_file.close()
    for item in yaml_config:
        if item == 'title':
            title = yaml_config[item]
        elif item == 'testdate':
            testdate = yaml_config[item]
        elif item == 'csv_dir':
            csv_dir = os.path.normpath(yaml_config[item])
            if not os.path.exists(csv_dir):
                print "FAIL: path \"" + csv_dir + "\" does not exist"
                sys.exit(0)
        elif item == 'results_server':
            results_server = yaml_config[item]
        elif item == 'results_link':
            results_link = yaml_config[item]
    if (results_link != results_server != ''):
        if not post_file.link_exists(results_server, results_link):
            sys.exit(0)
    browser_config = {
        'preferences': yaml_config['preferences'],
        'extensions': yaml_config['extensions'],
        'firefox': yaml_config['firefox'],
        'branch': yaml_config['branch'],
        'buildid': yaml_config['buildid'],
        'profile_path': yaml_config['profile_path'],
        'env': yaml_config['env'],
        'dirs': yaml_config['dirs'],
        'init_url': yaml_config['init_url']
    }
    #normalize paths to work accross platforms
    browser_config['firefox'] = os.path.normpath(browser_config['firefox'])
    if browser_config['profile_path'] != {}:
        browser_config['profile_path'] = os.path.normpath(
            browser_config['profile_path'])
    for dir in browser_config['dirs']:
        browser_config['dirs'][dir] = os.path.normpath(
            browser_config['dirs'][dir])
    tests = yaml_config['tests']
    config_file.close()
    if (testdate != ''):
        date = int(
            time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT')))
    else:
        date = int(time.time())  #TODO get this into own file
    utils.debug("using testdate: %d" % date)
    utils.debug("actual date: %d" % int(time.time()))

    utils.stamped_msg(title, "Started")
    for test in tests:
        utils.stamped_msg("Running test " + test, "Started")
        try:
            browser_dump, counter_dump = ttest.runTest(browser_config,
                                                       tests[test])
        except talosError, e:
            utils.stamped_msg("Failed " + test, "Stopped")
            print 'FAIL: Busted: ' + test
            print 'FAIL: ' + e.msg
            sys.exit(0)
        utils.debug("Received test results: " + " ".join(browser_dump))
        results[test] = [browser_dump, counter_dump]
        utils.stamped_msg("Completed test " + test, "Stopped")
예제 #4
0
def test_file(filename):
  """Runs the talos tests on the given config file and generates a report.
  
  Args:
    filename: the name of the file to run the tests on
  """
  
  browser_config = []
  tests = []
  title = ''
  testdate = ''
  csv_dir = ''
  results_server = ''
  results_link = ''
  results = {}
  
  # Read in the profile info from the YAML config file
  config_file = open(filename, 'r')
  yaml_config = yaml.load(config_file)
  config_file.close()
  for item in yaml_config:
    if item == 'title':
      title = yaml_config[item]
    elif item == 'testdate':
      testdate = yaml_config[item]
    elif item == 'csv_dir':
       csv_dir = os.path.normpath(yaml_config[item])
       if not os.path.exists(csv_dir):
         print "FAIL: path \"" + csv_dir + "\" does not exist"
         sys.exit(0)
    elif item == 'results_server':
       results_server = yaml_config[item]
    elif item == 'results_link' :
       results_link = yaml_config[item]
  if (results_link != results_server != ''):
    if not post_file.link_exists(results_server, results_link):
      sys.exit(0)
  browser_config = {'preferences'  : yaml_config['preferences'],
                    'extensions'   : yaml_config['extensions'],
                    'browser_path' : yaml_config['browser_path'],
                    'browser_log'  : yaml_config['browser_log'],
                    'symbols_path' : yaml_config.get('symbols_path', None),
                    'browser_wait' : yaml_config['browser_wait'],
                    'process'      : yaml_config['process'],
                    'extra_args'   : yaml_config['extra_args'],
                    'branch'       : yaml_config['branch'],
                    'buildid'      : yaml_config['buildid'],
                    'env'          : yaml_config['env'],
                    'dirs'         : yaml_config['dirs'],
                    'init_url'     : yaml_config['init_url']}
  if 'branch_name' in yaml_config:
      browser_config['branch_name'] = yaml_config['branch_name']
  if 'test_name_extension' in yaml_config:
      browser_config['test_name_extension'] = yaml_config['test_name_extension']
  else:
      browser_config['test_name_extension'] = ''
  #normalize paths to work accross platforms
  browser_config['browser_path'] = os.path.normpath(browser_config['browser_path'])
  for dir in browser_config['dirs']:
    browser_config['dirs'][dir] = os.path.normpath(browser_config['dirs'][dir])
  tests = yaml_config['tests']
  config_file.close()
  if (testdate != ''):
    date = int(time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT')))
  else:
    date = int(time.time()) #TODO get this into own file
  utils.debug("using testdate: %d" % date)
  utils.debug("actual date: %d" % int(time.time()))
  print 'RETURN:s: %s' % title
  #pull buildid & sourcestamp from browser
  browser_config = browserInfo(browser_config)

  if ffprocess.checkAllProcesses(browser_config['process']):
    print "FAIL: all firefox processes must be closed before tests can be run"
    sys.exit(0)

  utils.startTimer()
  utils.stamped_msg(title, "Started")
  for test in tests:
    testname = test['name']
    utils.stamped_msg("Running test " + testname, "Started")
    try:
      browser_dump, counter_dump, print_format = ttest.runTest(browser_config, test)
      utils.debug("Received test results: " + " ".join(browser_dump))
      results[testname] = [browser_dump, counter_dump, print_format]
      # If we're doing CSV, write this test immediately (bug 419367)
      if csv_dir != '':
        send_to_csv(csv_dir, {testname : results[testname]})
    except talosError, e:
      utils.stamped_msg("Failed " + testname, "Stopped")
      print 'FAIL: Busted: ' + testname
      print 'FAIL: ' + e.msg.replace('\n','\nRETURN:')
    utils.stamped_msg("Completed test " + testname, "Stopped")
예제 #5
0
def test_file(filename, to_screen):
    """Runs the talos tests on the given config file and generates a report.
  
  Args:
    filename: the name of the file to run the tests on
    to_screen: boolean, determine if all results should be outputed directly to stdout
  """

    browser_config = []
    tests = []
    title = ''
    testdate = ''
    csv_dir = ''
    results_server = ''
    results_link = ''
    results = {}

    # Read in the profile info from the YAML config file
    config_file = open(filename, 'r')
    yaml_config = yaml.load(config_file)
    config_file.close()
    for item in yaml_config:
        if item == 'title':
            title = yaml_config[item]
        elif item == 'testdate':
            testdate = yaml_config[item]
        elif item == 'csv_dir':
            csv_dir = os.path.normpath(yaml_config[item])
            if not os.path.exists(csv_dir):
                print "FAIL: path \"" + csv_dir + "\" does not exist"
                sys.exit(0)
        elif item == 'results_server':
            results_server = yaml_config[item]
        elif item == 'results_link':
            results_link = yaml_config[item]
    if (results_link != results_server != ''):
        if not post_file.link_exists(results_server, results_link):
            sys.exit(0)
    browser_config = {
        'preferences': yaml_config['preferences'],
        'extensions': yaml_config['extensions'],
        'browser_path': yaml_config['browser_path'],
        'browser_log': yaml_config['browser_log'],
        'symbols_path': yaml_config.get('symbols_path', None),
        'browser_wait': yaml_config['browser_wait'],
        'process': yaml_config['process'],
        'extra_args': yaml_config['extra_args'],
        'branch': yaml_config['branch'],
        'buildid': yaml_config['buildid'],
        'env': yaml_config['env'],
        'dirs': yaml_config.get('dirs', {}),
        'bundles': yaml_config.get('bundles', {}),
        'init_url': yaml_config['init_url']
    }

    if 'child_process' in yaml_config:
        browser_config['child_process'] = yaml_config['child_process']
    else:
        browser_config['child_process'] = 'plugin-container'
    if 'branch_name' in yaml_config:
        browser_config['branch_name'] = yaml_config['branch_name']
    if 'test_name_extension' in yaml_config:
        browser_config['test_name_extension'] = yaml_config[
            'test_name_extension']
    else:
        browser_config['test_name_extension'] = ''

    if 'sourcestamp' in yaml_config:
        browser_config['sourcestamp'] = yaml_config['sourcestamp']
    if 'repository' in yaml_config:
        browser_config['repository'] = yaml_config['repository']

    if 'deviceip' in yaml_config:
        browser_config['host'] = yaml_config['deviceip']
    else:
        browser_config['host'] = ''
    if 'deviceport' in yaml_config:
        browser_config['port'] = yaml_config['deviceport']
    else:
        browser_config['port'] = ''
    if 'webserver' in yaml_config:
        browser_config['webserver'] = yaml_config['webserver']
    else:
        browser_config['webserver'] = ''
    if 'deviceroot' in yaml_config:
        browser_config['deviceroot'] = yaml_config['deviceroot']
    else:
        browser_config['deviceroot'] = ''
    if 'remote' in yaml_config:
        browser_config['remote'] = yaml_config['remote']
    else:
        browser_config['remote'] = False

    #normalize paths to work accross platforms
    dm = None
    if (browser_config['remote'] == True):
        import devicemanager
        dm = devicemanager.DeviceManager(browser_config['host'],
                                         browser_config['port'])
    browser_config['browser_path'] = os.path.normpath(
        browser_config['browser_path'])
    for dir in browser_config['dirs']:
        browser_config['dirs'][dir] = os.path.normpath(
            browser_config['dirs'][dir])
    for bname in browser_config['bundles']:
        browser_config['bundles'][bname] = os.path.normpath(
            browser_config['bundles'][bname])
    tests = yaml_config['tests']
    config_file.close()
    if (testdate != ''):
        date = int(
            time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT')))
    else:
        date = int(time.time())  #TODO get this into own file
    utils.debug("using testdate: %d" % date)
    utils.debug("actual date: %d" % int(time.time()))
    print 'RETURN:s: %s' % title
    #pull buildid & sourcestamp from browser
    browser_config = browserInfo(browser_config, devicemanager=dm)

    utils.startTimer()
    utils.stamped_msg(title, "Started")
    for test in tests:
        testname = test['name']
        utils.stamped_msg("Running test " + testname, "Started")
        try:
            mytest = TTest(browser_config['remote'])
            browser_dump, counter_dump, print_format = mytest.runTest(
                browser_config, test)
            utils.debug("Received test results: " + " ".join(browser_dump))
            results[testname] = [browser_dump, counter_dump, print_format]
            # If we're doing CSV, write this test immediately (bug 419367)
            if csv_dir != '':
                send_to_csv(csv_dir, {testname: results[testname]})
            if to_screen:
                send_to_csv(None, {testname: results[testname]})
        except talosError, e:
            utils.stamped_msg("Failed " + testname, "Stopped")
            print 'FAIL: Busted: ' + testname
            print 'FAIL: ' + e.msg.replace('\n', '\nRETURN:')
        utils.stamped_msg("Completed test " + testname, "Stopped")
예제 #6
0
def test_file(filename):
    """Runs the talos tests on the given config file and generates a report.
  
  Args:
    filename: the name of the file to run the tests on
  """

    browser_config = []
    tests = []
    title = ''
    testdate = ''
    csv_dir = ''
    results_server = ''
    results_link = ''
    old_results_server = ''
    old_results_link = ''
    results = {}

    # Read in the profile info from the YAML config file
    config_file = open(filename, 'r')
    yaml_config = yaml.load(config_file)
    config_file.close()
    for item in yaml_config:
        if item == 'title':
            title = yaml_config[item]
        elif item == 'testdate':
            testdate = yaml_config[item]
        elif item == 'csv_dir':
            csv_dir = os.path.normpath(yaml_config[item])
            if not os.path.exists(csv_dir):
                print "FAIL: path \"" + csv_dir + "\" does not exist"
                sys.exit(0)
        elif item == 'results_server':
            results_server = yaml_config[item]
        elif item == 'results_link':
            results_link = yaml_config[item]
        elif item == 'old_results_server':
            old_results_server = yaml_config[item]
        elif item == 'old_results_link':
            old_results_link = yaml_config[item]
    if (results_link != results_server != ''):
        if not post_file.link_exists(results_server, results_link):
            sys.exit(0)
    if (old_results_link != old_results_server != ''):
        if not post_file.link_exists(old_results_server, old_results_link):
            sys.exit(0)
    browser_config = {
        'preferences': yaml_config['preferences'],
        'extensions': yaml_config['extensions'],
        'browser_path': yaml_config['browser_path'],
        'browser_log': yaml_config['browser_log'],
        'symbols_path': yaml_config.get('symbols_path', None),
        'browser_wait': yaml_config['browser_wait'],
        'process': yaml_config['process'],
        'extra_args': yaml_config['extra_args'],
        'branch': yaml_config['branch'],
        'buildid': yaml_config['buildid'],
        'profile_path': yaml_config['profile_path'],
        'env': yaml_config['env'],
        'dirs': yaml_config['dirs'],
        'init_url': yaml_config['init_url']
    }
    if 'branch_name' in yaml_config:
        browser_config['branch_name'] = yaml_config['branch_name']
    if 'test_name_extension' in yaml_config:
        browser_config['test_name_extension'] = yaml_config[
            'test_name_extension']
    else:
        browser_config['test_name_extension'] = ''
    #normalize paths to work accross platforms
    browser_config['browser_path'] = os.path.normpath(
        browser_config['browser_path'])
    if browser_config['profile_path'] != {}:
        browser_config['profile_path'] = os.path.normpath(
            browser_config['profile_path'])
    for dir in browser_config['dirs']:
        browser_config['dirs'][dir] = os.path.normpath(
            browser_config['dirs'][dir])
    tests = yaml_config['tests']
    config_file.close()
    if (testdate != ''):
        date = int(
            time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT')))
    else:
        date = int(time.time())  #TODO get this into own file
    utils.debug("using testdate: %d" % date)
    utils.debug("actual date: %d" % int(time.time()))
    print 'RETURN:s: %s' % title
    #pull buildid & sourcestamp from browser
    browser_config = browserInfo(browser_config)

    utils.startTimer()
    utils.stamped_msg(title, "Started")
    for test in tests:
        testname = test['name']
        utils.stamped_msg("Running test " + testname, "Started")
        try:
            browser_dump, counter_dump = ttest.runTest(browser_config, test)
            utils.debug("Received test results: " + " ".join(browser_dump))
            results[testname] = [browser_dump, counter_dump]
            # If we're doing CSV, write this test immediately (bug 419367)
            if csv_dir != '':
                send_to_csv(csv_dir, {testname: results[testname]})
        except talosError, e:
            utils.stamped_msg("Failed " + testname, "Stopped")
            print 'FAIL: Busted: ' + testname
            print 'FAIL: ' + e.msg
        utils.stamped_msg("Completed test " + testname, "Stopped")