tests, integ: fix unordered ports in _get_bridge_current_state()

When using _get_bridge_current_state() and comparing it using '==' then
the comparison could fail due to unordered ports. In order to solve
this, _get_bridge_current_state() is ordering the ports.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
This commit is contained in:
Fernando Fernandez Mancera 2020-03-24 12:12:19 +01:00 committed by Edward Haas
parent f1ed2a7243
commit 282f987152

View File

@ -154,7 +154,12 @@ def _modify_ports(ports_state):
@nmclient_context
def _get_bridge_current_state():
nmdev = nm.device.get_device_by_name(BRIDGE0)
return nm.bridge.get_info(nmdev) if nmdev else {}
state = nm.bridge.get_info(nmdev) if nmdev else {}
if state:
slaves = state.get(LB.CONFIG_SUBTREE, {}).get(LB.PORT_SUBTREE, [])
slaves.sort(key=lambda d: d[LB.Port.NAME])
return state
@mainloop_run