From d8952e2a6964f9d768ad19d07dca32d82468ad59 Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Sat, 23 Jul 2016 22:36:37 -0700 Subject: [PATCH] Add API tests for router and DHCP port status Add API tests that ensure DHCP ports and router interface ports become active. Router gateway ports were excluded because deployments using 'external_network_bridge = br-ex' will always have their external interface in the DOWN state. Related-Bug: #1590845 Related-Bug: #1605955 Change-Id: I843f9217a3c401e8221c9dd42cbd4ea55dcd7a81 --- .../tempest/api/admin/test_dhcp_agent_scheduler.py | 14 ++++++++++++++ neutron/tests/tempest/api/test_routers.py | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/neutron/tests/tempest/api/admin/test_dhcp_agent_scheduler.py b/neutron/tests/tempest/api/admin/test_dhcp_agent_scheduler.py index d058ffdd8da..5576e0dc55c 100644 --- a/neutron/tests/tempest/api/admin/test_dhcp_agent_scheduler.py +++ b/neutron/tests/tempest/api/admin/test_dhcp_agent_scheduler.py @@ -12,8 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import constants from tempest import test +from neutron.common import utils from neutron.tests.tempest.api import base @@ -30,6 +32,18 @@ class DHCPAgentSchedulersTestJSON(base.BaseAdminNetworkTest): cls.cidr = cls.subnet['cidr'] cls.port = cls.create_port(cls.network) + @test.idempotent_id('f164801e-1dd8-4b8b-b5d3-cc3ac77cfaa5') + def test_dhcp_port_status_active(self): + + def dhcp_port_active(): + for p in self.client.list_ports( + network_id=self.network['id'])['ports']: + if (p['device_owner'] == constants.DEVICE_OWNER_DHCP and + p['status'] == constants.PORT_STATUS_ACTIVE): + return True + return False + utils.wait_until_true(dhcp_port_active) + @test.idempotent_id('5032b1fe-eb42-4a64-8f3b-6e189d8b5c7d') def test_list_dhcp_agent_hosting_network(self): self.admin_client.list_dhcp_agent_hosting_network( diff --git a/neutron/tests/tempest/api/test_routers.py b/neutron/tests/tempest/api/test_routers.py index d0a38aad62a..7d08edd3319 100644 --- a/neutron/tests/tempest/api/test_routers.py +++ b/neutron/tests/tempest/api/test_routers.py @@ -18,6 +18,7 @@ import six from tempest.lib.common.utils import data_utils from tempest import test +from neutron.common import utils from neutron.tests.tempest.api import base from neutron.tests.tempest.api import base_routers from neutron.tests.tempest import config @@ -153,6 +154,17 @@ class RoutersTest(base_routers.BaseRouterTest): 'enable_snat': False}) self._verify_gateway_port(router['id']) + @test.idempotent_id('db3093b1-93b6-4893-be83-c4716c251b3e') + def test_router_interface_status(self): + network = self.create_network() + subnet = self.create_subnet(network) + # Add router interface with subnet id + router = self._create_router(data_utils.rand_name('router-'), True) + intf = self.create_router_interface(router['id'], subnet['id']) + status_active = lambda: self.client.show_port( + intf['port_id'])['port']['status'] == 'ACTIVE' + utils.wait_until_true(status_active) + @test.idempotent_id('c86ac3a8-50bd-4b00-a6b8-62af84a0765c') @test.requires_ext(extension='extraroute', service='network') def test_update_extra_route(self):