def test_get_version(self):
     common.services.register(ServiceName.REQUEST_ID, MagicMock())
     handler = AgentControlHandler()
     response = handler.get_version(VersionRequest())
     assert_that(response.result, equal_to(VersionResultCode.OK))
     assert_that(response.version, not_none())
     assert_that(response.revision, not_none())
 def test_get_version(self):
     common.services.register(ServiceName.REQUEST_ID, MagicMock())
     handler = AgentControlHandler()
     response = handler.get_version(VersionRequest())
     assert_that(response.result, equal_to(VersionResultCode.OK))
     assert_that(response.version, not_none())
     assert_that(response.revision, not_none())
Esempio n. 3
0
    def test_get_schedulers(self, leaf_scheduler_cls):
        leaf_scheduler = MagicMock()
        leaf_scheduler_cls.return_value = leaf_scheduler

        common.services.register(Host.Iface, MagicMock())
        scheduler_handler = SchedulerHandler()
        common.services.register(Scheduler.Iface, scheduler_handler)
        agent_config = MagicMock()
        agent_config.reboot_required = False
        common.services.register(ServiceName.AGENT_CONFIG, agent_config)
        common.services.register(ServiceName.REQUEST_ID, MagicMock())

        agent_control_handler = AgentControlHandler()
        request = GetSchedulersRequest()
        response = agent_control_handler.get_schedulers(request)

        child_host = ChildInfo(id="foo", address="address", port=12345)

        assert_that(response.schedulers, is_(empty()))
        leaf_scheduler_id = "leaf1"
        scheduler_handler.configure(
            [SchedulerRole(leaf_scheduler_id, "parent1",
                           host_children=[child_host])])
        leaf_scheduler._get_hosts.return_value = [child_host]

        response = agent_control_handler.get_schedulers(request)
        assert_that(response.schedulers, has_length(1))

        scheduler = response.schedulers[0]
        assert_that(scheduler.role.id, is_(leaf_scheduler_id))
        assert_that(scheduler.role.host_children[0], is_(child_host))
        assert_that(len(scheduler.role.host_children), is_(1))
        assert_that(response.result, is_(GetSchedulersResultCode.OK))
Esempio n. 4
0
 def test_get_version(self):
     handler = AgentControlHandler()
     response = handler.get_version(VersionRequest())
     assert_that(response.result, equal_to(VersionResultCode.OK))
     assert_that(response.version, not_none())
     assert_that(response.revision, not_none())