show pushlog url and how to resume on known exceptions

This commit is contained in:
Julien Pagès 2015-02-20 10:48:33 +01:00
Родитель 741bfe1f7b
Коммит d240ee9ea2
3 изменённых файлов: 57 добавлений и 5 удалений

Просмотреть файл

@ -326,9 +326,12 @@ class BisectRunner(object):
self.bisector = Bisector(fetch_config, test_runner)
self._logger = get_default_logger('Bisector')
def do_bisect(self, handler, good, bad, **kwargs):
return self.bisector.bisect(handler, good, bad, **kwargs)
def bisect_nightlies(self, good_date, bad_date):
handler = NightlyHandler(find_fix=self.options.find_fix)
result = self.bisector.bisect(handler, good_date, bad_date)
result = self.do_bisect(handler, good_date, bad_date)
if result == Bisector.FINISHED:
self._logger.info("Got as far as we can go bisecting nightlies...")
handler.print_range()
@ -398,8 +401,7 @@ class BisectRunner(object):
# we can change this at some point in the future, after those builds
# expire)
handler = InboundHandler(find_fix=self.options.find_fix)
result = self.bisector.bisect(handler, good_rev, bad_rev,
range=60*60*12)
result = self.do_bisect(handler, good_rev, bad_rev, range=60*60*12)
if result == Bisector.FINISHED:
self._logger.info("Oh noes, no (more) inbound revisions :(")
handler.print_range()

Просмотреть файл

@ -11,6 +11,7 @@ Entry point for the mozregression command line.
import mozinfo
import datetime
import sys
import atexit
from argparse import ArgumentParser
from mozlog.structured import commandline, get_default_logger
from requests.exceptions import RequestException
@ -149,6 +150,21 @@ def parse_args(argv=None):
return options
class ResumeInfoBisectRunner(BisectRunner):
def do_bisect(self, handler, good, bad, **kwargs):
try:
return BisectRunner.do_bisect(self, handler, good, bad, **kwargs)
except (KeyboardInterrupt, MozRegressionError, RequestException):
if handler.good_revision is not None and \
handler.bad_revision is not None:
atexit.register(self.on_exit_print_resume_info, handler)
raise
def on_exit_print_resume_info(self, handler):
handler.print_range()
self.print_resume_info(handler)
def bisect_inbound(runner, logger):
fetch_config = runner.fetch_config
options = runner.options
@ -240,7 +256,7 @@ def cli(argv=None):
test_runner = CommandTestRunner(fetch_config, options.command,
persist=options.persist)
runner = BisectRunner(fetch_config, test_runner, options)
runner = ResumeInfoBisectRunner(fetch_config, test_runner, options)
if fetch_config.is_inbound():
# this can be useful for both inbound and nightly, because we

Просмотреть файл

@ -19,7 +19,7 @@ class TestMainCli(unittest.TestCase):
@patch('mozlog.structured.commandline.setup_logging')
@patch('mozregression.main.set_http_cache_session')
@patch('mozregression.limitedfilecache.get_cache')
@patch('mozregression.main.BisectRunner')
@patch('mozregression.main.ResumeInfoBisectRunner')
def do_cli(self, argv, BisectRunner, get_cache, set_http_cache_session,
setup_logging):
def create_runner(fetch_config, test_runner, options):
@ -150,5 +150,39 @@ class TestMainCli(unittest.TestCase):
assert_called_with(utils.parse_date(good[1]),
utils.parse_date(bad[1]))
class TestResumeInfoBisectRunner(unittest.TestCase):
@patch('mozregression.main.BisectRunner')
def test_do_bisect(self, BisectRunner):
BisectRunner.do_bisect.return_value = 0
runner = main.ResumeInfoBisectRunner(None, None, None)
result = runner.do_bisect('handler', 'g', 'b', range=4)
self.assertEquals(result, 0)
BisectRunner.do_bisect.assert_called_with(runner, 'handler', 'g', 'b',
range=4)
@patch('atexit.register')
@patch('mozregression.main.BisectRunner')
def test_do_bisect_error(self, BisectRunner, register):
BisectRunner.do_bisect.side_effect = KeyboardInterrupt
runner = main.ResumeInfoBisectRunner(None, None, None)
handler = Mock(good_revision=1, bad_revision=2)
with self.assertRaises(KeyboardInterrupt):
runner.do_bisect(handler, 'g', 'b')
register.assert_called_with(runner.on_exit_print_resume_info,
handler)
@patch('mozregression.main.BisectRunner')
def test_on_exit_print_resume_info(self, BisectRunner):
handler = Mock()
runner = main.ResumeInfoBisectRunner(None, None, None)
runner.print_resume_info = Mock()
runner.on_exit_print_resume_info(handler)
handler.print_range.assert_called_with()
runner.print_resume_info.assert_called_with(handler)
if __name__ == '__main__':
unittest.main()