def setUp(self): self.set_up_kazoo_base() self.procs = [] self.thrift_server = None self.transports = [] self.runtime = RuntimeUtils(self.id()) self.runtime.start_cloud_store() host, port = '127.0.0.1', 13000 self.runtime.start_chairman(host, port) (transport, self.chairman_client) = create_chairman_client(host, port) self.transports.append(transport) # Wait for chairman to finish their elections _wait_on_code(self.chairman_client.get_schedulers, GetSchedulersResultCode.OK, GetSchedulersRequest)
def setUp(self): self.set_up_kazoo_base() self.zk_client = self._get_nonchroot_client() self.zk_client.start() self.runtime = RuntimeUtils(self.id()) # Create zk paths self.zk_client.create(MISSING_PREFIX) self.zk_client.create(HOSTS_PREFIX) self.zk_client.create(ROLES_PREFIX) self.root_conf = {} self.root_conf['healthcheck'] = {} self.root_conf['zookeeper'] = {} self.root_conf['zookeeper']['quorum'] = ("localhost:%i" % (DEFAULT_ZK_PORT, )) self.root_conf['healthcheck']['timeout_ms'] = ROOT_SCHEDULER_TIME_OUT self.root_conf['healthcheck']['period_ms'] = ROOT_SCHEDULER_PERIOD # start root scheduler self.root_host = "localhost" self.root_port = 15000 self.root_conf['bind'] = self.root_host self.root_conf['port'] = self.root_port self.runtime.start_root_scheduler(self.root_conf) (self.root_transport, self.root_sch_client) = create_root_client(self.root_port, self.root_host) # start chairman self.chairman_host = 'localhost' self.chairman_port = 13000 self.leaf_fanout = 2 self.runtime.start_chairman(self.chairman_host, self.chairman_port, self.leaf_fanout) (self.chairman_transport, self.chairman_client) = \ create_chairman_client(self.chairman_host, self.chairman_port) # Wait for chairman and root scheduler to finish their elections _wait_on_code(self.root_sch_client.get_schedulers, GetSchedulersResultCode.OK) _wait_on_code(self.chairman_client.get_schedulers, GetSchedulersResultCode.OK, GetSchedulersRequest)
def test_update_status(self): agent_host = 'localhost' agent_port1 = 20000 config = self.runtime.get_agent_config(agent_host, agent_port1, self.chairman_host, self.chairman_port) res = self.runtime.start_agent(config) _wait_for_configuration(self.root_sch_client, 1) root = get_hierarchy_from_zk(self.zk_client) # Update the hierarchy status root.update_status() # verify that the root scheduler and leaf are online assert_that(root.owner.status, is_(STATUS_ONLINE)) assert_that(len(root.children), is_(1)) assert_that(root.children.values()[0].owner.status, is_(STATUS_ONLINE)) # Kill both root scheduler and leaf host stop_service(self.runtime.root_procs[0]) self.runtime.stop_agent(res[0]) # Update the hierarchy status root.update_status() assert_that(root.owner.status, is_(STATUS_OFFLINE)) assert_that(root.children.values()[0].owner.status, is_(STATUS_OFFLINE)) # Start the root scheduler and leaf scheduler self.runtime.start_root_scheduler(self.root_conf) config = self.runtime.get_agent_config(agent_host, agent_port1, self.chairman_host, self.chairman_port) res = self.runtime.start_agent(config) (self.root_transport, self.root_sch_client) = create_root_client(self.root_port, self.root_host) # Wait for the root scheduler's leader election _wait_on_code(self.root_sch_client.get_schedulers, GetSchedulersResultCode.OK) # Check the status again root.update_status() # verify that the root scheduler and leaf are online assert_that(root.owner.status, is_(STATUS_ONLINE)) assert_that(root.children.values()[0].owner.status, is_(STATUS_ONLINE))
def setUp(self): if not CHAIRMAN_SIM: raise nose.plugins.skip.SkipTest("Skipping Chairman" "simulator test!") atexit.register(self.dump_sim_state) self.runtime = RuntimeUtils(self.id()) self.set_up_kazoo_base() self.zk_client = self._get_nonchroot_client() self.zk_client.start() # start chairman self.chairman_host = '127.0.0.1' self.chairman_port = 13000 self.leaf_fanout = 32 self.runtime.start_chairman(self.chairman_host, self.chairman_port, self.leaf_fanout) (_, self.client1) = create_chairman_client(self.chairman_host, self.chairman_port) # Wait for chairman to finish their elections _wait_on_code(self.client1.get_schedulers, GetSchedulersResultCode.OK, GetSchedulersRequest)
def setUp(self): self.set_up_kazoo_base() self.zk_client = self._get_nonchroot_client() self.zk_client.start() self.runtime = RuntimeUtils(self.id()) # Create zk paths self.zk_client.create(MISSING_PREFIX) self.zk_client.create(HOSTS_PREFIX) self.zk_client.create(ROLES_PREFIX) self.root_conf = {} self.root_conf["healthcheck"] = {} self.root_conf["zookeeper"] = {} self.root_conf["zookeeper"]["quorum"] = "localhost:%i" % (DEFAULT_ZK_PORT,) self.root_conf["healthcheck"]["timeout_ms"] = ROOT_SCHEDULER_TIME_OUT self.root_conf["healthcheck"]["period_ms"] = ROOT_SCHEDULER_PERIOD # start root scheduler self.root_host = "localhost" self.root_port = 15000 self.root_conf["bind"] = self.root_host self.root_conf["port"] = self.root_port self.runtime.start_root_scheduler(self.root_conf) (self.root_transport, self.root_sch_client) = create_root_client(self.root_port, self.root_host) # start chairman self.chairman_host = "localhost" self.chairman_port = 13000 self.leaf_fanout = 2 self.runtime.start_chairman(self.chairman_host, self.chairman_port, self.leaf_fanout) (self.chairman_transport, self.chairman_client) = create_chairman_client(self.chairman_host, self.chairman_port) # Wait for chairman and root scheduler to finish their elections _wait_on_code(self.root_sch_client.get_schedulers, GetSchedulersResultCode.OK) _wait_on_code(self.chairman_client.get_schedulers, GetSchedulersResultCode.OK, GetSchedulersRequest)
def test_update_status(self): agent_host = "localhost" agent_port1 = 20000 config = self.runtime.get_agent_config(agent_host, agent_port1, self.chairman_host, self.chairman_port) res = self.runtime.start_agent(config) _wait_for_configuration(self.root_sch_client, 1) root = get_hierarchy_from_zk(self.zk_client) # Update the hierarchy status root.update_status() # verify that the root scheduler and leaf are online assert_that(root.owner.status, is_(STATUS_ONLINE)) assert_that(len(root.children), is_(1)) assert_that(root.children.values()[0].owner.status, is_(STATUS_ONLINE)) # Kill both root scheduler and leaf host stop_service(self.runtime.root_procs[0]) self.runtime.stop_agent(res[0]) # Update the hierarchy status root.update_status() assert_that(root.owner.status, is_(STATUS_OFFLINE)) assert_that(root.children.values()[0].owner.status, is_(STATUS_OFFLINE)) # Start the root scheduler and leaf scheduler self.runtime.start_root_scheduler(self.root_conf) config = self.runtime.get_agent_config(agent_host, agent_port1, self.chairman_host, self.chairman_port) res = self.runtime.start_agent(config) (self.root_transport, self.root_sch_client) = create_root_client(self.root_port, self.root_host) # Wait for the root scheduler's leader election _wait_on_code(self.root_sch_client.get_schedulers, GetSchedulersResultCode.OK) # Check the status again root.update_status() # verify that the root scheduler and leaf are online assert_that(root.owner.status, is_(STATUS_ONLINE)) assert_that(root.children.values()[0].owner.status, is_(STATUS_ONLINE))