Petr Horáček has uploaded a new change for review. Change subject: net tests: keep connectivity ......................................................................
net tests: keep connectivity Change-Id: If0372344c4f4d4af194217ba41ff718c923c5716 Signed-off-by: Petr Horáček <phora...@redhat.com> --- A tests/network/func_keep_connectivity_test.py 1 file changed, 132 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/83/63683/1 diff --git a/tests/network/func_keep_connectivity_test.py b/tests/network/func_keep_connectivity_test.py new file mode 100644 index 0000000..93cc4cd --- /dev/null +++ b/tests/network/func_keep_connectivity_test.py @@ -0,0 +1,132 @@ +# Copyright 2016 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# +from __future__ import absolute_import + +from contextlib import contextmanager + +from nose.plugins.attrib import attr + +from vdsm.network.netinfo.nics import OPERSTATE_DOWN +from vdsm.network.netlink import monitor + +from .netfunctestlib import NetFuncTestCase, NOCHK +from .nettestlib import dummy_device, dummy_devices + +NETWORK1_NAME = 'test-network1' +NETWORK2_NAME = 'test-network2' +VLAN1 = 10 +VLAN2 = 20 +MTU0 = 1500 +MTU1 = 1000 +BOND_NAME = 'bond1' + + +class ConnectivityLostError(Exception): + pass + + +@attr(type='functional') +class KeepNicUpTemplate(NetFuncTestCase): + __test__ = False + + def test_set_lower_network_mtu(self): + with dummy_device() as nic: + NETSETUP = {NETWORK1_NAME: { + 'nic': nic, 'mtu': MTU0, 'switch': self.switch}} + with self.setupNetworks(NETSETUP, {}, NOCHK): + NETSETUP[NETWORK1_NAME]['mtu'] = MTU1 + with _operstate_not_set_down(nic): + self.setupNetworks(NETSETUP, {}, NOCHK) + + def test_add_another_vlan_network(self): + with dummy_device() as nic: + NETSETUP1 = {NETWORK1_NAME: { + 'nic': nic, 'vlan': VLAN1, 'switch': self.switch}} + NETSETUP2 = {NETWORK2_NAME: { + 'nic': nic, 'vlan': VLAN2, 'switch': self.switch}} + with self.setupNetworks(NETSETUP1, {}, NOCHK): + with _operstate_not_set_down(nic): + with self.setupNetworks(NETSETUP2, {}, NOCHK): + pass + + +@attr(type='functional', switch='legacy') +class KeepNicUpLegacyTest(KeepNicUpTemplate): + __test__ = True + switch = 'legacy' + + +@attr(type='functional', switch='ovs') +class KeepNicUpOvsTest(KeepNicUpTemplate): + __test__ = False # TODO: OVS configurator does not support this yet + switch = 'ovs' + + +@attr(type='functional') +class KeepBondUpTemplate(NetFuncTestCase): + __test__ = False + + def test_set_lower_network_mtu(self): + with dummy_devices(2) as (nic1, nic2): + NETSETUP = {NETWORK1_NAME: { + 'bonding': BOND_NAME, 'mtu': MTU0, 'switch': self.switch}} + BONDSETUP = { + BOND_NAME: {'nics': [nic1, nic2], 'switch': self.switch}} + with self.setupNetworks(NETSETUP, BONDSETUP, NOCHK): + NETSETUP[NETWORK1_NAME]['mtu'] = MTU1 + with _operstate_not_set_down(BOND_NAME): + self.setupNetworks(NETSETUP, {}, NOCHK) + + def test_add_another_vlan_network(self): + with dummy_devices(2) as (nic1, nic2): + NETSETUP1 = {NETWORK1_NAME: { + 'bonding': BOND_NAME, 'vlan': VLAN1, 'switch': self.switch}} + NETSETUP2 = {NETWORK2_NAME: { + 'bonding': BOND_NAME, 'vlan': VLAN2, 'switch': self.switch}} + BONDSETUP = { + BOND_NAME: {'nics': [nic1, nic2], 'switch': self.switch}} + with self.setupNetworks(NETSETUP1, BONDSETUP, NOCHK): + with _operstate_not_set_down(BOND_NAME): + with self.setupNetworks(NETSETUP2, {}, NOCHK): + pass + + +@attr(type='functional', switch='legacy') +class KeepBondUpLegacyTest(KeepBondUpTemplate): + __test__ = True + switch = 'legacy' + + +@attr(type='functional', switch='ovs') +class KeepBondUpOvsTest(KeepBondUpTemplate): + __test__ = False # TODO: OVS configurator does not support this yet + switch = 'ovs' + + +@contextmanager +def _operstate_not_set_down(iface_name): + try: + with monitor.Monitor(groups=('link',)) as mon: + yield + finally: + changes = ((event['name'], event['state']) for event in mon + if event['name'] == iface_name) + for _, state in changes: + if state == OPERSTATE_DOWN: + raise ConnectivityLostError('Iface was set DOWN.') -- To view, visit https://gerrit.ovirt.org/63683 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If0372344c4f4d4af194217ba41ff718c923c5716 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr Horáček <phora...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org