- Notifications
You must be signed in to change notification settings - Fork35
Closed
Description
When I run testgres tests through pytest from terminal,TestgresTests.test_simple_with_bin_dir
fails because it uses RemoteOperations object instead LocalOperations object.
A problem in the following line:
testgres/tests/test_simple_remote.py
Lines 58 to 59 in5e9ecbc
os_ops=RemoteOperations(conn_params) | |
testgres_config.set_os_ops(os_ops=os_ops) |
If I commenttestgres_config.set_os_ops
,TestgresTests.test_simple_with_bin_dir
works without any problems.
venvdima@ubuntu-work-01:~/MY/GitHub2/testgres/work-D20241204_001--tests-2$ python -B -m pytest -n 1 -l -v -k "test_simple_with_bin_dir"============================================================ test session starts ============================================================platform linux -- Python 3.12.1, pytest-8.3.4, pluggy-1.5.0 -- /home/dima/MY/GitHub2/testgres/work-D20241204_001--tests-2/venv/bin/pythoncachedir: .pytest_cacherootdir: /home/dima/MY/GitHub2/testgres/work-D20241204_001--tests-2configfile: pytest.initestpaths: ./testsplugins: cov-6.0.0, xdist-3.6.11 worker [1 item] scheduling tests via LoadSchedulingtests/test_simple.py::TestgresTests::test_simple_with_bin_dir [gw0] [100%] FAILED tests/test_simple.py::TestgresTests::test_simple_with_bin_dir ================================================================= FAILURES ==================================================================__________________________________________________ TestgresTests.test_simple_with_bin_dir ___________________________________________________[gw0] linux -- Python 3.12.1 /home/dima/MY/GitHub2/testgres/work-D20241204_001--tests-2/venv/bin/pythonself = <test_simple.TestgresTests testMethod=test_simple_with_bin_dir> def test_simple_with_bin_dir(self): with get_new_node() as node: node.init().start() bin_dir = node.bin_dir app = NodeApp() correct_bin_dir = app.make_simple(base_dir=node.base_dir, bin_dir=bin_dir) correct_bin_dir.slow_start() correct_bin_dir.safe_psql("SELECT 1;") try:> wrong_bin_dir = app.make_empty(base_dir=node.base_dir, bin_dir="wrong/path")app = <testgres.node.NodeApp object at 0x7fbadcbe5040>bin_dir = '/usr/local/pgsql/bin'correct_bin_dir = PostgresNode(name='testgres-6599ca75-42a4-469f-970a-965dcd306ed6', port=8919, base_dir='/home/dima/tgsn_4vzsO')node = PostgresNode(name='testgres-76ecfe03-ef28-4707-8da2-a1636212542b', port=45088, base_dir='/home/dima/tgsn_4vzsO')self = <test_simple.TestgresTests testMethod=test_simple_with_bin_dir>tests/test_simple.py:1058: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _testgres/node.py:1748: in make_empty node = PostgresNode(base_dir=real_base_dir, port=port, bin_dir=bin_dir) base_dir = '/home/dima/tgsn_4vzsO' bin_dir = 'wrong/path' port = None real_base_dir = '/home/dima/tgsn_4vzsO' self = <testgres.node.NodeApp object at 0x7fbadcbe5040>testgres/node.py:141: in __init__ self._pg_version = PgVer(get_pg_version(bin_dir)) base_dir = '/home/dima/tgsn_4vzsO' bin_dir = 'wrong/path' conn_params = <testgres.operations.os_ops.ConnectionParams object at 0x7fbadc68b500> name = None port = None prefix = None self = <[AttributeError("'PostgresNode' object has no attribute 'name'") raised in repr()] PostgresNode object at 0x7fbadcbe5e50>testgres/utils.py:183: in get_pg_version raw_ver = tconf.os_ops.exec_command(_params, encoding='utf-8') _params = ['wrong/path/postgres', '--version'] bin_dir = 'wrong/path' postgres_path = 'wrong/path/postgres'_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _self = <testgres.operations.remote_ops.RemoteOperations object at 0x7fbadc2baf00>, cmd = ['wrong/path/postgres', '--version']wait_exit = False, verbose = False, expect_error = False, encoding = 'utf-8', shell = True, text = False, input = None, stdin = Nonestdout = None, stderr = None, get_process = None, timeout = None, ignore_errors = False def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False, encoding=None, shell=True, text=False, input=None, stdin=None, stdout=None, stderr=None, get_process=None, timeout=None, ignore_errors=False): """ Execute a command in the SSH session. Args: - cmd (str): The command to be executed. """ ssh_cmd = [] if isinstance(cmd, str): ssh_cmd = ['ssh', self.ssh_dest] + self.ssh_args + [cmd] elif isinstance(cmd, list): ssh_cmd = ['ssh', self.ssh_dest] + self.ssh_args + cmd process = subprocess.Popen(ssh_cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if get_process: return process try: result, error = process.communicate(input, timeout=timeout) except subprocess.TimeoutExpired: process.kill() raise ExecUtilException("Command timed out after {} seconds.".format(timeout)) exit_status = process.returncode # [2024-12-04] We called xxx.decode without any verifications within many years ... assert type(result) == bytes # noqa: E721 assert type(error) == bytes # noqa: E721 # result_b = result error_b = error if encoding: result = result.decode(encoding) error = error.decode(encoding) if expect_error: raise Exception(result, error) if not error_b: error_found = False else: error_found = exit_status != 0 or any( marker in error_b for marker in [b'error', b'Permission denied', b'fatal', b'No such file or directory'] ) assert type(error_found) == bool # noqa: E721 if not ignore_errors and error_found: message = b"Utility exited with non-zero code. Error: " if encoding: message = message.decode(encoding) assert type(message) == type(error) # noqa: E721 message += error> raise ExecUtilException(message=message, command=cmd, exit_code=exit_status, out=result)E testgres.exceptions.ExecUtilException: Utility exited with non-zero code. Error: bash: line 1: wrong/path/postgres: No such file or directoryE E Command: ['wrong/path/postgres', '--version']E Exit code: 127cmd = ['wrong/path/postgres', '--version']encoding = 'utf-8'error = 'bash: line 1: wrong/path/postgres: No such file or directory\n'error_b = b'bash: line 1: wrong/path/postgres: No such file or directory\n'error_found = Trueexit_status = 127expect_error = Falseget_process = Noneignore_errors = Falseinput = Nonemessage = 'Utility exited with non-zero code. Error: bash: line 1: wrong/path/postgres: No such file or directory\n'process = <Popen: returncode: 127 args: ['ssh', 'dima@127.0.0.1', 'wrong/path/postgres...>result = ''self = <testgres.operations.remote_ops.RemoteOperations object at 0x7fbadc2baf00>shell = Truessh_cmd = ['ssh', 'dima@127.0.0.1', 'wrong/path/postgres', '--version']stderr = Nonestdin = Nonestdout = Nonetext = Falsetimeout = Noneverbose = Falsewait_exit = Falsetestgres/operations/remote_ops.py:117: ExecUtilException
Metadata
Metadata
Assignees
Labels
No labels