mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-04 03:08:21 +08:00
set module build state to 'failed' imediately
Fixes #1009 Signed-off-by: Valerij Maljulin <vmaljuli@redhat.com>
This commit is contained in:
@@ -78,12 +78,14 @@ def start_build_component(builder, c):
|
||||
c.state = koji.BUILD_STATES['FAILED']
|
||||
c.state_reason = "Failed to build artifact %s: %s" % (c.package, str(e))
|
||||
log.exception(e)
|
||||
c.module_build.transition(conf, models.BUILD_STATES['failed'])
|
||||
return
|
||||
|
||||
if not c.task_id and c.state == koji.BUILD_STATES['BUILDING']:
|
||||
c.state = koji.BUILD_STATES['FAILED']
|
||||
c.state_reason = ("Failed to build artifact %s: "
|
||||
"Builder did not return task ID" % (c.package))
|
||||
c.module_build.transition(conf, models.BUILD_STATES['failed'])
|
||||
return
|
||||
|
||||
|
||||
|
||||
@@ -861,6 +861,18 @@ class TestBatches:
|
||||
# Make sure that both components in the batch were submitted
|
||||
assert len(mock_sbc.mock_calls) == 2
|
||||
|
||||
def test_start_build_component_failed_state(self, default_buildroot_groups):
|
||||
"""
|
||||
Tests whether exception occured while building sets the state to failed
|
||||
"""
|
||||
builder = mock.MagicMock()
|
||||
builder.build.side_effect = Exception('Something have gone terribly wrong')
|
||||
component = mock.MagicMock()
|
||||
|
||||
module_build_service.utils.batches.start_build_component(builder, component)
|
||||
|
||||
assert component.state == koji.BUILD_STATES['FAILED']
|
||||
|
||||
@patch('module_build_service.utils.batches.start_build_component')
|
||||
@patch('module_build_service.config.Config.rebuild_strategy',
|
||||
new_callable=mock.PropertyMock, return_value='only-changed')
|
||||
|
||||
Reference in New Issue
Block a user