Merge "Remove zk host list parsing" into feature/zuulv3
This commit is contained in:
commit
87c75c0446
@ -1300,11 +1300,12 @@ class ZuulTestCase(BaseTestCase):
|
||||
self.config, self.sched)
|
||||
self.nodepool = zuul.nodepool.Nodepool(self.sched)
|
||||
self.zk = zuul.zk.ZooKeeper()
|
||||
self.zk.connect([self.zk_config])
|
||||
self.zk.connect(self.zk_config)
|
||||
|
||||
self.fake_nodepool = FakeNodepool(self.zk_config.host,
|
||||
self.zk_config.port,
|
||||
self.zk_config.chroot)
|
||||
self.fake_nodepool = FakeNodepool(
|
||||
self.zk_chroot_fixture.zookeeper_host,
|
||||
self.zk_chroot_fixture.zookeeper_port,
|
||||
self.zk_chroot_fixture.zookeeper_chroot)
|
||||
|
||||
self.sched.setLauncher(self.launch_client)
|
||||
self.sched.setMerger(self.merge_client)
|
||||
@ -1380,7 +1381,7 @@ class ZuulTestCase(BaseTestCase):
|
||||
|
||||
def setupZK(self):
|
||||
self.zk_chroot_fixture = self.useFixture(ChrootedKazooFixture())
|
||||
self.zk_config = zuul.zk.ZooKeeperConnectionConfig(
|
||||
self.zk_config = '%s:%s%s' % (
|
||||
self.zk_chroot_fixture.zookeeper_host,
|
||||
self.zk_chroot_fixture.zookeeper_port,
|
||||
self.zk_chroot_fixture.zookeeper_chroot)
|
||||
|
@ -30,22 +30,23 @@ class TestNodepool(BaseTestCase):
|
||||
super(BaseTestCase, self).setUp()
|
||||
|
||||
self.zk_chroot_fixture = self.useFixture(ChrootedKazooFixture())
|
||||
self.zk_config = zuul.zk.ZooKeeperConnectionConfig(
|
||||
self.zk_config = '%s:%s%s' % (
|
||||
self.zk_chroot_fixture.zookeeper_host,
|
||||
self.zk_chroot_fixture.zookeeper_port,
|
||||
self.zk_chroot_fixture.zookeeper_chroot)
|
||||
|
||||
self.zk = zuul.zk.ZooKeeper()
|
||||
self.zk.connect([self.zk_config])
|
||||
self.zk.connect(self.zk_config)
|
||||
|
||||
self.provisioned_requests = []
|
||||
# This class implements the scheduler methods zuul.nodepool
|
||||
# needs, so we pass 'self' as the scheduler.
|
||||
self.nodepool = zuul.nodepool.Nodepool(self)
|
||||
|
||||
self.fake_nodepool = FakeNodepool(self.zk_config.host,
|
||||
self.zk_config.port,
|
||||
self.zk_config.chroot)
|
||||
self.fake_nodepool = FakeNodepool(
|
||||
self.zk_chroot_fixture.zookeeper_host,
|
||||
self.zk_chroot_fixture.zookeeper_port,
|
||||
self.zk_chroot_fixture.zookeeper_chroot)
|
||||
|
||||
def waitForRequests(self):
|
||||
# Wait until all requests are complete.
|
||||
|
23
zuul/zk.py
23
zuul/zk.py
@ -64,23 +64,6 @@ class ZooKeeperConnectionConfig(object):
|
||||
self.chroot = chroot or ''
|
||||
|
||||
|
||||
def buildZooKeeperHosts(host_list):
|
||||
'''
|
||||
Build the ZK cluster host list for client connections.
|
||||
|
||||
:param list host_list: A list of
|
||||
:py:class:`~nodepool.zk.ZooKeeperConnectionConfig` objects (one
|
||||
per server) defining the ZooKeeper cluster servers.
|
||||
'''
|
||||
if not isinstance(host_list, list):
|
||||
raise Exception("'host_list' must be a list")
|
||||
hosts = []
|
||||
for host_def in host_list:
|
||||
host = '%s:%s%s' % (host_def.host, host_def.port, host_def.chroot)
|
||||
hosts.append(host)
|
||||
return ",".join(hosts)
|
||||
|
||||
|
||||
class ZooKeeper(object):
|
||||
'''
|
||||
Class implementing the ZooKeeper interface.
|
||||
@ -158,8 +141,7 @@ class ZooKeeper(object):
|
||||
|
||||
'''
|
||||
if self.client is None:
|
||||
hosts = buildZooKeeperHosts(host_list)
|
||||
self.client = KazooClient(hosts=hosts, read_only=read_only)
|
||||
self.client = KazooClient(hosts=host_list, read_only=read_only)
|
||||
self.client.add_listener(self._connection_listener)
|
||||
self.client.start()
|
||||
|
||||
@ -184,8 +166,7 @@ class ZooKeeper(object):
|
||||
(one per server) defining the ZooKeeper cluster servers.
|
||||
'''
|
||||
if self.client is not None:
|
||||
hosts = buildZooKeeperHosts(host_list)
|
||||
self.client.set_hosts(hosts=hosts)
|
||||
self.client.set_hosts(hosts=host_list)
|
||||
|
||||
def submitNodeRequest(self, node_request, watcher):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user