aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/tests/test_impl_eni.py
diff options
context:
space:
mode:
authorFeng Pan <fpan@redhat.com>2017-07-17 16:25:25 -0400
committerFeng Pan <fpan@redhat.com>2017-07-24 16:15:47 -0400
commit9ecc15f0edf2460c2eb2cac8e9ccca8cbb8d3808 (patch)
tree665bb067f795505f77d0d1eba98204e02dd11dec /os_net_config/tests/test_impl_eni.py
parent02da9fd51b454b1954b04a462cb05a14598fa172 (diff)
Merge Newton private changes
- Add interface mapping data to hiera - Add support for VPP interfaces - Continue bringing up interfaces even if one fails - Change hiera to json format List of commits: https://github.com/openstack/os-net-config/compare/stable/newton...trozet:stable/danube Change-Id: If7a2c6119bf613f1fc8846237b077cd8f0e26015 Signed-off-by: Feng Pan <fpan@redhat.com>
Diffstat (limited to 'os_net_config/tests/test_impl_eni.py')
-rw-r--r--os_net_config/tests/test_impl_eni.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/os_net_config/tests/test_impl_eni.py b/os_net_config/tests/test_impl_eni.py
index 4911cb9..51354f8 100644
--- a/os_net_config/tests/test_impl_eni.py
+++ b/os_net_config/tests/test_impl_eni.py
@@ -18,6 +18,7 @@ import tempfile
from oslo_concurrency import processutils
+import os_net_config
from os_net_config import impl_eni
from os_net_config import objects
from os_net_config.tests import base
@@ -360,3 +361,33 @@ class TestENINetConfigApply(base.TestCase):
self.assertEqual((_OVS_BRIDGE_DHCP + _OVS_PORT_IFACE), iface_data)
self.assertIn('eth0', self.ifup_interface_names)
self.assertIn('br0', self.ifup_interface_names)
+
+ def _failed_execute(*args, **kwargs):
+ if kwargs.get('check_exit_code', True):
+ raise processutils.ProcessExecutionError('Test stderr',
+ 'Test stdout',
+ str(kwargs))
+
+ def test_interface_failure(self):
+ self.stubs.Set(processutils, 'execute', self._failed_execute)
+ v4_addr = objects.Address('192.168.1.2/24')
+ interface = objects.Interface('em1', addresses=[v4_addr])
+ self.provider.add_interface(interface)
+
+ self.assertRaises(os_net_config.ConfigurationError,
+ self.provider.apply)
+ self.assertEqual(1, len(self.provider.errors))
+
+ def test_interface_failure_multiple(self):
+ self.stubs.Set(processutils, 'execute', self._failed_execute)
+ v4_addr = objects.Address('192.168.1.2/24')
+ interface = objects.Interface('em1', addresses=[v4_addr])
+ v4_addr2 = objects.Address('192.168.2.2/24')
+ interface2 = objects.Interface('em2', addresses=[v4_addr2])
+ self.provider.add_interface(interface)
+ self.provider.add_interface(interface2)
+
+ self.assertRaises(os_net_config.ConfigurationError,
+ self.provider.apply)
+ # Even though the first one failed, we should have attempted both
+ self.assertEqual(2, len(self.provider.errors))