patch state reporting bug
This commit fixes the sw-patch reporting bug. Bug description: Applied patches go to a Partial-Applied state after applying a new patch sw-patch query result before appllying a new patch: Patch ID RR Release Patch State =========================== == ======= =========== WRCP_22.12_PATCH_0001 Y 22.12 Applied WRCP_22.12_PATCH_0002 Y 22.12 Applied WRCP_22.12_PATCH_0003 Y 22.12 Applied WRCP_22.12_PATCH_0004 Y 22.12 Applied WRCP_22.12_PATCH_0005_JAN29 Y 22.12 Available Then after applying the latest patch, previously applied patches go to partial-applied, as follows: Patch ID RR Release Patch State =========================== == ======= ============= WRCP_22.12_PATCH_0001 Y 22.12 Partial-Apply WRCP_22.12_PATCH_0002 Y 22.12 Partial-Apply WRCP_22.12_PATCH_0003 Y 22.12 Partial-Apply WRCP_22.12_PATCH_0004 Y 22.12 Applied WRCP_22.12_PATCH_0005_JAN29 Y 22.12 Partial-Apply After with this bugfix, the patch reports are the following: Patch ID RR Release Patch State =========================== == ======= ============= WRCP_22.12_PATCH_0001 Y 22.12 Applied WRCP_22.12_PATCH_0002 Y 22.12 Applied WRCP_22.12_PATCH_0003 Y 22.12 Applied WRCP_22.12_PATCH_0004 Y 22.12 Applied WRCP_22.12_PATCH_0005_JAN29 Y 22.12 Partial-Apply Test Plan: PASS: Python code for patch_controler.py unit tests pass and a new test case was created to cover this condition Change-Id: Ibceeecbf025535b73886517b6ce02e6013d99aea Signed-off-by: caio-volpato <caio.volpato@windriver.com>
This commit is contained in:
parent
ee717b97e9
commit
8a61f3dd49
|
@ -863,11 +863,13 @@ class PatchController(PatchService):
|
|||
if self.patch_data.metadata[patch_id]["sw_version"] != self.hosts[ip].sw_version:
|
||||
continue
|
||||
|
||||
|
||||
if patch_id not in skip_patch:
|
||||
if self.patch_data.metadata[patch_id]["repostate"] == constants.AVAILABLE and \
|
||||
if self.patch_data.metadata[patch_id]["repostate"] in [constants.AVAILABLE, constants.APPLIED] and \
|
||||
self.hosts[ip].latest_sysroot_commit == \
|
||||
self.patch_data.contents[patch_id]["commit1"]["commit"]:
|
||||
self.patch_data.metadata[patch_id]["patchstate"] = constants.PARTIAL_REMOVE
|
||||
if self.patch_data.metadata[patch_id]["repostate"] == constants.AVAILABLE:
|
||||
self.patch_data.metadata[patch_id]["patchstate"] = constants.PARTIAL_REMOVE
|
||||
patch_dependency_list = self.get_patch_dependency_list(patch_id)
|
||||
for req_patch in patch_dependency_list:
|
||||
if self.patch_data.metadata[req_patch]["repostate"] == constants.AVAILABLE:
|
||||
|
|
|
@ -1521,23 +1521,19 @@ class CgcsPatchControllerTestCase(testtools.TestCase):
|
|||
def test_previosly_applied_goes_to_partial_applied(self):
|
||||
# bug description: Applied patches go to a Partial-Applied state after applying a new patch
|
||||
# after the system reboot all patches corretly goes to applied state
|
||||
patch_ids = self.create_patch_data(self.pc,
|
||||
CHECK_PATCH_STATES_QUERY_BUG,
|
||||
self.create_patch_data(self.pc,CHECK_PATCH_STATES_QUERY_BUG,
|
||||
CONTENTS_WITH_OSTREE_DATA_QUERY_BUG)
|
||||
|
||||
patch_ids.remove("Third_Patch_CURRENT")
|
||||
test_ip1 = '127.0.0.1'
|
||||
an_1 = AgentNeighbour(test_ip1)
|
||||
an_1.out_of_date = True
|
||||
an_1.sw_version = "12.34"
|
||||
an_1.latest_sysroot_commit = "commitThirdPatch"
|
||||
self.pc.interim_state = patch_ids
|
||||
self.pc.interim_state = []
|
||||
self.pc.hosts = {test_ip1: an_1}
|
||||
self.pc.check_patch_states()
|
||||
|
||||
print(self.pc.patch_data.metadata)
|
||||
|
||||
self.assertEqual(self.pc.patch_data.metadata["Third_Patch_CURRENT"]["patchstate"], "Applied")
|
||||
self.assertEqual(self.pc.patch_data.metadata["First_Patch_APPLIED"]["patchstate"], "Applied")
|
||||
self.assertEqual(self.pc.patch_data.metadata["Second_Patch_APPLIED"]["patchstate"], "Applied")
|
||||
self.assertEqual(self.pc.patch_data.metadata["Fourth_Patch_NEWLY_APPLIED"]["patchstate"], "Partial-Apply")
|
||||
|
||||
|
|
Loading…
Reference in New Issue