Skip to content
Snippets Groups Projects
Commit fcd8c477 authored by Dmitry Ivanov's avatar Dmitry Ivanov
Browse files

chore(pgproto): add a test for large messages

parent 7af06f74
No related branches found
No related tags found
No related merge requests found
Pipeline #67213 failed
from conftest import Postgres
import psycopg
def test_large_messages(postgres: Postgres):
user = "postgres"
password = "P@ssw0rd"
host = postgres.host
port = postgres.port
postgres.instance.sql(f"CREATE USER \"{user}\" WITH PASSWORD '{password}' USING md5")
postgres.instance.sql(f'GRANT CREATE TABLE TO "{user}"', sudo=True)
conn = psycopg.connect(f"user={user} password={password} host={host} port={port} sslmode=disable")
conn.autocommit = True
conn.execute(
"""
create table "t" (
"id" int not null primary key,
"value" text
)
option (timeout = 3);
"""
)
count = 100
payload = "A" * 2**17 # 128 KiB
# check if pgproto can read messages that are larger than the initial buffer size
dml = """ INSERT INTO "t" VALUES """
# TODO: dml += ",".join(f""" ({i}, %(payload)s::text """ for i in range(count))
dml += ",".join(f""" ({i}, cast (%(payload)s as text)) """ for i in range(count))
conn.execute(dml, {"payload": payload})
# check if pgproto can send messages that are larger than the initial buffer size
cur = conn.execute(""" SELECT * FROM "t" """)
assert sorted(cur.fetchall()) == [(i, payload) for i in range(count)]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment