Configure zk fixture cleanup early

Generally you want to put the cleanup in place before the resource is
created. This way if you have failure in setUp then you don't leak the
resources as they should be cleaned up after early failures. Move the zk
fixture's chroot cleanup to before we create the chroot. This way if
anything fails in setting that up we should get cleaned up properly.

Also explicitly close the tmp kazoo client after stopping it as kazoo
docs say not doing this can result in leaks.

Change-Id: I6d94909b5b4836aa09528e1de744c940c2a9a12f
diff --git a/tests/base.py b/tests/base.py
index 1f447da..30ff7a1 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -1068,6 +1068,8 @@
         rand_test_path = '%s_%s' % (random_bits, os.getpid())
         self.zookeeper_chroot = "/nodepool_test/%s" % rand_test_path
 
+        self.addCleanup(self._cleanup)
+
         # Ensure the chroot path exists and clean up any pre-existing znodes.
         _tmp_client = kazoo.client.KazooClient(
             hosts='%s:%s' % (self.zookeeper_host, self.zookeeper_port))
@@ -1080,8 +1082,6 @@
         _tmp_client.stop()
         _tmp_client.close()
 
-        self.addCleanup(self._cleanup)
-
     def _cleanup(self):
         '''Remove the chroot path.'''
         # Need a non-chroot'ed client to remove the chroot path
@@ -1090,6 +1090,7 @@
         _tmp_client.start()
         _tmp_client.delete(self.zookeeper_chroot, recursive=True)
         _tmp_client.stop()
+        _tmp_client.close()
 
 
 class MySQLSchemaFixture(fixtures.Fixture):