From 98ba619500810d3639d7b9a64cdc0360d81696f3 Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: May 15 2018 06:47:12 +0000 Subject: tests: remove errata-related policies, use Fedora policies instead The errata-related policies committed here in redhat.yaml were only ever hypothetical, whereas the Fedora ones in fedora.yaml closely match the actual policies used in Fedora's production deployment of Greenwave. Remove the made up ones, and make the tests all use realistic Fedora ones. --- diff --git a/conf/policies/fedora.yaml b/conf/policies/fedora.yaml index f920cce..7761de3 100644 --- a/conf/policies/fedora.yaml +++ b/conf/policies/fedora.yaml @@ -56,3 +56,13 @@ decision_context: bodhi_update_push_stable_with_remoterule blacklist: [] rules: - !RemoteOriginalSpecNvrRule {} + +# No Fedora product has *actually* used an empty policy like this, +# but we cover it in our tests for completeness. +--- !Policy +id: "empty-policy" +product_versions: +- fedora-24 +decision_context: bodhi_update_push_stable +blacklist: [] +rules: [] diff --git a/conf/policies/redhat.yaml b/conf/policies/redhat.yaml deleted file mode 100644 index bc1cded..0000000 --- a/conf/policies/redhat.yaml +++ /dev/null @@ -1,91 +0,0 @@ -# Mimic the default Errata rule used for RHEL-7 https://errata.devel.redhat.com/workflow_rules/1 -# In Errata, in order to transition to QE state, an advisory must complete rpmdiff test. -# A completed rpmdiff test could be some dist.rpmdiff.* testcases in ResultsDB and all the -# tests need to be passed. ---- !Policy -id: "1" -product_versions: - - rhel-7 -decision_context: errata_newfile_to_qe -blacklist: [] -rules: - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.abi_symbols} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.binary_stripping} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.build_log} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.changes_in_rpms} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.desktop_file_sanity} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.elflint} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.empty_payload} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.execshield} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.file_list} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.file_permissions} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.file_sizes} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.ipv6} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.java_byte_code} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.kernel_module_parameters} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.manpage_integrity} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.metadata} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.multilib_regressions} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.ownership} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.patches} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.pathnames} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.politics} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.rpath} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.rpm_changelog} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.rpm_config_doc_files} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.rpm_requires_provides} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.rpm_scripts} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.rpm_triggers} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.shell_syntax} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.specfile_checks} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.symlinks} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.upstream_source} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.virus_scan} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.analysis.xml_validity} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.abi_symbols} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.binary_stripping} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.build_log} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.changed_files} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.changes_in_rpms} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.desktop_file_sanity} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.dt_needed} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.elflint} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.empty_payload} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.execshield} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.file_list} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.file_permissions} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.file_sizes} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.files_moving_rpm} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.file_types} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.ipv6} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.java_byte_code} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.kernel_module_parameters} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.kernel_module_pci_ids} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.manpage_integrity} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.metadata} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.multilib_regressions} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.ownership} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.patches} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.pathnames} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.politics} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.rpath} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.rpm_changelog} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.rpm_config_doc_files} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.rpm_requires_provides} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.rpm_scripts} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.rpm_triggers} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.shell_syntax} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.specfile_checks} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.symlinks} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.upstream_source} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.virus_scan} - - !PassingTestCaseRule {test_case_name: dist.rpmdiff.comparison.xml_validity} -# Errata Tool "Unrestricted" rule set ---- !Policy -id: "errata-unrestricted" -product_versions: - - cdk-2 - - devstudio-2 -decision_context: errata_newfile_to_qe -blacklist: [] -rules: [] diff --git a/functional-tests/test_api_v1.py b/functional-tests/test_api_v1.py index b83c163..924c57e 100644 --- a/functional-tests/test_api_v1.py +++ b/functional-tests/test_api_v1.py @@ -5,80 +5,6 @@ import json from greenwave import __version__ -all_rpmdiff_testcase_names = [ - 'dist.rpmdiff.analysis.abi_symbols', - 'dist.rpmdiff.analysis.binary_stripping', - 'dist.rpmdiff.analysis.build_log', - 'dist.rpmdiff.analysis.changes_in_rpms', - 'dist.rpmdiff.analysis.desktop_file_sanity', - 'dist.rpmdiff.analysis.elflint', - 'dist.rpmdiff.analysis.empty_payload', - 'dist.rpmdiff.analysis.execshield', - 'dist.rpmdiff.analysis.file_list', - 'dist.rpmdiff.analysis.file_permissions', - 'dist.rpmdiff.analysis.file_sizes', - 'dist.rpmdiff.analysis.ipv6', - 'dist.rpmdiff.analysis.java_byte_code', - 'dist.rpmdiff.analysis.kernel_module_parameters', - 'dist.rpmdiff.analysis.manpage_integrity', - 'dist.rpmdiff.analysis.metadata', - 'dist.rpmdiff.analysis.multilib_regressions', - 'dist.rpmdiff.analysis.ownership', - 'dist.rpmdiff.analysis.patches', - 'dist.rpmdiff.analysis.pathnames', - 'dist.rpmdiff.analysis.politics', - 'dist.rpmdiff.analysis.rpath', - 'dist.rpmdiff.analysis.rpm_changelog', - 'dist.rpmdiff.analysis.rpm_config_doc_files', - 'dist.rpmdiff.analysis.rpm_requires_provides', - 'dist.rpmdiff.analysis.rpm_scripts', - 'dist.rpmdiff.analysis.rpm_triggers', - 'dist.rpmdiff.analysis.shell_syntax', - 'dist.rpmdiff.analysis.specfile_checks', - 'dist.rpmdiff.analysis.symlinks', - 'dist.rpmdiff.analysis.upstream_source', - 'dist.rpmdiff.analysis.virus_scan', - 'dist.rpmdiff.analysis.xml_validity', - 'dist.rpmdiff.comparison.abi_symbols', - 'dist.rpmdiff.comparison.binary_stripping', - 'dist.rpmdiff.comparison.build_log', - 'dist.rpmdiff.comparison.changed_files', - 'dist.rpmdiff.comparison.changes_in_rpms', - 'dist.rpmdiff.comparison.desktop_file_sanity', - 'dist.rpmdiff.comparison.dt_needed', - 'dist.rpmdiff.comparison.elflint', - 'dist.rpmdiff.comparison.empty_payload', - 'dist.rpmdiff.comparison.execshield', - 'dist.rpmdiff.comparison.file_list', - 'dist.rpmdiff.comparison.file_permissions', - 'dist.rpmdiff.comparison.file_sizes', - 'dist.rpmdiff.comparison.files_moving_rpm', - 'dist.rpmdiff.comparison.file_types', - 'dist.rpmdiff.comparison.ipv6', - 'dist.rpmdiff.comparison.java_byte_code', - 'dist.rpmdiff.comparison.kernel_module_parameters', - 'dist.rpmdiff.comparison.kernel_module_pci_ids', - 'dist.rpmdiff.comparison.manpage_integrity', - 'dist.rpmdiff.comparison.metadata', - 'dist.rpmdiff.comparison.multilib_regressions', - 'dist.rpmdiff.comparison.ownership', - 'dist.rpmdiff.comparison.patches', - 'dist.rpmdiff.comparison.pathnames', - 'dist.rpmdiff.comparison.politics', - 'dist.rpmdiff.comparison.rpath', - 'dist.rpmdiff.comparison.rpm_changelog', - 'dist.rpmdiff.comparison.rpm_config_doc_files', - 'dist.rpmdiff.comparison.rpm_requires_provides', - 'dist.rpmdiff.comparison.rpm_scripts', - 'dist.rpmdiff.comparison.rpm_triggers', - 'dist.rpmdiff.comparison.shell_syntax', - 'dist.rpmdiff.comparison.specfile_checks', - 'dist.rpmdiff.comparison.symlinks', - 'dist.rpmdiff.comparison.upstream_source', - 'dist.rpmdiff.comparison.virus_scan', - 'dist.rpmdiff.comparison.xml_validity', -] - TASKTRON_RELEASE_CRITICAL_TASKS = [ 'dist.abicheck', 'dist.rpmdeplint', @@ -97,7 +23,7 @@ def test_inspect_policies(requests_session, greenwave_server): assert r.status_code == 200 body = r.json() policies = body['policies'] - assert len(policies) == 7 + assert len(policies) == 6 assert any(p['id'] == 'taskotron_release_critical_tasks' for p in policies) assert any(p['decision_context'] == 'bodhi_update_push_stable' for p in policies) assert any(p['product_versions'] == ['fedora-26'] for p in policies) @@ -132,7 +58,7 @@ def test_version_endpoint_jsonp(requests_session, greenwave_server): def test_cannot_make_decision_without_product_version(requests_session, greenwave_server): data = { - 'decision_context': 'errata_newfile_to_qe', + 'decision_context': 'bodhi_update_push_stable', 'subject': [{'item': 'foo-1.0.0-1.el7', 'type': 'koji_build'}] } r = requests_session.post(greenwave_server + 'api/v1.0/decision', @@ -144,7 +70,7 @@ def test_cannot_make_decision_without_product_version(requests_session, greenwav def test_cannot_make_decision_without_decision_context(requests_session, greenwave_server): data = { - 'product_version': 'rhel-7', + 'product_version': 'fedora-26', 'subject': [{'item': 'foo-1.0.0-1.el7', 'type': 'koji_build'}] } r = requests_session.post(greenwave_server + 'api/v1.0/decision', @@ -156,8 +82,8 @@ def test_cannot_make_decision_without_decision_context(requests_session, greenwa def test_cannot_make_decision_without_subject(requests_session, greenwave_server): data = { - 'decision_context': 'errata_newfile_to_qe', - 'product_version': 'rhel-7', + 'decision_context': 'bodhi_update_push_stable', + 'product_version': 'fedora-26', } r = requests_session.post(greenwave_server + 'api/v1.0/decision', headers={'Content-Type': 'application/json'}, @@ -168,8 +94,8 @@ def test_cannot_make_decision_without_subject(requests_session, greenwave_server def test_cannot_make_decision_with_invalid_subject(requests_session, greenwave_server): data = { - 'decision_context': 'errata_newfile_to_qe', - 'product_version': 'rhel-7', + 'decision_context': 'bodhi_update_push_stable', + 'product_version': 'fedora-26', 'subject': 'foo-1.0.0-1.el7', } r = requests_session.post(greenwave_server + 'api/v1.0/decision', @@ -179,8 +105,8 @@ def test_cannot_make_decision_with_invalid_subject(requests_session, greenwave_s assert 'Invalid subject, must be a list of items' == r.json()['message'] data = { - 'decision_context': 'errata_newfile_to_qe', - 'product_version': 'rhel-7', + 'decision_context': 'bodhi_update_push_stable', + 'product_version': 'fedora-26', 'subject': ['foo-1.0.0-1.el7'], } r = requests_session.post(greenwave_server + 'api/v1.0/decision', @@ -193,7 +119,7 @@ def test_cannot_make_decision_with_invalid_subject(requests_session, greenwave_s def test_404_for_invalid_product_version(requests_session, greenwave_server): data = { 'decision_context': 'bodhi_push_update_stable', - 'product_version': 'f26', + 'product_version': 'f26', # not a real product version 'subject': [{'item': 'foo-1.0.0-1.el7', 'type': 'koji_build'}] } r = requests_session.post(greenwave_server + 'api/v1.0/decision', @@ -237,13 +163,13 @@ def test_invalid_payload(requests_session, greenwave_server): def test_make_a_decision_on_passed_result(requests_session, greenwave_server, testdatabuilder): nvr = testdatabuilder.unique_nvr() - for testcase_name in all_rpmdiff_testcase_names: + for testcase_name in TASKTRON_RELEASE_CRITICAL_TASKS: testdatabuilder.create_result(item=nvr, testcase_name=testcase_name, outcome='PASSED') data = { - 'decision_context': 'errata_newfile_to_qe', - 'product_version': 'rhel-7', + 'decision_context': 'bodhi_update_push_stable', + 'product_version': 'fedora-26', 'subject': [{'item': nvr, 'type': 'koji_build'}] } @@ -253,20 +179,24 @@ def test_make_a_decision_on_passed_result(requests_session, greenwave_server, te assert r.status_code == 200 res_data = r.json() assert res_data['policies_satisfied'] is True - assert res_data['applicable_policies'] == ['1'] + assert res_data['applicable_policies'] == [ + 'taskotron_release_critical_tasks_with_blacklist', + 'taskotron_release_critical_tasks', + ] expected_summary = 'all required tests passed' assert res_data['summary'] == expected_summary def test_make_a_decision_with_verbose_flag(requests_session, greenwave_server, testdatabuilder): nvr = testdatabuilder.unique_nvr() - for testcase_name in all_rpmdiff_testcase_names: - testdatabuilder.create_result(item=nvr, - testcase_name=testcase_name, - outcome='PASSED') + results = [] + for testcase_name in TASKTRON_RELEASE_CRITICAL_TASKS: + results.append(testdatabuilder.create_result(item=nvr, + testcase_name=testcase_name, + outcome='PASSED')) data = { - 'decision_context': 'errata_newfile_to_qe', - 'product_version': 'rhel-7', + 'decision_context': 'bodhi_update_push_stable', + 'product_version': 'fedora-26', 'subject': [{'item': nvr, 'type': 'koji_build'}], 'verbose': True, } @@ -276,28 +206,9 @@ def test_make_a_decision_with_verbose_flag(requests_session, greenwave_server, t data=json.dumps(data)) assert r.status_code == 200 res_data = r.json() - expected_result = { - u'data': { - u'item': [u'glibc-1.0-2.el7'], - u'type': [u'koji_build'] - }, - u'groups': [], - u'href': u'http://localhost:5001/api/v2.0/results/72', - u'id': 72, - u'note': None, - u'outcome': u'PASSED', - u'ref_url': None, - #u'submit_time': u'2018-01-28T12:55:54.641139', - u'testcase': { - u'href': u'http://localhost:5001/api/v2.0/testcases/dist.rpmdiff.analysis.abi_symbols', - u'name': u'dist.rpmdiff.analysis.abi_symbols', - u'ref_url': None, - } - } - assert len(res_data['results']) == len(all_rpmdiff_testcase_names) - del res_data['results'][-1]['submit_time'] - assert res_data['results'][-1] == expected_result + assert len(res_data['results']) == len(TASKTRON_RELEASE_CRITICAL_TASKS) + assert res_data['results'] == list(reversed(results)) expected_waivers = [] assert res_data['waivers'] == expected_waivers @@ -307,20 +218,20 @@ def test_make_a_decision_on_failed_result_with_waiver( nvr = testdatabuilder.unique_nvr() # First one failed but was waived result = testdatabuilder.create_result(item=nvr, - testcase_name=all_rpmdiff_testcase_names[0], + testcase_name=TASKTRON_RELEASE_CRITICAL_TASKS[0], outcome='FAILED') waiver = testdatabuilder.create_waiver(result={ # noqa "subject": dict([(key, value[0]) for key, value in result['data'].items()]), - "testcase": all_rpmdiff_testcase_names[0]}, product_version='rhel-7', + "testcase": TASKTRON_RELEASE_CRITICAL_TASKS[0]}, product_version='fedora-26', comment='This is fine') # The rest passed - for testcase_name in all_rpmdiff_testcase_names[1:]: + for testcase_name in TASKTRON_RELEASE_CRITICAL_TASKS[1:]: testdatabuilder.create_result(item=nvr, testcase_name=testcase_name, outcome='PASSED') data = { - 'decision_context': 'errata_newfile_to_qe', - 'product_version': 'rhel-7', + 'decision_context': 'bodhi_update_push_stable', + 'product_version': 'fedora-26', 'subject': [{'item': nvr, 'type': 'koji_build'}] } r = requests_session.post(greenwave_server + 'api/v1.0/decision', @@ -329,7 +240,8 @@ def test_make_a_decision_on_failed_result_with_waiver( assert r.status_code == 200 res_data = r.json() assert res_data['policies_satisfied'] is True - assert res_data['applicable_policies'] == ['1'] + assert 'taskotron_release_critical_tasks' in res_data['applicable_policies'] + assert 'taskotron_release_critical_tasks_with_blacklist' in res_data['applicable_policies'] expected_summary = 'all required tests passed' assert res_data['summary'] == expected_summary @@ -337,11 +249,11 @@ def test_make_a_decision_on_failed_result_with_waiver( def test_make_a_decision_on_failed_result(requests_session, greenwave_server, testdatabuilder): nvr = testdatabuilder.unique_nvr() result = testdatabuilder.create_result(item=nvr, - testcase_name='dist.rpmdiff.comparison.xml_validity', + testcase_name=TASKTRON_RELEASE_CRITICAL_TASKS[0], outcome='FAILED') data = { - 'decision_context': 'errata_newfile_to_qe', - 'product_version': 'rhel-7', + 'decision_context': 'bodhi_update_push_stable', + 'product_version': 'fedora-26', 'subject': [{'item': nvr, 'type': 'koji_build'}] } r = requests_session.post(greenwave_server + 'api/v1.0/decision', @@ -350,14 +262,15 @@ def test_make_a_decision_on_failed_result(requests_session, greenwave_server, te assert r.status_code == 200 res_data = r.json() assert res_data['policies_satisfied'] is False - assert res_data['applicable_policies'] == ['1'] - expected_summary = '1 of 71 required tests failed, 70 results missing' + assert 'taskotron_release_critical_tasks' in res_data['applicable_policies'] + assert 'taskotron_release_critical_tasks_with_blacklist' in res_data['applicable_policies'] + expected_summary = '1 of 3 required tests failed, 2 results missing' assert res_data['summary'] == expected_summary expected_unsatisfied_requirements = [ { 'item': {'item': nvr, 'type': 'koji_build'}, 'result_id': result['id'], - 'testcase': 'dist.rpmdiff.comparison.xml_validity', + 'testcase': TASKTRON_RELEASE_CRITICAL_TASKS[0], 'scenario': None, 'type': 'test-result-failed' }, @@ -367,7 +280,7 @@ def test_make_a_decision_on_failed_result(requests_session, greenwave_server, te 'testcase': name, 'type': 'test-result-missing', 'scenario': None, - } for name in all_rpmdiff_testcase_names if name != 'dist.rpmdiff.comparison.xml_validity' + } for name in TASKTRON_RELEASE_CRITICAL_TASKS[1:] ] assert sorted(res_data['unsatisfied_requirements']) == sorted(expected_unsatisfied_requirements) @@ -375,8 +288,8 @@ def test_make_a_decision_on_failed_result(requests_session, greenwave_server, te def test_make_a_decision_on_no_results(requests_session, greenwave_server, testdatabuilder): nvr = testdatabuilder.unique_nvr() data = { - 'decision_context': 'errata_newfile_to_qe', - 'product_version': 'rhel-7', + 'decision_context': 'bodhi_update_push_stable', + 'product_version': 'fedora-26', 'subject': [{'item': nvr, 'type': 'koji_build'}] } r = requests_session.post(greenwave_server + 'api/v1.0/decision', @@ -385,8 +298,9 @@ def test_make_a_decision_on_no_results(requests_session, greenwave_server, testd assert r.status_code == 200 res_data = r.json() assert res_data['policies_satisfied'] is False - assert res_data['applicable_policies'] == ['1'] - expected_summary = '71 of 71 required test results missing' + assert 'taskotron_release_critical_tasks' in res_data['applicable_policies'] + assert 'taskotron_release_critical_tasks_with_blacklist' in res_data['applicable_policies'] + expected_summary = '3 of 3 required test results missing' assert res_data['summary'] == expected_summary expected_unsatisfied_requirements = [ { @@ -394,17 +308,17 @@ def test_make_a_decision_on_no_results(requests_session, greenwave_server, testd 'testcase': name, 'type': 'test-result-missing', 'scenario': None, - } for name in all_rpmdiff_testcase_names + } for name in TASKTRON_RELEASE_CRITICAL_TASKS ] assert res_data['unsatisfied_requirements'] == expected_unsatisfied_requirements -def test_unrestricted_policy_is_always_satisfied( +def test_empty_policy_is_always_satisfied( requests_session, greenwave_server, testdatabuilder): nvr = testdatabuilder.unique_nvr() data = { - 'decision_context': 'errata_newfile_to_qe', - 'product_version': 'cdk-2', + 'decision_context': 'bodhi_update_push_stable', + 'product_version': 'fedora-24', 'subject': [{'item': nvr, 'type': 'koji_build'}] } r = requests_session.post(greenwave_server + 'api/v1.0/decision', @@ -413,7 +327,7 @@ def test_unrestricted_policy_is_always_satisfied( assert r.status_code == 200 res_data = r.json() assert res_data['policies_satisfied'] is True - assert res_data['applicable_policies'] == ['errata-unrestricted'] + assert res_data['applicable_policies'] == ['empty-policy'] expected_summary = 'no tests are required' assert res_data['summary'] == expected_summary assert res_data['unsatisfied_requirements'] == [] @@ -614,20 +528,20 @@ def test_ignore_waiver(requests_session, greenwave_server, testdatabuilder): """ nvr = testdatabuilder.unique_nvr() result = testdatabuilder.create_result(item=nvr, - testcase_name=all_rpmdiff_testcase_names[0], + testcase_name=TASKTRON_RELEASE_CRITICAL_TASKS[0], outcome='FAILED') waiver = testdatabuilder.create_waiver(result={ "subject": dict([(key, value[0]) for key, value in result['data'].items()]), - "testcase": all_rpmdiff_testcase_names[0]}, product_version='rhel-7', + "testcase": TASKTRON_RELEASE_CRITICAL_TASKS[0]}, product_version='fedora-26', comment='This is fine') # The rest passed - for testcase_name in all_rpmdiff_testcase_names[1:]: + for testcase_name in TASKTRON_RELEASE_CRITICAL_TASKS[1:]: testdatabuilder.create_result(item=nvr, testcase_name=testcase_name, outcome='PASSED') data = { - 'decision_context': 'errata_newfile_to_qe', - 'product_version': 'rhel-7', + 'decision_context': 'bodhi_update_push_stable', + 'product_version': 'fedora-26', 'subject': [{'item': nvr, 'type': 'koji_build'}] } r_ = requests_session.post(greenwave_server + 'api/v1.0/decision', @@ -649,7 +563,7 @@ def test_ignore_waiver(requests_session, greenwave_server, testdatabuilder): { 'item': {'item': nvr, 'type': 'koji_build'}, 'result_id': result['id'], - 'testcase': all_rpmdiff_testcase_names[0], + 'testcase': TASKTRON_RELEASE_CRITICAL_TASKS[0], 'type': 'test-result-failed', 'scenario': None, }, @@ -678,13 +592,13 @@ def test_cached_false_positive(requests_session, greenwave_server, testdatabuild (but it shouldn't) which means caching works. """ nvr = testdatabuilder.unique_nvr() - for testcase_name in all_rpmdiff_testcase_names: + for testcase_name in TASKTRON_RELEASE_CRITICAL_TASKS: testdatabuilder.create_result(item=nvr, testcase_name=testcase_name, outcome='PASSED') data = { - 'decision_context': 'errata_newfile_to_qe', - 'product_version': 'rhel-7', + 'decision_context': 'bodhi_update_push_stable', + 'product_version': 'fedora-26', 'subject': [{'item': nvr, 'type': 'koji_build'}] } r = requests_session.post(greenwave_server + 'api/v1.0/decision', @@ -697,7 +611,7 @@ def test_cached_false_positive(requests_session, greenwave_server, testdatabuild # Now, insert a *failing* result. The cache should return the old results # that exclude the failing one (erroneously). testdatabuilder.create_result(item=nvr, - testcase_name=testcase_name, + testcase_name=TASKTRON_RELEASE_CRITICAL_TASKS[-1], outcome='FAILED') r = requests_session.post(greenwave_server + 'api/v1.0/decision', headers={'Content-Type': 'application/json'}, diff --git a/greenwave/tests/test_policies.py b/greenwave/tests/test_policies.py index 4e28302..c4423b9 100644 --- a/greenwave/tests/test_policies.py +++ b/greenwave/tests/test_policies.py @@ -160,10 +160,11 @@ rules: def test_load_policies(): app = create_app('greenwave.config.TestingConfig') assert len(app.config['policies']) > 0 - assert any(policy.id == '1' for policy in app.config['policies']) - assert any(policy.decision_context == 'errata_newfile_to_qe' + assert any(policy.id == 'taskotron_release_critical_tasks' for policy in app.config['policies']) - assert any(getattr(rule, 'test_case_name', None) == 'dist.rpmdiff.analysis.abi_symbols' + assert any(policy.decision_context == 'bodhi_update_push_stable' + for policy in app.config['policies']) + assert any(getattr(rule, 'test_case_name', None) == 'dist.rpmdeplint' for policy in app.config['policies'] for rule in policy.rules)