Fix potential race in tests
The waitForNodes method was subject to the following race: main thread: create a db record for a new node test thread: verify that no nodes need to be created test thread: verify that no launch threads are running test thread: exit main thread: spawn the launch thread for the new node This change ensures that there are no nodes in the BUILDING state before assuming that the system is stable. Change-Id: I48f0c34c76e40c8fe8deff548100f7868c96428d
This commit is contained in:
parent
1ef8c7fdaf
commit
9b95c9428d
@ -29,7 +29,7 @@ import fixtures
|
|||||||
import testresources
|
import testresources
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from nodepool import allocation, fakeprovider, nodepool
|
from nodepool import allocation, fakeprovider, nodepool, nodedb
|
||||||
|
|
||||||
TRUE_VALUES = ('true', '1', 'yes')
|
TRUE_VALUES = ('true', '1', 'yes')
|
||||||
|
|
||||||
@ -232,8 +232,10 @@ class DBTestCase(BaseTestCase):
|
|||||||
with pool.getDB().getSession() as session:
|
with pool.getDB().getSession() as session:
|
||||||
needed = pool.getNeededNodes(session, allocation_history)
|
needed = pool.getNeededNodes(session, allocation_history)
|
||||||
if not needed:
|
if not needed:
|
||||||
break
|
nodes = session.getNodes(state=nodedb.BUILDING)
|
||||||
time.sleep(1)
|
if not nodes:
|
||||||
|
break
|
||||||
|
time.sleep(1)
|
||||||
self.wait_for_threads()
|
self.wait_for_threads()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user