Beispiel #1
0
 def bisect_nightlies(self):
     good_date, bad_date = self.options.good, self.options.bad
     handler = NightlyHandler(
         find_fix=self.options.find_fix,
         ensure_good_and_bad=self.options.mode != 'no-first-check',
     )
     result = self._do_bisect(handler, good_date, bad_date)
     if result == Bisection.FINISHED:
         LOG.info("Got as far as we can go bisecting nightlies...")
         handler.print_range()
         if self.fetch_config.can_go_inbound():
             LOG.info("Switching bisection method to taskcluster")
             self.fetch_config.set_repo(
                 self.fetch_config.get_nightly_repo(handler.bad_date))
             return self._bisect_inbounds(handler.good_revision,
                                          handler.bad_revision,
                                          expand=DEFAULT_EXPAND)
     elif result == Bisection.USER_EXIT:
         self._print_resume_info(handler)
     else:
         # NO_DATA
         LOG.info("Unable to get valid builds within the given"
                  " range. You should try to launch mozregression"
                  " again with a larger date range.")
         return 1
     return 0
Beispiel #2
0
 def bisect_nightlies(self):
     good_date, bad_date = self.options.good, self.options.bad
     handler = NightlyHandler(
         find_fix=self.options.find_fix,
         ensure_good_and_bad=self.options.mode != 'no-first-check',
     )
     result = self._do_bisect(handler, good_date, bad_date)
     if result == Bisection.FINISHED:
         LOG.info("Got as far as we can go bisecting nightlies...")
         handler.print_range()
         if self.fetch_config.can_go_inbound():
             LOG.info("Switching bisection method to taskcluster")
             self.fetch_config.set_repo(
                 self.fetch_config.get_nightly_repo(handler.bad_date))
             return self._bisect_inbounds(handler.good_revision,
                                          handler.bad_revision,
                                          expand=DEFAULT_EXPAND)
     elif result == Bisection.USER_EXIT:
         self._print_resume_info(handler)
     else:
         # NO_DATA
         LOG.info("Unable to get valid builds within the given"
                  " range. You should try to launch mozregression"
                  " again with a larger date range.")
         return 1
     return 0
Beispiel #3
0
 def bisect_nightlies(self):
     good_date, bad_date = self.options.good_date, self.options.bad_date
     handler = NightlyHandler(find_fix=self.options.find_fix)
     result = self._do_bisect(handler, good_date, bad_date)
     if result == Bisection.FINISHED:
         self._logger.info("Got as far as we can go bisecting nightlies...")
         handler.print_range()
         if self.fetch_config.can_go_inbound():
             good_rev, bad_rev = handler.find_inbound_changesets()
             return self._bisect_inbounds(good_rev, bad_rev)
         else:
             message = ("Can not bisect inbound for application `%s`"
                        % self.fetch_config.app_name)
             if self.fetch_config.is_inbound():
                 # the config is able to bissect inbound but not
                 # for this repo.
                 message += (" because the repo `%s` was specified"
                             % self.options.repo)
             self._logger.info(message + '.')
     elif result == Bisection.USER_EXIT:
         self._print_resume_info(handler)
     else:
         # NO_DATA
         self._logger.info("Unable to get valid builds within the given"
                           " range. You should try to launch mozregression"
                           " again with a larger date range.")
         return 1
     return 0
Beispiel #4
0
    def bisect_nightly(self):
        handler = NightlyHandler(ensure_good_and_bad=True)
        result = self.bisector.bisect(handler, self.good, self.bad)
        if result == Bisection.FINISHED:
            print "Got as far as we can go bisecting nightlies..."
            handler.print_range()
            print "Switching bisection method to taskcluster"
            result = self.bisect_inbound(handler.good_revision, handler.bad_revision)
        else:
            # TODO(ER): maybe this should be an exception...
            result = (None, None)

        return result
Beispiel #5
0
    def bisect_nightly(self):
        handler = NightlyHandler(ensure_good_and_bad=True)
        result = self.bisector.bisect(handler, self.good, self.bad)
        if result == Bisection.FINISHED:
            print("Got as far as we can go bisecting nightlies...")
            handler.print_range()
            print("Switching bisection method to taskcluster")
            result = self.bisect_inbound(handler.good_revision,
                                         handler.bad_revision)
        else:
            # TODO(ER): maybe this should be an exception...
            result = (None, None)

        return result
Beispiel #6
0
class TestNightlyHandler(unittest.TestCase):
    def setUp(self):
        self.handler = NightlyHandler()

    @patch('mozregression.bisector.BisectorHandler.initialize')
    def test_initialize(self, initialize):
        def get_associated_data(index):
            return index
        self.handler.build_range = [Mock(build_date=0),
                                    Mock(build_date=1)]
        self.handler.initialize()
        # check that members are set
        self.assertEqual(self.handler.good_date, 0)
        self.assertEqual(self.handler.bad_date, 1)

        initialize.assert_called_with(self.handler)

    @patch('mozregression.bisector.LOG')
    def test_print_progress(self, logger):
        log = []
        logger.info = log.append
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)

        new_data = [
            Mock(build_date=datetime.date(2014, 11, 15)),
            Mock(build_date=datetime.date(2014, 11, 20))
        ]

        self.handler._print_progress(new_data)
        self.assertIn('from [2014-11-10, 2014-11-20] (10 days)', log[0])
        self.assertIn('to [2014-11-15, 2014-11-20] (5 days)', log[0])
        self.assertIn('2 steps left', log[0])

    @patch('mozregression.bisector.LOG')
    def test_user_exit(self, logger):
        log = []
        logger.info = log.append
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)
        self.handler.user_exit(0)
        self.assertEqual('Newest known good nightly: 2014-11-10', log[0])
        self.assertEqual('Oldest known bad nightly: 2014-11-20', log[1])

    @patch('mozregression.bisector.LOG')
    def test_print_range_without_repo(self, logger):
        log = []
        logger.info = log.append
        logger.error = log.append
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)
        self.handler.print_range()
        self.assertIn("no pushlog url available", log[0])
        self.assertEqual('Newest known good nightly: 2014-11-10', log[1])
        self.assertEqual('Oldest known bad nightly: 2014-11-20', log[2])

    @patch('mozregression.bisector.LOG')
    def test_print_range_rev_availables(self, logger):
        self.handler.found_repo = 'https://hg.mozilla.repo'
        self.handler.good_revision = '2'
        self.handler.bad_revision = '6'
        self.handler.good_date = datetime.date(2015, 1, 1)
        self.handler.bad_date = datetime.date(2015, 1, 2)
        log = []
        logger.info = log.append

        self.handler.print_range()
        self.assertEqual(log[0], "Last good revision: 2 (2015-01-01)")
        self.assertEqual(log[1], "First bad revision: 6 (2015-01-02)")
        self.assertIn(self.handler.get_pushlog_url(), log[2])

    @patch('mozregression.bisector.LOG')
    def test_print_range_no_rev_availables(self, logger):
        self.handler.found_repo = 'https://hg.mozilla.repo'
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)
        log = []
        logger.info = log.append

        self.handler.print_range()
        self.assertEqual('Newest known good nightly: 2014-11-10', log[0])
        self.assertEqual('Oldest known bad nightly: 2014-11-20', log[1])
        self.assertIn("pushloghtml?startdate=2014-11-10&enddate=2014-11-20",
                      log[2])
Beispiel #7
0
class TestNightlyHandler(unittest.TestCase):
    def setUp(self):
        self.handler = NightlyHandler()

    def test_build_infos(self):
        def get_associated_data(index):
            return index
        new_data = MagicMock(get_associated_data=get_associated_data)
        self.handler.set_build_data(new_data)
        result = self.handler.build_infos(1)
        self.assertEqual(result, {
            'build_type': 'nightly',
            'build_date': 1,
        })

    @patch('mozregression.bisector.BisectorHandler.initialize')
    def test_initialize(self, initialize):
        def get_associated_data(index):
            return index
        self.handler.build_data = Mock(get_associated_data=get_associated_data)
        self.handler.initialize()
        # check that members are set
        self.assertEqual(self.handler.good_date, 0)
        self.assertEqual(self.handler.bad_date, -1)

        initialize.assert_called_with(self.handler)

    def test_print_progress(self):
        log = []
        self.handler._logger = Mock(info=log.append)
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)

        def get_associated_data(index):
            if index == 0:
                return datetime.date(2014, 11, 15)
            elif index == -1:
                return datetime.date(2014, 11, 20)
        new_data = Mock(get_associated_data=get_associated_data)

        self.handler._print_progress(new_data)
        self.assertIn('from [2014-11-10, 2014-11-20] (10 days)', log[0])
        self.assertIn('to [2014-11-15, 2014-11-20] (5 days)', log[0])
        self.assertIn('2 steps left', log[0])

    def test_user_exit(self):
        log = []
        self.handler._logger = Mock(info=log.append)
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)
        self.handler.user_exit(0)
        self.assertEqual('Newest known good nightly: 2014-11-10', log[0])
        self.assertEqual('Oldest known bad nightly: 2014-11-20', log[1])

    def test_print_range_without_repo(self):
        log = []
        self.handler._logger = Mock(info=log.append, error=log.append)
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)
        self.handler.print_range()
        self.assertIn("no pushlog url available", log[0])
        self.assertEqual('Newest known good nightly: 2014-11-10', log[1])
        self.assertEqual('Oldest known bad nightly: 2014-11-20', log[2])

    def test_print_range_rev_availables(self):
        self.handler.found_repo = 'https://hg.mozilla.repo'
        self.handler.good_revision = '2'
        self.handler.bad_revision = '6'
        log = []
        self.handler._logger = Mock(info=log.append)

        self.handler.print_range()
        self.assertEqual(log[0], "Last good revision: 2")
        self.assertEqual(log[1], "First bad revision: 6")
        self.assertIn(self.handler.get_pushlog_url(), log[2])

    def test_print_range_no_rev_availables(self):
        self.handler.found_repo = 'https://hg.mozilla.repo'
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)
        log = []
        self.handler._logger = Mock(info=log.append)

        self.handler.print_range()
        self.assertEqual('Newest known good nightly: 2014-11-10', log[0])
        self.assertEqual('Oldest known bad nightly: 2014-11-20', log[1])
        self.assertIn("pushloghtml?startdate=2014-11-10&enddate=2014-11-20",
                      log[2])
Beispiel #8
0
class TestNightlyHandler(unittest.TestCase):
    def setUp(self):
        self.handler = NightlyHandler()

    def test_build_infos(self):
        fetch_config = create_config('fennec-2.3', 'linux', 64)
        fetch_config.set_nightly_repo('my-repo')

        def get_associated_data(index):
            return index
        new_data = MagicMock(get_associated_data=get_associated_data)
        self.handler.set_build_data(new_data)
        result = self.handler.build_infos(1, fetch_config)
        self.assertEqual(result, {
            'build_type': 'nightly',
            'build_date': 1,
            'app_name': 'fennec',
            'repo': 'my-repo'
        })

    @patch('mozregression.bisector.BisectorHandler.initialize')
    def test_initialize(self, initialize):
        def get_associated_data(index):
            return index
        self.handler.build_data = Mock(get_associated_data=get_associated_data)
        self.handler.initialize()
        # check that members are set
        self.assertEqual(self.handler.good_date, 0)
        self.assertEqual(self.handler.bad_date, -1)

        initialize.assert_called_with(self.handler)

    def test_print_progress(self):
        log = []
        self.handler._logger = Mock(info=log.append)
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)

        def get_associated_data(index):
            if index == 0:
                return datetime.date(2014, 11, 15)
            elif index == -1:
                return datetime.date(2014, 11, 20)
        new_data = Mock(get_associated_data=get_associated_data)

        self.handler._print_progress(new_data)
        self.assertIn('from [2014-11-10, 2014-11-20] (10 days)', log[0])
        self.assertIn('to [2014-11-15, 2014-11-20] (5 days)', log[0])
        self.assertIn('2 steps left', log[0])

    def test_user_exit(self):
        log = []
        self.handler._logger = Mock(info=log.append)
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)
        self.handler.user_exit(0)
        self.assertEqual('Newest known good nightly: 2014-11-10', log[0])
        self.assertEqual('Oldest known bad nightly: 2014-11-20', log[1])

    def test_print_range_without_repo(self):
        log = []
        self.handler._logger = Mock(info=log.append, error=log.append)
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)
        self.handler.print_range()
        self.assertIn("no pushlog url available", log[0])
        self.assertEqual('Newest known good nightly: 2014-11-10', log[1])
        self.assertEqual('Oldest known bad nightly: 2014-11-20', log[2])

    def test_print_range_rev_availables(self):
        self.handler.found_repo = 'https://hg.mozilla.repo'
        self.handler.good_revision = '2'
        self.handler.bad_revision = '6'
        log = []
        self.handler._logger = Mock(info=log.append)

        self.handler.print_range()
        self.assertEqual(log[0], "Last good revision: 2")
        self.assertEqual(log[1], "First bad revision: 6")
        self.assertIn(self.handler.get_pushlog_url(), log[2])

    def test_print_range_no_rev_availables(self):
        self.handler.found_repo = 'https://hg.mozilla.repo'
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)
        log = []
        self.handler._logger = Mock(info=log.append)

        self.handler.print_range()
        self.assertEqual('Newest known good nightly: 2014-11-10', log[0])
        self.assertEqual('Oldest known bad nightly: 2014-11-20', log[1])
        self.assertIn("pushloghtml?startdate=2014-11-10&enddate=2014-11-20",
                      log[2])
Beispiel #9
0
class TestNightlyHandler(unittest.TestCase):
    def setUp(self):
        self.handler = NightlyHandler()

    @patch('mozregression.bisector.BisectorHandler.initialize')
    def test_initialize(self, initialize):
        def get_associated_data(index):
            return index

        self.handler.build_range = [Mock(build_date=0), Mock(build_date=1)]
        self.handler.initialize()
        # check that members are set
        self.assertEqual(self.handler.good_date, 0)
        self.assertEqual(self.handler.bad_date, 1)

        initialize.assert_called_with(self.handler)

    @patch('mozregression.bisector.LOG')
    def test_print_progress(self, logger):
        log = []
        logger.info = log.append
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)

        new_data = [
            Mock(build_date=datetime.date(2014, 11, 15)),
            Mock(build_date=datetime.date(2014, 11, 20))
        ]

        self.handler._print_progress(new_data)
        self.assertIn('from [2014-11-10, 2014-11-20] (10 days)', log[0])
        self.assertIn('to [2014-11-15, 2014-11-20] (5 days)', log[0])
        self.assertIn('2 steps left', log[0])

    @patch('mozregression.bisector.LOG')
    def test_user_exit(self, logger):
        log = []
        logger.info = log.append
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)
        self.handler.user_exit(0)
        self.assertEqual('Newest known good nightly: 2014-11-10', log[0])
        self.assertEqual('Oldest known bad nightly: 2014-11-20', log[1])

    @patch('mozregression.bisector.LOG')
    def test_print_range_without_repo(self, logger):
        log = []
        logger.info = log.append
        logger.error = log.append
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)
        self.handler.print_range()
        self.assertIn("no pushlog url available", log[0])
        self.assertEqual('Newest known good nightly: 2014-11-10', log[1])
        self.assertEqual('Oldest known bad nightly: 2014-11-20', log[2])

    @patch('mozregression.bisector.LOG')
    def test_print_range_rev_availables(self, logger):
        self.handler.found_repo = 'https://hg.mozilla.repo'
        self.handler.good_revision = '2'
        self.handler.bad_revision = '6'
        self.handler.good_date = datetime.date(2015, 1, 1)
        self.handler.bad_date = datetime.date(2015, 1, 2)
        log = []
        logger.info = log.append

        self.handler.print_range()
        self.assertEqual(log[0], "Last good revision: 2 (2015-01-01)")
        self.assertEqual(log[1], "First bad revision: 6 (2015-01-02)")
        self.assertIn(self.handler.get_pushlog_url(), log[2])

    @patch('mozregression.bisector.LOG')
    def test_print_range_no_rev_availables(self, logger):
        self.handler.found_repo = 'https://hg.mozilla.repo'
        self.handler.good_date = datetime.date(2014, 11, 10)
        self.handler.bad_date = datetime.date(2014, 11, 20)
        log = []
        logger.info = log.append

        self.handler.print_range()
        self.assertEqual('Newest known good nightly: 2014-11-10', log[0])
        self.assertEqual('Oldest known bad nightly: 2014-11-20', log[1])
        self.assertIn("pushloghtml?startdate=2014-11-10&enddate=2014-11-20",
                      log[2])