Esempio n. 1
0
def Setup(test_options):
    """Create and return the test runner factory and tests.

  Args:
    test_options: A PerformanceOptions object.

  Returns:
    A tuple of (TestRunnerFactory, tests).
  """
    # TODO(bulach): remove this once the bot side lands. BUG=318369
    constants.SetBuildType('Release')
    if os.path.exists(constants.PERF_OUTPUT_DIR):
        shutil.rmtree(constants.PERF_OUTPUT_DIR)
    os.makedirs(constants.PERF_OUTPUT_DIR)

    # Before running the tests, kill any leftover server.
    test_environment.CleanupLeftoverProcesses()
    forwarder.Forwarder.UseMultiprocessing()

    if test_options.single_step:
        # Running a single command, build the tests structure.
        tests = [['single_step', test_options.single_step]]

    if test_options.steps:
        with file(test_options.steps, 'r') as f:
            tests = json.load(f)

    # The list is necessary to keep the steps order, but internally
    # the format is squashed from a list of lists into a single dict:
    # [["A", "cmd"], ["B", "cmd"]] into {"A": "cmd", "B": "cmd"}
    sorted_test_names = [i[0] for i in tests]
    tests_dict = dict(tests)

    if test_options.test_filter:
        sorted_test_names = fnmatch.filter(sorted_test_names,
                                           test_options.test_filter)
        tests_dict = dict((k, v) for k, v in tests_dict.iteritems()
                          if k in sorted_test_names)

    flaky_steps = []
    if test_options.flaky_steps:
        with file(test_options.flaky_steps, 'r') as f:
            flaky_steps = json.load(f)

    def TestRunnerFactory(device, shard_index):
        return test_runner.TestRunner(test_options, device, tests_dict,
                                      flaky_steps)

    return (TestRunnerFactory, sorted_test_names)
Esempio n. 2
0
def Setup(test_options, active_devices):
    """Create and return the test runner factory and tests.

  Args:
    test_options: A PerformanceOptions object.

  Returns:
    A tuple of (TestRunnerFactory, tests, devices).
  """
    # TODO(bulach): remove this once the bot side lands. BUG=318369
    constants.SetBuildType('Release')
    if os.path.exists(constants.PERF_OUTPUT_DIR):
        shutil.rmtree(constants.PERF_OUTPUT_DIR)
    os.makedirs(constants.PERF_OUTPUT_DIR)

    # Before running the tests, kill any leftover server.
    test_environment.CleanupLeftoverProcesses(active_devices)

    # We want to keep device affinity, so return all devices ever seen.
    all_devices = _GetAllDevices(active_devices,
                                 test_options.known_devices_file)

    steps_dict = _GetStepsDict(test_options)
    sorted_step_names = sorted(steps_dict['steps'].keys())

    if test_options.test_filter:
        sorted_step_names = fnmatch.filter(sorted_step_names,
                                           test_options.test_filter)

    flaky_steps = []
    if test_options.flaky_steps:
        with file(test_options.flaky_steps, 'r') as f:
            flaky_steps = json.load(f)

    def TestRunnerFactory(device, shard_index):
        if str(device) in active_devices:
            return test_runner.TestRunner(test_options, device, shard_index,
                                          len(all_devices), steps_dict,
                                          flaky_steps)
        return None

    return (TestRunnerFactory, sorted_step_names, all_devices)
Esempio n. 3
0
def CleanupLeftoverProcesses():
    test_environment.CleanupLeftoverProcesses()