mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-14 08:52:56 +00:00
Merge batch_others and batch_pg_regress. The original idea was to split all the python tests into multiple "batches" and run each batch in parallel as a separate CI job. However, the batch_pg_regress batch was pretty short compared to all the tests in batch_others. We could split batch_others into multiple batches, but it actually seems better to just treat them as one big pool of tests and use pytest's handle the parallelism on its own. If we need to split them across multiple nodes in the future, we could use pytest-shard or something else, instead of managing the batches ourselves. Merge test_neon_regress.py, test_pg_regress.py and test_isolation.py into one file, test_pg_regress.py. Seems more clear to group all pg_regress-based tests into one file, now that they would all be in the same directory.
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
import pytest
|
|
from fixtures.log_helper import log
|
|
from fixtures.neon_fixtures import NeonEnv, NeonEnvBuilder, NeonPageserverHttpClient
|
|
|
|
|
|
def check_tenant(env: NeonEnv, pageserver_http: NeonPageserverHttpClient):
|
|
tenant_id, timeline_id = env.neon_cli.create_tenant()
|
|
pg = env.postgres.create_start("main", tenant_id=tenant_id)
|
|
# we rely upon autocommit after each statement
|
|
res_1 = pg.safe_psql_many(
|
|
queries=[
|
|
"CREATE TABLE t(key int primary key, value text)",
|
|
"INSERT INTO t SELECT generate_series(1,100000), 'payload'",
|
|
"SELECT sum(key) FROM t",
|
|
]
|
|
)
|
|
|
|
assert res_1[-1][0] == (5000050000,)
|
|
# TODO check detach on live instance
|
|
log.info("stopping compute")
|
|
pg.stop()
|
|
log.info("compute stopped")
|
|
|
|
pg.start()
|
|
res_2 = pg.safe_psql("SELECT sum(key) FROM t")
|
|
assert res_2[0] == (5000050000,)
|
|
|
|
pg.stop()
|
|
pageserver_http.tenant_detach(tenant_id)
|
|
|
|
|
|
@pytest.mark.parametrize("num_timelines,num_safekeepers", [(3, 1)])
|
|
def test_normal_work(neon_env_builder: NeonEnvBuilder, num_timelines: int, num_safekeepers: int):
|
|
"""
|
|
Basic test:
|
|
* create new tenant with a timeline
|
|
* write some data
|
|
* ensure that it was successfully written
|
|
* restart compute
|
|
* check that the data is there
|
|
* stop compute
|
|
* detach timeline
|
|
|
|
Repeat check for several tenants/timelines.
|
|
"""
|
|
|
|
neon_env_builder.num_safekeepers = num_safekeepers
|
|
env = neon_env_builder.init_start()
|
|
pageserver_http = env.pageserver.http_client()
|
|
|
|
for _ in range(num_timelines):
|
|
check_tenant(env, pageserver_http)
|