1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-04-16 12:18:38 +02:00

tests: fixes for module "pgpro560"

This commit is contained in:
Grigory Smolkin 2019-07-14 13:46:28 +03:00
parent 25fd9280c1
commit b41bc03be3

View File

@ -1,6 +1,6 @@
import os import os
import unittest import unittest
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, idx_ptrack from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
from datetime import datetime, timedelta from datetime import datetime, timedelta
import subprocess import subprocess
@ -30,19 +30,22 @@ class CheckSystemID(ProbackupTest, unittest.TestCase):
self.add_instance(backup_dir, 'node', node) self.add_instance(backup_dir, 'node', node)
node.slow_start() node.slow_start()
file = os.path.join(node.base_dir,'data', 'global', 'pg_control') file = os.path.join(node.base_dir, 'data', 'global', 'pg_control')
os.remove(file) os.remove(file)
try: try:
self.backup_node(backup_dir, 'node', node, options=['--stream']) self.backup_node(backup_dir, 'node', node, options=['--stream'])
# we should die here because exception is what we expect to happen # we should die here because exception is what we expect to happen
self.assertEqual(1, 0, "Expecting Error because pg_control was deleted.\n Output: {0} \n CMD: {1}".format( self.assertEqual(
repr(self.output), self.cmd)) 1, 0,
"Expecting Error because pg_control was deleted.\n "
"Output: {0} \n CMD: {1}".format(repr(self.output), self.cmd))
except ProbackupException as e: except ProbackupException as e:
self.assertTrue( self.assertTrue(
'ERROR: could not open file' in e.message 'ERROR: could not open file' in e.message and
and 'pg_control' in e.message, 'pg_control' in e.message,
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd)) '\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd))
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)
@ -75,24 +78,50 @@ class CheckSystemID(ProbackupTest, unittest.TestCase):
try: try:
self.backup_node(backup_dir, 'node1', node2, options=['--stream']) self.backup_node(backup_dir, 'node1', node2, options=['--stream'])
# we should die here because exception is what we expect to happen # we should die here because exception is what we expect to happen
self.assertEqual(1, 0, "Expecting Error because of SYSTEM ID mismatch.\n Output: {0} \n CMD: {1}".format( self.assertEqual(
repr(self.output), self.cmd)) 1, 0,
"Expecting Error because of SYSTEM ID mismatch.\n "
"Output: {0} \n CMD: {1}".format(repr(self.output), self.cmd))
except ProbackupException as e: except ProbackupException as e:
self.assertTrue( if self.get_version(node1) > 90600:
'ERROR: Backup data directory was initialized for system id' in e.message self.assertTrue(
and 'but connected instance system id is' in e.message, 'ERROR: Backup data directory was '
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd)) 'initialized for system id' in e.message and
'but connected instance system id is' in e.message,
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd))
else:
self.assertIn(
'ERROR: System identifier mismatch. '
'Connected PostgreSQL instance has system id',
e.message,
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd))
try: try:
self.backup_node(backup_dir, 'node1', node2, data_dir=node1.data_dir, options=['--stream']) self.backup_node(
backup_dir, 'node1', node2,
data_dir=node1.data_dir, options=['--stream'])
# we should die here because exception is what we expect to happen # we should die here because exception is what we expect to happen
self.assertEqual(1, 0, "Expecting Error because of of SYSTEM ID mismatch.\n Output: {0} \n CMD: {1}".format( self.assertEqual(
repr(self.output), self.cmd)) 1, 0,
"Expecting Error because of of SYSTEM ID mismatch.\n "
"Output: {0} \n CMD: {1}".format(repr(self.output), self.cmd))
except ProbackupException as e: except ProbackupException as e:
self.assertTrue( if self.get_version(node1) > 90600:
'ERROR: Backup data directory was initialized for system id' in e.message self.assertTrue(
and 'but connected instance system id is' in e.message, 'ERROR: Backup data directory was initialized '
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd)) 'for system id' in e.message and
'but connected instance system id is' in e.message,
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd))
else:
self.assertIn(
'ERROR: System identifier mismatch. '
'Connected PostgreSQL instance has system id',
e.message,
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
repr(e.message), self.cmd))
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)