From 73468c9eebfe9d89cfaf554c1b945e2ecfed9cb8 Mon Sep 17 00:00:00 2001 From: kshithijiyer Date: Fri, 31 Jul 2020 12:33:31 +0530 Subject: [Testfix] Fix I/O logic to use distinct file names Problem: Testcases test_mount_snap_delete and test_restore_online_vol were failing in the latest runs with the below traceback ``` Traceback (most recent call last): File "/usr/share/glustolibs/io/scripts/file_dir_ops.py", line 1246, in rc = args.func(args) File "/usr/share/glustolibs/io/scripts/file_dir_ops.py", line 374, in create_files base_file_name, file_types) File "/usr/share/glustolibs/io/scripts/file_dir_ops.py", line 341, in _create_files ret = pool.map(lambda file_tuple: _create_file(*file_tuple), files) File "/usr/lib64/python3.6/multiprocessing/pool.py", line 266, in map return self._map_async(func, iterable, mapstar, chunksize).get() File "/usr/lib64/python3.6/multiprocessing/pool.py", line 644, in get raise self._value File "/usr/lib64/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/usr/lib64/python3.6/multiprocessing/pool.py", line 44, in mapstar return list(map(*args)) File "/usr/share/glustolibs/io/scripts/file_dir_ops.py", line 341, in ret = pool.map(lambda file_tuple: _create_file(*file_tuple), files) File "/usr/share/glustolibs/io/scripts/file_dir_ops.py", line 270, in _create_file with open(file_abs_path, "w+") as new_file: FileExistsError: [Errno 17] File exists: '/mnt/testvol_distributed_glusterfs/file1.txt' ``` This was because I/O logic was trying to create 2 files with the same name from 2 clients. Fix: Modify logic to use counters to create files with different names. Change-Id: I2896736d28f6bd17435f941088fd634347e3f4fd Signed-off-by: kshithijiyer --- tests/functional/snapshot/test_mount_snap.py | 5 ++++- tests/functional/snapshot/test_restore_online_vol.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/functional/snapshot/test_mount_snap.py b/tests/functional/snapshot/test_mount_snap.py index 9b0bf2bfe..ef918ba8b 100644 --- a/tests/functional/snapshot/test_mount_snap.py +++ b/tests/functional/snapshot/test_mount_snap.py @@ -84,14 +84,17 @@ class TestSnapMountSnapshot(GlusterBaseClass): g.log.info("Starting IO on all mounts...") g.log.info("mounts: %s", self.mounts) all_mounts_procs = [] + self.counter = 1 for mount_obj in self.mounts: cmd = ("/usr/bin/env python %s create_files " - "-f 10 --base-file-name file %s" % ( + "-f 10 --base-file-name file%d %s" % ( self.script_upload_path, + self.counter, mount_obj.mountpoint)) proc = g.run_async(mount_obj.client_system, cmd, user=mount_obj.user) all_mounts_procs.append(proc) + self.counter += 100 # Validate I/O self.assertTrue( diff --git a/tests/functional/snapshot/test_restore_online_vol.py b/tests/functional/snapshot/test_restore_online_vol.py index 2a7f39cae..2fa46012b 100644 --- a/tests/functional/snapshot/test_restore_online_vol.py +++ b/tests/functional/snapshot/test_restore_online_vol.py @@ -112,9 +112,9 @@ class SnapRSOnline(GlusterBaseClass): "--num-of-files 2 %s" % ( self.script_upload_path, self.counter, mount_obj.mountpoint)) - proc = g.run_async(mount_obj.client_system, cmd, user=mount_obj.user) + self.counter += 100 self.all_mounts_procs.append(proc) self.io_validation_complete = False -- cgit