mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-23 06:09:59 +00:00
test_runner: improve wait_until (#9936)
Improves `wait_until` by: * Use `timeout` instead of `iterations`. This allows changing the timeout/interval parameters independently. * Make `timeout` and `interval` optional (default 20s and 0.5s). Most callers don't care. * Only output status every 1s by default, and add optional `status_interval` parameter. * Remove `show_intermediate_error`, this was always emitted anyway. Most callers have been updated to use the defaults, except where they had good reason otherwise.
This commit is contained in:
@@ -60,24 +60,22 @@ def test_clickhouse(remote_pg: RemotePostgres):
|
||||
"SETTINGS materialized_postgresql_tables_list = 'table1';"
|
||||
)
|
||||
wait_until(
|
||||
120,
|
||||
0.5,
|
||||
lambda: query_clickhouse(
|
||||
client,
|
||||
"select * from db1_postgres.table1 order by 1",
|
||||
"ee600d8f7cd05bd0b169fa81f44300a9dd10085a",
|
||||
),
|
||||
timeout=60,
|
||||
)
|
||||
cur.execute("INSERT INTO table1 (id, column1) VALUES (3, 'ghi'), (4, 'jkl');")
|
||||
conn.commit()
|
||||
wait_until(
|
||||
120,
|
||||
0.5,
|
||||
lambda: query_clickhouse(
|
||||
client,
|
||||
"select * from db1_postgres.table1 order by 1",
|
||||
"9eba2daaf7e4d7d27ac849525f68b562ab53947d",
|
||||
),
|
||||
timeout=60,
|
||||
)
|
||||
log.debug("Sleeping before final checking if Neon is still alive")
|
||||
time.sleep(3)
|
||||
|
||||
@@ -148,14 +148,12 @@ def test_debezium(debezium):
|
||||
)
|
||||
conn.commit()
|
||||
wait_until(
|
||||
100,
|
||||
0.5,
|
||||
lambda: get_kafka_msg(
|
||||
consumer,
|
||||
ts_ms,
|
||||
after={"first_name": "John", "last_name": "Dow", "email": "johndow@example.com"},
|
||||
),
|
||||
show_intermediate_error=True,
|
||||
timeout=60,
|
||||
)
|
||||
ts_ms = time.time() * 1000
|
||||
log.info("Insert 2 ts_ms: %s", ts_ms)
|
||||
@@ -165,28 +163,24 @@ def test_debezium(debezium):
|
||||
)
|
||||
conn.commit()
|
||||
wait_until(
|
||||
100,
|
||||
0.5,
|
||||
lambda: get_kafka_msg(
|
||||
consumer,
|
||||
ts_ms,
|
||||
after={"first_name": "Alex", "last_name": "Row", "email": "alexrow@example.com"},
|
||||
),
|
||||
show_intermediate_error=True,
|
||||
timeout=60,
|
||||
)
|
||||
ts_ms = time.time() * 1000
|
||||
log.info("Update ts_ms: %s", ts_ms)
|
||||
cur.execute("update inventory.customers set first_name = 'Alexander' where id = 2")
|
||||
conn.commit()
|
||||
wait_until(
|
||||
100,
|
||||
0.5,
|
||||
lambda: get_kafka_msg(
|
||||
consumer,
|
||||
ts_ms,
|
||||
after={"first_name": "Alexander"},
|
||||
),
|
||||
show_intermediate_error=True,
|
||||
timeout=60,
|
||||
)
|
||||
time.sleep(3)
|
||||
cur.execute("select 1")
|
||||
|
||||
Reference in New Issue
Block a user