Compare commits

...

2 Commits

Author SHA1 Message Date
Konstantin Knizhnik
08cf2749ca Reduce number of iteration in test_physical_replication to reduce test time 2024-05-22 11:52:31 +03:00
Konstantin Knizhnik
c85fd74d34 Fix test_physical_replication test taken in acount autocommit behaviour of psycopg 2024-04-08 17:37:48 +03:00

View File

@@ -6,7 +6,7 @@ from fixtures.neon_fixtures import NeonEnv
def test_physical_replication(neon_simple_env: NeonEnv): def test_physical_replication(neon_simple_env: NeonEnv):
env = neon_simple_env env = neon_simple_env
n_records = 100000 n_records = 10000
with env.endpoints.create_start( with env.endpoints.create_start(
branch_name="main", branch_name="main",
endpoint_id="primary", endpoint_id="primary",
@@ -18,12 +18,15 @@ def test_physical_replication(neon_simple_env: NeonEnv):
) )
time.sleep(1) time.sleep(1)
with env.endpoints.new_replica_start(origin=primary, endpoint_id="secondary") as secondary: with env.endpoints.new_replica_start(origin=primary, endpoint_id="secondary") as secondary:
with primary.connect() as p_con: p_con = primary.connect()
with p_con.cursor() as p_cur: s_con = secondary.connect()
with secondary.connect() as s_con: count = 0
with s_con.cursor() as s_cur: with p_con.cursor() as p_cur:
for pk in range(n_records): with s_con.cursor() as s_cur:
p_cur.execute("insert into t (pk) values (%s)", (pk,)) for pk in range(n_records):
s_cur.execute( p_cur.execute("insert into t (pk) values (%s)", (pk,))
"select * from t where pk=%s", (random.randrange(1, n_records),) s_cur.execute(
) "select count(*) from t where pk=%s", (random.randrange(1, n_records),)
)
count += s_cur.fetchall()[0][0]
assert count > 0