1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-02-09 14:33:17 +02:00

tests: fixes for 2.3.0

This commit is contained in:
Grigory Smolkin 2020-04-29 01:26:56 +03:00
parent 04dacea1e7
commit 2927549456
6 changed files with 148 additions and 19 deletions

View File

@ -1200,7 +1200,6 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
os.path.join(backup_dir, 'wal', 'master'),
os.path.join(backup_dir, 'wal', 'replica'))
# Check data correctness on replica
replica.slow_start(replica=True)
# FULL backup replica

View File

@ -3,6 +3,7 @@ import subprocess
import os
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
from sys import exit
import shutil
module_name = 'compatibility'
@ -627,24 +628,23 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
self.set_archiving(backup_dir, 'node', node, old_binary=True)
node.slow_start()
node.pgbench_init(scale=1)
node.pgbench_init(scale=20)
# FULL backup with OLD binary
self.backup_node(
backup_dir, 'node', node,
old_binary=True)
backup_dir, 'node', node, old_binary=True)
pgbench = node.pgbench(
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
options=["-c", "4", "-T", "10"])
options=["-c", "1", "-T", "10", "--no-vacuum"])
pgbench.wait()
pgbench.stdout.close()
# PAGE1 backup with OLD binary
backup_id = self.backup_node(
self.backup_node(
backup_dir, 'node', node,
backup_type='page', old_binary=True)
backup_type='page', old_binary=True, options=['--log-level-file=LOG'])
node.safe_psql(
'postgres',
@ -655,20 +655,20 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
'VACUUM pgbench_accounts')
# PAGE2 backup with OLD binary
backup_id = self.backup_node(
self.backup_node(
backup_dir, 'node', node,
backup_type='page', old_binary=True)
backup_type='page', old_binary=True, options=['--log-level-file=LOG'])
# PAGE3 backup with OLD binary
backup_id = self.backup_node(
backup_dir, 'node', node,
backup_type='page', old_binary=True)
backup_type='page', old_binary=True, options=['--log-level-file=LOG'])
pgdata = self.pgdata_content(node.data_dir)
# merge chain created by old binary with new binary
output = self.merge_backup(
backup_dir, "node", backup_id)
backup_dir, "node", backup_id, options=['--log-level-file=LOG'])
# check that in-place is disabled
self.assertIn(
@ -689,6 +689,129 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
# Clean after yourself
self.del_test_dir(module_name, fname)
# @unittest.expectedFailure
# @unittest.skip("skip")
def test_backward_compatibility_merge_2(self):
"""
Create node, take FULL and PAGE backups with old binary,
merge them with new binary.
old binary version =< 2.2.7
"""
fname = self.id().split('.')[3]
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
node = self.make_simple_node(
base_dir=os.path.join(module_name, fname, 'node'),
set_replication=True,
initdb_params=['--data-checksums'],
pg_options={'autovacuum': 'off'})
self.init_pb(backup_dir, old_binary=True)
self.add_instance(backup_dir, 'node', node, old_binary=True)
self.set_archiving(backup_dir, 'node', node, old_binary=True)
node.slow_start()
node.pgbench_init(scale=50)
node.safe_psql(
'postgres',
'VACUUM pgbench_accounts')
node_restored = self.make_simple_node(
base_dir=os.path.join(module_name, fname, 'node_restored'))
# FULL backup with OLD binary
self.backup_node(backup_dir, 'node', node, old_binary=True)
pgbench = node.pgbench(
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
options=["-c", "1", "-T", "10", "--no-vacuum"])
pgbench.wait()
pgbench.stdout.close()
# PAGE1 backup with OLD binary
page1 = self.backup_node(
backup_dir, 'node', node,
backup_type='page', old_binary=True)
pgdata1 = self.pgdata_content(node.data_dir)
node.safe_psql(
'postgres',
"DELETE from pgbench_accounts where ctid > '(10,1)'")
# PAGE2 backup with OLD binary
page2 = self.backup_node(
backup_dir, 'node', node,
backup_type='page', old_binary=True)
pgdata2 = self.pgdata_content(node.data_dir)
# PAGE3 backup with OLD binary
page3 = self.backup_node(
backup_dir, 'node', node,
backup_type='page', old_binary=True)
pgdata3 = self.pgdata_content(node.data_dir)
pgbench = node.pgbench(
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
options=["-c", "1", "-T", "10", "--no-vacuum"])
pgbench.wait()
pgbench.stdout.close()
# PAGE4 backup with NEW binary
page4 = self.backup_node(
backup_dir, 'node', node, backup_type='page')
pgdata4 = self.pgdata_content(node.data_dir)
# merge backups one by one and check data correctness
# merge PAGE1
self.merge_backup(
backup_dir, "node", page1, options=['--log-level-file=VERBOSE'])
# check data correctness for PAGE1
node_restored.cleanup()
self.restore_node(
backup_dir, 'node', node_restored, backup_id=page1,
options=['--log-level-file=VERBOSE'])
pgdata_restored = self.pgdata_content(node_restored.data_dir)
self.compare_pgdata(pgdata1, pgdata_restored)
# merge PAGE2
self.merge_backup(backup_dir, "node", page2)
# check data correctness for PAGE2
node_restored.cleanup()
self.restore_node(backup_dir, 'node', node_restored, backup_id=page2)
pgdata_restored = self.pgdata_content(node_restored.data_dir)
self.compare_pgdata(pgdata2, pgdata_restored)
# merge PAGE3
self.show_pb(backup_dir, 'node', page3)
self.merge_backup(backup_dir, "node", page3)
self.show_pb(backup_dir, 'node', page3)
# check data correctness for PAGE3
node_restored.cleanup()
self.restore_node(backup_dir, 'node', node_restored, backup_id=page3)
pgdata_restored = self.pgdata_content(node_restored.data_dir)
self.compare_pgdata(pgdata3, pgdata_restored)
# merge PAGE4
self.merge_backup(backup_dir, "node", page4)
# check data correctness for PAGE4
node_restored.cleanup()
self.restore_node(backup_dir, 'node', node_restored, backup_id=page4)
pgdata_restored = self.pgdata_content(node_restored.data_dir)
self.compare_pgdata(pgdata4, pgdata_restored)
# Clean after yourself
self.del_test_dir(module_name, fname)
# @unittest.skip("skip")
def test_page_vacuum_truncate(self):
"""

View File

@ -340,7 +340,8 @@ class ProbackupTest(object):
# set major version
with open(os.path.join(node.data_dir, 'PG_VERSION')) as f:
node.major_version = float(str(f.read().rstrip()))
node.major_version_str = str(f.read().rstrip())
node.major_version = float(node.major_version_str)
# Sane default parameters
options = {}

View File

@ -388,7 +388,9 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
set_replication=True,
ptrack_enable=True,
initdb_params=['--data-checksums'],
pg_options={'wal_level': 'replica'})
pg_options={
'wal_level': 'replica',
'autovacuum': 'off'})
self.init_pb(backup_dir)
self.add_instance(backup_dir, 'node', node)
@ -421,19 +423,20 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
node_restored.cleanup()
self.restore_node(
backup_dir, 'node', node_restored, options=["-j", "4"])
backup_dir, 'node', node_restored,
node_restored.data_dir, options=["-j", "4"])
# Physical comparison
if self.paranoia:
pgdata_restored = self.pgdata_content(
pgdata_restored = self.pgdata_content(
node_restored.data_dir, ignore_ptrack=False)
self.compare_pgdata(pgdata, pgdata_restored)
self.set_auto_conf(
node_restored, {'port': node_restored.port})
node_restored.slow_start()
# Physical comparison
self.compare_pgdata(pgdata, pgdata_restored)
# Clean after yourself
self.del_test_dir(module_name, fname)

View File

@ -1455,6 +1455,9 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
# node1 is back to be a master
node1.promote()
node1.safe_psql('postgres', 'CHECKPOINT')
self.switch_wal_segment(node1)
sleep(5)
# delta3_id = self.backup_node(
# backup_dir, 'node', node2, node2.data_dir, 'delta')

View File

@ -2462,7 +2462,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
node.slow_start()
cat_version = node.get_control_data()["Catalog version number"]
version_specific_dir = 'PG_' + str(node.major_version) + '_' + cat_version
version_specific_dir = 'PG_' + node.major_version_str + '_' + cat_version
# PG_10_201707211
# pg_tblspc/33172/PG_9.5_201510051/16386/