Example #1
0
def alerts_from_step_failure(cache, step_failure, master_url,
                             builder_name):  # pragma: no cover
  build = (
      buildbot.fetch_build_json(
          cache, master_url, builder_name,
          step_failure['build_number'])[0])

  step = next((s for s in build['steps']
               if s['name'] == step_failure['step_name']), None)
  step_template = {
      'master_url': master_url,
      'last_result_time': step['times'][1],
      'builder_name': builder_name,
      'last_failing_build': step_failure['build_number'],
      'step_name': step['name'],
      'latest_revisions': buildbot.revisions_from_build(build),
  }
  alerts = []
  reasons = reasons_for_failure(cache, step, build, builder_name, master_url)
  if not reasons:
    alert = dict(step_template)
    alert['reason'] = None
    alerts.append(alert)
  else:
    for reason in reasons:
      alert = dict(step_template)
      alert['reason'] = reason
      alerts.append(alert)

  return alerts
Example #2
0
 def test_revisions_from_build_no_properties(self):
     build = {'properties': []}
     self.assertEqual(buildbot.revisions_from_build(build), {
         'v8': None,
         'chromium': None,
         'nacl': None,
         'blink': None,
     })
Example #3
0
 def test_revisions_from_build_no_properties(self):
   build = {'properties': []}
   self.assertEqual(buildbot.revisions_from_build(build), {
     'v8': None,
     'chromium': None,
     'nacl': None,
     'blink': None,
   })
Example #4
0
def fill_in_transition(cache, alert, recent_build_ids,
                       old_alerts):  # pragma: no cover
  master = alert['master_url']
  builder = alert['builder_name']
  step = alert['step_name']
  reason = alert['reason']
  alert_key = generate_alert_key(master, builder, step, reason)

  old_alert = old_alerts.get(alert_key)
  # failing_build will be None if a previous run didn't fill in the transition.
  if old_alert and old_alert['failing_build'] is not None:
    logging.debug('Using old alert data. master: %s, builder: %s, step: %s,'
                  ' reason: %s', master, builder, step, reason)
    update_data = {k: old_alerts[alert_key][k] for k in [
        'passing_build', 'failing_build', 'failing_revisions',
        'passing_revisions']}
  else:
    logging.debug('Computing new alert data. master: %s, builder: %s, step: %s,'
                  ' reason: %s', master, builder, step, reason)

    last_pass_build, first_fail_build = \
      compute_transition(cache, alert, recent_build_ids)

    if first_fail_build:
      failing = buildbot.revisions_from_build(first_fail_build)
    else:
      failing = None

    if last_pass_build:
      passing = buildbot.revisions_from_build(last_pass_build)
    else:
      passing = None

    update_data = {
        'passing_build': (last_pass_build or {}).get('number'),
        'failing_build': (first_fail_build or {}).get('number'),
        'failing_revisions': failing,
        'passing_revisions': passing,
    }

  alert.update(update_data)
  return alert