hardcode template0 files

This commit is contained in:
Bojan Serafimov
2022-07-04 13:21:25 -04:00
parent 5587b3a27c
commit 20694a9285

View File

@@ -5,6 +5,11 @@ import shutil
from pathlib import Path
template0_files = [3430, 3256, 3429, 3118, 4171, 4165, 12960, 3576, 6102, 826, 3466, 12965, 12955, 4173, 3439,
2830, 4169, 1418, 3501, 4153, 4159, 2604, 4145, 4155, 1417, 2832, 2613, 2620, 3381, 6175, 6104, 12970, 4157,
4143, 2611, 2224, 6106, 4167, 2336, 4163, 2995, 3350, 4147, 2328, 2834, 3598, 4151, 4149, 3596]
def get_rel_paths(pg_bin, restored_dir):
"""Yeild list of relation paths"""
port = "55439" # Probably free
@@ -12,13 +17,15 @@ def get_rel_paths(pg_bin, restored_dir):
vanilla_pg.configure([f"port={port}"])
vanilla_pg.start()
query = "select datname from pg_database"
result = vanilla_pg.safe_psql(query, user="cloud_admin")
databases = [row[0] for row in result]
query = "select oid, datname from pg_database"
oid_dbname_pairs = vanilla_pg.safe_psql(query, user="cloud_admin")
for database in databases:
for oid, database in oid_dbname_pairs:
if database == "template0":
continue # TODO this one doesn't take connections
# We can't connect to template0, but it's always the same
for rel in template0_files:
yield f"base/{oid}/{rel}"
continue
query = "select pg_relation_filepath(oid) from pg_class"
result = vanilla_pg.safe_psql(query, user="cloud_admin", dbname=database)
@@ -55,7 +62,6 @@ def test_complete(pg_bin):
# Get the nodes
paths = list(get_rel_paths(pg_bin, restored_dir))
print(paths)
# Touch files that don't exist
for path in paths:
@@ -78,6 +84,7 @@ def test_complete(pg_bin):
exists = os.path.exists(empty_file)
if not exists:
print(f"Deleted empty file {empty_file} was not recreated")
assert(exists)
# Pack completed tar, being careful to preserve relative file names
tmp_tar_name = "tmp.tar"