Merge "test_metadata_routed: save console log"
diff --git a/neutron_tempest_plugin/api/clients.py b/neutron_tempest_plugin/api/clients.py
index 407e694..8f5256e 100644
--- a/neutron_tempest_plugin/api/clients.py
+++ b/neutron_tempest_plugin/api/clients.py
@@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+from tempest import clients as tempest_clients
+from tempest.lib.services import clients
from tempest.lib.services.compute import availability_zone_client
from tempest.lib.services.compute import hypervisor_client
from tempest.lib.services.compute import interfaces_client
@@ -20,7 +22,6 @@
from tempest.lib.services.compute import servers_client
from tempest.lib.services.identity.v2 import tenants_client
from tempest.lib.services.identity.v3 import projects_client
-from tempest import manager
from neutron_tempest_plugin import config
from neutron_tempest_plugin.services.network.json import network_client
@@ -28,7 +29,7 @@
CONF = config.CONF
-class Manager(manager.Manager):
+class Manager(clients.ServiceClients):
"""Top level manager for OpenStack tempest clients"""
default_params = {
'disable_ssl_certificate_validation':
@@ -47,7 +48,15 @@
default_params_with_timeout_values.update(default_params)
def __init__(self, credentials=None, service=None):
- super(Manager, self).__init__(credentials=credentials)
+ dscv = CONF.identity.disable_ssl_certificate_validation
+ _, uri = tempest_clients.get_auth_provider_class(credentials)
+ super(Manager, self).__init__(
+ credentials=credentials,
+ identity_uri=uri,
+ scope='project',
+ disable_ssl_certificate_validation=dscv,
+ ca_certs=CONF.identity.ca_certificates_file,
+ trace_requests=CONF.debug.trace_requests)
self._set_identity_clients()
diff --git a/neutron_tempest_plugin/api/test_routers.py b/neutron_tempest_plugin/api/test_routers.py
index d866dbc..5e916f5 100644
--- a/neutron_tempest_plugin/api/test_routers.py
+++ b/neutron_tempest_plugin/api/test_routers.py
@@ -15,9 +15,12 @@
import netaddr
+from neutron_lib import constants as const
+
from tempest.common import utils as tutils
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
+from tempest.lib import exceptions as lib_exc
from neutron_tempest_plugin.api import base
from neutron_tempest_plugin.api import base_routers
@@ -453,3 +456,57 @@
@decorators.idempotent_id('fb102124-20f8-4cb3-8c81-f16f5e41d192')
def test_list_no_pagination_limit_0(self):
self._test_list_no_pagination_limit_0()
+
+
+class RoutersDeleteTest(base_routers.BaseRouterTest):
+ """The only test in this class is a test that removes router!
+
+ * We cannot delete common and mandatory resources (router in this case)
+ * using the existing classes, as it will cause failure in other tests
+ * running in parallel.
+ """
+ @classmethod
+ def resource_setup(cls):
+ super(RoutersDeleteTest, cls).resource_setup()
+ cls.secgroup = cls.create_security_group(
+ name=data_utils.rand_name("test_port_secgroup"))
+ router_kwargs = {
+ 'router_name': data_utils.rand_name('router_to_delete'),
+ 'external_network_id': CONF.network.public_network_id}
+ cls.router = cls.create_router(**router_kwargs)
+
+ @decorators.idempotent_id('dbbc5c74-63c8-11eb-8881-74e5f9e2a801')
+ def test_delete_router(self):
+ # Create a port on tenant network and associate to the router.
+ # Try to delete router. Expected result: "Conflict Error" is raised.
+ network = self.create_network()
+ subnet = self.create_subnet(network)
+ self.create_router_interface(self.router['id'], subnet['id'])
+ port = self.create_port(
+ network, name=data_utils.rand_name("port"),
+ security_groups=[self.secgroup['id']])
+ self.create_floatingip(port=port)
+ self.assertRaises(
+ lib_exc.Conflict, self.client.delete_router, self.router['id'])
+ # Delete the associated port
+ # Try to delete router. Expected result: "Conflict Error" is raised.
+ # Note: there are still interfaces in use.
+ self.client.delete_port(port['id'])
+ self.assertRaises(
+ lib_exc.Conflict, self.client.delete_router, self.router['id'])
+ # Delete the rest of the router's ports
+ # Try to delete router. Expected result: "PASS"
+ interfaces = [
+ port for port in self.client.list_router_interfaces(
+ self.router['id'])['ports']
+ if port['device_owner'] in const.ROUTER_INTERFACE_OWNERS]
+ for i in interfaces:
+ try:
+ self.assertRaises(
+ lib_exc.Conflict, self.client.delete_router,
+ self.router['id'])
+ self.client.remove_router_interface_with_subnet_id(
+ self.router['id'], i['fixed_ips'][0]['subnet_id'])
+ except lib_exc.NotFound:
+ pass
+ self.client.delete_router(self.router['id'])
diff --git a/neutron_tempest_plugin/api/test_routers_negative.py b/neutron_tempest_plugin/api/test_routers_negative.py
index 86d58e2..a4b3619 100644
--- a/neutron_tempest_plugin/api/test_routers_negative.py
+++ b/neutron_tempest_plugin/api/test_routers_negative.py
@@ -37,19 +37,6 @@
cls.subnet = cls.create_subnet(cls.network)
-class RoutersNegativeTest(RoutersNegativeTestBase):
-
- @decorators.attr(type='negative')
- @decorators.idempotent_id('e3e751af-15a2-49cc-b214-a7154579e94f')
- def test_delete_router_in_use(self):
- # This port is deleted after a test by remove_router_interface.
- port = self.create_port(self.network)
- self.client.add_router_interface_with_port_id(
- self.router['id'], port['id'])
- with testtools.ExpectedException(lib_exc.Conflict):
- self.client.delete_router(self.router['id'])
-
-
class RoutersNegativePolicyTest(RoutersNegativeTestBase):
credentials = ['admin', 'primary', 'alt']