From 6d30e21a326ed3d323bd563cbdecb15ee1d95ec9 Mon Sep 17 00:00:00 2001 From: Dmitry Ivanov Date: Fri, 26 Aug 2022 20:42:32 +0300 Subject: [PATCH] Fix proxy tests (#2343) There might be different psql & locale configurations, therefore we should explicitly reset them to defaults. --- test_runner/batch_others/test_proxy.py | 17 +++-------------- test_runner/fixtures/neon_fixtures.py | 13 ++++++++----- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/test_runner/batch_others/test_proxy.py b/test_runner/batch_others/test_proxy.py index 4ffd458b22..1efb795140 100644 --- a/test_runner/batch_others/test_proxy.py +++ b/test_runner/batch_others/test_proxy.py @@ -115,33 +115,22 @@ async def test_psql_session_id(vanilla_pg: VanillaPostgres, link_proxy: NeonProx Step 4. assert that select 1 has been executed correctly. """ - # Step 1. psql = PSQL( host=link_proxy.host, port=link_proxy.proxy_port, ) - proc = await psql.run("select 1") + proc = await psql.run("select 42") - # Step 2.1 uri_prefix = link_proxy.link_auth_uri_prefix line_str = await get_uri_line_from_process_welcome_notice(uri_prefix, proc) - # step 2.2 psql_session_id = get_session_id_from_uri_line(uri_prefix, line_str) log.info(f"Parsed psql_session_id='{psql_session_id}' from Neon welcome message.") - # Step 3. create_and_send_db_info(vanilla_pg, psql_session_id, link_proxy.mgmt_port) - # Step 4. - # Expecting proxy output:: - # b' ?column? \n' - # b'----------\n' - # b' 1\n' - # b'(1 row)\n' - out_bytes = await proc.stdout.read() - expected_out_bytes = b" ?column? \n----------\n 1\n(1 row)\n\n" - assert out_bytes == expected_out_bytes + out = (await proc.stdout.read()).decode("utf-8").strip() + assert out == "42" # Pass extra options to the server. diff --git a/test_runner/fixtures/neon_fixtures.py b/test_runner/fixtures/neon_fixtures.py index 3af0cf4dcb..ad686e1fce 100644 --- a/test_runner/fixtures/neon_fixtures.py +++ b/test_runner/fixtures/neon_fixtures.py @@ -1738,13 +1738,16 @@ class PSQL: self.database_url = f"postgres://{host}:{port}/main?options=project%3Dgeneric-project-name" async def run(self, query=None): - run_args = [self.path, self.database_url] - run_args += ["--command", query] if query is not None else [] + run_args = [self.path, "--no-psqlrc", "--quiet", "--tuples-only", self.database_url] + if query is not None: + run_args += ["--command", query] - cmd_line = subprocess.list2cmdline(run_args) - log.info(f"Run psql: {cmd_line}") + log.info(f"Run psql: {subprocess.list2cmdline(run_args)}") return await asyncio.create_subprocess_exec( - *run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE + *run_args, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + env={"LC_ALL": "C", **os.environ}, # one locale to rule them all )