mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-21 07:00:38 +00:00
Send tar
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from fixtures.neon_fixtures import NeonEnvBuilder
|
||||
from uuid import UUID
|
||||
import tarfile
|
||||
import os
|
||||
|
||||
|
||||
@@ -14,6 +15,7 @@ def test_import(neon_env_builder,
|
||||
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")
|
||||
basebackup_tar_path = os.path.join(test_output_dir, "basebackup.tar.gz")
|
||||
os.mkdir(basebackup_dir)
|
||||
|
||||
# Create a repo, put some data in, take basebackup, and shut it down
|
||||
@@ -28,17 +30,21 @@ def test_import(neon_env_builder,
|
||||
timeline = pg.safe_psql("show neon.timeline_id")[0][0]
|
||||
pg_bin.run(["pg_basebackup", "-d", pg.connstr(), "-D", basebackup_dir])
|
||||
|
||||
# compress basebackup
|
||||
with tarfile.open(basebackup_tar_path, "w:gz") as tf:
|
||||
# TODO match iteration order to what pageserver would do
|
||||
tf.add(basebackup_dir)
|
||||
|
||||
# Create a new repo, load the basebackup into it, and check that data is there
|
||||
with NeonEnvBuilder(destination_repo_dir, port_distributor, default_broker, mock_s3_server) as builder:
|
||||
env = builder.init_start()
|
||||
# TODO do everything from neon_cli instead
|
||||
env.pageserver.safe_psql(f"import {tenant} {timeline}")
|
||||
env.neon_cli.raw_cli([
|
||||
"timeline",
|
||||
"import",
|
||||
"--tenant-id", tenant,
|
||||
"--timeline-id", timeline,
|
||||
"--node-name", node_name,
|
||||
"--tarfile", basebackup_tar_path,
|
||||
])
|
||||
pg = env.postgres.create_start(node_name, tenant_id=UUID(tenant))
|
||||
assert pg.safe_psql('select count(*) from t') == [(300000, )]
|
||||
# pg = env.postgres.create_start(node_name, tenant_id=UUID(tenant))
|
||||
# assert pg.safe_psql('select count(*) from t') == [(300000, )]
|
||||
|
||||
Reference in New Issue
Block a user