|
1 | 1 | import os
|
2 | 2 | import unittest
|
3 |
| -from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, idx_ptrack |
| 3 | +from .helpers.ptrack_helpers import ProbackupTest, ProbackupException |
4 | 4 | from datetime import datetime, timedelta
|
5 | 5 | import subprocess
|
6 | 6 |
|
@@ -30,19 +30,22 @@ def test_pgpro560_control_file_loss(self):
|
30 | 30 | self.add_instance(backup_dir, 'node', node)
|
31 | 31 | node.slow_start()
|
32 | 32 |
|
33 |
| - file = os.path.join(node.base_dir,'data', 'global', 'pg_control') |
| 33 | + file = os.path.join(node.base_dir, 'data', 'global', 'pg_control') |
34 | 34 | os.remove(file)
|
35 | 35 |
|
36 | 36 | try:
|
37 | 37 | self.backup_node(backup_dir, 'node', node, options=['--stream'])
|
38 | 38 | # we should die here because exception is what we expect to happen
|
39 |
| - self.assertEqual(1, 0, "Expecting Error because pg_control was deleted.\n Output: {0} \n CMD: {1}".format( |
40 |
| - repr(self.output), self.cmd)) |
| 39 | + self.assertEqual( |
| 40 | + 1, 0, |
| 41 | + "Expecting Error because pg_control was deleted.\n " |
| 42 | + "Output: {0} \n CMD: {1}".format(repr(self.output), self.cmd)) |
41 | 43 | except ProbackupException as e:
|
42 | 44 | self.assertTrue(
|
43 |
| - 'ERROR: could not open file' in e.message |
44 |
| - and 'pg_control' in e.message, |
45 |
| - '\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd)) |
| 45 | + 'ERROR: could not open file' in e.message and |
| 46 | + 'pg_control' in e.message, |
| 47 | + '\n Unexpected Error Message: {0}\n CMD: {1}'.format( |
| 48 | + repr(e.message), self.cmd)) |
46 | 49 |
|
47 | 50 | # Clean after yourself
|
48 | 51 | self.del_test_dir(module_name, fname)
|
@@ -75,24 +78,50 @@ def test_pgpro560_systemid_mismatch(self):
|
75 | 78 | try:
|
76 | 79 | self.backup_node(backup_dir, 'node1', node2, options=['--stream'])
|
77 | 80 | # we should die here because exception is what we expect to happen
|
78 |
| - self.assertEqual(1, 0, "Expecting Error because of SYSTEM ID mismatch.\n Output: {0} \n CMD: {1}".format( |
79 |
| - repr(self.output), self.cmd)) |
| 81 | + self.assertEqual( |
| 82 | + 1, 0, |
| 83 | + "Expecting Error because of SYSTEM ID mismatch.\n " |
| 84 | + "Output: {0} \n CMD: {1}".format(repr(self.output), self.cmd)) |
80 | 85 | except ProbackupException as e:
|
81 |
| - self.assertTrue( |
82 |
| - 'ERROR: Backup data directory was initialized for system id' in e.message |
83 |
| - and 'but connected instance system id is' in e.message, |
84 |
| - '\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd)) |
| 86 | + if self.get_version(node1) > 90600: |
| 87 | + self.assertTrue( |
| 88 | + 'ERROR: Backup data directory was ' |
| 89 | + 'initialized for system id' in e.message and |
| 90 | + 'but connected instance system id is' in e.message, |
| 91 | + '\n Unexpected Error Message: {0}\n CMD: {1}'.format( |
| 92 | + repr(e.message), self.cmd)) |
| 93 | + else: |
| 94 | + self.assertIn( |
| 95 | + 'ERROR: System identifier mismatch. ' |
| 96 | + 'Connected PostgreSQL instance has system id', |
| 97 | + e.message, |
| 98 | + '\n Unexpected Error Message: {0}\n CMD: {1}'.format( |
| 99 | + repr(e.message), self.cmd)) |
85 | 100 |
|
86 | 101 | try:
|
87 |
| - self.backup_node(backup_dir, 'node1', node2, data_dir=node1.data_dir, options=['--stream']) |
| 102 | + self.backup_node( |
| 103 | + backup_dir, 'node1', node2, |
| 104 | + data_dir=node1.data_dir, options=['--stream']) |
88 | 105 | # we should die here because exception is what we expect to happen
|
89 |
| - self.assertEqual(1, 0, "Expecting Error because of of SYSTEM ID mismatch.\n Output: {0} \n CMD: {1}".format( |
90 |
| - repr(self.output), self.cmd)) |
| 106 | + self.assertEqual( |
| 107 | + 1, 0, |
| 108 | + "Expecting Error because of of SYSTEM ID mismatch.\n " |
| 109 | + "Output: {0} \n CMD: {1}".format(repr(self.output), self.cmd)) |
91 | 110 | except ProbackupException as e:
|
92 |
| - self.assertTrue( |
93 |
| - 'ERROR: Backup data directory was initialized for system id' in e.message |
94 |
| - and 'but connected instance system id is' in e.message, |
95 |
| - '\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd)) |
| 111 | + if self.get_version(node1) > 90600: |
| 112 | + self.assertTrue( |
| 113 | + 'ERROR: Backup data directory was initialized ' |
| 114 | + 'for system id' in e.message and |
| 115 | + 'but connected instance system id is' in e.message, |
| 116 | + '\n Unexpected Error Message: {0}\n CMD: {1}'.format( |
| 117 | + repr(e.message), self.cmd)) |
| 118 | + else: |
| 119 | + self.assertIn( |
| 120 | + 'ERROR: System identifier mismatch. ' |
| 121 | + 'Connected PostgreSQL instance has system id', |
| 122 | + e.message, |
| 123 | + '\n Unexpected Error Message: {0}\n CMD: {1}'.format( |
| 124 | + repr(e.message), self.cmd)) |
96 | 125 |
|
97 | 126 | # Clean after yourself
|
98 | 127 | self.del_test_dir(module_name, fname)
|
0 commit comments