| |
@@ -21,6 +21,7 @@
|
| |
)
|
| |
from greenwave.resources import ResultsRetriever
|
| |
from greenwave.safe_yaml import SafeYAMLError
|
| |
+ from greenwave.waivers import waive_answers
|
| |
|
| |
|
| |
class DummyResultsRetriever(ResultsRetriever):
|
| |
@@ -28,7 +29,7 @@
|
| |
self, subject_identifier=None, testcase=None, outcome='PASSED',
|
| |
subject_type='koji_build'):
|
| |
super(DummyResultsRetriever, self).__init__(
|
| |
- ignore_results=[],
|
| |
+ ignore_ids=[],
|
| |
when='',
|
| |
timeout=0,
|
| |
verify=False,
|
| |
@@ -38,7 +39,7 @@
|
| |
self.testcase = testcase
|
| |
self.outcome = outcome
|
| |
|
| |
- def _make_request(self, params):
|
| |
+ def _retrieve_data(self, params):
|
| |
if (params.get('item') == self.subject_identifier and
|
| |
('type' not in params or self.subject_type in params['type'].split(',')) and
|
| |
params.get('testcases') == self.testcase):
|
| |
@@ -74,7 +75,7 @@
|
| |
'1 of 2 required test results missing'
|
| |
|
| |
|
| |
- def test_waive_absence_of_result(tmpdir):
|
| |
+ def test_decision_with_missing_result(tmpdir):
|
| |
p = tmpdir.join('fedora.yaml')
|
| |
p.write(dedent("""
|
| |
--- !Policy
|
| |
@@ -89,18 +90,14 @@
|
| |
policies = load_policies(tmpdir.strpath)
|
| |
policy = policies[0]
|
| |
|
| |
+ results = DummyResultsRetriever()
|
| |
+ subject_identifier = 'some_nevr'
|
| |
+
|
| |
# Ensure that absence of a result is failure.
|
| |
- item, results, waivers = {}, DummyResultsRetriever(), []
|
| |
- decision = policy.check('fedora-rawhide', item, results, waivers)
|
| |
+ decision = policy.check('fedora-rawhide', subject_identifier, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], TestResultMissing)
|
| |
|
| |
- # But also that waiving the absence works.
|
| |
- waivers = [{'testcase': 'sometest', 'waived': True}]
|
| |
- decision = policy.check('fedora-rawhide', item, results, waivers)
|
| |
- assert len(decision) == 1
|
| |
- assert isinstance(decision[0], RuleSatisfied)
|
| |
-
|
| |
|
| |
def test_waive_brew_koji_mismatch(tmpdir):
|
| |
""" Ensure that a koji_build waiver can match a brew-build result
|
| |
@@ -123,29 +120,26 @@
|
| |
policies = load_policies(tmpdir.strpath)
|
| |
policy = policies[0]
|
| |
|
| |
- results = DummyResultsRetriever('some_nevr', 'sometest', 'FAILED', 'brew-build')
|
| |
- waiver = {
|
| |
- u'subject_identifier': u'some_nevr',
|
| |
- u'subject_type': u'koji_build',
|
| |
- u'testcase': u'sometest',
|
| |
- u'waived': True,
|
| |
- }
|
| |
+ item = 'some_nevr'
|
| |
+ results = DummyResultsRetriever(item, 'sometest', 'FAILED', 'brew-build')
|
| |
|
| |
- item, waivers = 'some_nevr', [waiver]
|
| |
- decision = policy.check('fedora-rawhide', item, results, [])
|
| |
+ decision = policy.check('fedora-rawhide', item, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], TestResultFailed)
|
| |
|
| |
- decision = policy.check('fedora-rawhide', item, results, waivers)
|
| |
+ waivers = [{
|
| |
+ 'id': 1,
|
| |
+ 'subject_identifier': item,
|
| |
+ 'subject_type': 'koji_build',
|
| |
+ 'testcase': 'sometest',
|
| |
+ 'product_version': 'fedora-rawhide',
|
| |
+ 'waived': True,
|
| |
+ }]
|
| |
+ decision = policy.check('fedora-rawhide', item, results)
|
| |
+ decision = waive_answers(decision, waivers)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], RuleSatisfied)
|
| |
|
| |
- # Also, be sure that negative waivers work.
|
| |
- waivers[0]['waived'] = False
|
| |
- decision = policy.check('fedora-rawhide', item, results, waivers)
|
| |
- assert len(decision) == 1
|
| |
- assert isinstance(decision[0], TestResultFailed)
|
| |
-
|
| |
|
| |
def test_waive_bodhi_update(tmpdir):
|
| |
""" Ensure that a koji_build waiver can match a brew-build result
|
| |
@@ -170,27 +164,24 @@
|
| |
|
| |
item = 'some_bodhi_update'
|
| |
results = DummyResultsRetriever(item, 'sometest', 'FAILED', 'bodhi_update')
|
| |
- waivers = [{
|
| |
- u'subject_identifier': item,
|
| |
- u'subject_type': 'bodhi_update',
|
| |
- u'testcase': 'sometest',
|
| |
- u'waived': True,
|
| |
- }]
|
| |
|
| |
- decision = policy.check('fedora-rawhide', item, results, [])
|
| |
+ decision = policy.check('fedora-rawhide', item, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], TestResultFailed)
|
| |
|
| |
- decision = policy.check('fedora-rawhide', item, results, waivers)
|
| |
+ waivers = [{
|
| |
+ 'id': 1,
|
| |
+ 'subject_identifier': item,
|
| |
+ 'subject_type': 'bodhi_update',
|
| |
+ 'testcase': 'sometest',
|
| |
+ 'product_version': 'fedora-rawhide',
|
| |
+ 'waived': True,
|
| |
+ }]
|
| |
+ decision = policy.check('fedora-rawhide', item, results)
|
| |
+ decision = waive_answers(decision, waivers)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], RuleSatisfied)
|
| |
|
| |
- # Also, be sure that negative waivers work.
|
| |
- waivers[0]['waived'] = False
|
| |
- decision = policy.check('fedora-rawhide', item, results, waivers)
|
| |
- assert len(decision) == 1
|
| |
- assert isinstance(decision[0], TestResultFailed)
|
| |
-
|
| |
|
| |
def test_load_policies():
|
| |
app = create_app('greenwave.config.TestingConfig')
|
| |
@@ -322,23 +313,21 @@
|
| |
policies = load_policies(tmpdir.strpath)
|
| |
policy = policies[0]
|
| |
|
| |
- waivers = []
|
| |
-
|
| |
# Ensure that presence of a result is success.
|
| |
results = DummyResultsRetriever(nvr, 'dist.upgradepath')
|
| |
- decision = policy.check('fedora-26', nvr, results, waivers)
|
| |
+ decision = policy.check('fedora-26', nvr, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], RuleSatisfied)
|
| |
|
| |
# Ensure that absence of a result is failure.
|
| |
results = DummyResultsRetriever()
|
| |
- decision = policy.check('fedora-26', nvr, results, waivers)
|
| |
+ decision = policy.check('fedora-26', nvr, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], TestResultMissing)
|
| |
|
| |
# And that a result with a failure, is a failure.
|
| |
results = DummyResultsRetriever(nvr, 'dist.upgradepath', 'FAILED')
|
| |
- decision = policy.check('fedora-26', nvr, results, waivers)
|
| |
+ decision = policy.check('fedora-26', nvr, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], TestResultFailed)
|
| |
|
| |
@@ -383,25 +372,23 @@
|
| |
policies = load_policies(tmpdir.strpath)
|
| |
policy = policies[0]
|
| |
|
| |
- waivers = []
|
| |
-
|
| |
# Ensure that presence of a result is success.
|
| |
results = DummyResultsRetriever(nvr, 'baseos-ci.redhat-module.tier0.functional',
|
| |
subject_type='redhat-module')
|
| |
- decision = policy.check('rhel-8', nvr, results, waivers)
|
| |
+ decision = policy.check('rhel-8', nvr, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], RuleSatisfied)
|
| |
|
| |
# Ensure that absence of a result is failure.
|
| |
results = DummyResultsRetriever(subject_type='redhat-module')
|
| |
- decision = policy.check('rhel-8', nvr, results, waivers)
|
| |
+ decision = policy.check('rhel-8', nvr, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], TestResultMissing)
|
| |
|
| |
# And that a result with a failure, is a failure.
|
| |
results = DummyResultsRetriever(nvr, 'baseos-ci.redhat-module.tier0.functional',
|
| |
'FAILED', subject_type='redhat-module')
|
| |
- decision = policy.check('rhel-8', nvr, results, waivers)
|
| |
+ decision = policy.check('rhel-8', nvr, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], TestResultFailed)
|
| |
|
| |
@@ -438,9 +425,9 @@
|
| |
policies = load_policies(tmpdir.strpath)
|
| |
policy = policies[0]
|
| |
|
| |
- results, waivers = [], []
|
| |
+ results = DummyResultsRetriever()
|
| |
expected_details = "Policy 'untitled': Attribute 'product_versions' is required"
|
| |
- decision = policy.check('fedora-26', nvr, results, waivers)
|
| |
+ decision = policy.check('fedora-26', nvr, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], InvalidGatingYaml)
|
| |
assert decision[0].is_satisfied is False
|
| |
@@ -494,8 +481,8 @@
|
| |
policies = load_policies(tmpdir.strpath)
|
| |
policy = policies[0]
|
| |
|
| |
- results, waivers = [], []
|
| |
- decision = policy.check('fedora-26', nvr, results, waivers)
|
| |
+ results = DummyResultsRetriever()
|
| |
+ decision = policy.check('fedora-26', nvr, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], InvalidGatingYaml)
|
| |
assert decision[0].is_satisfied is False
|
| |
@@ -549,16 +536,19 @@
|
| |
policies = load_policies(tmpdir.strpath)
|
| |
policy = policies[0]
|
| |
|
| |
- results = []
|
| |
+ results = DummyResultsRetriever()
|
| |
waivers = [{
|
| |
+ 'id': 1,
|
| |
'subject_type': 'koji_build',
|
| |
'subject_identifier': 'nethack-1.2.3-1.el9000',
|
| |
'subject': {'type': 'koji_build', 'item': 'nethack-1.2.3-1.el9000'},
|
| |
'testcase': 'invalid-gating-yaml',
|
| |
'product_version': 'fedora-26',
|
| |
- 'comment': 'Waiving the invalig gating.yaml file'
|
| |
+ 'comment': 'Waiving the invalid gating.yaml file',
|
| |
+ 'waived': True,
|
| |
}]
|
| |
- decision = policy.check('fedora-26', nvr, results, waivers)
|
| |
+ decision = policy.check('fedora-26', nvr, results)
|
| |
+ decision = waive_answers(decision, waivers)
|
| |
assert len(decision) == 0
|
| |
|
| |
|
| |
@@ -635,9 +625,8 @@
|
| |
policies = load_policies(tmpdir.strpath)
|
| |
policy = policies[0]
|
| |
|
| |
- waivers = []
|
| |
results = DummyResultsRetriever('nethack-1.2.3-1.el9000', 'sometest', 'PASSED', 'kind-of-magic')
|
| |
- decision = policy.check('rhel-9000', 'nethack-1.2.3-1.el9000', results, waivers)
|
| |
+ decision = policy.check('rhel-9000', 'nethack-1.2.3-1.el9000', results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], TestResultPassed)
|
| |
|
| |
@@ -664,9 +653,8 @@
|
| |
policies = load_policies(tmpdir.strpath)
|
| |
policy = policies[0]
|
| |
|
| |
- waivers = []
|
| |
results = DummyResultsRetriever('nethack-1.2.3-1.el9000', 'sometest', 'PASSED', 'koji_build')
|
| |
- decision = policy.check('rhel-9000', 'nethack-1.2.3-1.el9000', results, waivers)
|
| |
+ decision = policy.check('rhel-9000', 'nethack-1.2.3-1.el9000', results)
|
| |
assert len(decision) == num_decisions
|
| |
if num_decisions:
|
| |
assert isinstance(decision[0], TestResultPassed)
|
| |
@@ -861,8 +849,7 @@
|
| |
policy = policies[0]
|
| |
results = DummyResultsRetriever(nv, 'test_for_new_type', 'PASSED',
|
| |
'component-version')
|
| |
- waivers = []
|
| |
- decision = policy.check('fedora-29', nv, results, waivers)
|
| |
+ decision = policy.check('fedora-29', nv, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], RuleSatisfied)
|
| |
|
| |
@@ -885,8 +872,7 @@
|
| |
policy = policies[0]
|
| |
results = DummyResultsRetriever(nsvc, 'test_for_redhat_module_type', 'PASSED',
|
| |
'redhat-module')
|
| |
- waivers = []
|
| |
- decision = policy.check('fedora-29', nsvc, results, waivers)
|
| |
+ decision = policy.check('fedora-29', nsvc, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], RuleSatisfied)
|
| |
|
| |
@@ -927,22 +913,21 @@
|
| |
with mock.patch('greenwave.resources.retrieve_yaml_remote_rule') as f:
|
| |
f.return_value = remote_fragment
|
| |
policy = OnDemandPolicy.create_from_json(serverside_json) # pylint: disable=W0212
|
| |
- waivers = []
|
| |
|
| |
# Ensure that presence of a result is success.
|
| |
results = DummyResultsRetriever(nvr, 'dist.upgradepath')
|
| |
- decision = policy.check('fedora-26', nvr, results, waivers)
|
| |
+ decision = policy.check('fedora-26', nvr, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], RuleSatisfied)
|
| |
|
| |
# Ensure that absence of a result is failure.
|
| |
results = DummyResultsRetriever()
|
| |
- decision = policy.check('fedora-26', nvr, results, waivers)
|
| |
+ decision = policy.check('fedora-26', nvr, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], TestResultMissing)
|
| |
|
| |
# And that a result with a failure, is a failure.
|
| |
results = DummyResultsRetriever(nvr, 'dist.upgradepath', 'FAILED')
|
| |
- decision = policy.check('fedora-26', nvr, results, waivers)
|
| |
+ decision = policy.check('fedora-26', nvr, results)
|
| |
assert len(decision) == 1
|
| |
assert isinstance(decision[0], TestResultFailed)
|
| |
Why removing this? Isn't this here because of this?
https://docs.pagure.org/greenwave/package-specific-policies.html#tolerate-an-invalid-gating-yaml-file