Fix: Patchstate incorrect when there are no hosts
If there are no hosts, the patchstate is expected to be "n/a" since we can't be sure of the current patch state. However, only the first patch's patchstate is set to "n/a" while the remaining patch's have a patchstate of "Available" (or whatever was previously reported for them). This commit fixes the issue. Test Plan: Tested with unit test case Closes-Bug: 2006398 Signed-off-by: Jessica Castelino <jessica.castelino@windriver.com> Change-Id: I7f34d35f552a04d46e3f88af9548d2e74c241310
This commit is contained in:
parent
0c66195059
commit
09048aa032
@ -781,7 +781,7 @@ class PatchController(PatchService):
|
|||||||
if len(self.hosts) == 0:
|
if len(self.hosts) == 0:
|
||||||
for patch_id in self.patch_data.metadata:
|
for patch_id in self.patch_data.metadata:
|
||||||
self.patch_data.metadata[patch_id]["patchstate"] = constants.UNKNOWN
|
self.patch_data.metadata[patch_id]["patchstate"] = constants.UNKNOWN
|
||||||
return
|
return
|
||||||
|
|
||||||
# Default to allowing in-service patching
|
# Default to allowing in-service patching
|
||||||
self.allow_insvc_patching = True
|
self.allow_insvc_patching = True
|
||||||
|
@ -943,3 +943,14 @@ class CgcsPatchControllerTestCase(testtools.TestCase):
|
|||||||
_mock_exists.return_value = True
|
_mock_exists.return_value = True
|
||||||
response = self.pc.patch_commit(patch_ids)
|
response = self.pc.patch_commit(patch_ids)
|
||||||
self.assertEqual(response["info"], "The patches have been committed.")
|
self.assertEqual(response["info"], "The patches have been committed.")
|
||||||
|
|
||||||
|
def test_check_patch_states_no_hosts(self):
|
||||||
|
self.create_patch_data(self.pc,
|
||||||
|
PATCH_LIST_AVAILABLE,
|
||||||
|
CONTENTS_WITH_OSTREE_DATA)
|
||||||
|
self.pc.hosts = []
|
||||||
|
self.pc.check_patch_states()
|
||||||
|
self.assertEqual(self.pc.patch_data.metadata["First_Patch"]["patchstate"], "n/a")
|
||||||
|
self.assertEqual(self.pc.patch_data.metadata["Second_Patch"]["patchstate"], "n/a")
|
||||||
|
self.assertEqual(self.pc.patch_data.metadata["Third_Patch"]["patchstate"], "n/a")
|
||||||
|
self.assertEqual(self.pc.patch_data.metadata["Fourth_Patch"]["patchstate"], "n/a")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user