Loading tests/integration/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ gkfs_enable_python_testing( BINARY_DIRECTORIES ${CMAKE_BINARY_DIR}/src/daemon/ ${CMAKE_BINARY_DIR}/src/client/ ${CMAKE_BINARY_DIR}/tests/integration/harness/ ${CMAKE_BINARY_DIR}/examples/gfind/ LIBRARY_PREFIX_DIRECTORIES ${CMAKE_PREFIX_PATH} ) Loading tests/integration/directories/test_directories.py +13 −5 Original line number Diff line number Diff line Loading @@ -220,11 +220,19 @@ def test_extended(gkfs_daemon, gkfs_shell, gkfs_client): ret = gkfs_client.write(file_a, buf, 1) assert ret.retval == 1 preload = 'LIBGKFS_HOSTS_FILE='+str(gkfs_client._patched_env['LIBGKFS_HOSTS_FILE'])+' LD_PRELOAD='+str(gkfs_client._preload_library) stream = os.popen(preload+' '+str(gkfs_daemon._workspace.bindirs[1])+'/sfind '+str(topdir)+' -M '+str(gkfs_daemon.mountdir)+' -S 1 -name "*_k*"'); output = stream.read() assert output == "MATCHED 0/4\n" cmd = gkfs_shell.sfind( topdir, '-M', gkfs_daemon.mountdir, '-S', 1, '-name', '*_k*' ) assert cmd.exit_code == 0 assert cmd.stdout.decode() == "MATCHED 0/4\n" @pytest.mark.skip(reason="invalid errno returned on success") @pytest.mark.parametrize("directory_path", Loading tests/integration/harness/gkfs.py +45 −6 Original line number Diff line number Diff line Loading @@ -140,6 +140,32 @@ def _process_exists(pid): return True def _find_search_paths(additional_paths=None): """ Return the entire list of search paths available to the process. If additional_paths is not provided, $PATH env is returned. Parameters ---------- additional_paths: `list` If provided, additional paths that should be used for searching before falling back to the contents of $PATH. Returns ------- A list containing the paths that should be searched for commands. """ paths_to_search = [] if isinstance(additional_paths, (tuple, list)): paths_to_search.extend(additional_paths) env_paths = os.environ.get("PATH", "").split(os.pathsep) paths_to_search.extend(env_paths) return paths_to_search class FwdDaemonCreator: """ Factory that allows tests to create forwarding daemons in a workspace. Loading Loading @@ -439,7 +465,7 @@ class ShellClient: def __init__(self, workspace): self._workspace = workspace self._cmd = sh.Command("bash") self._search_paths = _find_search_paths(self._workspace.bindirs) self._env = os.environ.copy() libdirs = ':'.join( Loading Loading @@ -552,6 +578,8 @@ class ShellClient: if intercept_shell: logger.debug(f"patched env: {self._patched_env}") self._cmd = sh.Command("bash") # 'sh' raises an exception if the return code is not zero; # since we'd rather check for return codes explictly, we # whitelist all exit codes from 1 to 255 as 'ok' using the Loading Loading @@ -608,19 +636,27 @@ class ShellClient: extra properties to it. """ bash_c_args = f"{cmd} {' '.join(str(a) for a in args)}" logger.debug(f"running bash") logger.debug(f"cmd: bash -c '{bash_c_args}'") found_cmd = sh.which(cmd, self._search_paths) if not found_cmd: raise sh.CommandNotFound(cmd) self._cmd = sh.Command(found_cmd) logger.debug(f"running program") logger.debug(f"cmd: {cmd} {' '.join(str(a) for a in args)}") logger.debug(f"search_paths: {':'.join(str(p) for p in self._search_paths)}") logger.debug(f"timeout: {timeout} seconds") logger.debug(f"timeout_signal: {signal.Signals(timeout_signal).name}") logger.debug(f"patched env:\n{pformat(self._patched_env)}") # 'sh' raises an exception if the return code is not zero; # since we'd rather check for return codes explictly, we # whitelist all exit codes from 1 to 255 as 'ok' using the # _ok_code argument proc = self._cmd('-c', bash_c_args, proc = self._cmd( args, _env = self._env, # _out=sys.stdout, # _err=sys.stderr, Loading @@ -629,6 +665,9 @@ class ShellClient: # _ok_code=list(range(0, 256)) ) logger.debug(f"program stdout: {proc.stdout}") logger.debug(f"program stderr: {proc.stderr}") return ShellCommand(cmd, proc) def __getattr__(self, name): Loading Loading
tests/integration/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ gkfs_enable_python_testing( BINARY_DIRECTORIES ${CMAKE_BINARY_DIR}/src/daemon/ ${CMAKE_BINARY_DIR}/src/client/ ${CMAKE_BINARY_DIR}/tests/integration/harness/ ${CMAKE_BINARY_DIR}/examples/gfind/ LIBRARY_PREFIX_DIRECTORIES ${CMAKE_PREFIX_PATH} ) Loading
tests/integration/directories/test_directories.py +13 −5 Original line number Diff line number Diff line Loading @@ -220,11 +220,19 @@ def test_extended(gkfs_daemon, gkfs_shell, gkfs_client): ret = gkfs_client.write(file_a, buf, 1) assert ret.retval == 1 preload = 'LIBGKFS_HOSTS_FILE='+str(gkfs_client._patched_env['LIBGKFS_HOSTS_FILE'])+' LD_PRELOAD='+str(gkfs_client._preload_library) stream = os.popen(preload+' '+str(gkfs_daemon._workspace.bindirs[1])+'/sfind '+str(topdir)+' -M '+str(gkfs_daemon.mountdir)+' -S 1 -name "*_k*"'); output = stream.read() assert output == "MATCHED 0/4\n" cmd = gkfs_shell.sfind( topdir, '-M', gkfs_daemon.mountdir, '-S', 1, '-name', '*_k*' ) assert cmd.exit_code == 0 assert cmd.stdout.decode() == "MATCHED 0/4\n" @pytest.mark.skip(reason="invalid errno returned on success") @pytest.mark.parametrize("directory_path", Loading
tests/integration/harness/gkfs.py +45 −6 Original line number Diff line number Diff line Loading @@ -140,6 +140,32 @@ def _process_exists(pid): return True def _find_search_paths(additional_paths=None): """ Return the entire list of search paths available to the process. If additional_paths is not provided, $PATH env is returned. Parameters ---------- additional_paths: `list` If provided, additional paths that should be used for searching before falling back to the contents of $PATH. Returns ------- A list containing the paths that should be searched for commands. """ paths_to_search = [] if isinstance(additional_paths, (tuple, list)): paths_to_search.extend(additional_paths) env_paths = os.environ.get("PATH", "").split(os.pathsep) paths_to_search.extend(env_paths) return paths_to_search class FwdDaemonCreator: """ Factory that allows tests to create forwarding daemons in a workspace. Loading Loading @@ -439,7 +465,7 @@ class ShellClient: def __init__(self, workspace): self._workspace = workspace self._cmd = sh.Command("bash") self._search_paths = _find_search_paths(self._workspace.bindirs) self._env = os.environ.copy() libdirs = ':'.join( Loading Loading @@ -552,6 +578,8 @@ class ShellClient: if intercept_shell: logger.debug(f"patched env: {self._patched_env}") self._cmd = sh.Command("bash") # 'sh' raises an exception if the return code is not zero; # since we'd rather check for return codes explictly, we # whitelist all exit codes from 1 to 255 as 'ok' using the Loading Loading @@ -608,19 +636,27 @@ class ShellClient: extra properties to it. """ bash_c_args = f"{cmd} {' '.join(str(a) for a in args)}" logger.debug(f"running bash") logger.debug(f"cmd: bash -c '{bash_c_args}'") found_cmd = sh.which(cmd, self._search_paths) if not found_cmd: raise sh.CommandNotFound(cmd) self._cmd = sh.Command(found_cmd) logger.debug(f"running program") logger.debug(f"cmd: {cmd} {' '.join(str(a) for a in args)}") logger.debug(f"search_paths: {':'.join(str(p) for p in self._search_paths)}") logger.debug(f"timeout: {timeout} seconds") logger.debug(f"timeout_signal: {signal.Signals(timeout_signal).name}") logger.debug(f"patched env:\n{pformat(self._patched_env)}") # 'sh' raises an exception if the return code is not zero; # since we'd rather check for return codes explictly, we # whitelist all exit codes from 1 to 255 as 'ok' using the # _ok_code argument proc = self._cmd('-c', bash_c_args, proc = self._cmd( args, _env = self._env, # _out=sys.stdout, # _err=sys.stderr, Loading @@ -629,6 +665,9 @@ class ShellClient: # _ok_code=list(range(0, 256)) ) logger.debug(f"program stdout: {proc.stdout}") logger.debug(f"program stderr: {proc.stderr}") return ShellCommand(cmd, proc) def __getattr__(self, name): Loading