Default to /tmp for scenario (create|get)_timestamp()
Long ago, the (create|get)_timestamp() calls wrote to and read from
/tmp by default but were changed to default to /mnt in change
I527557a3cf3618ffa6589dbd1dbc92f2268ed50e, when the dev_name kwarg
was added.
This makes sense if dev_name was passed and the device is mounted to
mount_path, but if dev_name was not specified, writing the timestamp to
a mount_path of /mnt can cause issues in some scenario tests when
servers have an ephemeral disk and a CirrOS image is used.
CirrOS mounts the first ephemeral disk to /mnt if one is found:
https://github.com/cirros-dev/cirros/blob/0322c12289d32f825b176d5f46cd88a78b8461a3/src/sbin/cirros-apply#L90
So if a flavor with ephemeral=1 is configured in tempest.conf, scenario
tests that create a server, write a timestamp file, snapshot the
server, create another server from the snapshot, and then try to read
the timestamp back from the second server, will incorrectly fail because
the /mnt/timestamp file was on the ephemeral disk which will not be
copied over during a snapshot or shelve offload..
This changes (create|get)_timestamp() to write/read from /tmp by default
and only use mount_path if a dev_name to mount was supplied.
Change-Id: Iec41ff7cba616fd469de0019f76ab54072f6fc28
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 20495ee..c33be55 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -1140,14 +1140,19 @@
server=server,
username=username)
+ # Default the directory in which to write the timestamp file to /tmp
+ # and only use the mount_path as the target directory if we mounted
+ # dev_name to mount_path.
+ target_dir = '/tmp'
if dev_name is not None:
ssh_client.make_fs(dev_name, fs=fs)
ssh_client.exec_command('sudo mount /dev/%s %s' % (dev_name,
mount_path))
- cmd_timestamp = 'sudo sh -c "date > %s/timestamp; sync"' % mount_path
+ target_dir = mount_path
+ cmd_timestamp = 'sudo sh -c "date > %s/timestamp; sync"' % target_dir
ssh_client.exec_command(cmd_timestamp)
timestamp = ssh_client.exec_command('sudo cat %s/timestamp'
- % mount_path)
+ % target_dir)
if dev_name is not None:
ssh_client.exec_command('sudo umount %s' % mount_path)
return timestamp
@@ -1172,10 +1177,15 @@
server=server,
username=username)
+ # Default the directory from which to read the timestamp file to /tmp
+ # and only use the mount_path as the target directory if we mounted
+ # dev_name to mount_path.
+ target_dir = '/tmp'
if dev_name is not None:
ssh_client.mount(dev_name, mount_path)
+ target_dir = mount_path
timestamp = ssh_client.exec_command('sudo cat %s/timestamp'
- % mount_path)
+ % target_dir)
if dev_name is not None:
ssh_client.exec_command('sudo umount %s' % mount_path)
return timestamp