diff --git a/software/software/db/api.py b/software/software/db/api.py index 316f1fcb..78d303f6 100644 --- a/software/software/db/api.py +++ b/software/software/db/api.py @@ -110,11 +110,11 @@ class SoftwareAPI: def begin_update(self): tid = threading.get_native_id() msg = f"{tid} is to acquire lock." - LOG.info(msg) + LOG.debug(msg) SoftwareAPI._lock.acquire() def end_update(self): SoftwareAPI._lock.release() tid = threading.get_native_id() msg = f"{tid} released lock." - LOG.info(msg) + LOG.debug(msg) diff --git a/software/software/software_controller.py b/software/software/software_controller.py index 70b38295..05bd7408 100644 --- a/software/software/software_controller.py +++ b/software/software/software_controller.py @@ -581,16 +581,10 @@ class PatchMessageAgentInstallResp(messages.PatchMessage): sc.hosts_lock.release() deploy_host_state = DeployHostState(hostname) - # NOTE(bqian) apparently it uses 2 boolean to indicate 2 situations - # where there could be 4 combinations if self.status: deploy_host_state.deployed() - return - elif self.reject_reason: + else: deploy_host_state.deploy_failed() - return - - LOG.error("Bug: shouldn't reach here") def send(self, sock): # pylint: disable=unused-argument LOG.error("Should not get here") @@ -1346,7 +1340,7 @@ class PatchController(PatchService): # Get the release_id from the patch's metadata # and check to see if it's already uploaded - release_id = get_release_from_patch(patch_file,'id') + release_id = get_release_from_patch(patch_file, 'id') release = self.release_collection.get_release_by_id(release_id) diff --git a/software/software/tests/test_software_controller_messages.py b/software/software/tests/test_software_controller_messages.py index 4a6814fe..5bf372e8 100644 --- a/software/software/tests/test_software_controller_messages.py +++ b/software/software/tests/test_software_controller_messages.py @@ -19,7 +19,7 @@ from software.software_controller import PatchMessageQueryDetailedResp from software.software_controller import PatchMessageAgentInstallReq from software.software_controller import PatchMessageAgentInstallResp from software.software_controller import PatchMessageDropHostReq - +from software.states import DEPLOY_HOST_STATES FAKE_AGENT_ADDRESS = "127.0.0.1" FAKE_AGENT_MCAST_GROUP = "239.1.1.4" @@ -35,7 +35,7 @@ class FakeSoftwareController(object): self.allow_insvc_softwareing = True self.controller_address = FAKE_CONTROLLER_ADDRESS self.controller_neighbours = {} - self.hosts = {} + self.hosts = {FAKE_HOST_IP: {"hostname": "controller-0"}} self.interim_state = {} self.latest_feed_commit = FAKE_OSTREE_FEED_COMMIT self.patch_op_counter = 0 @@ -143,12 +143,16 @@ class SoftwareControllerMessagesTestCase(testtools.TestCase): mock_sock.sendall.assert_called() @mock.patch('software.software_controller.sc', FakeSoftwareController()) - def test_message_class_handle(self): + @mock.patch('software.db.api.SoftwareAPI.get_deploy_host_by_hostname', + return_value={"state": DEPLOY_HOST_STATES.DEPLOYING}) + @mock.patch('software.software_entities.DeployHostHandler.update', return_value=True) + def test_message_class_handle(self, mock_get_deploy_host_by_hostname, mock_update): # pylint: disable=unused-argument """'handle' method tests""" addr = [FAKE_CONTROLLER_ADDRESS, ] # addr is a list mock_sock = mock.Mock() special_setup = { PatchMessageDropHostReq: ('ip', FAKE_HOST_IP), + PatchMessageAgentInstallResp: ('status', True), } for message_class in SoftwareControllerMessagesTestCase.message_classes: