Set random name in common function create_server
This is to set random name in volume.base.create_server, to avoid random name definition everytime calling create_server. Change-Id: I3078339806f2b3f472ce8f6010ae2364aebbf1dc
This commit is contained in:
parent
7ee11ccf5a
commit
7867a6e294
|
@ -172,7 +172,11 @@ class BaseVolumeTest(tempest.test.BaseTestCase):
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def create_server(self, name, **kwargs):
|
def create_server(self, **kwargs):
|
||||||
|
name = kwargs.get(
|
||||||
|
'name',
|
||||||
|
data_utils.rand_name(self.__class__.__name__ + '-instance'))
|
||||||
|
|
||||||
tenant_network = self.get_tenant_network()
|
tenant_network = self.get_tenant_network()
|
||||||
body, _ = compute.create_test_server(
|
body, _ = compute.create_test_server(
|
||||||
self.os,
|
self.os,
|
||||||
|
|
|
@ -55,10 +55,7 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
|
||||||
@test.services('compute')
|
@test.services('compute')
|
||||||
def test_attach_detach_volume_to_instance(self):
|
def test_attach_detach_volume_to_instance(self):
|
||||||
# Create a server
|
# Create a server
|
||||||
srv_name = data_utils.rand_name(self.__class__.__name__ + '-Instance')
|
server = self.create_server(wait_until='ACTIVE')
|
||||||
server = self.create_server(
|
|
||||||
name=srv_name,
|
|
||||||
wait_until='ACTIVE')
|
|
||||||
# Volume is attached and detached successfully from an instance
|
# Volume is attached and detached successfully from an instance
|
||||||
self.client.attach_volume(self.volume['id'],
|
self.client.attach_volume(self.volume['id'],
|
||||||
instance_uuid=server['id'],
|
instance_uuid=server['id'],
|
||||||
|
@ -89,10 +86,7 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
|
||||||
@test.services('compute')
|
@test.services('compute')
|
||||||
def test_get_volume_attachment(self):
|
def test_get_volume_attachment(self):
|
||||||
# Create a server
|
# Create a server
|
||||||
srv_name = data_utils.rand_name(self.__class__.__name__ + '-Instance')
|
server = self.create_server(wait_until='ACTIVE')
|
||||||
server = self.create_server(
|
|
||||||
name=srv_name,
|
|
||||||
wait_until='ACTIVE')
|
|
||||||
# Verify that a volume's attachment information is retrieved
|
# Verify that a volume's attachment information is retrieved
|
||||||
self.client.attach_volume(self.volume['id'],
|
self.client.attach_volume(self.volume['id'],
|
||||||
instance_uuid=server['id'],
|
instance_uuid=server['id'],
|
||||||
|
|
|
@ -84,9 +84,7 @@ class VolumesBackupsV2Test(base.BaseVolumeTest):
|
||||||
volume = self.create_volume()
|
volume = self.create_volume()
|
||||||
self.addCleanup(self.volumes_client.delete_volume,
|
self.addCleanup(self.volumes_client.delete_volume,
|
||||||
volume['id'])
|
volume['id'])
|
||||||
server_name = data_utils.rand_name(
|
server = self.create_server(wait_until='ACTIVE')
|
||||||
self.__class__.__name__ + '-instance')
|
|
||||||
server = self.create_server(name=server_name, wait_until='ACTIVE')
|
|
||||||
# Attach volume to instance
|
# Attach volume to instance
|
||||||
self.servers_client.attach_volume(server['id'],
|
self.servers_client.attach_volume(server['id'],
|
||||||
volumeId=volume['id'])
|
volumeId=volume['id'])
|
||||||
|
|
|
@ -176,10 +176,7 @@ class VolumesV2NegativeTest(base.BaseVolumeTest):
|
||||||
@test.idempotent_id('f5e56b0a-5d02-43c1-a2a7-c9b792c2e3f6')
|
@test.idempotent_id('f5e56b0a-5d02-43c1-a2a7-c9b792c2e3f6')
|
||||||
@test.services('compute')
|
@test.services('compute')
|
||||||
def test_attach_volumes_with_nonexistent_volume_id(self):
|
def test_attach_volumes_with_nonexistent_volume_id(self):
|
||||||
srv_name = data_utils.rand_name(self.__class__.__name__ + '-Instance')
|
server = self.create_server(wait_until='ACTIVE')
|
||||||
server = self.create_server(
|
|
||||||
name=srv_name,
|
|
||||||
wait_until='ACTIVE')
|
|
||||||
|
|
||||||
self.assertRaises(lib_exc.NotFound,
|
self.assertRaises(lib_exc.NotFound,
|
||||||
self.client.attach_volume,
|
self.client.attach_volume,
|
||||||
|
|
|
@ -45,11 +45,7 @@ class VolumesV2SnapshotTestJSON(base.BaseVolumeTest):
|
||||||
def test_snapshot_create_with_volume_in_use(self):
|
def test_snapshot_create_with_volume_in_use(self):
|
||||||
# Create a snapshot when volume status is in-use
|
# Create a snapshot when volume status is in-use
|
||||||
# Create a test instance
|
# Create a test instance
|
||||||
server_name = data_utils.rand_name(
|
server = self.create_server(wait_until='ACTIVE')
|
||||||
self.__class__.__name__ + '-instance')
|
|
||||||
server = self.create_server(
|
|
||||||
name=server_name,
|
|
||||||
wait_until='ACTIVE')
|
|
||||||
self.servers_client.attach_volume(
|
self.servers_client.attach_volume(
|
||||||
server['id'], volumeId=self.volume_origin['id'],
|
server['id'], volumeId=self.volume_origin['id'],
|
||||||
device='/dev/%s' % CONF.compute.volume_device_name)
|
device='/dev/%s' % CONF.compute.volume_device_name)
|
||||||
|
|
Loading…
Reference in New Issue