mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-07 05:22:56 +00:00
The CI times out after 10 minutes of no output. It's annoying if a test hangs and is killed by the CI timeout, because you don't get information about which test was running. Try to avoid that, by adding a slightly smaller timeout in pytest itself. You can override it on a per-test basis if needed, but let's try to keep our tests shorter than that. For the Postgres regression tests, use a longer 30 minute timeout. They're not really a single test, but many tests wrapped in a single pytest test. It's OK for them to run longer in aggregate, each Postgres test is still fairly short.
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
import pytest
|
|
from contextlib import closing
|
|
from fixtures.zenith_fixtures import ZenithEnvBuilder
|
|
from fixtures.benchmark_fixture import ZenithBenchmarker
|
|
|
|
|
|
# This test sometimes runs for longer than the global 5 minute timeout.
|
|
@pytest.mark.timeout(600)
|
|
def test_startup(zenith_env_builder: ZenithEnvBuilder, zenbenchmark: ZenithBenchmarker):
|
|
zenith_env_builder.num_safekeepers = 3
|
|
env = zenith_env_builder.init_start()
|
|
|
|
# Start
|
|
env.zenith_cli.create_branch('test_startup')
|
|
with zenbenchmark.record_duration("startup_time"):
|
|
pg = env.postgres.create_start('test_startup')
|
|
pg.safe_psql("select 1;")
|
|
|
|
# Restart
|
|
pg.stop_and_destroy()
|
|
with zenbenchmark.record_duration("restart_time"):
|
|
pg.create_start('test_startup')
|
|
pg.safe_psql("select 1;")
|
|
|
|
# Fill up
|
|
num_rows = 1000000 # 30 MB
|
|
num_tables = 100
|
|
with closing(pg.connect()) as conn:
|
|
with conn.cursor() as cur:
|
|
for i in range(num_tables):
|
|
cur.execute(f'create table t_{i} (i integer);')
|
|
cur.execute(f'insert into t_{i} values (generate_series(1,{num_rows}));')
|
|
|
|
# Read
|
|
with zenbenchmark.record_duration("read_time"):
|
|
pg.safe_psql("select * from t_0;")
|
|
|
|
# Read again
|
|
with zenbenchmark.record_duration("second_read_time"):
|
|
pg.safe_psql("select * from t_0;")
|
|
|
|
# Restart
|
|
pg.stop_and_destroy()
|
|
with zenbenchmark.record_duration("restart_with_data"):
|
|
pg.create_start('test_startup')
|
|
pg.safe_psql("select 1;")
|
|
|
|
# Read
|
|
with zenbenchmark.record_duration("read_after_restart"):
|
|
pg.safe_psql("select * from t_0;")
|