From 2d59a1e2088c054fa4c23632912c60ae55c907ab Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Thu, 23 Nov 2023 16:30:47 -0800 Subject: [PATCH] Send UpdateReadyForTesting when update is edited and builds change Test systems should re-test an update if it's edited and its builds change. Before b33609db3b022afc114d014fde1b1c926f6d975b we could rely on UpdateReadyForTesting being sent (after a delay) when this happened, because editing the builds causes the update to be sent back to pending state and then to testing state, and we were publishing the message any time an update hit testing state. But now we publish the message on update creation instead of when the update reaches testing status, that is no longer the case. So instead we should directly publish UpdateReadyForTesting when an update is edited and the builds change. Signed-off-by: Adam Williamson (cherry picked from commit 5baa421c0b2652d8c1d6f9b34f50edf25061ff2d) --- bodhi-server/bodhi/server/models.py | 5 +++ bodhi-server/tests/services/test_updates.py | 42 +++++++++++++-------- bodhi-server/tests/test_models.py | 2 +- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/bodhi-server/bodhi/server/models.py b/bodhi-server/bodhi/server/models.py index 1c503242b2..83360c8328 100644 --- a/bodhi-server/bodhi/server/models.py +++ b/bodhi-server/bodhi/server/models.py @@ -2717,6 +2717,11 @@ def edit(cls, request, data): 'removed_builds': removed_builds } )) + if (new_builds or removed_builds) and up.content_type == ContentType.rpm: + message = update_schemas.UpdateReadyForTestingV3.from_dict( + message=up._build_group_test_message(agent=request.identity.name) + ) + notifications.publish(message) # If editing a Pending update, all of whose builds are signed, for a release # which isn't composed by Bodhi (i.e. Rawhide), move it directly to Testing. diff --git a/bodhi-server/tests/services/test_updates.py b/bodhi-server/tests/services/test_updates.py index af28dbe98e..3b4df53889 100644 --- a/bodhi-server/tests/services/test_updates.py +++ b/bodhi-server/tests/services/test_updates.py @@ -3311,7 +3311,8 @@ def test_edit_update(self, *args): args['builds'] = 'bodhi-2.0.0-3.fc17' args['requirements'] = 'upgradepath' - with fml_testing.mock_sends(update_schemas.UpdateEditV2): + with fml_testing.mock_sends(update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) up = r.json_body @@ -3378,7 +3379,8 @@ def test_edit_rpm_update_from_tag(self, *args): update['requirements'] = 'upgradepath' with mock.patch('bodhi.server.buildsys.DevBuildsys.getTag', self.mock_getTag): - with fml_testing.mock_sends(update_schemas.UpdateEditV2): + with fml_testing.mock_sends(update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', update) up = r.json_body @@ -3445,7 +3447,8 @@ def test_edit_pending_update_with_new_builds(self, info, get_tags, tag_task, *ar args['edited'] = upd.alias args['builds'] = 'bodhi-2.0.0-3.fc17' - with fml_testing.mock_sends(update_schemas.UpdateEditV2): + with fml_testing.mock_sends(update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) info.assert_any_call('Unpushing bodhi-2.0.0-2.fc17') @@ -3505,7 +3508,8 @@ def test_edit_testing_update_with_new_builds(self, info, get_tags, tag_task, *ar args['builds'] = 'bodhi-2.0.0-3.fc17' with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, - update_schemas.UpdateEditV2): + update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) info.assert_any_call('Unpushing bodhi-2.0.0-2.fc17') @@ -3566,7 +3570,8 @@ def test_edit_testing_update_with_new_builds_with_stable_request(self, info, get args['builds'] = 'bodhi-2.0.0-3.fc17' with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, - update_schemas.UpdateEditV2): + update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) info.assert_any_call('Unpushing bodhi-2.0.0-2.fc17') @@ -3665,7 +3670,8 @@ def test_edit_pending_sidetag_update_with_new_builds(self, info, get_tags, tag_t args['edited'] = upd.alias args['builds'] = 'bodhi-2.0.0-3.fc17' - with fml_testing.mock_sends(update_schemas.UpdateEditV2): + with fml_testing.mock_sends(update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) info.assert_any_call('Unpushing bodhi-2.0.0-2.fc17') @@ -3727,7 +3733,8 @@ def test_edit_testing_sidetag_update_with_new_builds(self, info, get_tags, tag_t args['builds'] = 'bodhi-2.0.0-3.fc17' with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, - update_schemas.UpdateEditV2): + update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) info.assert_any_call('Unpushing bodhi-2.0.0-2.fc17') @@ -4801,7 +4808,8 @@ def test_edit_update_bugs(self, *args): args['bugs'] = '56789,98765' with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, - update_schemas.UpdateEditV2): + update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) up = r.json_body @@ -4951,7 +4959,7 @@ def test_edit_testing_update_reset_karma(self, *args): args['edited'] = upd.alias args['builds'] = 'bodhi-2.0.0-3.fc17' - with fml_testing.mock_sends(*[base_schemas.BodhiMessage] * 2): + with fml_testing.mock_sends(*[base_schemas.BodhiMessage] * 3): r = self.app.post_json('/updates/', args) up = r.json_body @@ -4995,7 +5003,7 @@ def test_edit_testing_update_reset_karma_with_same_tester(self, *args): new_nvr = 'bodhi-2.0.0-3.fc17' args['edited'] = upd.alias args['builds'] = new_nvr - with fml_testing.mock_sends(*[base_schemas.BodhiMessage] * 3): + with fml_testing.mock_sends(*[base_schemas.BodhiMessage] * 4): r = self.app.post_json('/updates/', args) up = r.json_body assert up['title'] == new_nvr @@ -5013,7 +5021,7 @@ def test_edit_testing_update_reset_karma_with_same_tester(self, *args): newer_nvr = 'bodhi-2.0.0-4.fc17' args['edited'] = upd.alias args['builds'] = newer_nvr - with fml_testing.mock_sends(*[base_schemas.BodhiMessage] * 2): + with fml_testing.mock_sends(*[base_schemas.BodhiMessage] * 3): r = self.app.post_json('/updates/', args) up = r.json_body assert up['title'] == newer_nvr @@ -6020,7 +6028,8 @@ def test_edit_update_with_expired_override(self, *args): args['edited'] = upd.alias args['builds'] = new_nvr - with fml_testing.mock_sends(update_schemas.UpdateEditV2): + with fml_testing.mock_sends(update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) up = r.json_body @@ -6030,7 +6039,8 @@ def test_edit_update_with_expired_override(self, *args): args['edited'] = upd.alias args['builds'] = nvr - with fml_testing.mock_sends(update_schemas.UpdateEditV2): + with fml_testing.mock_sends(update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) up = r.json_body @@ -6187,7 +6197,8 @@ def test_edit_testing_update_with_build_from_unpushed_update(self, *args): args['edited'] = upd.alias args['builds'] = '%s,%s' % (nvr1, nvr2) with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, - update_schemas.UpdateEditV2): + update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) up = r.json_body assert len(up['builds']) == 2 @@ -6248,7 +6259,8 @@ def test_meets_testing_requirements_since_karma_reset_critpath(self, *args): args['builds'] = 'bodhi-2.0.0-3.fc17' with fml_testing.mock_sends(update_schemas.UpdateRequestTestingV1, - update_schemas.UpdateEditV2): + update_schemas.UpdateEditV2, + update_schemas.UpdateReadyForTestingV3): r = self.app.post_json('/updates/', args) up = r.json_body diff --git a/bodhi-server/tests/test_models.py b/bodhi-server/tests/test_models.py index 2213707fcf..9fd4ca82e3 100644 --- a/bodhi-server/tests/test_models.py +++ b/bodhi-server/tests/test_models.py @@ -2225,7 +2225,7 @@ def test_version_hash(self): request.db = self.db request.identity.name = 'tester' self.db.flush() - with mock_sends(Message): + with mock_sends(Message, Message): model.Update.edit(request, data) # now, with two builds, check the hash has changed