def test_add_bridge_with_stp(self, switch): if switch == 'ovs': pytest.xfail('stp is currently not implemented for ovs') if switch == 'legacy' and running_on_fedora(29): pytest.xfail('Fails on Fedora 29') with dummy_devices(1) as (nic, ): NETCREATE = { NETWORK_NAME: { 'nic': nic, 'switch': switch, 'stp': True } } with adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK): adapter.assertNetworkExists(NETWORK_NAME) adapter.assertNetworkBridged(NETWORK_NAME) adapter.assertBridgeOpts(NETWORK_NAME, NETCREATE[NETWORK_NAME])
def test_add_net_with_dhcp(self, switch, families, bridged, def_route): if switch == 'legacy' and running_on_fedora(29): pytest.xfail('Fails on Fedora 29') if switch == 'ovs' and IpFamily.IPv6 in families: pytest.xfail('IPv6 dynamic fails with OvS' 'see https://bugzilla.redhat.com/1773471') if families == (IpFamily.IPv6, ) and def_route: pytest.skip('Skipping default route + dynamic with IPv6 ' 'see https://bugzilla.redhat.com/1467332') with veth_pair() as (server, client): addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN) addrAdd(server, IPv6_ADDRESS, IPv6_CIDR, IpFamily.IPv6) linkSet(server, ['up']) linkSet(client, ['up']) with dnsmasq_run( server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO, DHCPv6_RANGE_FROM, DHCPv6_RANGE_TO, router=DHCPv4_GATEWAY, ): network_attrs = { 'bridged': bridged, 'nic': client, 'blockingdhcp': True, 'switch': switch, 'defaultRoute': def_route, } if IpFamily.IPv4 in families: network_attrs['bootproto'] = 'dhcp' if IpFamily.IPv6 in families: network_attrs['dhcpv6'] = True netcreate = {NETWORK_NAME: network_attrs} with adapter.setupNetworks(netcreate, {}, NOCHK): adapter.assertNetworkIp(NETWORK_NAME, netcreate[NETWORK_NAME])
def test_switch_change_bonded_network_with_dhclient(self, sw_src, sw_dst): if sw_src == 'ovs' and sw_dst == 'legacy' and running_on_fedora(29): pytest.xfail('Fails on Fedora 29') with veth_pair() as (server, nic1): with dummy_device() as nic2: NETSETUP_SOURCE = { NET1_NAME: { 'bonding': BOND_NAME, 'bootproto': 'dhcp', 'blockingdhcp': True, 'switch': sw_src, } } NETSETUP_TARGET = _change_switch_type(NETSETUP_SOURCE, sw_dst) BONDSETUP_SOURCE = { BOND_NAME: { 'nics': [nic1, nic2], 'switch': sw_src } } BONDSETUP_TARGET = _change_switch_type(BONDSETUP_SOURCE, sw_dst) addrAdd(server, IPv4_ADDRESS, IPv4_PREFIX_LEN) linkSet(server, ['up']) with dnsmasq_run( server, DHCPv4_RANGE_FROM, DHCPv4_RANGE_TO, router=IPv4_ADDRESS, ): with adapter.setupNetworks(NETSETUP_SOURCE, BONDSETUP_SOURCE, NOCHK): adapter.setupNetworks(NETSETUP_TARGET, BONDSETUP_TARGET, NOCHK) adapter.assertNetwork(NET1_NAME, NETSETUP_TARGET[NET1_NAME]) adapter.assertBond(BOND_NAME, BONDSETUP_TARGET[BOND_NAME])
VLAN2 = 20 BOND_NAME = 'bond1' _100USEC = 100 * 1000 adapter = None @pytest.fixture(scope='module', autouse=True) def create_adapter(target): global adapter adapter = NetFuncTestAdapter(target) # TODO: When QoS will be available on OVS, enable the tests. @pytest.mark.xfail( condition=running_on_fedora(29), reason='Failing on legacy switch, fedora 29', strict=True, ) @nftestlib.parametrize_legacy_switch class TestNetworkHostQos(object): @nftestlib.parametrize_bridged @nftestlib.parametrize_bonded def test_add_vlan_network_with_qos(self, switch, bridged, bonded): HOST_QOS_CONFIG = { 'out': { 'ls': { 'm1': rate(rate_in_mbps=4), 'd': _100USEC, 'm2': rate(rate_in_mbps=3), },
class TestBridge(object): @pytest.mark.nmstate @nftestlib.parametrize_switch def test_add_bridge_with_stp(self, switch): if switch == 'ovs': pytest.xfail('stp is currently not implemented for ovs') if switch == 'legacy' and running_on_fedora(29): pytest.xfail('Fails on Fedora 29') with dummy_devices(1) as (nic, ): NETCREATE = { NETWORK_NAME: { 'nic': nic, 'switch': switch, 'stp': True } } with adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK): adapter.assertNetworkExists(NETWORK_NAME) adapter.assertNetworkBridged(NETWORK_NAME) adapter.assertBridgeOpts(NETWORK_NAME, NETCREATE[NETWORK_NAME]) @nftestlib.parametrize_legacy_switch def test_add_bridge_with_custom_opts(self, switch): with dummy_devices(1) as (nic, ): NET_ATTRS = { 'nic': nic, 'switch': switch, 'custom': { 'bridge_opts': 'multicast_snooping=0 multicast_router=0' }, } NETCREATE = {NETWORK_NAME: NET_ATTRS} with adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK): adapter.assertBridgeOpts(NETWORK_NAME, NET_ATTRS) @pytest.mark.nmstate @nftestlib.parametrize_legacy_switch def test_create_network_over_an_existing_unowned_bridge(self, switch): with _create_linux_bridge(NETWORK_NAME) as brname: with dummy_devices(1) as (nic, ): NETCREATE = { brname: { 'bridged': True, 'nic': nic, 'switch': switch } } with adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK): adapter.assertNetwork(brname, NETCREATE[brname]) @pytest.mark.skip(reason='Unstable link while NM is running (BZ#1498022) ' 'and on CI even with NM down') @nftestlib.parametrize_legacy_switch def test_create_network_and_reuse_existing_owned_bridge(self, switch): with dummy_devices(2) as (nic1, nic2): NETSETUP1 = {NETWORK_NAME: {'nic': nic1, 'switch': switch}} NETSETUP2 = {NETWORK_NAME: {'nic': nic2, 'switch': switch}} with adapter.setupNetworks(NETSETUP1, {}, nftestlib.NOCHK): with _create_tap() as tapdev: _attach_dev_to_bridge(tapdev, NETWORK_NAME) with nftestlib.monitor_stable_link_state(NETWORK_NAME): adapter.setupNetworks(NETSETUP2, {}, nftestlib.NOCHK) adapter.assertNetwork(NETWORK_NAME, NETSETUP2[NETWORK_NAME]) @pytest.mark.nmstate @nftestlib.parametrize_legacy_switch @pytest.mark.xfail( condition=running_on_fedora(29), reason='Failing on legacy switch, fedora 29', strict=True, ) def test_reconfigure_bridge_with_vanished_port(self, switch): with dummy_device() as nic1: NETCREATE = { NETWORK_NAME: { 'nic': nic1, 'bridged': True, 'switch': switch } } with adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK): with dummy_device() as nic2: NETCREATE[NETWORK_NAME]['nic'] = nic2 adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK) adapter.refresh_netinfo() assert adapter.netinfo.networks[NETWORK_NAME]['ports'] == [] NETCREATE[NETWORK_NAME]['nic'] = nic1 adapter.setupNetworks(NETCREATE, {}, nftestlib.NOCHK) net_ports = adapter.netinfo.networks[NETWORK_NAME]['ports'] assert net_ports == [nic1]
VLAN1 = 10 VLAN2 = 20 _100USEC = 100 * 1000 adapter = None @pytest.fixture(scope='module', autouse=True) def create_adapter(target): global adapter adapter = NetFuncTestAdapter(target) # TODO: When QoS will be available on OVS, enable the tests. @pytest.mark.parametrize('switch', [pytest.mark.legacy_switch('legacy')]) @pytest.mark.xfail(running_on_fedora(), reason='BZ#1645113', strict=True) class TestNetworkHostQos(object): def test_add_vlan_network_with_qos(self, switch): HOST_QOS_CONFIG = { 'out': { 'ls': { 'm1': rate(rate_in_mbps=4), 'd': _100USEC, 'm2': rate(rate_in_mbps=3) }, 'ul': { 'm2': rate(rate_in_mbps=8) } } } with dummy_device() as nic:
VLAN1 = 10 VLAN2 = 20 _100USEC = 100 * 1000 adapter = None @pytest.fixture(scope='module', autouse=True) def create_adapter(target): global adapter adapter = NetFuncTestAdapter(target) # TODO: When QoS will be available on OVS, enable the tests. @pytest.mark.parametrize('switch', [pytest.mark.legacy_switch('legacy')]) @pytest.mark.xfail(running_on_fedora(), reason='BZ#1645113', strict=True) class TestNetworkHostQos(object): def test_add_vlan_network_with_qos(self, switch): HOST_QOS_CONFIG = {'out': {'ls': {'m1': rate(rate_in_mbps=4), 'd': _100USEC, 'm2': rate(rate_in_mbps=3)}, 'ul': {'m2': rate(rate_in_mbps=8)}}} with dummy_device() as nic: NETCREATE = {NETWORK1_NAME: {'nic': nic, 'vlan': VLAN1, 'hostQos': HOST_QOS_CONFIG, 'switch': switch}} with adapter.setupNetworks(NETCREATE, {}, NOCHK): adapter.assertHostQos(NETWORK1_NAME, NETCREATE[NETWORK1_NAME])