def test_send_service_event_revinfo_smoke(self): args = send_event.get_arguments([ '--event-mon-service-name', 'thing', '--service-event-type', 'START', '--service-event-revinfo', os.path.join(DATA_DIR, 'revinfo.txt') ]) send_event.send_service_event(args)
def test_logrequest_path_service_type_override(self): with infra_libs.temporary_directory(prefix='send_event_test-') as tmpdir: outfile = os.path.join(tmpdir, 'out.bin') args = send_event.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) send_event._process_logrequest_path(args) self.assertTrue(send_event.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 main(argv): # pragma: no cover # Does nothing when no arguments are passed, to make it safe to import this # module (main() is executed on import, because this file is called __main__). status = 0 if len(argv) == 0: return status success_metric = ts_mon.BooleanMetric('send_monitoring_event/success') try: args = send_event.get_arguments(argv) send_event.process_argparse_options(args) if args.build_event_type: success_metric.set(send_event.send_build_event(args)) elif args.service_event_type: success_metric.set(send_event.send_service_event(args)) elif args.events_from_file: success_metric.set(send_event.send_events_from_file(args)) 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) finally: event_mon.close() try: ts_mon.flush() except ts_mon.MonitoringNoConfiguredMonitorError: pass return status
def main(argv): # pragma: no cover # Does nothing when no arguments are passed, to make it safe to import this # module (main() is executed on import, because this file is called __main__). status = 0 if len(argv) == 0: return status try: args = send_event.get_arguments(argv) send_event.process_argparse_options(args) if args.build_event_type: success_metric.set(send_event.send_build_event(args)) elif args.service_event_type: success_metric.set(send_event.send_service_event(args)) elif args.events_from_file: success_metric.set(send_event.send_events_from_file(args)) 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 main(argv): # pragma: no cover # Does nothing when no arguments are passed, to make it safe to import this # module (main() is executed on import, because this file is called __main__). status = 0 if len(argv) == 0: return status success_metric = ts_mon.BooleanMetric('send_monitoring_event/success') try: args = send_event.get_arguments(argv) send_event.process_argparse_options(args) if args.build_event_type: success_metric.set(send_event.send_build_event(args)) elif args.service_event_type: success_metric.set(send_event.send_service_event(args)) elif args.events_from_file: success_metric.set(send_event.send_events_from_file(args)) 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) finally: event_mon.close() try: ts_mon.flush() except ts_mon.MonitoringNoConfiguredMonitorError: pass return status
def test_send_service_event_revinfo_smoke(self): args = send_event.get_arguments( ['--event-mon-service-name', 'thing', '--service-event-type', 'START', '--service-event-revinfo', os.path.join(DATA_DIR, 'revinfo.txt')]) send_event.send_service_event(args)
def test_send_service_event_stack_trace_smoke(self): args = send_event.get_arguments( ['--event-mon-service-name', 'thing', '--service-event-stack-trace', 'stack trace']) send_event.send_service_event(args)
def test_send_service_event_stack_trace_smoke(self): args = send_event.get_arguments([ '--event-mon-service-name', 'thing', '--service-event-stack-trace', 'stack trace' ]) send_event.send_service_event(args)