diff --git a/iib/workers/greenwave.py b/iib/workers/greenwave.py index 22527482a..f29578083 100644 --- a/iib/workers/greenwave.py +++ b/iib/workers/greenwave.py @@ -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) @@ -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}') @@ -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) diff --git a/tests/test_workers/test_greenwave.py b/tests/test_workers/test_greenwave.py index 679045b4c..475992776 100644 --- a/tests/test_workers/test_greenwave.py +++ b/tests/test_workers/test_greenwave.py @@ -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' ), ), ),