summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-11-28 18:30:45 +0000
committerGerrit Code Review <review@openstack.org>2018-11-28 18:30:45 +0000
commit75158ccd07a37669ebb629095f6d2e58074d6a4d (patch)
tree9a5e429bb2a6fd82bfd2eb6d08f5438dae98c061
parentf13c736f52467a138238ace4c57fc68243abe12b (diff)
parente4b1ab790e245545760f2036ed82f91df137f266 (diff)
Merge "Fix test race in test_hold_expiration_higher_than_default"
-rw-r--r--nodepool/tests/unit/test_launcher.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/nodepool/tests/unit/test_launcher.py b/nodepool/tests/unit/test_launcher.py
index b59732a..4b12ff2 100644
--- a/nodepool/tests/unit/test_launcher.py
+++ b/nodepool/tests/unit/test_launcher.py
@@ -22,6 +22,7 @@ import mock
22from nodepool import tests 22from nodepool import tests
23from nodepool import zk 23from nodepool import zk
24from nodepool.driver.fake import provider as fakeprovider 24from nodepool.driver.fake import provider as fakeprovider
25from nodepool.nodeutils import iterate_timeout
25import nodepool.launcher 26import nodepool.launcher
26 27
27from kazoo import exceptions as kze 28from kazoo import exceptions as kze
@@ -1003,8 +1004,8 @@ class TestLauncher(tests.DBTestCase):
1003 nodes = self.waitForNodes('fake-label', 2) 1004 nodes = self.waitForNodes('fake-label', 2)
1004 self.log.debug("...done waiting for initial pool.") 1005 self.log.debug("...done waiting for initial pool.")
1005 node_custom = nodes[0] 1006 node_custom = nodes[0]
1006 # TODO make it a multiple of fixture's max-hold-age 1007 # Make hold expiration much larger than max hold age.
1007 hold_expiration = 20 1008 hold_expiration = 180
1008 node = nodes[1] 1009 node = nodes[1]
1009 self.log.debug("Holding node %s... (default)" % node.id) 1010 self.log.debug("Holding node %s... (default)" % node.id)
1010 self.log.debug("Holding node %s...(%s seconds)" % (node_custom.id, 1011 self.log.debug("Holding node %s...(%s seconds)" % (node_custom.id,
@@ -1029,9 +1030,21 @@ class TestLauncher(tests.DBTestCase):
1029 # Wait for the instance to be cleaned up 1030 # Wait for the instance to be cleaned up
1030 manager = pool.getProviderManager('fake-provider') 1031 manager = pool.getProviderManager('fake-provider')
1031 self.waitForInstanceDeletion(manager, node.external_id) 1032 self.waitForInstanceDeletion(manager, node.external_id)
1032 # custom node should be deleted as well 1033
1033 held_nodes = [n for n in self.zk.nodeIterator() if n.state == zk.HOLD] 1034 # The custom node should be deleted as well but it may be slightly
1034 self.assertEqual(0, len(held_nodes), held_nodes) 1035 # delayed after the other node. Because of that we have defined a much
1036 # higher hold time than the max hold age. So we can give nodepool a few
1037 # extra seconds to clean it up and still validate that the max hold
1038 # age is not violated.
1039 for _ in iterate_timeout(10, Exception, 'assert custom_node is gone'):
1040 try:
1041 held_nodes = [n for n in self.zk.nodeIterator(cached=False)
1042 if n.state == zk.HOLD]
1043 self.assertEqual(0, len(held_nodes), held_nodes)
1044 break
1045 except AssertionError:
1046 # node still listed, retry
1047 pass
1035 1048
1036 def test_label_provider(self): 1049 def test_label_provider(self):
1037 """Test that only providers listed in the label satisfy the request""" 1050 """Test that only providers listed in the label satisfy the request"""