mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-10 23:29:34 +02:00
50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
|
import unittest
|
||
|
import os
|
||
|
from os import path
|
||
|
import six
|
||
|
from .pb_lib import ProbackupTest
|
||
|
from testgres import stop_all
|
||
|
|
||
|
|
||
|
class OptionTest(ProbackupTest, unittest.TestCase):
|
||
|
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
super(OptionTest, self).__init__(*args, **kwargs)
|
||
|
|
||
|
@classmethod
|
||
|
def tearDownClass(cls):
|
||
|
stop_all()
|
||
|
|
||
|
def test_ok_1(self):
|
||
|
"""Status DONE and OK"""
|
||
|
node = self.make_bnode('done_ok', base_dir="tmp_dirs/show/ok_1")
|
||
|
node.start()
|
||
|
self.assertEqual(self.init_pb(node), six.b(""))
|
||
|
|
||
|
self.assertEqual(
|
||
|
self.backup_pb(node, options=["--quiet"]),
|
||
|
six.b("")
|
||
|
)
|
||
|
self.assertIn(six.b("OK"), self.show_pb(node))
|
||
|
|
||
|
node.stop()
|
||
|
|
||
|
def test_corrupt_2(self):
|
||
|
"""Status DONE and OK"""
|
||
|
node = self.make_bnode('corrupt', base_dir="tmp_dirs/show/corrupt_2")
|
||
|
node.start()
|
||
|
self.assertEqual(self.init_pb(node), six.b(""))
|
||
|
|
||
|
self.assertEqual(
|
||
|
self.backup_pb(node, options=["--quiet"]),
|
||
|
six.b("")
|
||
|
)
|
||
|
|
||
|
id_backup = self.show_pb(node).splitlines()[3].split()[0]
|
||
|
os.remove(path.join(self.backup_dir(node), "backups", id_backup.decode("utf-8"), "database", "postgresql.conf"))
|
||
|
|
||
|
self.validate_pb(node, id_backup)
|
||
|
self.assertIn(six.b("CORRUPT"), self.show_pb(node))
|
||
|
|
||
|
node.stop()
|