diff options
author | Don Garrett <dgarrett@google.com> | 2014-05-21 13:43:20 -0700 |
---|---|---|
committer | Don Garrett <dgarrett@chromium.org> | 2014-05-21 23:43:58 +0000 |
commit | 1382f1000498d5f6ed0451f1488a4d96b0c6c19d (patch) | |
tree | 4f25b8e15c4956dc5bccbd581e679b478a0b44ef /buildbot | |
parent | a42491359d23e148621ec857c19887554c81f520 (diff) | |
download | chromite-1382f1000498d5f6ed0451f1488a4d96b0c6c19d.tar.gz |
release-stages: Validate board config before trying Paygen.
In order to avoid running paygen against an board which hasn't had
payload generation configured, we explicitly validate that the config
exists. This is done before creating a subprocess so that the
exception type can be preserved, not converted to BackgroundFailure.
BUG=chromium:374641
TEST=lint + unittests
CQ-DEPEND=CL:*164151
Change-Id: I0f04850705b7c2c76512bf057fd2091c2b9d9fad
Reviewed-on: https://chromium-review.googlesource.com/200803
Reviewed-by: Yu-Ju Hong <yjhong@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
Diffstat (limited to 'buildbot')
-rw-r--r-- | buildbot/stages/release_stages.py | 37 | ||||
-rwxr-xr-x | buildbot/stages/release_stages_unittest.py | 16 |
2 files changed, 41 insertions, 12 deletions
diff --git a/buildbot/stages/release_stages.py b/buildbot/stages/release_stages.py index 89050bd68..e936e023e 100644 --- a/buildbot/stages/release_stages.py +++ b/buildbot/stages/release_stages.py @@ -4,12 +4,12 @@ """Module containing the various stages that a builder runs.""" -import ConfigParser import json import logging import os from chromite.buildbot import cbuildbot_commands as commands +from chromite.buildbot import cbuildbot_failures from chromite.buildbot import cbuildbot_run from chromite.buildbot.stages import artifact_stages from chromite.lib import cros_build_lib @@ -40,34 +40,34 @@ class SignerTestStage(artifact_stages.ArchivingStage): commands.RunSignerTests(self._build_root, self._current_board) -class SignerResultsException(Exception): - """An expected failure from the SignerResultsStage.""" - - -class SignerResultsTimeout(SignerResultsException): +class SignerResultsTimeout(cbuildbot_failures.StepFailure): """The signer did not produce any results inside the expected time.""" -class SignerFailure(SignerResultsException): +class SignerFailure(cbuildbot_failures.StepFailure): """The signer returned an error result.""" -class MissingInstructionException(SignerResultsException): +class MissingInstructionException(cbuildbot_failures.StepFailure): """We didn't receive the list of signing instructions PushImage uploaded.""" -class MalformedResultsException(SignerResultsException): +class MalformedResultsException(cbuildbot_failures.StepFailure): """The Signer results aren't formatted as we expect.""" -class PaygenSigningRequirementsError(Exception): +class PaygenSigningRequirementsError(cbuildbot_failures.StepFailure): """Paygen stage can't run if signing failed.""" -class PaygenCrostoolsNotAvailableError(Exception): +class PaygenCrostoolsNotAvailableError(cbuildbot_failures.StepFailure): """Paygen stage can't run if signing failed.""" +class PaygenNoPaygenConfigForBoard(cbuildbot_failures.StepFailure): + """Paygen can't run with a release.conf config for the board.""" + + class PaygenStage(artifact_stages.ArchivingStage): """Stage that generates release payloads. @@ -113,7 +113,7 @@ class PaygenStage(artifact_stages.ArchivingStage): # If Paygen fails to find anything needed in release.conf, treat it # as a warning, not a failure. This is common during new board bring up. - if issubclass(exc_type, ConfigParser.Error): + if issubclass(exc_type, PaygenNoPaygenConfigForBoard): return self._HandleExceptionAsWarning(exc_info) return super(PaygenStage, self)._HandleStageException(exc_info) @@ -294,6 +294,19 @@ class PaygenStage(artifact_stages.ArchivingStage): assert version, "We can't generate payloads without a release_tag." logging.info("Generating payloads for: %s, %s", board, version) + # Test to see if the current board has a Paygen configuration. We do + # this here, no in the sub-process so we don't have to pass back a + # failure reason. + try: + from crostools.lib import paygen_build_lib + paygen_build_lib.ValidateBoardConfig(board) + except paygen_build_lib.BoardNotConfigured: + raise PaygenNoPaygenConfigForBoard( + 'No release.conf entry was found for board %s. Get a TPM to fix.' % + board) + except ImportError: + raise PaygenCrostoolsNotAvailableError() + with parallel.BackgroundTaskRunner(self._RunPaygenInProcess) as per_channel: def channel_notifier(channel): per_channel.put((channel, board, version, self._run.debug, diff --git a/buildbot/stages/release_stages_unittest.py b/buildbot/stages/release_stages_unittest.py index e6f7a9a68..8083bd735 100755 --- a/buildbot/stages/release_stages_unittest.py +++ b/buildbot/stages/release_stages_unittest.py @@ -287,6 +287,8 @@ class PaygenStageTest(generic_stages_unittest.AbstractStageTest): notifier(channel) return side_effect + @unittest.skipIf(not CROSTOOLS_AVAILABLE, + 'Internal crostools repository needed.') def testPerformStageSuccess(self): """Test that SignerResultsStage works when signing works.""" @@ -306,6 +308,8 @@ class PaygenStageTest(generic_stages_unittest.AbstractStageTest): queue.put.assert_any_call(('stable', 'x86-mario', '0.0.1', False, True)) queue.put.assert_any_call(('beta', 'x86-mario', '0.0.1', False, True)) + @unittest.skipIf(not CROSTOOLS_AVAILABLE, + 'Internal crostools repository needed.') def testPerformStageSigningFailed(self): """Test that SignerResultsStage works when signing works.""" with patch(release_stages.parallel, 'BackgroundTaskRunner') as background: @@ -324,6 +328,8 @@ class PaygenStageTest(generic_stages_unittest.AbstractStageTest): # Ensure no work was queued up. self.assertFalse(queue.put.called) + @unittest.skipIf(not CROSTOOLS_AVAILABLE, + 'Internal crostools repository needed.') def testPerformStageTrybot(self): """Test the PerformStage alternate behavior for trybot runs.""" with patch(release_stages.parallel, 'BackgroundTaskRunner') as background: @@ -348,6 +354,16 @@ class PaygenStageTest(generic_stages_unittest.AbstractStageTest): @unittest.skipIf(not CROSTOOLS_AVAILABLE, 'Internal crostools repository needed.') + def testPerformStageUnknownBoard(self): + """Test that SignerResultsStage works when signing works.""" + self._current_board = 'unknown-board-name' + stage = self.ConstructStage() + + self.assertRaises(release_stages.PaygenNoPaygenConfigForBoard, + stage.PerformStage) + + @unittest.skipIf(not CROSTOOLS_AVAILABLE, + 'Internal crostools repository needed.') def testRunPaygenInProcess(self): """Test that SignerResultsStage works when signing works.""" with patch(paygen_build_lib, 'CreatePayloads') as create_payloads: |