mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-15 17:32:56 +00:00
## Problem Currently our testing environment only supports running a single pageserver at a time. This is insufficient for testing failover and migrations. - Dependency of writing tests for #5207 ## Summary of changes - `neon_local` and `neon_fixture` now handle multiple pageservers - This is a breaking change to the `.neon/config` format: any local environments will need recreating - Existing tests continue to work unchanged: - The default number of pageservers is 1 - `NeonEnv.pageserver` is now a helper property that retrieves the first pageserver if there is only one, else throws. - Pageserver data directories are now at `.neon/pageserver_{n}` where n is 1,2,3... - Compatibility tests get some special casing to migrate neon_local configs: these are not meant to be backward/forward compatible, but they were treated that way by the test.
56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
from fixtures.neon_fixtures import (
|
|
NeonEnvBuilder,
|
|
PgBin,
|
|
VanillaPostgres,
|
|
)
|
|
from fixtures.port_distributor import PortDistributor
|
|
from fixtures.types import TenantId, TimelineId
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
sys.platform != "linux",
|
|
reason="restore_from_wal.sh supports only Linux",
|
|
)
|
|
def test_wal_restore(
|
|
neon_env_builder: NeonEnvBuilder,
|
|
pg_bin: PgBin,
|
|
test_output_dir: Path,
|
|
port_distributor: PortDistributor,
|
|
base_dir: Path,
|
|
pg_distrib_dir: Path,
|
|
):
|
|
env = neon_env_builder.init_start()
|
|
env.neon_cli.create_branch("test_wal_restore")
|
|
endpoint = env.endpoints.create_start("test_wal_restore")
|
|
endpoint.safe_psql("create table t as select generate_series(1,300000)")
|
|
tenant_id = TenantId(endpoint.safe_psql("show neon.tenant_id")[0][0])
|
|
timeline_id = TimelineId(endpoint.safe_psql("show neon.timeline_id")[0][0])
|
|
env.pageserver.stop()
|
|
port = port_distributor.get_port()
|
|
data_dir = test_output_dir / "pgsql.restored"
|
|
with VanillaPostgres(
|
|
data_dir, PgBin(test_output_dir, env.pg_distrib_dir, env.pg_version), port
|
|
) as restored:
|
|
pg_bin.run_capture(
|
|
[
|
|
str(base_dir / "libs" / "utils" / "scripts" / "restore_from_wal.sh"),
|
|
str(pg_distrib_dir / f"v{env.pg_version}/bin"),
|
|
str(
|
|
test_output_dir
|
|
/ "repo"
|
|
/ "safekeepers"
|
|
/ "sk1"
|
|
/ str(tenant_id)
|
|
/ str(timeline_id)
|
|
),
|
|
str(data_dir),
|
|
str(port),
|
|
]
|
|
)
|
|
restored.start()
|
|
assert restored.safe_psql("select count(*) from t", user="cloud_admin") == [(300000,)]
|