From 99260b18ab9075a5bc9de26ee11936c505d028cf Mon Sep 17 00:00:00 2001 From: Bojan Serafimov Date: Tue, 7 Jun 2022 19:16:29 -0400 Subject: [PATCH] Add test --- test_runner/batch_others/test_import.py | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test_runner/batch_others/test_import.py diff --git a/test_runner/batch_others/test_import.py b/test_runner/batch_others/test_import.py new file mode 100644 index 0000000000..824b5236a8 --- /dev/null +++ b/test_runner/batch_others/test_import.py @@ -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, )]