1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-07-17 07:22:20 +02:00

tests: json format for show command

This commit is contained in:
Grigory Smolkin
2018-06-02 20:35:37 +03:00
parent 8aa559b17b
commit 191d5e30e9
12 changed files with 292 additions and 181 deletions

View File

@ -427,7 +427,11 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
# @unittest.expectedFailure # @unittest.expectedFailure
# @unittest.skip("skip") # @unittest.skip("skip")
def test_replica_archive(self): def test_replica_archive(self):
"""make node without archiving, take stream backup and turn it into replica, set replica with archiving, make archive backup from replica""" """
make node without archiving, take stream backup and
turn it into replica, set replica with archiving,
make archive backup from replica
"""
fname = self.id().split('.')[3] fname = self.id().split('.')[3]
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
master = self.make_simple_node( master = self.make_simple_node(
@ -468,7 +472,9 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
after = replica.safe_psql("postgres", "SELECT * FROM t_heap") after = replica.safe_psql("postgres", "SELECT * FROM t_heap")
self.assertEqual(before, after) self.assertEqual(before, after)
# Change data on master, take FULL backup from replica, restore taken backup and check that restored data equal to original data # Change data on master, take FULL backup from replica,
# restore taken backup and check that restored data equal
# to original data
master.psql( master.psql(
"postgres", "postgres",
"insert into t_heap as select i as id, md5(i::text) as text, " "insert into t_heap as select i as id, md5(i::text) as text, "
@ -502,7 +508,9 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
after = node.safe_psql("postgres", "SELECT * FROM t_heap") after = node.safe_psql("postgres", "SELECT * FROM t_heap")
self.assertEqual(before, after) self.assertEqual(before, after)
# Change data on master, make PAGE backup from replica, restore taken backup and check that restored data equal to original data # Change data on master, make PAGE backup from replica,
# restore taken backup and check that restored data equal
# to original data
master.psql( master.psql(
"postgres", "postgres",
"insert into t_heap as select i as id, md5(i::text) as text, " "insert into t_heap as select i as id, md5(i::text) as text, "

View File

@ -29,15 +29,11 @@ class BackupTest(ProbackupTest, unittest.TestCase):
self.set_archiving(backup_dir, 'node', node) self.set_archiving(backup_dir, 'node', node)
node.start() node.start()
# full backup mode
# with open(path.join(node.logs_dir, "backup_full.log"), "wb") as backup_log:
# backup_log.write(self.backup_node(node, options=["--verbose"]))
backup_id = self.backup_node(backup_dir, 'node', node) backup_id = self.backup_node(backup_dir, 'node', node)
show_backup = self.show_pb(backup_dir, 'node')[0] show_backup = self.show_pb(backup_dir, 'node')[0]
self.assertEqual(show_backup['Status'], "OK") self.assertEqual(show_backup['status'], "OK")
self.assertEqual(show_backup['Mode'], "FULL") self.assertEqual(show_backup['backup-mode'], "FULL")
# postmaster.pid and postmaster.opts shouldn't be copied # postmaster.pid and postmaster.opts shouldn't be copied
excluded = True excluded = True
@ -61,29 +57,29 @@ class BackupTest(ProbackupTest, unittest.TestCase):
# print self.show_pb(node) # print self.show_pb(node)
show_backup = self.show_pb(backup_dir, 'node')[1] show_backup = self.show_pb(backup_dir, 'node')[1]
self.assertEqual(show_backup['Status'], "OK") self.assertEqual(show_backup['status'], "OK")
self.assertEqual(show_backup['Mode'], "PAGE") self.assertEqual(show_backup['backup-mode'], "PAGE")
# Check parent backup # Check parent backup
self.assertEqual( self.assertEqual(
backup_id, backup_id,
self.show_pb( self.show_pb(
backup_dir, 'node', backup_dir, 'node',
backup_id=show_backup['ID'])["parent-backup-id"]) backup_id=show_backup['id'])["parent-backup-id"])
# ptrack backup mode # ptrack backup mode
self.backup_node(backup_dir, 'node', node, backup_type="ptrack") self.backup_node(backup_dir, 'node', node, backup_type="ptrack")
show_backup = self.show_pb(backup_dir, 'node')[2] show_backup = self.show_pb(backup_dir, 'node')[2]
self.assertEqual(show_backup['Status'], "OK") self.assertEqual(show_backup['status'], "OK")
self.assertEqual(show_backup['Mode'], "PTRACK") self.assertEqual(show_backup['backup-mode'], "PTRACK")
# Check parent backup # Check parent backup
self.assertEqual( self.assertEqual(
page_backup_id, page_backup_id,
self.show_pb( self.show_pb(
backup_dir, 'node', backup_dir, 'node',
backup_id=show_backup['ID'])["parent-backup-id"]) backup_id=show_backup['id'])["parent-backup-id"])
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)
@ -106,7 +102,7 @@ class BackupTest(ProbackupTest, unittest.TestCase):
self.backup_node( self.backup_node(
backup_dir, 'node', node, backup_dir, 'node', node,
options=["-C"]) options=["-C"])
self.assertEqual(self.show_pb(backup_dir, 'node')[0]['Status'], "OK") self.assertEqual(self.show_pb(backup_dir, 'node')[0]['status'], "OK")
node.stop() node.stop()
# Clean after yourself # Clean after yourself
@ -162,7 +158,7 @@ class BackupTest(ProbackupTest, unittest.TestCase):
repr(e.message), self.cmd)) repr(e.message), self.cmd))
self.assertEqual( self.assertEqual(
self.show_pb(backup_dir, 'node')[0]['Status'], self.show_pb(backup_dir, 'node')[0]['status'],
"ERROR") "ERROR")
# Clean after yourself # Clean after yourself
@ -227,7 +223,7 @@ class BackupTest(ProbackupTest, unittest.TestCase):
self.assertEqual( self.assertEqual(
self.show_pb(backup_dir, 'node', backup_id)['status'], "CORRUPT") self.show_pb(backup_dir, 'node', backup_id)['status'], "CORRUPT")
self.assertEqual( self.assertEqual(
self.show_pb(backup_dir, 'node')[1]['Status'], "ERROR") self.show_pb(backup_dir, 'node')[1]['status'], "ERROR")
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)
@ -250,12 +246,12 @@ class BackupTest(ProbackupTest, unittest.TestCase):
self.backup_node( self.backup_node(
backup_dir, 'node', node, backup_dir, 'node', node,
backup_type="full", options=["-j", "4"]) backup_type="full", options=["-j", "4"])
self.assertEqual(self.show_pb(backup_dir, 'node')[0]['Status'], "OK") self.assertEqual(self.show_pb(backup_dir, 'node')[0]['status'], "OK")
self.backup_node( self.backup_node(
backup_dir, 'node', node, backup_dir, 'node', node,
backup_type="ptrack", options=["-j", "4"]) backup_type="ptrack", options=["-j", "4"])
self.assertEqual(self.show_pb(backup_dir, 'node')[0]['Status'], "OK") self.assertEqual(self.show_pb(backup_dir, 'node')[0]['status'], "OK")
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)
@ -282,11 +278,11 @@ class BackupTest(ProbackupTest, unittest.TestCase):
backup_dir, 'node', node, backup_type="full", backup_dir, 'node', node, backup_type="full",
options=["-j", "4", "--stream"]) options=["-j", "4", "--stream"])
self.assertEqual(self.show_pb(backup_dir, 'node')[0]['Status'], "OK") self.assertEqual(self.show_pb(backup_dir, 'node')[0]['status'], "OK")
self.backup_node( self.backup_node(
backup_dir, 'node', node, backup_dir, 'node', node,
backup_type="ptrack", options=["-j", "4", "--stream"]) backup_type="ptrack", options=["-j", "4", "--stream"])
self.assertEqual(self.show_pb(backup_dir, 'node')[1]['Status'], "OK") self.assertEqual(self.show_pb(backup_dir, 'node')[1]['status'], "OK")
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)
@ -342,7 +338,7 @@ class BackupTest(ProbackupTest, unittest.TestCase):
f.close f.close
self.assertTrue( self.assertTrue(
self.show_pb(backup_dir, 'node')[1]['Status'] == 'OK', self.show_pb(backup_dir, 'node')[1]['status'] == 'OK',
"Backup Status should be OK") "Backup Status should be OK")
# Clean after yourself # Clean after yourself
@ -415,7 +411,7 @@ class BackupTest(ProbackupTest, unittest.TestCase):
repr(e.message), self.cmd)) repr(e.message), self.cmd))
self.assertTrue( self.assertTrue(
self.show_pb(backup_dir, 'node')[1]['Status'] == 'ERROR', self.show_pb(backup_dir, 'node')[1]['status'] == 'ERROR',
"Backup Status should be ERROR") "Backup Status should be ERROR")
# Clean after yourself # Clean after yourself

View File

@ -44,13 +44,13 @@ class DeleteTest(ProbackupTest, unittest.TestCase):
self.backup_node(backup_dir, 'node', node) self.backup_node(backup_dir, 'node', node)
show_backups = self.show_pb(backup_dir, 'node') show_backups = self.show_pb(backup_dir, 'node')
id_1 = show_backups[0]['ID'] id_1 = show_backups[0]['id']
id_2 = show_backups[1]['ID'] id_2 = show_backups[1]['id']
id_3 = show_backups[2]['ID'] id_3 = show_backups[2]['id']
self.delete_pb(backup_dir, 'node', id_2) self.delete_pb(backup_dir, 'node', id_2)
show_backups = self.show_pb(backup_dir, 'node') show_backups = self.show_pb(backup_dir, 'node')
self.assertEqual(show_backups[0]['ID'], id_1) self.assertEqual(show_backups[0]['id'], id_1)
self.assertEqual(show_backups[1]['ID'], id_3) self.assertEqual(show_backups[1]['id'], id_3)
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)
@ -82,15 +82,15 @@ class DeleteTest(ProbackupTest, unittest.TestCase):
self.assertEqual(len(show_backups), 4) self.assertEqual(len(show_backups), 4)
# delete first page backup # delete first page backup
self.delete_pb(backup_dir, 'node', show_backups[1]['ID']) self.delete_pb(backup_dir, 'node', show_backups[1]['id'])
show_backups = self.show_pb(backup_dir, 'node') show_backups = self.show_pb(backup_dir, 'node')
self.assertEqual(len(show_backups), 2) self.assertEqual(len(show_backups), 2)
self.assertEqual(show_backups[0]['Mode'], "FULL") self.assertEqual(show_backups[0]['backup-mode'], "FULL")
self.assertEqual(show_backups[0]['Status'], "OK") self.assertEqual(show_backups[0]['status'], "OK")
self.assertEqual(show_backups[1]['Mode'], "FULL") self.assertEqual(show_backups[1]['backup-mode'], "FULL")
self.assertEqual(show_backups[1]['Status'], "OK") self.assertEqual(show_backups[1]['status'], "OK")
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)
@ -122,15 +122,15 @@ class DeleteTest(ProbackupTest, unittest.TestCase):
self.assertEqual(len(show_backups), 4) self.assertEqual(len(show_backups), 4)
# delete first page backup # delete first page backup
self.delete_pb(backup_dir, 'node', show_backups[1]['ID']) self.delete_pb(backup_dir, 'node', show_backups[1]['id'])
show_backups = self.show_pb(backup_dir, 'node') show_backups = self.show_pb(backup_dir, 'node')
self.assertEqual(len(show_backups), 2) self.assertEqual(len(show_backups), 2)
self.assertEqual(show_backups[0]['Mode'], "FULL") self.assertEqual(show_backups[0]['backup-mode'], "FULL")
self.assertEqual(show_backups[0]['Status'], "OK") self.assertEqual(show_backups[0]['status'], "OK")
self.assertEqual(show_backups[1]['Mode'], "FULL") self.assertEqual(show_backups[1]['backup-mode'], "FULL")
self.assertEqual(show_backups[1]['Status'], "OK") self.assertEqual(show_backups[1]['status'], "OK")
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)

View File

@ -1191,7 +1191,7 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
f.close f.close
self.assertTrue( self.assertTrue(
self.show_pb(backup_dir, 'node')[1]['Status'] == 'OK', self.show_pb(backup_dir, 'node')[1]['status'] == 'OK',
"Backup Status should be OK") "Backup Status should be OK")
# Clean after yourself # Clean after yourself
@ -1264,7 +1264,7 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
repr(e.message), self.cmd)) repr(e.message), self.cmd))
self.assertTrue( self.assertTrue(
self.show_pb(backup_dir, 'node')[1]['Status'] == 'ERROR', self.show_pb(backup_dir, 'node')[1]['status'] == 'ERROR',
"Backup Status should be ERROR") "Backup Status should be ERROR")
# Clean after yourself # Clean after yourself

View File

@ -34,25 +34,33 @@ class ExcludeTest(ProbackupTest, unittest.TestCase):
temp_schema_name = conn.execute("SELECT nspname FROM pg_namespace WHERE oid = pg_my_temp_schema()")[0][0] temp_schema_name = conn.execute("SELECT nspname FROM pg_namespace WHERE oid = pg_my_temp_schema()")[0][0]
conn.commit() conn.commit()
temp_toast_schema_name = "pg_toast_" + temp_schema_name.replace("pg_", "") temp_toast_schema_name = "pg_toast_" + temp_schema_name.replace(
"pg_", "")
conn.commit() conn.commit()
conn.execute("create index test_idx on test (generate_series)") conn.execute("create index test_idx on test (generate_series)")
conn.commit() conn.commit()
heap_path = conn.execute("select pg_relation_filepath('test')")[0][0] heap_path = conn.execute(
"select pg_relation_filepath('test')")[0][0]
conn.commit() conn.commit()
index_path = conn.execute("select pg_relation_filepath('test_idx')")[0][0] index_path = conn.execute(
"select pg_relation_filepath('test_idx')")[0][0]
conn.commit() conn.commit()
heap_oid = conn.execute("select 'test'::regclass::oid")[0][0] heap_oid = conn.execute("select 'test'::regclass::oid")[0][0]
conn.commit() conn.commit()
toast_path = conn.execute("select pg_relation_filepath('{0}.{1}')".format(temp_toast_schema_name, "pg_toast_" + str(heap_oid)))[0][0] toast_path = conn.execute(
"select pg_relation_filepath('{0}.{1}')".format(
temp_toast_schema_name, "pg_toast_" + str(heap_oid)))[0][0]
conn.commit() conn.commit()
toast_idx_path = conn.execute("select pg_relation_filepath('{0}.{1}')".format(temp_toast_schema_name, "pg_toast_" + str(heap_oid) + "_index"))[0][0] toast_idx_path = conn.execute(
"select pg_relation_filepath('{0}.{1}')".format(
temp_toast_schema_name,
"pg_toast_" + str(heap_oid) + "_index"))[0][0]
conn.commit() conn.commit()
temp_table_filename = os.path.basename(heap_path) temp_table_filename = os.path.basename(heap_path)

View File

@ -12,6 +12,7 @@ import select
import psycopg2 import psycopg2
from time import sleep from time import sleep
import re import re
import json
idx_ptrack = { idx_ptrack = {
't_heap': { 't_heap': {
@ -598,7 +599,7 @@ class ProbackupTest(object):
def show_pb( def show_pb(
self, backup_dir, instance=None, backup_id=None, self, backup_dir, instance=None, backup_id=None,
options=[], as_text=False options=[], as_text=False, as_json=True
): ):
backup_list = [] backup_list = []
@ -613,11 +614,31 @@ class ProbackupTest(object):
if backup_id: if backup_id:
cmd_list += ["-i", backup_id] cmd_list += ["-i", backup_id]
if as_json:
cmd_list += ["--format=json"]
if as_text: if as_text:
# You should print it when calling as_text=true # You should print it when calling as_text=true
return self.run_pb(cmd_list + options) return self.run_pb(cmd_list + options)
# get show result as list of lines # get show result as list of lines
if as_json:
data = json.loads(self.run_pb(cmd_list + options))
# print(data)
for instance_data in data:
# find specific instance if requested
if instance and instance_data['instance'] != instance:
continue
for backup in reversed(instance_data['backups']):
# find specific backup if requested
if backup_id:
if backup['id'] == backup_id:
return backup
else:
backup_list.append(backup)
return backup_list
else:
show_splitted = self.run_pb(cmd_list + options).splitlines() show_splitted = self.run_pb(cmd_list + options).splitlines()
if instance is not None and backup_id is None: if instance is not None and backup_id is None:
# cut header(ID, Mode, etc) from show as single string # cut header(ID, Mode, etc) from show as single string

View File

@ -63,7 +63,7 @@ class ArchiveCheck(ProbackupTest, unittest.TestCase):
'\n Unexpected Error Message: {0}\n CMD: {1}'.format( '\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd)) repr(e.message), self.cmd))
backup_id = self.show_pb(backup_dir, 'node')[0]['ID'] backup_id = self.show_pb(backup_dir, 'node')[0]['id']
self.assertEqual( self.assertEqual(
'ERROR', self.show_pb(backup_dir, 'node', backup_id)['status'], 'ERROR', self.show_pb(backup_dir, 'node', backup_id)['status'],
'Backup should have ERROR status') 'Backup should have ERROR status')

View File

@ -268,7 +268,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# Physical comparison # Physical comparison
if self.paranoia: if self.paranoia:
pgdata_restored = self.pgdata_content(node_restored.data_dir, ignore_ptrack=False) pgdata_restored = self.pgdata_content(
node_restored.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored) self.compare_pgdata(pgdata, pgdata_restored)
node_restored.append_conf( node_restored.append_conf(
@ -430,7 +431,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# Physical comparison # Physical comparison
if self.paranoia: if self.paranoia:
pgdata_restored = self.pgdata_content(node_restored.data_dir, ignore_ptrack=False) pgdata_restored = self.pgdata_content(
node_restored.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored) self.compare_pgdata(pgdata, pgdata_restored)
node_restored.append_conf( node_restored.append_conf(
@ -503,7 +505,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# Physical comparison # Physical comparison
if self.paranoia: if self.paranoia:
pgdata_restored = self.pgdata_content(node.data_dir, ignore_ptrack=False) pgdata_restored = self.pgdata_content(
node.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored) self.compare_pgdata(pgdata, pgdata_restored)
node.start() node.start()
@ -584,8 +587,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
repr(self.output), self.cmd) repr(self.output), self.cmd)
) )
node.start() node.start()
while node.safe_psql( while node.psql(
"postgres", "select pg_is_in_recovery()") == 't\n': "postgres", "select pg_is_in_recovery()")[0] != 0:
time.sleep(1) time.sleep(1)
full_result_new = node.safe_psql("postgres", "SELECT * FROM t_heap") full_result_new = node.safe_psql("postgres", "SELECT * FROM t_heap")
self.assertEqual(full_result, full_result_new) self.assertEqual(full_result, full_result_new)
@ -604,12 +607,13 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
) )
if self.paranoia: if self.paranoia:
pgdata_restored = self.pgdata_content(node.data_dir, ignore_ptrack=False) pgdata_restored = self.pgdata_content(
node.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored) self.compare_pgdata(pgdata, pgdata_restored)
node.start() node.start()
while node.safe_psql( while node.psql(
"postgres", "select pg_is_in_recovery()") == 't\n': "postgres", "select pg_is_in_recovery()")[0] != 0:
time.sleep(1) time.sleep(1)
ptrack_result_new = node.safe_psql("postgres", "SELECT * FROM t_heap") ptrack_result_new = node.safe_psql("postgres", "SELECT * FROM t_heap")
self.assertEqual(ptrack_result, ptrack_result_new) self.assertEqual(ptrack_result, ptrack_result_new)
@ -688,9 +692,11 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
repr(self.output), self.cmd) repr(self.output), self.cmd)
) )
node.start() node.start()
while node.safe_psql(
"postgres", "select pg_is_in_recovery()") == 't\n': while node.psql(
"postgres", "select pg_is_in_recovery()")[0] != 0:
time.sleep(1) time.sleep(1)
full_result_new = node.safe_psql("postgres", "SELECT * FROM t_heap") full_result_new = node.safe_psql("postgres", "SELECT * FROM t_heap")
self.assertEqual(full_result, full_result_new) self.assertEqual(full_result, full_result_new)
node.cleanup() node.cleanup()
@ -711,12 +717,13 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
) )
if self.paranoia: if self.paranoia:
pgdata_restored = self.pgdata_content(node.data_dir, ignore_ptrack=False) pgdata_restored = self.pgdata_content(
node.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored) self.compare_pgdata(pgdata, pgdata_restored)
node.start() node.start()
while node.safe_psql( while node.psql(
"postgres", "select pg_is_in_recovery()") == 't\n': "postgres", "select pg_is_in_recovery()")[0] != 0:
time.sleep(1) time.sleep(1)
ptrack_result_new = node.safe_psql("postgres", "SELECT * FROM t_heap") ptrack_result_new = node.safe_psql("postgres", "SELECT * FROM t_heap")
self.assertEqual(ptrack_result, ptrack_result_new) self.assertEqual(ptrack_result, ptrack_result_new)
@ -811,7 +818,10 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# @unittest.skip("skip") # @unittest.skip("skip")
def test_page_pgpro417(self): def test_page_pgpro417(self):
"""Make archive node, take full backup, take page backup, delete page backup. Try to take ptrack backup, which should fail""" """
Make archive node, take full backup, take page backup,
delete page backup. Try to take ptrack backup, which should fail
"""
self.maxDiff = None self.maxDiff = None
fname = self.id().split('.')[3] fname = self.id().split('.')[3]
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@ -880,7 +890,10 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# @unittest.skip("skip") # @unittest.skip("skip")
def test_full_pgpro417(self): def test_full_pgpro417(self):
"""Make node, take two full backups, delete full second backup. Try to take ptrack backup, which should fail""" """
Make node, take two full backups, delete full second backup.
Try to take ptrack backup, which should fail
"""
self.maxDiff = None self.maxDiff = None
fname = self.id().split('.')[3] fname = self.id().split('.')[3]
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@ -954,7 +967,10 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# @unittest.skip("skip") # @unittest.skip("skip")
def test_create_db(self): def test_create_db(self):
"""Make node, take full backup, create database db1, take ptrack backup, restore database and check it presense""" """
Make node, take full backup, create database db1, take ptrack backup,
restore database and check it presense
"""
self.maxDiff = None self.maxDiff = None
fname = self.id().split('.')[3] fname = self.id().split('.')[3]
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@ -1017,7 +1033,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# COMPARE PHYSICAL CONTENT # COMPARE PHYSICAL CONTENT
if self.paranoia: if self.paranoia:
pgdata_restored = self.pgdata_content(node_restored.data_dir, ignore_ptrack=False) pgdata_restored = self.pgdata_content(
node_restored.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored) self.compare_pgdata(pgdata, pgdata_restored)
# START RESTORED NODE # START RESTORED NODE
@ -1046,7 +1063,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# COMPARE PHYSICAL CONTENT # COMPARE PHYSICAL CONTENT
if self.paranoia: if self.paranoia:
pgdata_restored = self.pgdata_content(node_restored.data_dir, ignore_ptrack=False) pgdata_restored = self.pgdata_content(
node_restored.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored) self.compare_pgdata(pgdata, pgdata_restored)
# START RESTORED NODE # START RESTORED NODE
@ -1151,7 +1169,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# GET RESTORED PGDATA AND COMPARE # GET RESTORED PGDATA AND COMPARE
if self.paranoia: if self.paranoia:
pgdata_restored = self.pgdata_content(node_restored.data_dir, ignore_ptrack=False) pgdata_restored = self.pgdata_content(
node_restored.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored) self.compare_pgdata(pgdata, pgdata_restored)
# START RESTORED NODE # START RESTORED NODE
@ -1159,8 +1178,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
'postgresql.auto.conf', 'port = {0}'.format(node_restored.port)) 'postgresql.auto.conf', 'port = {0}'.format(node_restored.port))
node_restored.start() node_restored.start()
while node_restored.safe_psql( while node_restored.psql(
"postgres", "select pg_is_in_recovery()") == 't\n': "postgres", "select pg_is_in_recovery()")[0] != 0:
time.sleep(1) time.sleep(1)
result_new = node_restored.safe_psql( result_new = node_restored.safe_psql(
"postgres", "select * from t_heap") "postgres", "select * from t_heap")
@ -1229,7 +1248,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# GET PHYSICAL CONTENT and COMPARE PHYSICAL CONTENT # GET PHYSICAL CONTENT and COMPARE PHYSICAL CONTENT
if self.paranoia: if self.paranoia:
pgdata_restored = self.pgdata_content(node_restored.data_dir, ignore_ptrack=False) pgdata_restored = self.pgdata_content(
node_restored.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored) self.compare_pgdata(pgdata, pgdata_restored)
# START RESTORED NODE # START RESTORED NODE
@ -1240,7 +1260,10 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# @unittest.skip("skip") # @unittest.skip("skip")
def test_drop_tablespace(self): def test_drop_tablespace(self):
"""Make node, create table, alter table tablespace, take ptrack backup, move table from tablespace, take ptrack backup""" """
Make node, create table, alter table tablespace, take ptrack backup,
move table from tablespace, take ptrack backup
"""
self.maxDiff = None self.maxDiff = None
fname = self.id().split('.')[3] fname = self.id().split('.')[3]
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@ -1321,7 +1344,10 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# @unittest.skip("skip") # @unittest.skip("skip")
def test_ptrack_alter_tablespace(self): def test_ptrack_alter_tablespace(self):
"""Make node, create table, alter table tablespace, take ptrack backup, move table from tablespace, take ptrack backup""" """
Make node, create table, alter table tablespace, take ptrack backup,
move table from tablespace, take ptrack backup
"""
self.maxDiff = None self.maxDiff = None
fname = self.id().split('.')[3] fname = self.id().split('.')[3]
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@ -1379,15 +1405,16 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# GET PHYSICAL CONTENT FROM RESTORED NODE and COMPARE PHYSICAL CONTENT # GET PHYSICAL CONTENT FROM RESTORED NODE and COMPARE PHYSICAL CONTENT
if self.paranoia: if self.paranoia:
pgdata_restored = self.pgdata_content(restored_node.data_dir, ignore_ptrack=False) pgdata_restored = self.pgdata_content(
restored_node.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored) self.compare_pgdata(pgdata, pgdata_restored)
# START RESTORED NODE # START RESTORED NODE
restored_node.append_conf( restored_node.append_conf(
"postgresql.auto.conf", "port = {0}".format(restored_node.port)) "postgresql.auto.conf", "port = {0}".format(restored_node.port))
restored_node.start() restored_node.start()
while restored_node.safe_psql( while restored_node.psql(
"postgres", "select pg_is_in_recovery()") == 't\n': "postgres", "select pg_is_in_recovery()")[0] != 0:
time.sleep(1) time.sleep(1)
# COMPARE LOGICAL CONTENT # COMPARE LOGICAL CONTENT
@ -1416,14 +1443,15 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# GET PHYSICAL CONTENT FROM RESTORED NODE and COMPARE PHYSICAL CONTENT # GET PHYSICAL CONTENT FROM RESTORED NODE and COMPARE PHYSICAL CONTENT
if self.paranoia: if self.paranoia:
pgdata_restored = self.pgdata_content(restored_node.data_dir, ignore_ptrack=False) pgdata_restored = self.pgdata_content(
restored_node.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored) self.compare_pgdata(pgdata, pgdata_restored)
# START RESTORED NODE # START RESTORED NODE
restored_node.append_conf( restored_node.append_conf(
"postgresql.auto.conf", "port = {0}".format(restored_node.port)) "postgresql.auto.conf", "port = {0}".format(restored_node.port))
restored_node.start() restored_node.start()
while restored_node.safe_psql( while restored_node.psql(
"postgres", "postgres",
"select pg_is_in_recovery()") == 't\n': "select pg_is_in_recovery()") == 't\n':
time.sleep(1) time.sleep(1)
@ -1437,7 +1465,10 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# @unittest.skip("skip") # @unittest.skip("skip")
def test_ptrack_multiple_segments(self): def test_ptrack_multiple_segments(self):
"""Make node, create table, alter table tablespace, take ptrack backup, move table from tablespace, take ptrack backup""" """
Make node, create table, alter table tablespace,
take ptrack backup, move table from tablespace, take ptrack backup
"""
fname = self.id().split('.')[3] fname = self.id().split('.')[3]
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
node = self.make_simple_node( node = self.make_simple_node(
@ -1446,9 +1477,10 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
initdb_params=['--data-checksums'], initdb_params=['--data-checksums'],
pg_options={ pg_options={
'wal_level': 'replica', 'max_wal_senders': '2', 'wal_level': 'replica', 'max_wal_senders': '2',
'ptrack_enable': 'on', 'fsync': 'off', 'shared_buffers': '128MB', 'ptrack_enable': 'on', 'fsync': 'off',
'maintenance_work_mem': '1GB', 'autovacuum': 'off', 'autovacuum': 'off',
'full_page_writes': 'off'} 'full_page_writes': 'off'
}
) )
self.init_pb(backup_dir) self.init_pb(backup_dir)
@ -1514,14 +1546,15 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
# GET PHYSICAL CONTENT FROM NODE_RESTORED # GET PHYSICAL CONTENT FROM NODE_RESTORED
if self.paranoia: if self.paranoia:
pgdata_restored = self.pgdata_content(restored_node.data_dir, ignore_ptrack=False) pgdata_restored = self.pgdata_content(
restored_node.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored) self.compare_pgdata(pgdata, pgdata_restored)
# START RESTORED NODE # START RESTORED NODE
restored_node.append_conf( restored_node.append_conf(
"postgresql.auto.conf", "port = {0}".format(restored_node.port)) "postgresql.auto.conf", "port = {0}".format(restored_node.port))
restored_node.start() restored_node.start()
while restored_node.safe_psql( while restored_node.psql(
"postgres", "postgres",
"select pg_is_in_recovery()") == 't\n': "select pg_is_in_recovery()") == 't\n':
time.sleep(1) time.sleep(1)

View File

@ -718,7 +718,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
con.commit() con.commit()
backup_id = self.backup_node(backup_dir, 'node', node) backup_id = self.backup_node(backup_dir, 'node', node)
self.assertEqual(self.show_pb(backup_dir, 'node')[0]['Status'], "OK") self.assertEqual(self.show_pb(backup_dir, 'node')[0]['status'], "OK")
# 1 - Try to restore to existing directory # 1 - Try to restore to existing directory
node.stop() node.stop()
@ -785,8 +785,8 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
backup_dir, 'node', node, backup_type="page") backup_dir, 'node', node, backup_type="page")
show_pb = self.show_pb(backup_dir, 'node') show_pb = self.show_pb(backup_dir, 'node')
self.assertEqual(show_pb[1]['Status'], "OK") self.assertEqual(show_pb[1]['status'], "OK")
self.assertEqual(show_pb[2]['Status'], "OK") self.assertEqual(show_pb[2]['status'], "OK")
node.stop() node.stop()
node.cleanup() node.cleanup()
@ -829,7 +829,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
# Full backup # Full backup
self.backup_node(backup_dir, 'node', node) self.backup_node(backup_dir, 'node', node)
self.assertEqual(self.show_pb(backup_dir, 'node')[0]['Status'], "OK") self.assertEqual(self.show_pb(backup_dir, 'node')[0]['status'], "OK")
# Create tablespace # Create tablespace
tblspc_path = os.path.join(node.base_dir, "tblspc") tblspc_path = os.path.join(node.base_dir, "tblspc")
@ -845,8 +845,9 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
# First page backup # First page backup
self.backup_node(backup_dir, 'node', node, backup_type="page") self.backup_node(backup_dir, 'node', node, backup_type="page")
self.assertEqual(self.show_pb(backup_dir, 'node')[1]['Status'], "OK") self.assertEqual(self.show_pb(backup_dir, 'node')[1]['status'], "OK")
self.assertEqual(self.show_pb(backup_dir, 'node')[1]['Mode'], "PAGE") self.assertEqual(
self.show_pb(backup_dir, 'node')[1]['backup-mode'], "PAGE")
# Create tablespace table # Create tablespace table
with node.connect("postgres") as con: with node.connect("postgres") as con:
@ -862,8 +863,9 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
# Second page backup # Second page backup
backup_id = self.backup_node( backup_id = self.backup_node(
backup_dir, 'node', node, backup_type="page") backup_dir, 'node', node, backup_type="page")
self.assertEqual(self.show_pb(backup_dir, 'node')[2]['Status'], "OK") self.assertEqual(self.show_pb(backup_dir, 'node')[2]['status'], "OK")
self.assertEqual(self.show_pb(backup_dir, 'node')[2]['Mode'], "PAGE") self.assertEqual(
self.show_pb(backup_dir, 'node')[2]['backup-mode'], "PAGE")
node.stop() node.stop()
node.cleanup() node.cleanup()

View File

@ -14,7 +14,8 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
def test_retention_redundancy_1(self): def test_retention_redundancy_1(self):
"""purge backups using redundancy-based retention policy""" """purge backups using redundancy-based retention policy"""
fname = self.id().split('.')[3] fname = self.id().split('.')[3]
node = self.make_simple_node(base_dir="{0}/{1}/node".format(module_name, fname), node = self.make_simple_node(
base_dir="{0}/{1}/node".format(module_name, fname),
initdb_params=['--data-checksums'], initdb_params=['--data-checksums'],
pg_options={'wal_level': 'replica'} pg_options={'wal_level': 'replica'}
) )
@ -24,7 +25,9 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
self.set_archiving(backup_dir, 'node', node) self.set_archiving(backup_dir, 'node', node)
node.start() node.start()
with open(os.path.join(backup_dir, 'backups', 'node', "pg_probackup.conf"), "a") as conf: with open(os.path.join(
backup_dir, 'backups', 'node',
"pg_probackup.conf"), "a") as conf:
conf.write("retention-redundancy = 1\n") conf.write("retention-redundancy = 1\n")
# Make backups to be purged # Make backups to be purged
@ -68,7 +71,8 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
def test_retention_window_2(self): def test_retention_window_2(self):
"""purge backups using window-based retention policy""" """purge backups using window-based retention policy"""
fname = self.id().split('.')[3] fname = self.id().split('.')[3]
node = self.make_simple_node(base_dir="{0}/{1}/node".format(module_name, fname), node = self.make_simple_node(
base_dir="{0}/{1}/node".format(module_name, fname),
initdb_params=['--data-checksums'], initdb_params=['--data-checksums'],
pg_options={'wal_level': 'replica'} pg_options={'wal_level': 'replica'}
) )

View File

@ -36,6 +36,35 @@ class OptionTest(ProbackupTest, unittest.TestCase):
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)
# @unittest.skip("skip")
# @unittest.expectedFailure
def test_show_json(self):
"""Status DONE and OK"""
fname = self.id().split('.')[3]
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
node = self.make_simple_node(
base_dir="{0}/{1}/node".format(module_name, fname),
initdb_params=['--data-checksums'],
pg_options={'wal_level': 'replica'}
)
self.init_pb(backup_dir)
self.add_instance(backup_dir, 'node', node)
self.set_archiving(backup_dir, 'node', node)
node.start()
self.assertEqual(
self.backup_node(
backup_dir, 'node', node,
options=["--log-level-console=panic"]),
None
)
self.backup_node(backup_dir, 'node', node)
self.assertIn("OK", self.show_pb(backup_dir, 'node', as_text=True))
# Clean after yourself
self.del_test_dir(module_name, fname)
# @unittest.skip("skip") # @unittest.skip("skip")
def test_corrupt_2(self): def test_corrupt_2(self):
"""Status CORRUPT""" """Status CORRUPT"""

View File

@ -908,7 +908,8 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
backup_id = self.backup_node(backup_dir, 'node', node) backup_id = self.backup_node(backup_dir, 'node', node)
target_xid = None target_xid = None
with node.connect("postgres") as con: with node.connect("postgres") as con:
res = con.execute("INSERT INTO tbl0005 VALUES ('inserted') RETURNING (xmin)") res = con.execute(
"INSERT INTO tbl0005 VALUES ('inserted') RETURNING (xmin)")
con.commit() con.commit()
target_xid = res[0][0] target_xid = res[0][0]
@ -1041,7 +1042,10 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
# @unittest.skip("skip") # @unittest.skip("skip")
def test_validate_corrupt_wal_between_backups(self): def test_validate_corrupt_wal_between_backups(self):
"""make archive node, make full backup, corrupt all wal files, run validate to real xid, expect errors""" """
make archive node, make full backup, corrupt all wal files,
run validate to real xid, expect errors
"""
fname = self.id().split('.')[3] fname = self.id().split('.')[3]
node = self.make_simple_node( node = self.make_simple_node(
base_dir="{0}/{1}/node".format(module_name, fname), base_dir="{0}/{1}/node".format(module_name, fname),
@ -1083,7 +1087,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
else: else:
walfile = node.safe_psql( walfile = node.safe_psql(
'postgres', 'postgres',
'select pg_walfile_name(pg_current_wal_location())').rstrip() 'select pg_walfile_name(pg_current_wal_lsn())').rstrip()
if self.archive_compress: if self.archive_compress:
walfile = walfile + '.gz' walfile = walfile + '.gz'
@ -1134,12 +1138,12 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
self.assertEqual( self.assertEqual(
'OK', 'OK',
self.show_pb(backup_dir, 'node')[0]['Status'], self.show_pb(backup_dir, 'node')[0]['status'],
'Backup STATUS should be "OK"') 'Backup STATUS should be "OK"')
self.assertEqual( self.assertEqual(
'OK', 'OK',
self.show_pb(backup_dir, 'node')[1]['Status'], self.show_pb(backup_dir, 'node')[1]['status'],
'Backup STATUS should be "OK"') 'Backup STATUS should be "OK"')
# Clean after yourself # Clean after yourself
@ -1208,7 +1212,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
self.assertEqual( self.assertEqual(
'ERROR', 'ERROR',
self.show_pb(backup_dir, 'node')[1]['Status'], self.show_pb(backup_dir, 'node')[1]['status'],
'Backup {0} should have STATUS "ERROR"') 'Backup {0} should have STATUS "ERROR"')
# Clean after yourself # Clean after yourself
@ -1405,7 +1409,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
except ProbackupException as e: except ProbackupException as e:
pass pass
self.assertTrue( self.assertTrue(
self.show_pb(backup_dir, 'node')[6]['Status'] == 'ERROR') self.show_pb(backup_dir, 'node')[6]['status'] == 'ERROR')
self.set_archiving(backup_dir, 'node', node) self.set_archiving(backup_dir, 'node', node)
node.reload() node.reload()
self.backup_node(backup_dir, 'node', node, backup_type='page') self.backup_node(backup_dir, 'node', node, backup_type='page')
@ -1440,14 +1444,19 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
'\n Unexpected Error Message: {0}\n CMD: {1}'.format( '\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd)) repr(e.message), self.cmd))
self.assertTrue(self.show_pb(backup_dir, 'node')[0]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[0]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[1]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[1]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[2]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[2]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[3]['Status'] == 'CORRUPT') self.assertTrue(
self.assertTrue(self.show_pb(backup_dir, 'node')[4]['Status'] == 'ORPHAN') self.show_pb(backup_dir, 'node')[3]['status'] == 'CORRUPT')
self.assertTrue(self.show_pb(backup_dir, 'node')[5]['Status'] == 'ORPHAN') self.assertTrue(
self.assertTrue(self.show_pb(backup_dir, 'node')[6]['Status'] == 'ERROR') self.show_pb(backup_dir, 'node')[4]['status'] == 'ORPHAN')
self.assertTrue(self.show_pb(backup_dir, 'node')[7]['Status'] == 'ORPHAN') self.assertTrue(
self.show_pb(backup_dir, 'node')[5]['status'] == 'ORPHAN')
self.assertTrue(
self.show_pb(backup_dir, 'node')[6]['status'] == 'ERROR')
self.assertTrue(
self.show_pb(backup_dir, 'node')[7]['status'] == 'ORPHAN')
os.rename(file_new, file) os.rename(file_new, file)
try: try:
@ -1459,14 +1468,15 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
'\n Unexpected Error Message: {0}\n CMD: {1}'.format( '\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd)) repr(e.message), self.cmd))
self.assertTrue(self.show_pb(backup_dir, 'node')[0]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[0]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[1]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[1]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[2]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[2]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[3]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[3]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[4]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[4]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[5]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[5]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[6]['Status'] == 'ERROR') self.assertTrue(
self.assertTrue(self.show_pb(backup_dir, 'node')[7]['Status'] == 'OK') self.show_pb(backup_dir, 'node')[6]['status'] == 'ERROR')
self.assertTrue(self.show_pb(backup_dir, 'node')[7]['status'] == 'OK')
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)
@ -1537,13 +1547,13 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
'\n Unexpected Error Message: {0}\n CMD: {1}'.format( '\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd)) repr(e.message), self.cmd))
self.assertTrue(self.show_pb(backup_dir, 'node')[0]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[0]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[1]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[1]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[2]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[2]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[3]['Status'] == 'CORRUPT') self.assertTrue(self.show_pb(backup_dir, 'node')[3]['status'] == 'CORRUPT')
self.assertTrue(self.show_pb(backup_dir, 'node')[4]['Status'] == 'ORPHAN') self.assertTrue(self.show_pb(backup_dir, 'node')[4]['status'] == 'ORPHAN')
self.assertTrue(self.show_pb(backup_dir, 'node')[5]['Status'] == 'ORPHAN') self.assertTrue(self.show_pb(backup_dir, 'node')[5]['status'] == 'ORPHAN')
self.assertTrue(self.show_pb(backup_dir, 'node')[6]['Status'] == 'ORPHAN') self.assertTrue(self.show_pb(backup_dir, 'node')[6]['status'] == 'ORPHAN')
os.rename(file_new, file) os.rename(file_new, file)
file = os.path.join( file = os.path.join(
@ -1562,13 +1572,13 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
'\n Unexpected Error Message: {0}\n CMD: {1}'.format( '\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd)) repr(e.message), self.cmd))
self.assertTrue(self.show_pb(backup_dir, 'node')[0]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[0]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[1]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[1]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[2]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[2]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[3]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[3]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[4]['Status'] == 'OK') self.assertTrue(self.show_pb(backup_dir, 'node')[4]['status'] == 'OK')
self.assertTrue(self.show_pb(backup_dir, 'node')[5]['Status'] == 'CORRUPT') self.assertTrue(self.show_pb(backup_dir, 'node')[5]['status'] == 'CORRUPT')
self.assertTrue(self.show_pb(backup_dir, 'node')[6]['Status'] == 'ORPHAN') self.assertTrue(self.show_pb(backup_dir, 'node')[6]['status'] == 'ORPHAN')
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)