Skip to content

Commit

Permalink
resultsdb/waiverdb: skip updating gating status if it's ignored
Browse files Browse the repository at this point in the history
There's no point recalculating the gating status in response to
a new result or a new waiver if the status is 'ignored', which
means there are no requirements. Doing so just results in this
kind of unnecessary pingpong:
https://bodhi.fedoraproject.org/updates/FEDORA-2023-0e548f86e7

Signed-off-by: Adam Williamson <awilliam@redhat.com>
  • Loading branch information
AdamWill authored and mattiaverga committed Apr 17, 2023
1 parent 3abdf50 commit 1fbc80d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions bodhi-server/bodhi/server/consumers/resultsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __call__(self, message: fedora_messaging.api.Message):
if (
(passed and status == TestGatingStatus.passed)
or (not passed and status == TestGatingStatus.failed)
or status == TestGatingStatus.ignored
):
log.debug("Not updating test_gating_status as no chance of a change")
return
Expand Down
13 changes: 8 additions & 5 deletions bodhi-server/bodhi/server/consumers/waiverdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ def __call__(self, message: fedora_messaging.api.Message):
with self.db_factory():
# find the update
update = update_from_db_message(message.id, subject)
# update the gating status unless it's already "passed", a
# waiver can't change it from passed to anything else
if update and update.test_gating_status != TestGatingStatus.passed:
log.info(f"Updating the test_gating_status for: {update.alias}")
update.update_test_gating_status()
if update:
# update the gating status unless it's already "passed" (a
# waiver can't change it from passed to anything else) or
# "ignored" (that's not going to change either)
updtgs = update.test_gating_status
if updtgs not in (TestGatingStatus.passed, TestGatingStatus.ignored):
log.info(f"Updating the test_gating_status for: {update.alias}")
update.update_test_gating_status()
14 changes: 12 additions & 2 deletions bodhi-server/tests/consumers/test_resultsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,15 @@ def test_resultsdb_passed_koji_test(self):
update.test_gating_status = models.TestGatingStatus.waiting
self.handler(testmsg)
assert update.test_gating_status == models.TestGatingStatus.passed
# now check we don't update if already passed
# now check we don't update if already passed...
with mock.patch("bodhi.server.models.Update.update_test_gating_status") as updmock:
self.handler(testmsg)
assert updmock.call_count == 0
# ...or ignored
update.test_gating_status = models.TestGatingStatus.ignored
self.handler(testmsg)
assert updmock.call_count == 0
assert update.test_gating_status == models.TestGatingStatus.ignored

def test_resultsdb_failed_koji_test(self):
"""
Expand Down Expand Up @@ -152,10 +157,15 @@ def test_resultsdb_failed_koji_test(self):
update.test_gating_status = models.TestGatingStatus.waiting
self.handler(testmsg)
assert update.test_gating_status == models.TestGatingStatus.failed
# now check we don't update if already failed
# now check we don't update if already failed...
with mock.patch("bodhi.server.models.Update.update_test_gating_status") as updmock:
self.handler(testmsg)
assert updmock.call_count == 0
# ...or ignored
update.test_gating_status = models.TestGatingStatus.ignored
self.handler(testmsg)
assert updmock.call_count == 0
assert update.test_gating_status == models.TestGatingStatus.ignored

def test_resultsdb_bodhi_tests(self):
"""
Expand Down
7 changes: 6 additions & 1 deletion bodhi-server/tests/consumers/test_waiverdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@ def test_waiverdb_koji_waiver(self):
update.test_gating_status = models.TestGatingStatus.waiting
self.handler(testmsg)
assert update.test_gating_status == models.TestGatingStatus.passed
# now check we don't update if already passed
# now check we don't update if already passed...
with mock.patch("bodhi.server.models.Update.update_test_gating_status") as updmock:
self.handler(testmsg)
assert updmock.call_count == 0
# ...or ignored
update.test_gating_status = models.TestGatingStatus.ignored
self.handler(testmsg)
assert updmock.call_count == 0
assert update.test_gating_status == models.TestGatingStatus.ignored

def test_waiverdb_bodhi_waiver(self):
"""
Expand Down
1 change: 1 addition & 0 deletions news/PR5202.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bodhi will not try to recalculate the gating status in response to a new result or a new waiver if the status is `ignored`

0 comments on commit 1fbc80d

Please sign in to comment.