예제 #1
0
    def setUp(self):
        super(BuildrunnerTest, self).setUp()

        self.runbuild = os.path.join(SCRIPT_DIR, '..', 'runbuild.py')
        self.capture = chromium_utils.FilterCapture()
        self.master_dir = os.path.join(SCRIPT_DIR, 'data', 'runbuild_master')

        self.failing_master_dir = os.path.join(SCRIPT_DIR, 'data',
                                               'failing_master')
예제 #2
0
def SendGomaStats(goma_stats_file, goma_crash_report, build_data_dir):
    """Send GomaStats monitoring event.

  Note: this function also removes goma_stats_file.
  """
    try:
        goma_options = []
        if goma_stats_file and os.path.exists(goma_stats_file):
            # send GomaStats.
            goma_options = [
                '--build-event-goma-stats-path',
                goma_stats_file,
            ]
        elif goma_crash_report and os.path.exists(goma_crash_report):
            # crash report.
            goma_options = [
                '--build-event-goma-error',
                'GOMA_ERROR_CRASHED',
                '--build-event-goma-crash-report-id-path',
                goma_crash_report,
            ]
        elif IsCompilerProxyKilledByFatalError():
            goma_options = [
                '--build-event-goma-error',
                'GOMA_ERROR_LOG_FATAL',
            ]
        else:
            # unknown error.
            goma_options = [
                '--build-event-goma-error',
                'GOMA_ERROR_UNKNOWN',
            ]
        run_cmd = PLATFORM_RUN_CMD.get(os.name)
        if not run_cmd:
            print 'Unknown os.name: %s' % os.name
            return
        send_monitoring_event_cmd = [
            sys.executable, run_cmd, 'infra.tools.send_monitoring_event',
            '--event-mon-run-type', 'prod', '--build-event-type', 'BUILD',
            '--event-mon-timestamp-kind', 'POINT', '--event-logrequest-path',
            os.path.join(build_data_dir, 'log_request_proto')
        ] + goma_options
        cmd_filter = chromium_utils.FilterCapture()
        retcode = chromium_utils.RunCommand(send_monitoring_event_cmd,
                                            filter_obj=cmd_filter,
                                            max_time=30)
        if retcode:
            print('Execution of send_monitoring_event failed with code %s' %
                  retcode)
            print '\n'.join(cmd_filter.text)
    except Exception, inst:  # safety net
        print('send_monitoring_event for goma failed: %s' % inst)
예제 #3
0
def SendCountersToTsMon(counters):
    """Send goma status counter to ts_mon.

  Args:
    counters: a list of data which is sent to ts_mon.
  """

    if not counters:
        print('No counter to send to ts_mon is specified')
        return

    try:
        run_cmd = PLATFORM_RUN_CMD.get(os.name)
        if not run_cmd:
            print 'Unknown os.name: %s' % os.name
            return

        counters_json = []
        for c in counters:
            c_json = json.dumps(c)
            # base64 encode on windows because it doesn't like json
            # on the command-line.
            if os.name == 'nt':
                c_json = base64.b64encode(c_json)
            counters_json.append('--counter')
            counters_json.append(c_json)

        cmd = [
            sys.executable, run_cmd, 'infra.tools.send_ts_mon_values',
            '--verbose', '--ts-mon-target-type', 'task',
            '--ts-mon-task-service-name', 'goma-client',
            '--ts-mon-task-job-name', 'default'
        ]
        cmd.extend(counters_json)
        cmd_filter = chromium_utils.FilterCapture()
        retcode = chromium_utils.RunCommand(cmd,
                                            filter_obj=cmd_filter,
                                            max_time=30)
        if retcode:
            print('Execution of send_ts_mon_values failed with code %s' %
                  retcode)
            print '\n'.join(cmd_filter.text)
    except Exception as ex:
        print('error while sending counters to ts_mon: counter=%s: %s' %
              (counters, ex))
예제 #4
0
    def _process_changes(self, _change):
        capture = chromium_utils.FilterCapture()
        cmd = [sys.executable, self.gsutil, 'cat', self.changeurl]
        ret = chromium_utils.RunCommand(cmd, filter_obj=capture, env=self.env)
        parsed_revision = capture.text[0].strip()

        if ret != 0:
            raise RuntimeError(
                'GSURLPoller poll failed with exit code: %s.\nCmd: %s.\nURL: %s\n'
                'Error messages: %s. ' %
                (ret, ' '.join(cmd), self.changeurl, '\n'.join(capture.text)))
        log.msg('GSURLPoller finished polling %s' % self.changeurl)
        if self.last_change != parsed_revision:
            self.master.addChange(who='gsurl_poller',
                                  files=[],
                                  revision=parsed_revision,
                                  comments='comment',
                                  category=self.category)
            self.last_change = parsed_revision
예제 #5
0
  def setUp(self):
    super(TelemetryTest, self).setUp()

    self.telemetry = os.path.join(SCRIPT_DIR, '..', 'telemetry.py')
    self.capture = chromium_utils.FilterCapture()
예제 #6
0
 def setUp(self):
     self.capture = chromium_utils.FilterCapture()
     self.tempfd, self.tempfn = tempfile.mkstemp()
     self.temp = os.fdopen(self.tempfd, 'wb')
     self.script = os.path.join(SCRIPT_DIR, os.pardir, 'annotator.py')
예제 #7
0
def SendGomaTsMon(json_file, exit_status):
    """Send latest Goma status to ts_mon.

  Args:
    json_file: json filename string that has goma_ctl.py jsonstatus.
    exit_status: integer exit status of the build.
  """
    json_statuses = {}
    try:
        with open(json_file) as f:
            json_statuses = json.load(f)

        if not json_statuses:
            print('no json status is recorded in %s' % json_file)
            return

        if len(json_statuses.get('notice', [])) != 1:
            print('unknown json statuses style: %s' % json_statuses)
            return

        json_status = json_statuses['notice'][0]
        if json_status['version'] != 1:
            print('unknown version: %s' % json_status)
            return

        infra_status = json_status.get('infra_status')

        result = 'success'
        if exit_status != 0:
            result = 'failure'
            if (exit_status < 0 or not infra_status
                    or infra_status['ping_status_code'] != 200
                    or infra_status.get('num_user_error', 0) > 0):
                result = 'exception'

        num_failure = 0
        ping_status_code = 0
        if infra_status:
            num_failure = infra_status['num_exec_compiler_proxy_failure']
            ping_status_code = infra_status['ping_status_code']

        clobber = 0
        if os.environ.get('BUILDBOT_CLOBBER'):
            clobber = 1

        counter = {
            'name': 'goma/failure',
            'value': num_failure,
            'builder': os.environ.get('BUILDBOT_BUILDERNAME', 'unknown'),
            'master': os.environ.get('BUILDBOT_MASTERNAME', 'unknown'),
            'slave': os.environ.get('BUILDBOT_SLAVENAME', 'unknown'),
            'clobber': clobber,
            'os': chromium_utils.PlatformName(),
            'ping_status_code': ping_status_code,
            'result': result
        }
        start_time = GetCompilerProxyStartTime()
        if start_time:
            counter['start_time'] = int(time.mktime(start_time.timetuple()))
        run_cmd = PLATFORM_RUN_CMD.get(os.name)
        if not run_cmd:
            print 'Unknown os.name: %s' % os.name
            return

        counter_json = json.dumps(counter)
        # base64 encode on windows because it doesn't like json on the command-line.
        if os.name == 'nt':
            counter_json = base64.b64encode(counter_json)
        cmd = [
            sys.executable, run_cmd, 'infra.tools.send_ts_mon_values',
            '--verbose', '--ts-mon-target-type', 'task',
            '--ts-mon-task-service-name', 'goma-client',
            '--ts-mon-task-job-name', 'default', '--counter', counter_json
        ]
        cmd_filter = chromium_utils.FilterCapture()
        retcode = chromium_utils.RunCommand(cmd,
                                            filter_obj=cmd_filter,
                                            max_time=30)
        if retcode:
            print('Execution of send_ts_mon_values failed with code %s' %
                  retcode)
            print '\n'.join(cmd_filter.text)

    except Exception as ex:
        print('error while sending ts mon json_file=%s: %s' % (json_file, ex))