Fix race in test_node_list_json

The recent change to use the node cache in the webapp means that
we may get differing values for the 'locked' value when listing
nodes depending on timing.  Let's not check the value, just whether
it's present.

Change-Id: I3167a9dffaedb39587ab44a3adf9efb3ef655a91
This commit is contained in:
James E. Blair 2022-07-27 13:35:41 -07:00
parent 9641b719f9
commit 3dca2c4299

View File

@ -212,13 +212,15 @@ class TestWebApp(tests.DBTestCase):
'application/json')
data = f.read()
objs = json.loads(data.decode('utf8'))
# We don't check the value of 'locked' because we may get a
# cached value returned.
self.assertDictContainsSubset({'id': '0000000000',
'ipv6': '',
'label': ['fake-label'],
'locked': 'unlocked',
'provider': 'fake-provider',
'public_ipv4': 'fake',
'state': 'ready'}, objs[0])
self.assertTrue('locked' in objs[0])
# specify valid node_id
req = request.Request(
"http://localhost:%s/node-list?node_id=%s" % (port,
@ -229,13 +231,15 @@ class TestWebApp(tests.DBTestCase):
'application/json')
data = f.read()
objs = json.loads(data.decode('utf8'))
# We don't check the value of 'locked' because we may get a
# cached value returned.
self.assertDictContainsSubset({'id': '0000000000',
'ipv6': '',
'label': ['fake-label'],
'locked': 'unlocked',
'provider': 'fake-provider',
'public_ipv4': 'fake',
'state': 'ready'}, objs[0])
self.assertTrue('locked' in objs[0])
# node_id not found
req = request.Request(
"http://localhost:%s/node-list?node_id=%s" % (port,