Merge "API test refactoring about create_project"
This commit is contained in:
commit
f772094105
neutron/tests/tempest/api
@ -47,12 +47,7 @@ class FloatingIPAdminTestJSON(base.BaseAdminNetworkTest):
|
||||
body = self.client.create_floatingip(
|
||||
floating_network_id=self.ext_net_id)
|
||||
floating_ip = body['floatingip']
|
||||
test_project = data_utils.rand_name('test_project_')
|
||||
test_description = data_utils.rand_name('desc_')
|
||||
project = self.identity_admin_client.create_project(
|
||||
name=test_project, description=test_description)['project']
|
||||
project_id = project['id']
|
||||
self.addCleanup(self.identity_admin_client.delete_project, project_id)
|
||||
project_id = self.create_project()['id']
|
||||
|
||||
port = self.admin_client.create_port(network_id=self.network['id'],
|
||||
project_id=project_id)
|
||||
|
@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest.lib import decorators
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
from tempest import test
|
||||
@ -33,17 +32,6 @@ class QuotasTestBase(base.BaseAdminNetworkTest):
|
||||
def resource_setup(cls):
|
||||
super(QuotasTestBase, cls).resource_setup()
|
||||
|
||||
def _create_tenant(self):
|
||||
# Add a tenant to conduct the test
|
||||
test_tenant = data_utils.rand_name('test_tenant_')
|
||||
test_description = data_utils.rand_name('desc_')
|
||||
project = self.identity_admin_client.create_project(
|
||||
name=test_tenant,
|
||||
description=test_description)['project']
|
||||
self.addCleanup(
|
||||
self.identity_admin_client.delete_project, project['id'])
|
||||
return project
|
||||
|
||||
def _setup_quotas(self, project_id, **new_quotas):
|
||||
# Change quotas for tenant
|
||||
quota_set = self.admin_client.update_quotas(project_id,
|
||||
@ -96,7 +84,7 @@ class QuotasTest(QuotasTestBase):
|
||||
@decorators.attr(type='gate')
|
||||
@decorators.idempotent_id('2390f766-836d-40ef-9aeb-e810d78207fb')
|
||||
def test_quotas(self):
|
||||
tenant_id = self._create_tenant()['id']
|
||||
tenant_id = self.create_project()['id']
|
||||
new_quotas = {'network': 0, 'security_group': 0}
|
||||
|
||||
# Change quotas for tenant
|
||||
@ -129,7 +117,7 @@ class QuotasTest(QuotasTestBase):
|
||||
@decorators.attr(type='gate')
|
||||
@test.requires_ext(extension="quota_details", service="network")
|
||||
def test_detail_quotas(self):
|
||||
tenant_id = self._create_tenant()['id']
|
||||
tenant_id = self.create_project()['id']
|
||||
new_quotas = {'network': {'used': 1, 'limit': 2, 'reserved': 0},
|
||||
'port': {'used': 1, 'limit': 2, 'reserved': 0}}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class QuotasAdminNegativeTestJSON(test_quotas.QuotasTestBase):
|
||||
@decorators.attr(type='negative')
|
||||
@decorators.idempotent_id('952f9b24-9156-4bdc-90f3-682a3d4302f0')
|
||||
def test_create_network_when_quotas_is_full(self):
|
||||
tenant_id = self._create_tenant()['id']
|
||||
tenant_id = self.create_project()['id']
|
||||
new_quotas = {'network': 1}
|
||||
self._setup_quotas(tenant_id, **new_quotas)
|
||||
|
||||
@ -40,7 +40,7 @@ class QuotasAdminNegativeTestJSON(test_quotas.QuotasTestBase):
|
||||
@decorators.attr(type='negative')
|
||||
@decorators.idempotent_id('0b7f99e3-9f77-45ce-9a89-b39a184de618')
|
||||
def test_create_subnet_when_quotas_is_full(self):
|
||||
tenant_id = self._create_tenant()['id']
|
||||
tenant_id = self.create_project()['id']
|
||||
new_quotas = {'subnet': 1}
|
||||
self._setup_quotas(tenant_id, **new_quotas)
|
||||
|
||||
@ -62,7 +62,7 @@ class QuotasAdminNegativeTestJSON(test_quotas.QuotasTestBase):
|
||||
@decorators.attr(type='negative')
|
||||
@decorators.idempotent_id('fe20d9f9-346c-4a20-bbfa-d9ca390f4dc6')
|
||||
def test_create_port_when_quotas_is_full(self):
|
||||
tenant_id = self._create_tenant()['id']
|
||||
tenant_id = self.create_project()['id']
|
||||
new_quotas = {'port': 1}
|
||||
self._setup_quotas(tenant_id, **new_quotas)
|
||||
|
||||
@ -90,7 +90,7 @@ class QuotasAdminNegativeTestJSON(test_quotas.QuotasTestBase):
|
||||
@decorators.idempotent_id('bb1e9c3c-7e6f-41f1-b579-63dbc655ecb7')
|
||||
@test.requires_ext(extension="router", service="network")
|
||||
def test_create_router_when_quotas_is_full(self):
|
||||
tenant_id = self._create_tenant()['id']
|
||||
tenant_id = self.create_project()['id']
|
||||
new_quotas = {'router': 1}
|
||||
self._setup_quotas(tenant_id, **new_quotas)
|
||||
|
||||
@ -108,7 +108,7 @@ class QuotasAdminNegativeTestJSON(test_quotas.QuotasTestBase):
|
||||
@decorators.idempotent_id('5c924ff7-b7a9-474f-92a3-dbe0f976ec13')
|
||||
@test.requires_ext(extension="security-group", service="network")
|
||||
def test_create_security_group_when_quotas_is_full(self):
|
||||
tenant_id = self._create_tenant()['id']
|
||||
tenant_id = self.create_project()['id']
|
||||
sg_args = {'tenant_id': tenant_id}
|
||||
# avoid a number that is made by default
|
||||
sg_list = self.admin_client.list_security_groups(
|
||||
@ -129,7 +129,7 @@ class QuotasAdminNegativeTestJSON(test_quotas.QuotasTestBase):
|
||||
@decorators.idempotent_id('b7143480-6118-4ed4-be38-1b6f15f30d05')
|
||||
@test.requires_ext(extension="security-group", service="network")
|
||||
def test_create_security_group_rule_when_quotas_is_full(self):
|
||||
tenant_id = self._create_tenant()['id']
|
||||
tenant_id = self.create_project()['id']
|
||||
sg_args = {'tenant_id': tenant_id}
|
||||
|
||||
sg = self.admin_client.create_security_group(
|
||||
@ -161,7 +161,7 @@ class QuotasAdminNegativeTestJSON(test_quotas.QuotasTestBase):
|
||||
@decorators.idempotent_id('d00fe5bb-9db8-4e1a-9c31-490f52897e6f')
|
||||
@test.requires_ext(extension="router", service="network")
|
||||
def test_create_floatingip_when_quotas_is_full(self):
|
||||
tenant_id = self._create_tenant()['id']
|
||||
tenant_id = self.create_project()['id']
|
||||
new_quotas = {'floatingip': 1}
|
||||
self._setup_quotas(tenant_id, **new_quotas)
|
||||
|
||||
|
@ -115,6 +115,7 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
cls.subnetpools = []
|
||||
cls.admin_subnetpools = []
|
||||
cls.security_groups = []
|
||||
cls.projects = []
|
||||
|
||||
@classmethod
|
||||
def resource_cleanup(cls):
|
||||
@ -191,6 +192,11 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
cls.admin_client.delete_address_scope,
|
||||
address_scope['id'])
|
||||
|
||||
for project in cls.projects:
|
||||
cls._try_delete_resource(
|
||||
cls.identity_admin_client.delete_project,
|
||||
project['id'])
|
||||
|
||||
# Clean up QoS rules
|
||||
for qos_rule in cls.qos_rules:
|
||||
cls._try_delete_resource(cls.admin_client.delete_qos_rule,
|
||||
@ -435,6 +441,16 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
cls.subnetpools.append(body['subnetpool'])
|
||||
return body['subnetpool']
|
||||
|
||||
@classmethod
|
||||
def create_project(cls, name=None, description=None):
|
||||
test_project = name or data_utils.rand_name('test_project_')
|
||||
test_description = description or data_utils.rand_name('desc_')
|
||||
project = cls.identity_admin_client.create_project(
|
||||
name=test_project,
|
||||
description=test_description)['project']
|
||||
cls.projects.append(project)
|
||||
return project
|
||||
|
||||
|
||||
class BaseAdminNetworkTest(BaseNetworkTest):
|
||||
|
||||
|
@ -37,17 +37,6 @@ class QosTestJSON(base.BaseAdminNetworkTest):
|
||||
if driver['name'] == driver_name:
|
||||
return driver
|
||||
|
||||
def _create_project(self):
|
||||
# Add a project to conduct the test
|
||||
test_project = data_utils.rand_name('test_project_')
|
||||
test_description = data_utils.rand_name('desc_')
|
||||
project = self.identity_admin_client.create_project(
|
||||
name=test_project,
|
||||
description=test_description)['project']
|
||||
self.addCleanup(
|
||||
self.identity_admin_client.delete_project, project['id'])
|
||||
return project
|
||||
|
||||
@decorators.idempotent_id('108fbdf7-3463-4e47-9871-d07f3dcf5bbb')
|
||||
def test_create_policy(self):
|
||||
policy = self.create_qos_policy(name='test-policy',
|
||||
@ -371,7 +360,7 @@ class QosTestJSON(base.BaseAdminNetworkTest):
|
||||
|
||||
@decorators.idempotent_id('18d94f22-b9d5-4390-af12-d30a0cfc4cd3')
|
||||
def test_default_policy_creating_network_without_policy(self):
|
||||
project_id = self._create_project()['id']
|
||||
project_id = self.create_project()['id']
|
||||
policy = self.create_qos_policy(name='test-policy',
|
||||
tenant_id=project_id,
|
||||
is_default=True)
|
||||
@ -383,7 +372,7 @@ class QosTestJSON(base.BaseAdminNetworkTest):
|
||||
|
||||
@decorators.idempotent_id('807cce45-38e5-482d-94db-36e1796aba73')
|
||||
def test_default_policy_creating_network_with_policy(self):
|
||||
project_id = self._create_project()['id']
|
||||
project_id = self.create_project()['id']
|
||||
self.create_qos_policy(name='test-policy',
|
||||
tenant_id=project_id,
|
||||
is_default=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user