Merge "test_stamp_pattern: cleanup class scope variable usage"
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 036914e..9ecb883 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -573,8 +573,10 @@
floating_ip['ip'], thing['id'])
return floating_ip
- def create_timestamp(self, server_or_ip, dev_name=None, mount_path='/mnt'):
- ssh_client = self.get_remote_client(server_or_ip)
+ def create_timestamp(self, server_or_ip, dev_name=None, mount_path='/mnt',
+ private_key=None):
+ ssh_client = self.get_remote_client(server_or_ip,
+ private_key=private_key)
if dev_name is not None:
ssh_client.make_fs(dev_name)
ssh_client.mount(dev_name, mount_path)
@@ -586,8 +588,10 @@
ssh_client.umount(mount_path)
return timestamp
- def get_timestamp(self, server_or_ip, dev_name=None, mount_path='/mnt'):
- ssh_client = self.get_remote_client(server_or_ip)
+ def get_timestamp(self, server_or_ip, dev_name=None, mount_path='/mnt',
+ private_key=None):
+ ssh_client = self.get_remote_client(server_or_ip,
+ private_key=private_key)
if dev_name is not None:
ssh_client.mount(dev_name, mount_path)
timestamp = ssh_client.exec_command('sudo cat %s/timestamp'
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index a4f9896..6eceeb2 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -63,20 +63,17 @@
self.snapshots_client.wait_for_snapshot_status(volume_snapshot['id'],
status)
- def _boot_image(self, image_id):
- security_groups = [{'name': self.security_group['name']}]
+ def _boot_image(self, image_id, keypair, security_group):
+ security_groups = [{'name': security_group['name']}]
create_kwargs = {
- 'key_name': self.keypair['name'],
+ 'key_name': keypair['name'],
'security_groups': security_groups
}
return self.create_server(image=image_id, create_kwargs=create_kwargs)
- def _add_keypair(self):
- self.keypair = self.create_keypair()
-
def _create_volume_snapshot(self, volume):
snapshot_name = data_utils.rand_name('scenario-snapshot')
- _, snapshot = self.snapshots_client.create_snapshot(
+ snapshot = self.snapshots_client.create_snapshot(
volume['id'], display_name=snapshot_name)['snapshot']
def cleaner():
@@ -111,8 +108,9 @@
self.servers_client.detach_volume(server['id'], volume['id'])
self._wait_for_volume_status(volume, 'available')
- def _wait_for_volume_available_on_the_system(self, server_or_ip):
- ssh = self.get_remote_client(server_or_ip)
+ def _wait_for_volume_available_on_the_system(self, server_or_ip,
+ private_key):
+ ssh = self.get_remote_client(server_or_ip, private_key=private_key)
def _func():
part = ssh.get_partitions()
@@ -131,12 +129,13 @@
@tempest.test.services('compute', 'network', 'volume', 'image')
def test_stamp_pattern(self):
# prepare for booting an instance
- self._add_keypair()
- self.security_group = self._create_security_group()
+ keypair = self.create_keypair()
+ security_group = self._create_security_group()
# boot an instance and create a timestamp file in it
volume = self._create_volume()
- server = self._boot_image(CONF.compute.image_ref)
+ server = self._boot_image(CONF.compute.image_ref, keypair,
+ security_group)
# create and add floating IP to server1
if CONF.compute.use_floatingip_for_ssh:
@@ -146,9 +145,11 @@
ip_for_server = server
self._attach_volume(server, volume)
- self._wait_for_volume_available_on_the_system(ip_for_server)
+ self._wait_for_volume_available_on_the_system(ip_for_server,
+ keypair['private_key'])
timestamp = self.create_timestamp(ip_for_server,
- CONF.compute.volume_device_name)
+ CONF.compute.volume_device_name,
+ private_key=keypair['private_key'])
self._detach_volume(server, volume)
# snapshot the volume
@@ -162,7 +163,8 @@
snapshot_id=volume_snapshot['id'])
# boot second instance from the snapshot(instance2)
- server_from_snapshot = self._boot_image(snapshot_image['id'])
+ server_from_snapshot = self._boot_image(snapshot_image['id'],
+ keypair, security_group)
# create and add floating IP to server_from_snapshot
if CONF.compute.use_floatingip_for_ssh:
@@ -174,9 +176,11 @@
# attach volume2 to instance2
self._attach_volume(server_from_snapshot, volume_from_snapshot)
- self._wait_for_volume_available_on_the_system(ip_for_snapshot)
+ self._wait_for_volume_available_on_the_system(ip_for_snapshot,
+ keypair['private_key'])
# check the existence of the timestamp file in the volume2
timestamp2 = self.get_timestamp(ip_for_snapshot,
- CONF.compute.volume_device_name)
+ CONF.compute.volume_device_name,
+ private_key=keypair['private_key'])
self.assertEqual(timestamp, timestamp2)