1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-01-20 11:34:51 +02:00

Update tests. Add cfs_validate_backup test

This commit is contained in:
s.logvinenko 2017-10-02 17:35:20 +03:00
parent 948927142b
commit dd14c27f38
5 changed files with 143 additions and 12 deletions

View File

@ -7,7 +7,8 @@ from . import init_test, option_test, show_test, \
ptrack_vacuum_bits_frozen, ptrack_vacuum_bits_visibility, \
ptrack_vacuum_full, ptrack_vacuum_truncate, pgpro560, pgpro589, \
false_positive, replica, compression, page, ptrack, archive, \
cfs_backup_noenc, cfs_backup_enc, cfs_restore_noenc
cfs_backup_noenc, cfs_backup_enc, cfs_restore_noenc, cfs_restore_enc, \
cfs_validate_backup
def load_tests(loader, tests, pattern):
@ -40,7 +41,8 @@ def load_tests(loader, tests, pattern):
suite.addTests(loader.loadTestsFromModule(cfs_backup_noenc))
suite.addTests(loader.loadTestsFromModule(cfs_backup_enc))
suite.addTests(loader.loadTestsFromModule(cfs_restore_noenc))
suite.addTests(loader.loadTestsFromModule(cfs_restore_enc))
suite.addTests(loader.loadTestsFromModule(cfs_validate_backup))
return suite
# ToDo:

View File

@ -1,7 +1,6 @@
import os
from .cfs_backup_noenc import CfsBackupNoEncTest
from .helpers.cfs_helpers import find_by_name
module_name = 'cfs_backup_enc'
tblspace_name = 'cfs_tblspace'

19
tests/cfs_restore_enc.py Normal file
View File

@ -0,0 +1,19 @@
import os
from .cfs_restore_noenc import CfsRestoreNoencEmptyTablespaceTest,CfsRestoreNoencTest
module_name = 'cfs_restore_enc'
class CfsRestoreEncEmptyTablespaceTest(CfsRestoreNoencEmptyTablespaceTest):
# --- Begin --- #
def setUp(self):
os.environ["PG_CIPHER_KEY"] = "super_secret_cipher_key"
super(CfsRestoreNoencEmptyTablespaceTest, self).setUp()
class CfsRestoreEncTest(CfsRestoreNoencTest):
# --- Begin --- #
def setUp(self):
os.environ["PG_CIPHER_KEY"] = "super_secret_cipher_key"
super(CfsRestoreNoencTest, self).setUp()

View File

@ -12,7 +12,7 @@ import os
import unittest
import shutil
from .helpers.cfs_helpers import find_by_extensions, find_by_name
from .helpers.cfs_helpers import find_by_name
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
@ -22,7 +22,7 @@ tblspace_name = 'cfs_tblspace_noenc'
tblspace_name_new = 'cfs_tblspace_new'
class CfsRestoreBaseTest(ProbackupTest, unittest.TestCase):
class CfsRestoreBase(ProbackupTest, unittest.TestCase):
def setUp(self):
self.fname = self.id().split('.')[3]
self.backup_dir = os.path.join(self.tmp_path, module_name, self.fname, 'backup')
@ -67,7 +67,7 @@ class CfsRestoreBaseTest(ProbackupTest, unittest.TestCase):
self.del_test_dir(module_name, self.fname)
class CfsRestoreNoencEmptyTablespaceTest(CfsRestoreBaseTest):
class CfsRestoreNoencEmptyTablespaceTest(CfsRestoreBase):
# @unittest.expectedFailure
# @unittest.skip("skip")
def test_restore_empty_tablespace_from_fullbackup(self):
@ -111,7 +111,7 @@ class CfsRestoreNoencEmptyTablespaceTest(CfsRestoreBaseTest):
)
class CfsRestoreNoencTest(CfsRestoreBaseTest):
class CfsRestoreNoencTest(CfsRestoreBase):
def add_data_in_cluster(self):
self.node.safe_psql(
"postgres",
@ -147,7 +147,7 @@ class CfsRestoreNoencTest(CfsRestoreBaseTest):
)
self.assertTrue(
find_by_name([self.get_tblspace_path(self.node, tblspace_name)], ['pg_compression']),
"ERROR: File pg_compression not found in backup dir"
"ERROR: File pg_compression not found in tablespace dir"
)
try:
self.node.start()
@ -285,14 +285,100 @@ class CfsRestoreNoencTest(CfsRestoreBaseTest):
self.node_new.cleanup()
# @unittest.expectedFailure
@unittest.skip("skip")
# @unittest.skip("skip")
def test_restore_from_fullbackup_to_old_location_tablespace_new_location(self):
pass
self.node.stop(['-m', 'immediate'])
self.node.cleanup()
shutil.rmtree(self.get_tblspace_path(self.node, tblspace_name))
os.mkdir(self.get_tblspace_path(self.node, tblspace_name_new))
try:
self.restore_node(
self.backup_dir,
'node', self.node,
backup_id=self.backup_id,
options=[
"-T %s = %s".format(
self.get_tblspace_path(self.node, tblspace_name),
self.get_tblspace_path(self.node, tblspace_name_new)
)
]
)
except ProbackupException as e:
self.fail(
"ERROR: Restore from full backup failed. \n {0} \n {1}".format(
repr(self.cmd),
repr(e.message)
)
)
self.assertTrue(
find_by_name([self.get_tblspace_path(self.node, tblspace_name_new)], ['pg_compression']),
"ERROR: File pg_compression not found in new tablespace location"
)
try:
self.node.start()
except ProbackupException as e:
self.fail(
"ERROR: Instance not started after restore. \n {0} \n {1}".format(
repr(self.cmd),
repr(e.message)
)
)
self.assertEqual(
repr(self.node.safe_psql("postgres", "SELECT * FROM %s" % 't1')),
repr(self.table_t1)
)
# @unittest.expectedFailure
@unittest.skip("skip")
# @unittest.skip("skip")
def test_restore_from_fullbackup_to_old_location_tablespace_new_location_3_jobs(self):
pass
self.node.stop(['-m', 'immediate'])
self.node.cleanup()
shutil.rmtree(self.get_tblspace_path(self.node, tblspace_name))
os.mkdir(self.get_tblspace_path(self.node, tblspace_name_new))
try:
self.restore_node(
self.backup_dir,
'node', self.node,
backup_id=self.backup_id,
options=[
"j",
"3",
"-T %s = %s".format(
self.get_tblspace_path(self.node, tblspace_name),
self.get_tblspace_path(self.node, tblspace_name_new)
)
]
)
except ProbackupException as e:
self.fail(
"ERROR: Restore from full backup failed. \n {0} \n {1}".format(
repr(self.cmd),
repr(e.message)
)
)
self.assertTrue(
find_by_name([self.get_tblspace_path(self.node, tblspace_name_new)], ['pg_compression']),
"ERROR: File pg_compression not found in new tablespace location"
)
try:
self.node.start()
except ProbackupException as e:
self.fail(
"ERROR: Instance not started after restore. \n {0} \n {1}".format(
repr(self.cmd),
repr(e.message)
)
)
self.assertEqual(
repr(self.node.safe_psql("postgres", "SELECT * FROM %s" % 't1')),
repr(self.table_t1)
)
# @unittest.expectedFailure
@unittest.skip("skip")

View File

@ -0,0 +1,25 @@
import os
import unittest
import random
from .helpers.cfs_helpers import find_by_extensions, find_by_name, find_by_pattern, corrupt_file
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
module_name = 'cfs_validate_backup'
tblspace_name = 'cfs_tblspace'
class CfsValidateBackupNoenc(ProbackupTest,unittest.TestCase):
def setUp(self):
pass
def test_validate_fullbackup_empty_tablespace_after_delete_pg_compression(self):
pass
def tearDown(self):
pass
class CfsValidateBackupNoenc(CfsValidateBackupNoenc):
os.environ["PG_CIPHER_KEY"] = "super_secret_cipher_key"
super(CfsValidateBackupNoenc).setUp()