diff --git a/tests/base.py b/tests/base.py index c81ac7d3d6..bbf4d366fd 100755 --- a/tests/base.py +++ b/tests/base.py @@ -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) diff --git a/tests/unit/test_nodepool.py b/tests/unit/test_nodepool.py index 6462f9af98..19c7e05bf4 100644 --- a/tests/unit/test_nodepool.py +++ b/tests/unit/test_nodepool.py @@ -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. diff --git a/zuul/zk.py b/zuul/zk.py index a4568738fa..2009945b86 100644 --- a/zuul/zk.py +++ b/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): '''