def get_swarm_results(keys):
  """Simplifies the call to yield_results().

  The timeout is hard-coded to 10 seconds.
  """
  return list(
      swarm_get_results.yield_results(
          'http://host:9001', keys, 10., None))
Ejemplo n.º 2
0
def v0(client, options, test_name):
    """This code supports all the earliest versions of swarm_client.

  This is before --version was added.
  """
    sys.path.insert(0, client)
    import swarm_get_results  # pylint: disable=F0401

    timeout = swarm_get_results.DEFAULT_SHARD_WAIT_TIME
    test_keys = swarm_get_results.get_test_keys(options.swarming, test_name,
                                                timeout)
    if not test_keys:
        print >> sys.stderr, 'No test keys to get results with.'
        return 1

    if options.shards == -1:
        options.shards = len(test_keys)
    elif len(test_keys) < options.shards:
        print >> sys.stderr, (
            'Warning: Test should have %d shards, but only %d '
            'test keys were found' % (options.shards, len(test_keys)))

    gtest_parser = gtest_utils.GTestLogParser()
    exit_code = None
    shards_remaining = range(len(test_keys))
    first_result = True
    for index, result in swarm_get_results.yield_results(
            options.swarming, test_keys, timeout, None):
        assert index == result['config_instance_index']
        if first_result and result['num_config_instances'] != len(test_keys):
            # There are more test_keys than actual shards.
            shards_remaining = shards_remaining[:
                                                result['num_config_instances']]
        shards_remaining.remove(index)
        first_result = False
        output, test_exit_code = gen_shard_output(result, gtest_parser)
        print output
        exit_code = max(exit_code, test_exit_code)

    # Print the annotation before the summary so it's easier to find when scolling
    # down.
    annotation_utils.annotate(test_name, exit_code, gtest_parser)
    print('')
    return exit_code
def v0(client, options, test_name):
  """This code supports all the earliest versions of swarm_client.

  This is before --version was added.
  """
  sys.path.insert(0, client)
  import swarm_get_results  # pylint: disable=F0401

  timeout = swarm_get_results.DEFAULT_SHARD_WAIT_TIME
  test_keys = swarm_get_results.get_test_keys(
      options.swarming, test_name, timeout)
  if not test_keys:
    print >> sys.stderr, 'No test keys to get results with.'
    return 1

  if options.shards == -1:
    options.shards = len(test_keys)
  elif len(test_keys) < options.shards:
    print >> sys.stderr, ('Warning: Test should have %d shards, but only %d '
                          'test keys were found' % (options.shards,
                                                    len(test_keys)))

  gtest_parser = gtest_utils.GTestLogParser()
  exit_code = None
  shards_remaining = range(len(test_keys))
  first_result = True
  for index, result in swarm_get_results.yield_results(
      options.swarming, test_keys, timeout, None):
    assert index == result['config_instance_index']
    if first_result and result['num_config_instances'] != len(test_keys):
      # There are more test_keys than actual shards.
      shards_remaining = shards_remaining[:result['num_config_instances']]
    shards_remaining.remove(index)
    first_result = False
    output, test_exit_code = gen_shard_output(result, gtest_parser)
    print output
    exit_code = max(exit_code, test_exit_code)

  # Print the annotation before the summary so it's easier to find when scolling
  # down.
  annotation_utils.annotate(test_name, exit_code, gtest_parser)
  print('')
  return exit_code