cbuildbot.py, cbuildbot_stages.py: add a --mock-tree-status option
This CL adds a command line flag to cbuildbot.py which allows a tester
to override the tree status. The flag is intended to be used with
--buildbot --debug flags enabled. A normal --debug run will ignore the
tree status, but the newly added flag also causes --debug to NOT ignore
the tree status.
The purpose of this CL is to make it possible to test
CL:I98dec5afa3cddb9bfb15523f3d8c947979917138
BUG=chromium:319939
TEST=Ran a local x86-mario-paladin run with --buildbot --debug and
--mock-tree-status=closed. Saw the build wait in CommitQueueSync for the
tree to open.
Change-Id: I8608e470a4a6d2427b93889e175f95fef868dea6
Reviewed-on: https://chromium-review.googlesource.com/179854
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
Tested-by: Aviv Keshet <akeshet@chromium.org>
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 0726077..1097174 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -45,6 +45,8 @@
from chromite.lib import sudo
from chromite.lib import timeout_util
+import mock
+
_DEFAULT_LOG_DIR = 'cbuildbot_logs'
_BUILDBOT_LOG_FILE = 'cbuildbot.log'
@@ -1184,6 +1186,14 @@
group.add_remote_option('--validation_pool', default=None,
help='Path to a pickled validation pool. Intended '
'for use only with the commit queue.')
+ group.add_remote_option('--mock-tree-status', dest='mock_tree_status',
+ default=None, action='store',
+ help='Override the tree status value that would be '
+ 'returned from the the actual tree. Example '
+ 'values: open, closed, throttled. When used '
+ 'in conjunction with --debug, the tree status '
+ 'will not be ignored as it usually is in a '
+ '--debug run.')
parser.add_option_group(group)
@@ -1556,4 +1566,8 @@
if options.buildbot or options.remote_trybot:
_DisableYamaHardLinkChecks()
+ if options.mock_tree_status is not None:
+ stack.Add(mock.patch.object, timeout_util, '_GetStatus',
+ return_value=options.mock_tree_status)
+
_RunBuildStagesWrapper(options, build_config)