mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-08 22:12:56 +00:00
Fix proxy tests (#2343)
There might be different psql & locale configurations, therefore we should explicitly reset them to defaults.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user