Actually connect

This commit is contained in:
Bojan Serafimov
2022-09-13 15:29:36 -04:00
parent ecbda94790
commit cd8c96233f
3 changed files with 46 additions and 18 deletions

View File

@@ -1,3 +1,5 @@
from contextlib import closing
from fixtures.neon_fixtures import NeonEnvBuilder, ReplayBin
@@ -10,15 +12,30 @@ def test_trace_replay(neon_env_builder: NeonEnvBuilder, replay_bin: ReplayBin):
"trace_read_requests": "true",
}
)
timeline = env.neon_cli.create_timeline("test_trace_replay", tenant_id=tenant)
env.neon_cli.create_timeline("test_trace_replay", tenant_id=tenant)
pg = env.postgres.create_start("test_trace_replay", "main", tenant)
pg.safe_psql("select 1;")
pg.safe_psql("select 1;")
pg.safe_psql("select 1;")
pg.safe_psql("select 1;")
trace_path = env.repo_dir / "traces" / str(tenant) / str(timeline) / str(timeline)
assert trace_path.exists()
with closing(pg.connect()) as conn:
with conn.cursor() as cur:
cur.execute("create table t (i integer);")
cur.execute(f"insert into t values (generate_series(1,{10000}));")
cur.execute("select count(*) from t;")
# Stop pg so we drop the connection and flush the traces
pg.stop()
# TODO turn off tracing now?
# trace_path = env.repo_dir / "traces" / str(tenant) / str(timeline) / str(timeline)
# assert trace_path.exists()
print("replaying")
ps_connstr = env.pageserver.connstr().replace("'", "\\'")
ps_connstr = env.pageserver.connstr()
# ps_connstr = "host=localhost port=15004 dbname=postgres user=neon_admin"
output = replay_bin.replay_all(ps_connstr)
print(output)