Merge "Clean-up Tempest test networks with project_id"
This commit is contained in:
commit
98e5dcaffd
@ -25,8 +25,8 @@ class NetworksTestAdmin(base.BaseAdminNetworkTest):
|
||||
project_id = self.client.tenant_id # non-admin
|
||||
|
||||
name = 'admin-created-with-project_id'
|
||||
body = self.admin_client.create_network_keystone_v3(name, project_id)
|
||||
new_net = body['network']
|
||||
new_net = self.create_network_keystone_v3(name, project_id,
|
||||
client=self.admin_client)
|
||||
self.assertEqual(name, new_net['name'])
|
||||
self.assertEqual(project_id, new_net['project_id'])
|
||||
self.assertEqual(project_id, new_net['tenant_id'])
|
||||
@ -43,9 +43,8 @@ class NetworksTestAdmin(base.BaseAdminNetworkTest):
|
||||
project_id = self.client.tenant_id # non-admin
|
||||
|
||||
name = 'created-with-project-and-tenant'
|
||||
body = self.admin_client.create_network_keystone_v3(
|
||||
name, project_id, tenant_id=project_id)
|
||||
new_net = body['network']
|
||||
new_net = self.create_network_keystone_v3(
|
||||
name, project_id, tenant_id=project_id, client=self.admin_client)
|
||||
self.assertEqual(name, new_net['name'])
|
||||
self.assertEqual(project_id, new_net['project_id'])
|
||||
self.assertEqual(project_id, new_net['tenant_id'])
|
||||
@ -64,7 +63,8 @@ class NetworksTestAdmin(base.BaseAdminNetworkTest):
|
||||
|
||||
name = 'created-with-project-and-other-tenant'
|
||||
e = self.assertRaises(lib_exc.BadRequest,
|
||||
self.admin_client.create_network_keystone_v3,
|
||||
name, project_id, tenant_id=other_tenant)
|
||||
self.create_network_keystone_v3, name,
|
||||
project_id, tenant_id=other_tenant,
|
||||
client=self.admin_client)
|
||||
expected_message = "'project_id' and 'tenant_id' do not match"
|
||||
self.assertEqual(expected_message, e.resp_body['message'])
|
||||
|
@ -93,7 +93,7 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
super(BaseNetworkTest, cls).resource_setup()
|
||||
|
||||
cls.networks = []
|
||||
cls.shared_networks = []
|
||||
cls.admin_networks = []
|
||||
cls.subnets = []
|
||||
cls.ports = []
|
||||
cls.routers = []
|
||||
@ -162,8 +162,8 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
cls._try_delete_resource(cls.client.delete_network,
|
||||
network['id'])
|
||||
|
||||
# Clean up shared networks
|
||||
for network in cls.shared_networks:
|
||||
# Clean up admin networks
|
||||
for network in cls.admin_networks:
|
||||
cls._try_delete_resource(cls.admin_client.delete_network,
|
||||
network['id'])
|
||||
|
||||
@ -222,7 +222,24 @@ class BaseNetworkTest(test.BaseTestCase):
|
||||
post_body.update({'name': network_name, 'shared': True})
|
||||
body = cls.admin_client.create_network(**post_body)
|
||||
network = body['network']
|
||||
cls.shared_networks.append(network)
|
||||
cls.admin_networks.append(network)
|
||||
return network
|
||||
|
||||
@classmethod
|
||||
def create_network_keystone_v3(cls, network_name=None, project_id=None,
|
||||
tenant_id=None, client=None):
|
||||
"""Wrapper utility that creates a test network with project_id."""
|
||||
client = client or cls.client
|
||||
network_name = network_name or data_utils.rand_name(
|
||||
'test-network-with-project_id')
|
||||
project_id = cls.client.tenant_id
|
||||
body = client.create_network_keystone_v3(network_name, project_id,
|
||||
tenant_id)
|
||||
network = body['network']
|
||||
if client is cls.client:
|
||||
cls.networks.append(network)
|
||||
else:
|
||||
cls.admin_networks.append(network)
|
||||
return network
|
||||
|
||||
@classmethod
|
||||
|
@ -106,8 +106,7 @@ class NetworksTestJSON(base.BaseNetworkTest):
|
||||
project_id = self.client.tenant_id
|
||||
|
||||
name = 'created-with-project_id'
|
||||
body = self.client.create_network_keystone_v3(name, project_id)
|
||||
new_net = body['network']
|
||||
new_net = self.create_network_keystone_v3(name, project_id)
|
||||
self.assertEqual(name, new_net['name'])
|
||||
self.assertEqual(project_id, new_net['project_id'])
|
||||
self.assertEqual(project_id, new_net['tenant_id'])
|
||||
|
Loading…
Reference in New Issue
Block a user