From 01f5a1c7b74e6051524ba424fbfe4039f4f6c477 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Wed, 26 Sep 2018 11:15:05 +0300 Subject: [PATCH] Adjust router notification test Commit I01ced41201b61c624e675375b7bcd9589b2553e0 added a unit test which needs to be adjusted to the vmware-nsx plugins, mainly becasue the plugins do not support changing the external network flag. Change-Id: Ibbadb81c658bf81165899e35ba55204485ab86b8 --- vmware_nsx/tests/unit/nsx_v/test_plugin.py | 17 +++++++++++++++++ vmware_nsx/tests/unit/nsx_v3/test_plugin.py | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/vmware_nsx/tests/unit/nsx_v/test_plugin.py b/vmware_nsx/tests/unit/nsx_v/test_plugin.py index 7124f4d410..6ff7239479 100644 --- a/vmware_nsx/tests/unit/nsx_v/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v/test_plugin.py @@ -46,6 +46,9 @@ from neutron_lib.api.definitions import portbindings from neutron_lib.api.definitions import provider_net as pnet from neutron_lib.api.definitions import router_availability_zone as raz_apidef from neutron_lib.api import validators +from neutron_lib.callbacks import events +from neutron_lib.callbacks import registry +from neutron_lib.callbacks import resources from neutron_lib import constants from neutron_lib import context from neutron_lib import exceptions as n_exc @@ -2814,6 +2817,20 @@ class L3NatTestCaseBase(test_l3_plugin.L3NatTestCaseMixin): self.assertFalse(is_dhcp_meta) self.new_delete_request('ports', port_req['port']['id']) + def test_router_add_gateway_notifications(self): + with self.router() as r,\ + self._create_l3_ext_network() as ext_net,\ + self.subnet(network=ext_net): + with mock.patch.object(registry, 'notify') as notify: + self._add_external_gateway_to_router( + r['router']['id'], ext_net['network']['id']) + expected = [mock.call( + resources.ROUTER_GATEWAY, + events.AFTER_CREATE, mock.ANY, + context=mock.ANY, gw_ips=mock.ANY, + network_id=mock.ANY, router_id=mock.ANY)] + notify.assert_has_calls(expected) + def test_router_delete_ipv6_slaac_subnet_inuse_returns_409(self): self.skipTest('No DHCP v6 Support yet') diff --git a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py index 184a8cdab1..e6b709bf4b 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py @@ -42,7 +42,10 @@ from neutron_lib.api.definitions import port_security as psec from neutron_lib.api.definitions import portbindings from neutron_lib.api.definitions import provider_net as pnet from neutron_lib.api.definitions import vlantransparent as vlan_apidef +from neutron_lib.callbacks import events from neutron_lib.callbacks import exceptions as nc_exc +from neutron_lib.callbacks import registry +from neutron_lib.callbacks import resources from neutron_lib import constants from neutron_lib import context from neutron_lib import exceptions as n_exc @@ -2216,6 +2219,20 @@ class TestL3NatTestCase(L3NatTest, super(TestL3NatTestCase, self).test_floatingip_update_different_router() + def test_router_add_gateway_notifications(self): + with self.router() as r,\ + self._create_l3_ext_network() as ext_net,\ + self.subnet(network=ext_net): + with mock.patch.object(registry, 'notify') as notify: + self._add_external_gateway_to_router( + r['router']['id'], ext_net['network']['id']) + expected = [mock.call( + resources.ROUTER_GATEWAY, + events.AFTER_CREATE, mock.ANY, + context=mock.ANY, gw_ips=mock.ANY, + network_id=mock.ANY, router_id=mock.ANY)] + notify.assert_has_calls(expected) + def test_create_l3_ext_network_with_default_tier0(self): self._test_create_l3_ext_network()