Files
tempest/tempest/api/compute/test_tenant_networks.py
T
Ghanshyam Mann fd90dacc8e Skip test early to improve memory footprint and time
When we skip the test class using skip_checks(), it check
the conditions and skip the test class at first step
without creating any keystone credentials. But when
tests are skipped with other decorator at test level then
it does create keystone credentials, setup network resources
and service clients.

Wehn all the tests in test class are skipped based on common
condition then it is better to skip them using the skip_check
so that we do not create any keystone, network resources which
will improve the DB queries keystone, neutron does and also
speed up the test skip.

Related-Bug: #2004780
Change-Id: Id5e6ddcb83aaa6133c28ef188183d98e26e4925b
2023-08-04 11:20:00 -07:00

63 lines
2.2 KiB
Python

# Copyright 2015 NEC Corporation. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest.api.compute import base
from tempest.common import utils
from tempest import config
from tempest.lib import decorators
CONF = config.CONF
class ComputeTenantNetworksTest(base.BaseV2ComputeTest):
"""Test compute tenant networks API with microversion less than 2.36"""
max_microversion = '2.35'
@classmethod
def skip_checks(cls):
super(ComputeTenantNetworksTest, cls).skip_checks()
if not CONF.service_available.neutron:
skip_msg = (
"%s skipped as Neutron is not available" % cls.__name__)
raise cls.skipException(skip_msg)
@classmethod
def resource_setup(cls):
super(ComputeTenantNetworksTest, cls).resource_setup()
cls.client = cls.os_primary.tenant_networks_client
cls.network = cls.get_tenant_network()
@classmethod
def setup_credentials(cls):
cls.set_network_resources(network=True)
super(ComputeTenantNetworksTest, cls).setup_credentials()
@decorators.idempotent_id('edfea98e-bbe3-4c7a-9739-87b986baff26')
@utils.services('network')
def test_list_show_tenant_networks(self):
"""Test list/show tenant networks
Fetch all networks that are visible to the tenant: this may include
shared and external networks.
"""
tenant_networks = [
n['id'] for n in self.client.list_tenant_networks()['networks']
]
self.assertIn(self.network['id'], tenant_networks,
"No tenant networks found.")
net = self.client.show_tenant_network(self.network['id'])
self.assertEqual(self.network['id'], net['network']['id'])