def test_send_service_event_revinfo_smoke(self): args = get_arguments([ '--event-mon-service-name', 'thing', '--service-event-type', 'START', '--service-event-revinfo', os.path.join(DATA_DIR, 'revinfo.txt') ]) common.send_service_event(args)
def main(self, opts): # pragma: no cover status = 0 try: if opts.build_event_type: success_metric.set(common.send_build_event(opts)) elif opts.service_event_type: success_metric.set(common.send_service_event(opts)) elif opts.events_from_file: success_metric.set(common.send_events_from_file(opts)) else: print >> sys.stderr, ('At least one of the --*-event-type options or ' '--events-from-file should be provided. Nothing ' 'was sent.') status = 2 success_metric.set(False) except Exception: success_metric.set(False) traceback.print_exc() # helps with debugging locally. finally: event_mon.close() try: ts_mon.flush() except ts_mon.MonitoringNoConfiguredMonitorError: logging.error("Unable to flush ts_mon because it's not configured.") except Exception: logging.exception("Flushing ts_mon metrics failed.") return status
def test_logrequest_path_service_type_override(self): with infra_libs.temporary_directory(prefix='common_test-') as tmpdir: outfile = os.path.join(tmpdir, 'out.bin') args = get_arguments([ '--event-mon-run-type', 'file', '--event-mon-output-file', outfile, '--event-mon-service-name', 'thing', '--event-logrequest-path', os.path.join(DATA_DIR, 'service-bar-service.bin'), '--service-event-type', 'STOP', ]) self.assertEquals(args.event_mon_run_type, 'file') event_mon.process_argparse_options(args) common.process_argparse_options(args) self.assertTrue(common.send_service_event(args)) # Now open the resulting file and check what was written with open(outfile, 'rb') as f: request = LogRequestLite.FromString(f.read()) self.assertEqual(len(request.log_event), 1) event = ChromeInfraEvent.FromString( request.log_event[0].source_extension) self.assertEqual(event.event_source.host_name, 'myhostname') self.assertEqual(event.service_event.type, ServiceEvent.STOP) self.assertEqual(event.timestamp_kind, ChromeInfraEvent.END)
def test_send_service_event_stack_trace_smoke(self): args = get_arguments([ '--event-mon-service-name', 'thing', '--service-event-stack-trace', 'stack trace' ]) common.send_service_event(args)
def test_send_service_event_revinfo_from_gclient_smoke(self): args = get_arguments([ '--event-mon-service-name', 'thing', '--service-event-type', 'START', '--service-event-revinfo-from-gclient' ]) common.send_service_event(args)