def testTreeIsThrottled(self): """Tests that we return True if the tree is throttled.""" self._SetupMockTreeStatusResponses( final_tree_status='Tree is throttled (flaky bug on flaky builder)', final_general_state=constants.TREE_THROTTLED) self.assertTrue(tree_status.IsTreeOpen(status_url=self.status_url, throttled_ok=True))
def CommitNewLKGM(self): """Commits the new LKGM file using our template commit message.""" lv = distutils.version.LooseVersion if not self._lkgm and not lv(self._lkgm) < lv(self._old_lkgm): raise LKGMNotFound('No valid LKGM found. Did you run FindNewLKGM?') commit_msg = self._COMMIT_MSG % dict(version=self._lkgm) try: # Add the new versioned file. osutils.WriteFile( os.path.join(self._checkout_dir, constants.PATH_TO_CHROME_LKGM), self._lkgm) cros_build_lib.RunCommand( ['git', 'add', constants.PATH_TO_CHROME_LKGM], cwd=self._checkout_dir) # Commit it! cros_build_lib.RunCommand( ['git', 'commit', '-m', commit_msg], cwd=self._checkout_dir) except cros_build_lib.RunCommandError as e: raise LKGMNotCommitted( 'Could not create git commit with new LKGM: %r' % e) if not tree_status.IsTreeOpen(status_url=gclient.STATUS_URL, period=self._SLEEP_TIMEOUT, timeout=self._TREE_TIMEOUT): raise LKGMNotCommitted('Chromium Tree is closed') if not self._dryrun: try: cros_build_lib.RunCommand( ['git', 'cl', 'land', '-f', '--bypass-hooks', '-m', commit_msg], cwd=self._checkout_dir) except cros_build_lib.RunCommandError as e: raise LKGMNotCommitted('Could not submit LKGM: %r' % e)
def testTreeIsThrottledNotOk(self): """Tests that we respect throttled_ok""" self._SetupMockTreeStatusResponses( rejected_tree_status='Tree is throttled (flaky bug on flaky builder)', rejected_general_state=constants.TREE_THROTTLED, output_final_status=False) self.assertFalse(tree_status.IsTreeOpen(status_url=self.status_url, period=0.1))
def testTreeIsClosed(self): """Tests that we return false is the tree is closed.""" self._SetupMockTreeStatusResponses(output_final_status=False) self.assertFalse(tree_status.IsTreeOpen(status_url=self.status_url, period=0.1))
def testTreeIsOpen(self): """Tests that we return True is the tree is open.""" self._SetupMockTreeStatusResponses(rejected_status_count=5, retries_500=5) self.assertTrue(tree_status.IsTreeOpen(status_url=self.status_url, period=0))