예제 #1
0
def get_impacts_on_prod_builds(testcase, testcase_file_path):
    """Get testcase impact on production builds, which are extended stable, stable
  and beta."""
    impacts = Impacts()
    try:
        impacts.stable = get_impact_on_build('stable',
                                             testcase.impact_stable_version,
                                             testcase, testcase_file_path)
    except AppFailedException:
        return get_impacts_from_url(testcase.regression, testcase.job_type)

    try:
        impacts.beta = get_impact_on_build('beta',
                                           testcase.impact_beta_version,
                                           testcase, testcase_file_path)
    except AppFailedException:
        # If beta fails to get the binary, we ignore. At least, we have stable.
        pass

    try:
        impacts.extended_stable = get_impact_on_build(
            'extended_stable', testcase.impact_extended_stable_version,
            testcase, testcase_file_path)
    except AppFailedException:
        return get_impacts_from_url(testcase.regression, testcase.job_type)

    # Always record the affected head version.
    start_revision, end_revision = get_start_and_end_revision(
        testcase.regression, testcase.job_type)
    build_revision_mappings = build_info.get_build_to_revision_mappings()
    impacts.head = get_head_impact(build_revision_mappings, start_revision,
                                   end_revision)

    return impacts
예제 #2
0
def get_impacts_from_url(regression_range, job_type, platform=None):
  """Gets impact string using the build information url."""
  logs.log('Get component impacts from URL: range %s, '
           'job type %s.' % (regression_range, str(job_type)))
  component_name = data_handler.get_component_name(job_type)
  if component_name:
    return get_component_impacts_from_url(component_name, regression_range,
                                          job_type, platform)

  start_revision, end_revision = get_start_and_end_revision(
      regression_range, job_type)
  logs.log('Proceeding to calculate impacts as non-component based on '
           'range %s-%s' % (str(start_revision), str(end_revision)))
  if not end_revision:
    return Impacts()

  logs.log(f'Gathering build to revision mappings for {platform}')
  build_revision_mappings = build_info.get_build_to_revision_mappings(platform)
  if not build_revision_mappings:
    return Impacts()

  logs.log('Calculating impacts from URL')
  extended_stable = get_impact(
      build_revision_mappings.get('extended_stable'), start_revision,
      end_revision)
  stable = get_impact(
      build_revision_mappings.get('stable'), start_revision, end_revision)
  beta = get_impact(
      build_revision_mappings.get('beta'), start_revision, end_revision)
  head = get_head_impact(build_revision_mappings, start_revision, end_revision)

  return Impacts(stable, beta, extended_stable, head)
예제 #3
0
def get_impacts_from_url(regression_range, job_type, platform=None):
    """Gets impact string using the build information url."""
    component_name = data_handler.get_component_name(job_type)
    if component_name:
        return get_component_impacts_from_url(component_name, regression_range,
                                              job_type, platform)

    start_revision, end_revision = get_start_and_end_revision(
        regression_range, job_type)
    if not end_revision:
        return Impacts()

    build_revision_mappings = build_info.get_build_to_revision_mappings(
        platform)
    if not build_revision_mappings:
        return Impacts()

    extended_stable = get_impact(
        build_revision_mappings.get('extended_stable'), start_revision,
        end_revision)
    stable = get_impact(build_revision_mappings.get('stable'), start_revision,
                        end_revision)
    beta = get_impact(build_revision_mappings.get('beta'), start_revision,
                      end_revision)
    head = get_head_impact(build_revision_mappings, start_revision,
                           end_revision)

    return Impacts(stable, beta, extended_stable, head)
예제 #4
0
 def test_get_build_to_revision_mappings_with_valid_platform(self):
   """Tests if a valid platform (WIN) results in the correct metadata dict from
      ChromiumDash."""
   result = build_info.get_build_to_revision_mappings('WINDOWS')
   expected_result = {
       'beta': {
           'revision': '885287',
           'version': '92.0.4515.70'
       },
       'canary': {
           'revision': '896380',
           'version': '93.0.4557.2'
       },
       'dev': {
           'revision': '894125',
           'version': '93.0.4549.3'
       },
       'stable': {
           'revision': '870763',
           'version': '91.0.4472.124'
       },
       'extended_stable': {
           'revision': '870763',
           'version': '91.0.4472.114'
       }
   }
   self.assertDictEqual(result, expected_result)
예제 #5
0
def get_component_impacts_from_url(component_name,
                                   regression_range,
                                   job_type,
                                   platform=None):
  """Gets component impact string using the build information url."""
  logs.log('Getting component impacts from URL. Component name %s, '
           'regression range %s, job type %s, platform %s.' %
           (component_name, regression_range, str(job_type), str(platform)))
  start_revision, end_revision = get_start_and_end_revision(
      regression_range, job_type)
  logs.log('Start and end revision %s, %s' % (start_revision, end_revision))
  if not end_revision:
    return Impacts()

  build_revision_mappings = build_info.get_build_to_revision_mappings(platform)
  if not build_revision_mappings:
    return Impacts()

  found_impacts = dict()
  for build in ['extended_stable', 'stable', 'beta', 'canary']:
    mapping = build_revision_mappings.get(build)
    logs.log('Considering impacts for %s.' % (build))
    # TODO(yuanjunh): bypass for now but remove it after ES is enabled.
    if build == 'extended_stable' and not mapping:
      found_impacts[build] = Impact()
      continue
    # Some platforms don't have canary, so use dev to represent
    # the affected head version.
    if build == 'canary' and not mapping:
      mapping = build_revision_mappings.get('dev')
    if not mapping:
      return Impacts()
    chromium_revision = mapping['revision']
    logs.log('Chromium revision is %s.' % (chromium_revision))
    component_revision = get_component_information_by_name(
        chromium_revision, component_name)
    logs.log('Component revision is %s.' % (component_revision))
    if not component_revision:
      return Impacts()
    branched_from = revisions.revision_to_branched_from(
        component_revision['url'], component_revision['rev'])
    logs.log('Branched from revision is %s.' % (branched_from))
    if not branched_from:
      # This is a head revision, not branched.
      branched_from = component_revision['rev']
    impact = get_impact({
        'revision': branched_from,
        'version': mapping['version']
    }, start_revision, end_revision, build == 'canary')
    logs.log('Resulting impact is %s.' % (str(impact)))
    found_impacts[build] = impact
  return Impacts(found_impacts['stable'], found_impacts['beta'],
                 found_impacts['extended_stable'], found_impacts['canary'])
예제 #6
0
def get_component_impacts_from_url(component_name,
                                   regression_range,
                                   job_type,
                                   platform=None):
    """Gets component impact string using the build information url."""
    start_revision, end_revision = get_start_and_end_revision(
        regression_range, job_type)
    if not end_revision:
        return Impacts()

    build_revision_mappings = build_info.get_build_to_revision_mappings(
        platform)
    if not build_revision_mappings:
        return Impacts()

    found_impacts = dict()
    for build in ['extended_stable', 'stable', 'beta', 'canary']:
        mapping = build_revision_mappings.get(build)
        # TODO(yuanjunh): bypass for now but remove it after ES is enabled.
        if build == 'extended_stable' and not mapping:
            found_impacts[build] = Impact()
            continue
        # Some platforms don't have canary, so use dev to represent
        # the affected head version.
        if build == 'canary' and not mapping:
            mapping = build_revision_mappings.get('dev')
        if not mapping:
            return Impacts()
        chromium_revision = mapping['revision']
        component_revision = get_component_information_by_name(
            chromium_revision, component_name)
        if not component_revision:
            return Impacts()
        branched_from = revisions.revision_to_branched_from(
            component_revision['url'], component_revision['rev'])
        if not branched_from:
            # This is a head revision, not branched.
            branched_from = component_revision['rev']
        impact = get_impact(
            {
                'revision': branched_from,
                'version': mapping['version']
            }, start_revision, end_revision, build == 'canary')
        found_impacts[build] = impact
    return Impacts(found_impacts['stable'], found_impacts['beta'],
                   found_impacts['extended_stable'], found_impacts['canary'])
예제 #7
0
 def test_get_build_to_revision_mappings_for_linux(self):
   """Tests if a valid platform (Linux) results in the correct metadata dict
      from ChromiumDash."""
   result = build_info.get_build_to_revision_mappings('LINUX')
   expected_result = {
       'beta': {
           'revision': '885287',
           'version': '92.0.4515.70'
       },
       'dev': {
           'revision': '894125',
           'version': '93.0.4549.3'
       },
       'stable': {
           'revision': '870763',
           'version': '91.0.4472.114'
       },
       'extended_stable': {
           'revision': '870763',
           'version': '91.0.4472.114'
       }
   }
   self.assertDictEqual(result, expected_result)
예제 #8
0
 def test_get_build_to_revision_mappings_with_invalid_platform(self):
   """Tests if an invalid platform results in the correct (empty) dict."""
   result = build_info.get_build_to_revision_mappings('foo')
   self.assertEqual(result, {})