mock_get_pm.assert_called_with(False, 'sudo')
mock_loop.called_once()
+ def test_setup_tunnel_port_error_negative(self):
+ with contextlib.nested(
+ mock.patch.object(self.agent.tun_br, 'add_tunnel_port',
+ return_value='-1'),
+ mock.patch.object(ovs_neutron_agent.LOG, 'error')
+ ) as (add_tunnel_port_fn, log_error_fn):
+ ofport = self.agent.setup_tunnel_port(
+ 'gre-1', 'remote_ip', constants.TYPE_GRE)
+ add_tunnel_port_fn.assert_called_once_with(
+ 'gre-1', 'remote_ip', self.agent.local_ip, constants.TYPE_GRE,
+ self.agent.vxlan_udp_port)
+ log_error_fn.assert_called_once_with(
+ _("Failed to set-up %(type)s tunnel port to %(ip)s"),
+ {'type': constants.TYPE_GRE, 'ip': 'remote_ip'})
+ self.assertEqual(ofport, 0)
+
+ def test_setup_tunnel_port_error_not_int(self):
+ with contextlib.nested(
+ mock.patch.object(self.agent.tun_br, 'add_tunnel_port',
+ return_value=None),
+ mock.patch.object(ovs_neutron_agent.LOG, 'exception'),
+ mock.patch.object(ovs_neutron_agent.LOG, 'error')
+ ) as (add_tunnel_port_fn, log_exc_fn, log_error_fn):
+ ofport = self.agent.setup_tunnel_port(
+ 'gre-1', 'remote_ip', constants.TYPE_GRE)
+ add_tunnel_port_fn.assert_called_once_with(
+ 'gre-1', 'remote_ip', self.agent.local_ip, constants.TYPE_GRE,
+ self.agent.vxlan_udp_port)
+ log_exc_fn.assert_called_once_with(
+ _("ofport should have a value that can be "
+ "interpreted as an integer"))
+ log_error_fn.assert_called_once_with(
+ _("Failed to set-up %(type)s tunnel port to %(ip)s"),
+ {'type': constants.TYPE_GRE, 'ip': 'remote_ip'})
+ self.assertEqual(ofport, 0)
+
class AncillaryBridgesTest(base.BaseTestCase):