Skip to content

Commit fcd8698

Browse files
committed
test(neutron): fake Ironic waits like the SDK instead of forcing the state
1 parent 5c30dd4 commit fcd8698

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎python/neutron-understack/neutron_understack/tests/test_ironic.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ def nodes(**filters):
6060
client.irclient.nodes.side_effect = nodes
6161

6262

63+
def _wait_for(node, state):
64+
"""Wait like the SDK: only watch the node, so a missed transition times out."""
65+
if node.provision_state != state:
66+
raise sdk_exc.ResourceTimeout(f"{node.id} did not reach {state}")
67+
68+
6369
class _FakeBaremetal:
6470
def __init__(
6571
self,
@@ -150,7 +156,7 @@ def update_node(self, node, retry_on_conflict=False, **fields):
150156
return self._copy()
151157

152158
def wait_for_nodes_provision_state(self, nodes, state, timeout=None):
153-
self.node.provision_state = state
159+
_wait_for(self.node, state)
154160
return [self._copy()]
155161

156162

@@ -1055,8 +1061,7 @@ def set_node_provision_state(self, node, target_state, wait=True, timeout=None):
10551061

10561062
def wait_for_nodes_provision_state(self, nodes, state, timeout=None):
10571063
node_id = self._id(nodes[0])
1058-
if self.by_id[node_id].provision_state != state:
1059-
raise RuntimeError(f"{node_id} did not reach {state}")
1064+
_wait_for(self.by_id[node_id], state)
10601065
return [self._copy(node_id)]
10611066

10621067

0 commit comments

Comments
 (0)