Skip to content

Commit

Permalink
Return all test cases for unsatisfied requirements.
Browse files Browse the repository at this point in the history
Refers to CLOUDDST-993 for more info.
  • Loading branch information
lipoja authored and mprahl committed Jun 24, 2020
1 parent e1aca57 commit 11c4de8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 5 additions & 1 deletion iib/workers/greenwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def gate_bundles(bundles, greenwave_config):

log.info('Gating on bundles: %s', ', '.join(bundles))
gating_unsatisfied_bundles = []
testcases = []
for bundle in bundles:
koji_build_nvr = _get_koji_build_nvr(bundle)
log.debug('Querying Greenwave for decision on %s', koji_build_nvr)
Expand Down Expand Up @@ -60,6 +61,8 @@ def gate_bundles(bundles, greenwave_config):
if not data['policies_satisfied']:
log.info('Gating decision for %s: %s', bundle, data)
gating_unsatisfied_bundles.append(bundle)
testcases = [item['testcase'] for item in data.get('unsatisfied_requirements', [])]

except KeyError:
log.error('Missing key "policies_satisfied" for %s: %s', bundle, data)
raise IIBError(f'Key "policies_satisfied" missing in Greenwave response for {bundle}')
Expand All @@ -69,7 +72,8 @@ def gate_bundles(bundles, greenwave_config):
f'Unsatisfied Greenwave policy for {", ".join(gating_unsatisfied_bundles)} '
f'with decision_context: {greenwave_config["decision_context"]}, '
f'product_version: {greenwave_config["product_version"]}, '
f'and subject_type: {greenwave_config["subject_type"]}'
f'subject_type: {greenwave_config["subject_type"]} '
f'and test cases: {", ".join(testcases)}'
)
raise IIBError(error_msg)

Expand Down
24 changes: 22 additions & 2 deletions tests/test_workers/test_greenwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,31 @@ def test_gate_bundles_success(mock_requests, mock_gkbn):
),
(
True,
{'policies_satisfied': False},
{
'policies_satisfied': False,
'unsatisfied_requirements': [
{
'result_id': 123,
'subject_identifier': 'some-bundle-container-1.5.0-4',
'subject_type': 'koji_build',
'testcase': 'test-case-operator-metadata-fetch',
'type': 'test-result-passed',
},
{
'result_id': 1234,
'subject_identifier': 'some-bundle-container-1.5.0-4',
'subject_type': 'koji_build',
'testcase': 'test-case-operator-metadata-preparation',
'type': 'test-result-passed',
},
],
},
(
'Unsatisfied Greenwave policy for some-bundle '
'with decision_context: iib_cvp_redhat_operator, '
'product_version: cvp, and subject_type: koji_build'
'product_version: cvp, subject_type: koji_build '
'and test cases: test-case-operator-metadata-fetch, '
'test-case-operator-metadata-preparation'
),
),
),
Expand Down

0 comments on commit 11c4de8

Please sign in to comment.