mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-26 15:49:58 +00:00
Add tests for different Postgres client libraries (#2008)
* Add tests for different postgres clients * test/fixtures: sanitize test name for test_output_dir * test/fixtures: do not look for etcd before runtime * Add workflow for testing Postgres client libraries
This commit is contained in:
committed by
GitHub
parent
844832ffe4
commit
05f6a1394d
8
test_runner/pg_clients/python/asyncpg/Dockerfile
Normal file
8
test_runner/pg_clients/python/asyncpg/Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM python:3.10
|
||||
WORKDIR /source
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN python3 -m pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
CMD ["python3", "asyncpg_example.py"]
|
||||
30
test_runner/pg_clients/python/asyncpg/asyncpg_example.py
Executable file
30
test_runner/pg_clients/python/asyncpg/asyncpg_example.py
Executable file
@@ -0,0 +1,30 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
import asyncpg
|
||||
|
||||
|
||||
async def run(**kwargs) -> asyncpg.Record:
|
||||
conn = await asyncpg.connect(
|
||||
**kwargs,
|
||||
statement_cache_size=0, # Prepared statements doesn't work pgbouncer
|
||||
)
|
||||
rv = await conn.fetchrow("SELECT 1")
|
||||
await conn.close()
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
kwargs = {
|
||||
k.lstrip("NEON_").lower(): v
|
||||
for k in ("NEON_HOST", "NEON_DATABASE", "NEON_USER", "NEON_PASSWORD")
|
||||
if (v := os.environ.get(k, None)) is not None
|
||||
}
|
||||
|
||||
loop = asyncio.new_event_loop()
|
||||
row = loop.run_until_complete(run(**kwargs))
|
||||
|
||||
print(row[0])
|
||||
1
test_runner/pg_clients/python/asyncpg/requirements.txt
Normal file
1
test_runner/pg_clients/python/asyncpg/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
asyncpg==0.25.0
|
||||
8
test_runner/pg_clients/python/pg8000/Dockerfile
Normal file
8
test_runner/pg_clients/python/pg8000/Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
||||
FROM python:3.10
|
||||
WORKDIR /source
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN python3 -m pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
CMD ["python3", "pg8000_example.py"]
|
||||
0
test_runner/pg_clients/python/pg8000/README.md
Normal file
0
test_runner/pg_clients/python/pg8000/README.md
Normal file
23
test_runner/pg_clients/python/pg8000/pg8000_example.py
Executable file
23
test_runner/pg_clients/python/pg8000/pg8000_example.py
Executable file
@@ -0,0 +1,23 @@
|
||||
#! /usr/bin/env python3
|
||||
|
||||
import os
|
||||
import ssl
|
||||
|
||||
import pg8000.dbapi
|
||||
|
||||
if __name__ == "__main__":
|
||||
kwargs = {
|
||||
k.lstrip("NEON_").lower(): v
|
||||
for k in ("NEON_HOST", "NEON_DATABASE", "NEON_USER", "NEON_PASSWORD")
|
||||
if (v := os.environ.get(k, None)) is not None
|
||||
}
|
||||
conn = pg8000.dbapi.connect(
|
||||
**kwargs,
|
||||
ssl_context=True,
|
||||
)
|
||||
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT 1")
|
||||
row = cursor.fetchone()
|
||||
print(row[0])
|
||||
conn.close()
|
||||
1
test_runner/pg_clients/python/pg8000/requirements.txt
Normal file
1
test_runner/pg_clients/python/pg8000/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
pg8000==1.29.1
|
||||
Reference in New Issue
Block a user