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

Merge branch 'fix_cfs_backup_test'

This commit is contained in:
anastasia 2021-02-12 13:29:54 +03:00
commit 6619f82c43
5 changed files with 61 additions and 48 deletions

View File

@ -1,7 +1,11 @@
[см wiki](https://confluence.postgrespro.ru/display/DEV/pg_probackup) [see wiki](https://confluence.postgrespro.ru/display/DEV/pg_probackup)
``` ```
Note: For now these are works on Linux and "kinda" works on Windows Note: For now these tests work on Linux and "kinda" work on Windows
```
```
Note: tests require python3 to work properly.
``` ```
``` ```

View File

@ -20,9 +20,9 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
self.node = self.make_simple_node( self.node = self.make_simple_node(
base_dir="{0}/{1}/node".format(module_name, self.fname), base_dir="{0}/{1}/node".format(module_name, self.fname),
set_replication=True, set_replication=True,
ptrack_enable=True,
initdb_params=['--data-checksums'], initdb_params=['--data-checksums'],
pg_options={ pg_options={
'ptrack_enable': 'on',
'cfs_encryption': 'off', 'cfs_encryption': 'off',
'max_wal_senders': '2', 'max_wal_senders': '2',
'shared_buffers': '200MB' 'shared_buffers': '200MB'
@ -35,18 +35,27 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
self.node.slow_start() self.node.slow_start()
if self.node.major_version >= 12:
self.node.safe_psql(
"postgres",
"CREATE EXTENSION ptrack")
self.create_tblspace_in_node(self.node, tblspace_name, cfs=True) self.create_tblspace_in_node(self.node, tblspace_name, cfs=True)
tblspace = self.node.safe_psql( tblspace = self.node.safe_psql(
"postgres", "postgres",
"SELECT * FROM pg_tablespace WHERE spcname='{0}'".format( "SELECT * FROM pg_tablespace WHERE spcname='{0}'".format(
tblspace_name) tblspace_name))
)
self.assertTrue( self.assertIn(
tblspace_name in tblspace and "compression=true" in tblspace, tblspace_name, str(tblspace),
"ERROR: The tablespace not created " "ERROR: The tablespace not created "
"or it create without compressions" "or it create without compressions")
)
self.assertIn(
"compression=true", str(tblspace),
"ERROR: The tablespace not created "
"or it create without compressions")
self.assertTrue( self.assertTrue(
find_by_name( find_by_name(
@ -473,7 +482,7 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
) )
# --- Section: Incremental from fill tablespace --- # # --- Section: Incremental from fill tablespace --- #
@unittest.expectedFailure # @unittest.expectedFailure
# @unittest.skip("skip") # @unittest.skip("skip")
@unittest.skipUnless(ProbackupTest.enterprise, 'skip') @unittest.skipUnless(ProbackupTest.enterprise, 'skip')
def test_fullbackup_after_create_table_ptrack_after_create_table(self): def test_fullbackup_after_create_table_ptrack_after_create_table(self):
@ -537,7 +546,7 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
) )
) )
@unittest.expectedFailure # @unittest.expectedFailure
# @unittest.skip("skip") # @unittest.skip("skip")
@unittest.skipUnless(ProbackupTest.enterprise, 'skip') @unittest.skipUnless(ProbackupTest.enterprise, 'skip')
def test_fullbackup_after_create_table_ptrack_after_create_table_stream(self): def test_fullbackup_after_create_table_ptrack_after_create_table_stream(self):
@ -603,7 +612,7 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
) )
) )
@unittest.expectedFailure # @unittest.expectedFailure
# @unittest.skip("skip") # @unittest.skip("skip")
@unittest.skipUnless(ProbackupTest.enterprise, 'skip') @unittest.skipUnless(ProbackupTest.enterprise, 'skip')
def test_fullbackup_after_create_table_page_after_create_table(self): def test_fullbackup_after_create_table_page_after_create_table(self):
@ -738,12 +747,14 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
# CHECK FULL BACKUP # CHECK FULL BACKUP
self.node.stop() self.node.stop()
self.node.cleanup() self.node.cleanup()
shutil.rmtree( shutil.rmtree(self.get_tblspace_path(self.node, tblspace_name))
self.get_tblspace_path(self.node, tblspace_name),
ignore_errors=True)
self.restore_node( self.restore_node(
self.backup_dir, 'node', self.node, self.backup_dir, 'node', self.node, backup_id=backup_id_full,
backup_id=backup_id_full, options=["-j", "4"]) options=[
"-j", "4",
"--recovery-target=immediate",
"--recovery-target-action=promote"])
self.node.slow_start() self.node.slow_start()
self.assertEqual( self.assertEqual(
full_result, full_result,
@ -757,8 +768,12 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
self.get_tblspace_path(self.node, tblspace_name), self.get_tblspace_path(self.node, tblspace_name),
ignore_errors=True) ignore_errors=True)
self.restore_node( self.restore_node(
self.backup_dir, 'node', self.node, self.backup_dir, 'node', self.node, backup_id=backup_id_page,
backup_id=backup_id_page, options=["-j", "4"]) options=[
"-j", "4",
"--recovery-target=immediate",
"--recovery-target-action=promote"])
self.node.slow_start() self.node.slow_start()
self.assertEqual( self.assertEqual(
page_result, page_result,
@ -786,8 +801,7 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
"AS SELECT i AS id, MD5(i::text) AS text, " "AS SELECT i AS id, MD5(i::text) AS text, "
"MD5(repeat(i::text,10))::tsvector AS tsvector " "MD5(repeat(i::text,10))::tsvector AS tsvector "
"FROM generate_series(0,1005000) i".format( "FROM generate_series(0,1005000) i".format(
't_heap_1', tblspace_name_1) 't_heap_1', tblspace_name_1))
)
self.node.safe_psql( self.node.safe_psql(
"postgres", "postgres",
@ -795,8 +809,7 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
"AS SELECT i AS id, MD5(i::text) AS text, " "AS SELECT i AS id, MD5(i::text) AS text, "
"MD5(repeat(i::text,10))::tsvector AS tsvector " "MD5(repeat(i::text,10))::tsvector AS tsvector "
"FROM generate_series(0,1005000) i".format( "FROM generate_series(0,1005000) i".format(
't_heap_2', tblspace_name_2) 't_heap_2', tblspace_name_2))
)
full_result_1 = self.node.safe_psql( full_result_1 = self.node.safe_psql(
"postgres", "SELECT * FROM t_heap_1") "postgres", "SELECT * FROM t_heap_1")
@ -864,21 +877,16 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
# CHECK FULL BACKUP # CHECK FULL BACKUP
self.node.stop() self.node.stop()
self.node.cleanup()
shutil.rmtree(
self.get_tblspace_path(self.node, tblspace_name),
ignore_errors=True)
shutil.rmtree(
self.get_tblspace_path(self.node, tblspace_name_1),
ignore_errors=True)
shutil.rmtree(
self.get_tblspace_path(self.node, tblspace_name_2),
ignore_errors=True)
self.restore_node( self.restore_node(
self.backup_dir, 'node', self.node, self.backup_dir, 'node', self.node,
backup_id=backup_id_full, options=["-j", "4"]) backup_id=backup_id_full,
options=[
"-j", "4", "--incremental-mode=checksum",
"--recovery-target=immediate",
"--recovery-target-action=promote"])
self.node.slow_start() self.node.slow_start()
self.assertEqual( self.assertEqual(
full_result_1, full_result_1,
self.node.safe_psql("postgres", "SELECT * FROM t_heap_1"), self.node.safe_psql("postgres", "SELECT * FROM t_heap_1"),
@ -890,21 +898,16 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
# CHECK PAGE BACKUP # CHECK PAGE BACKUP
self.node.stop() self.node.stop()
self.node.cleanup()
shutil.rmtree(
self.get_tblspace_path(self.node, tblspace_name),
ignore_errors=True)
shutil.rmtree(
self.get_tblspace_path(self.node, tblspace_name_1),
ignore_errors=True)
shutil.rmtree(
self.get_tblspace_path(self.node, tblspace_name_2),
ignore_errors=True)
self.restore_node( self.restore_node(
self.backup_dir, 'node', self.node, self.backup_dir, 'node', self.node,
backup_id=backup_id_page, options=["-j", "4"]) backup_id=backup_id_page,
options=[
"-j", "4", "--incremental-mode=checksum",
"--recovery-target=immediate",
"--recovery-target-action=promote"])
self.node.slow_start() self.node.slow_start()
self.assertEqual( self.assertEqual(
page_result_1, page_result_1,
self.node.safe_psql("postgres", "SELECT * FROM t_heap_1"), self.node.safe_psql("postgres", "SELECT * FROM t_heap_1"),
@ -914,7 +917,7 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
self.node.safe_psql("postgres", "SELECT * FROM t_heap_2"), self.node.safe_psql("postgres", "SELECT * FROM t_heap_2"),
'Lost data after restore') 'Lost data after restore')
@unittest.expectedFailure # @unittest.expectedFailure
# @unittest.skip("skip") # @unittest.skip("skip")
@unittest.skipUnless(ProbackupTest.enterprise, 'skip') @unittest.skipUnless(ProbackupTest.enterprise, 'skip')
def test_fullbackup_after_create_table_page_after_create_table_stream(self): def test_fullbackup_after_create_table_page_after_create_table_stream(self):

View File

@ -88,4 +88,6 @@ def corrupt_file(filename):
def random_string(n): def random_string(n):
a = string.ascii_letters + string.digits a = string.ascii_letters + string.digits
return ''.join([random.choice(a) for i in range(int(n)+1)]) random_str = ''.join([random.choice(a) for i in range(int(n)+1)])
return str.encode(random_str)
# return ''.join([random.choice(a) for i in range(int(n)+1)])

View File

@ -1711,6 +1711,9 @@ class IncrRestoreTest(ProbackupTest, unittest.TestCase):
# @unittest.skip("skip") # @unittest.skip("skip")
# @unittest.expectedFailure # @unittest.expectedFailure
# This test will pass with Enterprise
# because it has checksums enabled by default
@unittest.skipIf(ProbackupTest.enterprise, 'skip')
def test_incr_lsn_long_xact_1(self): def test_incr_lsn_long_xact_1(self):
""" """
""" """

View File

@ -3451,7 +3451,8 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
# Clean after yourself # Clean after yourself
self.del_test_dir(module_name, fname) self.del_test_dir(module_name, fname)
# @unittest.expectedFailure #TODO fix the test
@unittest.expectedFailure
# @unittest.skip("skip") # @unittest.skip("skip")
def test_validate_target_lsn(self): def test_validate_target_lsn(self):
""" """