Fix race in test_node_request_canceled
Even though our nodepool is paused, it still sees events and so adds them to the provisioned_requests list. This test only passed before in the cases where it ran very quickly and beat the arrival of the event. To make this safer, allow the event to arrive and assert that even after the request is deleted, we still only saw one request and it remains in 'requested' state (ie, it was never fulfilled after we canceled it). Change-Id: I92996842e1205c7cde880c20d3350c05b2ca1edf
This commit is contained in:
parent
dd38659335
commit
80f2d5ae7d
|
@ -115,12 +115,20 @@ class TestNodepool(TestNodepoolBase):
|
|||
self.fake_nodepool.pause()
|
||||
request = self.nodepool.requestNodes(
|
||||
"test-uuid", job, "tenant", "pipeline", "provider", 0, 0)
|
||||
for x in iterate_timeout(30, 'request created'):
|
||||
if len(self.nodepool.zk_nodepool._node_request_cache):
|
||||
break
|
||||
|
||||
self.assertEqual(len(self.nodepool.provisioned_requests), 0)
|
||||
self.nodepool.cancelRequest(request)
|
||||
|
||||
for x in iterate_timeout(30, 'request deleted'):
|
||||
if not len(self.fake_nodepool.getNodeRequests()):
|
||||
if len(self.nodepool.provisioned_requests):
|
||||
break
|
||||
self.assertEqual(len(self.nodepool.provisioned_requests), 0)
|
||||
|
||||
self.assertEqual(len(self.nodepool.provisioned_requests), 1)
|
||||
self.assertEqual(self.nodepool.provisioned_requests[0].state,
|
||||
'requested')
|
||||
|
||||
def test_node_request_priority(self):
|
||||
# Test that requests are satisfied in priority order
|
||||
|
|
Loading…
Reference in New Issue