Change in vdsm[master]: net: tests: test setupNetworks instead of addNetwork
phoracek at redhat.com
phoracek at redhat.com
Fri Feb 12 12:14:10 UTC 2016
Petr Horáček has uploaded a new change for review.
Change subject: net: tests: test setupNetworks instead of addNetwork
......................................................................
net: tests: test setupNetworks instead of addNetwork
We want to simplify addNetwork function and remove its archaic
parameters for bonding setup which is not a part of API anymore.
With this patch, we use setupNetworks() instead of _addNetwork().
Change-Id: I1e117f9c4233111a0300e487afd06fb858c4ac02
Signed-off-by: Petr Horáček <phoracek at redhat.com>
---
M lib/vdsm/netconfpersistence.py
M tests/configNetworkTests.py
2 files changed, 45 insertions(+), 41 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/53471/1
diff --git a/lib/vdsm/netconfpersistence.py b/lib/vdsm/netconfpersistence.py
index 9099699..99b254d 100644
--- a/lib/vdsm/netconfpersistence.py
+++ b/lib/vdsm/netconfpersistence.py
@@ -49,7 +49,7 @@
cleanAttrs = dict((key, value) for key, value in attributes.iteritems()
if value is not None and key not in
('configurator', '_netinfo', 'force',
- 'bondingOptions', 'implicitBonding'))
+ 'implicitBonding'))
self.networks[network] = cleanAttrs
logging.info('Adding network %s(%s)', network, cleanAttrs)
diff --git a/tests/configNetworkTests.py b/tests/configNetworkTests.py
index 646efe2..f0a20a9 100644
--- a/tests/configNetworkTests.py
+++ b/tests/configNetworkTests.py
@@ -30,7 +30,6 @@
from vdsm.network import api
from vdsm.network import errors
from vdsm.network.configurators import ifcfg
-from vdsm.network.canonize import canonize_networks
from vdsm.network.models import Bond, Bridge, Nic, Vlan
@@ -44,12 +43,47 @@
'testing.')
+def _fakeNetinfo():
+ _netinfo = {
+ 'networks': {
+ 'fakent': {'iface': 'fakeint', 'bridged': False},
+ 'fakebrnet': {'iface': 'fakebr', 'bridged': True,
+ 'ports': ['eth0', 'eth1']},
+ 'fakebrnet1': {'iface': 'fakebr1', 'bridged': True,
+ 'ports': ['bond00']},
+ 'fakebrnet2': {'iface': 'fakebr2', 'bridged': True,
+ 'ports': ['eth7.1']},
+ 'fakebrnet3': {'iface': 'eth8', 'bridged': False}
+ },
+ 'vlans': {
+ 'eth3.2': {'iface': 'eth3',
+ 'addr': '10.10.10.10',
+ 'netmask': '255.255.0.0',
+ 'mtu': 1500
+ },
+ 'eth7.1': {'iface': 'eth7',
+ 'addr': '192.168.100.1',
+ 'netmask': '255.255.255.0',
+ 'mtu': 1500
+ }
+ },
+ 'nics': ['eth0', 'eth1', 'eth2', 'eth3', 'eth4', 'eth5', 'eth6', 'eth7',
+ 'eth8', 'eth9', 'eth10'],
+ 'bridges': {
+ 'fakebr': {'ports': ['eth0', 'eth1']},
+ 'fakebr1': {'ports': ['bond00']},
+ 'fakebr2': {'ports': ['eth7.1']}
+ },
+ 'bondings': {'bond00': {'slaves': ['eth5', 'eth6']}}
+ }
+ return netinfo.cache.CachingNetInfo(_netinfo)
+
+
class TestConfigNetwork(TestCaseBase):
- def _addNetworkWithExc(self, netName, opts, errCode):
+ def _setupNetworksWithExc(self, nets, bonds, errCode):
with self.assertRaises(errors.ConfigNetworkError) as cneContext:
- canonize_networks({netName: opts})
- api._addNetwork(netName, **opts)
+ api.setupNetworks(nets, bonds, {'connectivityCheck': False})
self.assertEqual(cneContext.exception.errCode, errCode)
# Monkey patch the real network detection from the netinfo module.
@@ -62,46 +96,16 @@
@MonkeyPatch(Bridge, 'configure', lambda *x: _raiseInvalidOpException())
@MonkeyPatch(Nic, 'configure', lambda *x: _raiseInvalidOpException())
@MonkeyPatch(Vlan, 'configure', lambda *x: _raiseInvalidOpException())
+ @MonkeyPatch(netinfo.cache, 'CachingNetInfo', lambda *x: _fakeNetinfo)
def testAddNetworkValidation(self):
- _netinfo = {
- 'networks': {
- 'fakent': {'iface': 'fakeint', 'bridged': False},
- 'fakebrnet': {'iface': 'fakebr', 'bridged': True,
- 'ports': ['eth0', 'eth1']},
- 'fakebrnet1': {'iface': 'fakebr1', 'bridged': True,
- 'ports': ['bond00']},
- 'fakebrnet2': {'iface': 'fakebr2', 'bridged': True,
- 'ports': ['eth7.1']},
- 'fakebrnet3': {'iface': 'eth8', 'bridged': False}
- },
- 'vlans': {
- 'eth3.2': {'iface': 'eth3',
- 'addr': '10.10.10.10',
- 'netmask': '255.255.0.0',
- 'mtu': 1500
- },
- 'eth7.1': {'iface': 'eth7',
- 'addr': '192.168.100.1',
- 'netmask': '255.255.255.0',
- 'mtu': 1500
- }
- },
- 'nics': ['eth0', 'eth1', 'eth2', 'eth3', 'eth4', 'eth5', 'eth6',
- 'eth7', 'eth8', 'eth9', 'eth10'],
- 'bridges': {
- 'fakebr': {'ports': ['eth0', 'eth1']},
- 'fakebr1': {'ports': ['bond00']},
- 'fakebr2': {'ports': ['eth7.1']}
- },
- 'bondings': {'bond00': {'slaves': ['eth5', 'eth6']}}
- }
-
- fakeInfo = netinfo.cache.CachingNetInfo(_netinfo)
nics = ['eth2']
+ # TODO: mozna bude potreba drzet fake netinfo zmenene
+
# Test for already existing bridge.
- self._addNetworkWithExc('fakebrnet', dict(nics=nics, mtu=DEFAULT_MTU,
- _netinfo=fakeInfo), errors.ERR_USED_BRIDGE)
+ self._setupNetworksWithExc(
+ {'fakebrnet': {'nics': nics, 'mtu': DEFAULT_MTU}}, {},
+ errors.ERR_USED_BRIDGE)
# Test for already existing network.
self._addNetworkWithExc('fakent', dict(nics=nics, _netinfo=fakeInfo,
--
To view, visit https://gerrit.ovirt.org/53471
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1e117f9c4233111a0300e487afd06fb858c4ac02
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek at redhat.com>
More information about the vdsm-patches
mailing list