From 9086dca536f89f9887bff28968a29a363a70ae4b Mon Sep 17 00:00:00 2001 From: Martin Kopec Date: Wed, 20 Mar 2024 13:18:57 +0100 Subject: [PATCH] Parametrize target_dir for the timestamp The default location where we write timestamp files is /tmp, however, this location does not work for all systems - /tmp directory cannot be expected to persist across reboots of an instance. This commit allows users to set their preferred location and override the default (/tmp) target dir. Closes-Bug: #2051268 Change-Id: Id23ae70001525c8eb95d6baf0aca2b4d399e63a1 --- ...dd-scenario-config-opt-target-dir-5a969b64be1dc718.yaml | 7 +++++++ tempest/config.py | 5 ++++- tempest/scenario/manager.py | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/Add-scenario-config-opt-target-dir-5a969b64be1dc718.yaml diff --git a/releasenotes/notes/Add-scenario-config-opt-target-dir-5a969b64be1dc718.yaml b/releasenotes/notes/Add-scenario-config-opt-target-dir-5a969b64be1dc718.yaml new file mode 100644 index 0000000000..3adacfc4ed --- /dev/null +++ b/releasenotes/notes/Add-scenario-config-opt-target-dir-5a969b64be1dc718.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Adding a new config options `[scenario]/target_dir` which allows + users to specify the location where timestamps files will be + written to. The default value is /tmp that, however, cannot be + expected to persist across reboots of an instance. diff --git a/tempest/config.py b/tempest/config.py index b1f736c865..471782b551 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -1217,7 +1217,10 @@ ScenarioGroup = [ default='icmp', choices=('icmp', 'tcp', 'udp'), help='The protocol used in security groups tests to check ' - 'connectivity.') + 'connectivity.'), + cfg.StrOpt('target_dir', + default='/tmp', + help='Directory in which to write the timestamp file.'), ] diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py index 714a7c76c7..cb2101780c 100644 --- a/tempest/scenario/manager.py +++ b/tempest/scenario/manager.py @@ -1227,7 +1227,7 @@ class ScenarioTest(tempest.test.BaseTestCase): # 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' + target_dir = CONF.scenario.target_dir if dev_name is not None: mount_path = os.path.join(mount_path, dev_name) ssh_client.make_fs(dev_name, fs=fs) @@ -1266,7 +1266,7 @@ class ScenarioTest(tempest.test.BaseTestCase): # 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' + target_dir = CONF.scenario.target_dir if dev_name is not None: mount_path = os.path.join(mount_path, dev_name) ssh_client.mkdir(mount_path)