From 0cf4484eea40d185d618beb2655fde0b5ac19002 Mon Sep 17 00:00:00 2001
From: David Shrewsbury <shrewsbury.dave@gmail.com>
Date: Tue, 12 Jul 2016 19:51:04 -0400
Subject: [PATCH] Use random strings for ZK test paths

The getUniqueInteger() does not get a number unique between parallel
test runs, so the chroot path will often conflict between tests unless
run serially. Use something more random by copying what we do from the
MySQL fixture.

Change-Id: Ia716836344813d993fbc2345467695778b0d1789
---
 nodepool/tests/__init__.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/nodepool/tests/__init__.py b/nodepool/tests/__init__.py
index afae79e3e..d49a53445 100644
--- a/nodepool/tests/__init__.py
+++ b/nodepool/tests/__init__.py
@@ -521,7 +521,12 @@ class ZKTestCase(BaseTestCase):
         self.useFixture(f)
         self.zookeeper_host = f.zookeeper_host
         self.zookeeper_port = f.zookeeper_port
-        self.chroot_path = "/nodepool_test/%s" % self.getUniqueInteger()
+        # Make sure the test chroot paths do not conflict
+        random_bits = ''.join(random.choice(string.ascii_lowercase +
+                                            string.ascii_uppercase)
+                              for x in range(8))
+        rand_test_path = '%s_%s' % (random_bits, os.getpid())
+        self.chroot_path = "/nodepool_test/%s" % rand_test_path
 
         # Ensure the chroot path exists and clean up an pre-existing znodes
         _tmp_client = kazoo.client.KazooClient(