2016-12-09 20:30:22 +02:00
|
|
|
import os
|
2017-06-27 11:43:45 +02:00
|
|
|
import unittest
|
2017-06-27 07:42:52 +02:00
|
|
|
from .helpers.ptrack_helpers import ProbackupTest
|
2016-12-09 20:30:22 +02:00
|
|
|
|
|
|
|
|
2017-07-12 16:28:28 +02:00
|
|
|
module_name = 'show'
|
|
|
|
|
2016-12-09 20:30:22 +02:00
|
|
|
|
2017-07-12 16:28:28 +02:00
|
|
|
class OptionTest(ProbackupTest, unittest.TestCase):
|
2017-05-03 13:14:48 +02:00
|
|
|
|
2017-05-22 13:17:43 +02:00
|
|
|
# @unittest.skip("skip")
|
|
|
|
# @unittest.expectedFailure
|
2017-06-20 12:57:23 +02:00
|
|
|
def test_show_1(self):
|
2017-05-03 13:14:48 +02:00
|
|
|
"""Status DONE and OK"""
|
|
|
|
fname = self.id().split('.')[3]
|
2017-07-12 16:28:28 +02:00
|
|
|
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),
|
2017-05-03 13:14:48 +02:00
|
|
|
initdb_params=['--data-checksums'],
|
|
|
|
pg_options={'wal_level': 'replica'}
|
|
|
|
)
|
2017-06-20 12:57:23 +02:00
|
|
|
|
|
|
|
self.init_pb(backup_dir)
|
|
|
|
self.add_instance(backup_dir, 'node', node)
|
|
|
|
self.set_archiving(backup_dir, 'node', node)
|
2017-05-03 13:14:48 +02:00
|
|
|
node.start()
|
|
|
|
|
|
|
|
self.assertEqual(
|
2017-12-13 10:15:42 +02:00
|
|
|
self.backup_node(backup_dir, 'node', node, options=["--log-level-console=panic"]),
|
2017-05-03 13:14:48 +02:00
|
|
|
None
|
|
|
|
)
|
2017-06-27 07:42:52 +02:00
|
|
|
self.assertIn("OK", self.show_pb(backup_dir, 'node', as_text=True))
|
|
|
|
|
|
|
|
# Clean after yourself
|
2017-07-12 16:28:28 +02:00
|
|
|
self.del_test_dir(module_name, fname)
|
2017-05-03 13:14:48 +02:00
|
|
|
|
2017-06-20 12:57:23 +02:00
|
|
|
# @unittest.skip("skip")
|
2017-05-03 13:14:48 +02:00
|
|
|
def test_corrupt_2(self):
|
|
|
|
"""Status CORRUPT"""
|
|
|
|
fname = self.id().split('.')[3]
|
2017-07-12 16:28:28 +02:00
|
|
|
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),
|
2017-05-03 13:14:48 +02:00
|
|
|
initdb_params=['--data-checksums'],
|
|
|
|
pg_options={'wal_level': 'replica'}
|
|
|
|
)
|
2017-06-20 12:57:23 +02:00
|
|
|
|
|
|
|
self.init_pb(backup_dir)
|
|
|
|
self.add_instance(backup_dir, 'node', node)
|
|
|
|
self.set_archiving(backup_dir, 'node', node)
|
2017-05-03 13:14:48 +02:00
|
|
|
node.start()
|
|
|
|
|
2017-06-20 12:57:23 +02:00
|
|
|
backup_id = self.backup_node(backup_dir, 'node', node)
|
|
|
|
|
|
|
|
# delete file which belong to backup
|
2017-06-27 11:43:45 +02:00
|
|
|
file = os.path.join(backup_dir, "backups", "node", backup_id, "database", "postgresql.conf")
|
2017-06-20 12:57:23 +02:00
|
|
|
os.remove(file)
|
2017-05-03 13:14:48 +02:00
|
|
|
|
2017-06-20 12:57:23 +02:00
|
|
|
self.validate_pb(backup_dir, 'node', backup_id)
|
2017-06-27 07:42:52 +02:00
|
|
|
self.assertIn("CORRUPT", self.show_pb(backup_dir, as_text=True))
|
|
|
|
|
|
|
|
# Clean after yourself
|
2017-07-12 16:28:28 +02:00
|
|
|
self.del_test_dir(module_name, fname)
|