mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-21 07:00:38 +00:00
Add test
This commit is contained in:
36
test_runner/batch_others/test_import.py
Normal file
36
test_runner/batch_others/test_import.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from fixtures.neon_fixtures import NeonEnvBuilder
|
||||
import os
|
||||
|
||||
|
||||
def test_import(neon_env_builder,
|
||||
port_distributor,
|
||||
default_broker,
|
||||
mock_s3_server,
|
||||
test_output_dir,
|
||||
pg_bin):
|
||||
"""Move a timeline to a new neon stack using pg_basebackup as interface."""
|
||||
source_repo_dir = os.path.join(test_output_dir, "source_repo")
|
||||
destination_repo_dir = os.path.join(test_output_dir, "destination_repo")
|
||||
basebackup_dir = os.path.join(test_output_dir, "basebackup")
|
||||
os.mkdir(basebackup_dir)
|
||||
|
||||
# Create a repo, put some data in, take basebackup, and shut it down
|
||||
with NeonEnvBuilder(source_repo_dir, port_distributor, default_broker, mock_s3_server) as builder:
|
||||
env = builder.init_start()
|
||||
env.neon_cli.create_branch("test_import")
|
||||
pg = env.postgres.create_start('test_import')
|
||||
pg.safe_psql("create table t as select generate_series(1,300000)")
|
||||
assert pg.safe_psql('select count(*) from t') == [(300000, )]
|
||||
|
||||
tenant = pg.safe_psql("show neon.tenant_id")[0][0]
|
||||
timeline = pg.safe_psql("SHOW neon.timeline_id")[0][0]
|
||||
pg_bin.run(["pg_basebackup", "-d", pg.connstr(), "-D", basebackup_dir])
|
||||
|
||||
# Create a new repo, and load the basebackup into it
|
||||
with NeonEnvBuilder(destination_repo_dir, port_distributor, default_broker, mock_s3_server) as builder:
|
||||
env = builder.init_start()
|
||||
# TODO attach tenant.timeline with given basebackup
|
||||
|
||||
# TODO
|
||||
# pg = ...
|
||||
# assert pg.safe_psql('select count(*) from t') == [(300000, )]
|
||||
Reference in New Issue
Block a user