def main(jenkins_build_url, test_reports_dir, jstest_reports_file, lint_reports_file, hipchat_room, slack_channel, dry_run): if dry_run: alertlib.enter_test_mode() logging.getLogger().setLevel(logging.INFO) num_errors = 0 if test_reports_dir: num_errors += report_test_failures(test_reports_dir, jenkins_build_url, hipchat_room, slack_channel) # If we ran any of the alternate-tests above, we'll fake having # emitted otuput to the output file. if jstest_reports_file: if 'javascript' in _ALTERNATE_TESTS_VALUES: with open(jstest_reports_file, 'w') as f: # TODO(csilvers): send a cStringIO to report_* instead. f.write(_ALTERNATE_TESTS_VALUES['javascript']) num_errors += report_jstest_failures(jstest_reports_file, hipchat_room, slack_channel) if lint_reports_file: if 'lint' in _ALTERNATE_TESTS_VALUES: with open(lint_reports_file, 'w') as f: f.write(_ALTERNATE_TESTS_VALUES['lint']) num_errors += report_lint_failures(lint_reports_file, hipchat_room, slack_channel) return num_errors
def test_test_mode(self): alertlib.enter_test_mode() try: alertlib.Alert('test message') \ .send_to_hipchat('1s and 0s') \ .send_to_email('ka-admin') \ .send_to_pagerduty('oncall') \ .send_to_logs() \ .send_to_graphite('stats.alerted') finally: alertlib.exit_test_mode() # Should only log, not send to anything self.assertEqual([], self.sent_to_hipchat) self.assertEqual([], self.sent_to_google_mail) self.assertEqual([], self.sent_to_sendmail) self.assertEqual([], self.sent_to_syslog) self.assertEqual([], self.sent_to_graphite) self.assertEqual( [('alertlib: would send to hipchat room 1s and 0s: ' 'test message',), ("alertlib: would send email to " "['*****@*****.**'] " "(from alertlib <*****@*****.**> CC None BCC None): " "(subject test message) test message",), ("alertlib: would send pagerduty email to " "['*****@*****.**'] " "(subject test message) test message",), ('alertlib: would send to graphite: stats.alerted 1',) ], self.sent_to_info_log)
def main(jenkins_build_url, test_reports_dir, jstest_reports_file, lint_reports_file, e2e_test_reports_file, slack_channel, dry_run): if dry_run: alertlib.enter_test_mode() logging.getLogger().setLevel(logging.INFO) jenkins_build_url = jenkins_build_url.rstrip("/") num_errors = 0 if test_reports_dir: num_errors += report_test_failures(test_reports_dir, jenkins_build_url, slack_channel) # If we ran any of the alternate-tests above, we'll fake having # emitted otuput to the output file. if jstest_reports_file: if 'javascript' in _ALTERNATE_TESTS_VALUES: with open(jstest_reports_file, 'w') as f: # TODO(csilvers): send a cStringIO to report_* instead. f.write(_ALTERNATE_TESTS_VALUES['javascript']) num_errors += report_jstest_failures(jstest_reports_file, jenkins_build_url, slack_channel) if lint_reports_file: if 'lint' in _ALTERNATE_TESTS_VALUES: with open(lint_reports_file, 'w') as f: f.write(_ALTERNATE_TESTS_VALUES['lint']) num_errors += report_lint_failures(lint_reports_file, slack_channel) if e2e_test_reports_file: num_errors += report_e2e_failures(e2e_test_reports_file, jenkins_build_url, slack_channel) return num_errors
def test_test_mode(self): alertlib.enter_test_mode() try: alertlib.Alert('test message') \ .send_to_hipchat('1s and 0s') \ .send_to_email('ka-admin') \ .send_to_pagerduty('oncall') \ .send_to_logs() \ .send_to_graphite('stats.alerted') finally: alertlib.exit_test_mode() # Should only log, not send to anything self.assertEqual([], self.sent_to_hipchat) self.assertEqual([], self.sent_to_google_mail) self.assertEqual([], self.sent_to_sendmail) self.assertEqual([], self.sent_to_syslog) self.assertEqual([], self.sent_to_graphite) self.assertEqual( [('alertlib: would send to hipchat room 1s and 0s: ' 'test message', ), ("alertlib: would send email to " "['*****@*****.**'] " "(from alertlib <*****@*****.**> CC None BCC None): " "(subject test message) test message", ), ("alertlib: would send pagerduty email to " "['*****@*****.**'] " "(subject test message) test message", ), ('alertlib: would send to graphite: stats.alerted 1', )], self.sent_to_info_log)
def main(argv): parser = setup_parser() args = parser.parse_args(argv) if args.dry_run: logging.getLogger().setLevel(logging.INFO) alertlib.enter_test_mode() rc = run_with_timeout(args.duration, [args.command] + args.arg, args.signal, args.kill_after, args.cwd) if rc == 124: alert.alert('TIMEOUT running %s' % args.command, args) return rc
def main(argv): parser = setup_parser() args = parser.parse_args(argv) if sys.stdin.isatty(): print >> sys.stderr, '>> Enter the message to alert, then hit control-D' message = sys.stdin.read().strip() if args.dry_run: alertlib.enter_test_mode() logging.getLogger().setLevel(logging.INFO) alert(message, args)
def main(argv): parser = setup_parser() args = parser.parse_args(argv) if sys.stdin.isatty(): print >>sys.stderr, ">> Enter the message to alert, then hit control-D" message = sys.stdin.read().strip() if args.dry_run: alertlib.enter_test_mode() logging.getLogger().setLevel(logging.INFO) alert(message, args)