From 5587b3a27c2ea42c6ef152f6736d39b643b36a3c Mon Sep 17 00:00:00 2001 From: Bojan Serafimov Date: Mon, 4 Jul 2022 13:09:50 -0400 Subject: [PATCH] Check all dbs --- .../batch_others/test_complete_basebackup.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/test_runner/batch_others/test_complete_basebackup.py b/test_runner/batch_others/test_complete_basebackup.py index 7faeeaf471..7506b00e2a 100644 --- a/test_runner/batch_others/test_complete_basebackup.py +++ b/test_runner/batch_others/test_complete_basebackup.py @@ -6,19 +6,26 @@ from pathlib import Path def get_rel_paths(pg_bin, restored_dir): - """Return list of relation paths""" + """Yeild list of relation paths""" port = "55439" # Probably free with VanillaPostgres(restored_dir, pg_bin, port, init=False) as vanilla_pg: vanilla_pg.configure([f"port={port}"]) vanilla_pg.start() - query = "select pg_relation_filepath(oid) from pg_class" + query = "select datname from pg_database" result = vanilla_pg.safe_psql(query, user="cloud_admin") - return [ - row[0] - for row in result - if row[0] is not None # TODO why is it None sometimes? - ] + databases = [row[0] for row in result] + + for database in databases: + if database == "template0": + continue # TODO this one doesn't take connections + + query = "select pg_relation_filepath(oid) from pg_class" + result = vanilla_pg.safe_psql(query, user="cloud_admin", dbname=database) + for row in result: + filepath = row[0] + if filepath is not None: + yield filepath def test_complete(pg_bin): @@ -47,7 +54,8 @@ def test_complete(pg_bin): os.remove(empty_file) # Get the nodes - paths = get_rel_paths(pg_bin, restored_dir) + paths = list(get_rel_paths(pg_bin, restored_dir)) + print(paths) # Touch files that don't exist for path in paths: @@ -70,7 +78,6 @@ def test_complete(pg_bin): exists = os.path.exists(empty_file) if not exists: print(f"Deleted empty file {empty_file} was not recreated") - exit(1) # Pack completed tar, being careful to preserve relative file names tmp_tar_name = "tmp.tar"