Skip to content

Commit

Permalink
network: test stp bridge options with nmstate
Browse files Browse the repository at this point in the history
Test that nmstate correctly applies STP bridge options passed during
setup networks.
It is not possible to set the STP state to 'off' and at the same time
pass non-default values for the other STP attributes (max-age,
hello-time, forward-delay).

Change-Id: Ie904f9943d9cb8a99718f85ab7c8c9a264b97a39
Bug-Url: https://bugzilla.redhat.com/2108974
Signed-off-by: Eitan Raviv <[email protected]>
  • Loading branch information
erav committed Aug 10, 2022
1 parent c6adffb commit 632e649
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions tests/network/functional/bridge_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,59 @@ def hidden_nic():


class TestBridge(object):
DEFAULT_STP_OPTS = (
'forward_delay=1500 hello_time=200 max_age=2000 priority=32768'
)
NON_DEFAULT_STP_OPTS = (
'forward_delay=1600 hello_time=300 max_age=3000 priority=1'
)

@nftestlib.parametrize_switch
def test_add_bridge_with_stp(self, adapter, switch, nic0):
@pytest.mark.parametrize(argnames='stp_state', argvalues=[True, False])
def test_add_bridge_with_stp(self, adapter, switch, nic0, stp_state):
if switch == 'ovs':
pytest.xfail('stp is currently not implemented for ovs')

NETCREATE = {
NETWORK_NAME: {'nic': nic0, 'switch': switch, 'stp': True}
NETWORK_NAME: {'nic': nic0, 'switch': switch, 'stp': stp_state}
}
with adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK):
adapter.assertNetworkExists(NETWORK_NAME)
adapter.assertNetworkBridged(NETWORK_NAME)
adapter.assertBridgeOpts(NETWORK_NAME, NETCREATE[NETWORK_NAME])

@pytest.mark.parametrize(
argnames='stp_opts',
argvalues=[
{'stp': False, 'opts': DEFAULT_STP_OPTS},
{'stp': True, 'opts': DEFAULT_STP_OPTS},
{'stp': True, 'opts': NON_DEFAULT_STP_OPTS},
],
)
@nftestlib.parametrize_legacy_switch
def test_add_bridge_stp_with_opts(self, adapter, switch, nic0, stp_opts):
net_attrs = self._net_attrs_with_bridge_opts(
switch, nic0, stp_opts['opts']
)
net_attrs['stp'] = stp_opts['stp']
NETCREATE = {NETWORK_NAME: net_attrs}
with adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK):
adapter.assertBridgeOpts(NETWORK_NAME, net_attrs)

@nftestlib.parametrize_legacy_switch
def test_add_bridge_with_custom_opts(self, adapter, switch, nic0):
NET_ATTRS = {
opts = 'multicast_snooping=0 multicast_router=0'
net_attrs = self._net_attrs_with_bridge_opts(switch, nic0, opts)
NETCREATE = {NETWORK_NAME: net_attrs}
with adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK):
adapter.assertBridgeOpts(NETWORK_NAME, net_attrs)

def _net_attrs_with_bridge_opts(self, switch, nic0, bridge_opts):
return {
'nic': nic0,
'switch': switch,
'custom': {
'bridge_opts': 'multicast_snooping=0 multicast_router=0'
},
'custom': {'bridge_opts': bridge_opts},
}
NETCREATE = {NETWORK_NAME: NET_ATTRS}
with adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK):
adapter.assertBridgeOpts(NETWORK_NAME, NET_ATTRS)

@pytest.mark.xfail(
reason='Unstable on oVirt CI',
Expand Down

0 comments on commit 632e649

Please sign in to comment.