mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-14 00:42:54 +00:00
* Use logging in python tests * Use f-strings for logs * Don't log test output while running * Use only pytest logging handler * Add more info about pytest logging
40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
from contextlib import closing
|
|
from uuid import UUID
|
|
import psycopg2.extras
|
|
from fixtures.zenith_fixtures import PostgresFactory, ZenithPageserver
|
|
from fixtures.log_helper import log
|
|
|
|
def test_timeline_size(
|
|
zenith_cli, pageserver: ZenithPageserver, postgres: PostgresFactory, pg_bin
|
|
):
|
|
# Branch at the point where only 100 rows were inserted
|
|
zenith_cli.run(["branch", "test_timeline_size", "empty"])
|
|
|
|
client = pageserver.http_client()
|
|
res = client.branch_detail(UUID(pageserver.initial_tenant), "test_timeline_size")
|
|
assert res["current_logical_size"] == res["current_logical_size_non_incremental"]
|
|
|
|
pgmain = postgres.create_start("test_timeline_size")
|
|
log.info("postgres is running on 'test_timeline_size' branch")
|
|
|
|
with closing(pgmain.connect()) as conn:
|
|
with conn.cursor() as cur:
|
|
cur.execute("SHOW zenith.zenith_timeline")
|
|
|
|
# Create table, and insert the first 100 rows
|
|
cur.execute("CREATE TABLE foo (t text)")
|
|
cur.execute(
|
|
"""
|
|
INSERT INTO foo
|
|
SELECT 'long string to consume some space' || g
|
|
FROM generate_series(1, 10) g
|
|
"""
|
|
)
|
|
|
|
res = client.branch_detail(UUID(pageserver.initial_tenant), "test_timeline_size")
|
|
assert res["current_logical_size"] == res["current_logical_size_non_incremental"]
|
|
cur.execute("TRUNCATE foo")
|
|
|
|
res = client.branch_detail(UUID(pageserver.initial_tenant), "test_timeline_size")
|
|
assert res["current_logical_size"] == res["current_logical_size_non_incremental"]
|