|
| 1 | +import unittest |
| 2 | +import subprocess |
| 3 | +import os |
| 4 | +from .helpers.ptrack_helpers import ProbackupTest, ProbackupException |
| 5 | +from sys import exit |
| 6 | + |
| 7 | +module_name = 'config' |
| 8 | + |
| 9 | + |
| 10 | +class ConfigTest(ProbackupTest, unittest.TestCase): |
| 11 | + |
| 12 | + # @unittest.expectedFailure |
| 13 | + # @unittest.skip("skip") |
| 14 | + def test_remove_instance_config(self): |
| 15 | + """remove pg_probackup.conf""" |
| 16 | + fname = self.id().split('.')[3] |
| 17 | + backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') |
| 18 | + node = self.make_simple_node( |
| 19 | + base_dir=os.path.join(module_name, fname, 'node'), |
| 20 | + set_replication=True, |
| 21 | + initdb_params=['--data-checksums']) |
| 22 | + |
| 23 | + self.init_pb(backup_dir) |
| 24 | + self.add_instance(backup_dir, 'node', node) |
| 25 | + self.show_pb(backup_dir) |
| 26 | + self.set_archiving(backup_dir, 'node', node) |
| 27 | + node.slow_start() |
| 28 | + |
| 29 | + self.backup_node(backup_dir, 'node', node) |
| 30 | + |
| 31 | + self.backup_node( |
| 32 | + backup_dir, 'node', node, backup_type='page') |
| 33 | + |
| 34 | + conf_file = os.path.join( |
| 35 | + backup_dir, 'backups','node', 'pg_probackup.conf') |
| 36 | + |
| 37 | + os.unlink(os.path.join(backup_dir, 'backups','node', 'pg_probackup.conf')) |
| 38 | + |
| 39 | + try: |
| 40 | + self.backup_node( |
| 41 | + backup_dir, 'node', node, backup_type='page') |
| 42 | + self.assertEqual( |
| 43 | + 1, 0, |
| 44 | + "Expecting Error because pg_probackup.conf is missing. " |
| 45 | + ".\n Output: {0} \n CMD: {1}".format( |
| 46 | + repr(self.output), self.cmd)) |
| 47 | + except ProbackupException as e: |
| 48 | + self.assertIn( |
| 49 | + 'ERROR: could not open file "{0}": ' |
| 50 | + 'No such file or directory'.format(conf_file), |
| 51 | + e.message, |
| 52 | + "\n Unexpected Error Message: {0}\n CMD: {1}".format( |
| 53 | + repr(e.message), self.cmd)) |
0 commit comments