1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-12-01 09:51:43 +02:00
pg_probackup/tests/snapfs.py

63 lines
1.7 KiB
Python
Raw Normal View History

2019-01-25 18:37:21 +02:00
import unittest
import os
from time import sleep
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
module_name = 'snapfs'
class SnapFSTest(ProbackupTest, unittest.TestCase):
# @unittest.skip("skip")
# @unittest.expectedFailure
2019-02-11 19:04:33 +02:00
def test_snapfs_simple(self):
2019-01-25 18:37:21 +02:00
"""standart backup modes with ARCHIVE WAL method"""
fname = self.id().split('.')[3]
node = self.make_simple_node(
base_dir=os.path.join(module_name, fname, 'node'),
initdb_params=['--data-checksums'],
pg_options={
'wal_level': 'replica'})
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
self.init_pb(backup_dir)
self.add_instance(backup_dir, 'node', node)
self.set_archiving(backup_dir, 'node', node)
node.slow_start()
self.backup_node(backup_dir, 'node', node)
node.safe_psql(
'postgres',
'select pg_make_snapshot()')
2019-02-11 19:04:33 +02:00
node.pgbench_init(scale=10)
2019-01-25 18:37:21 +02:00
pgbench = node.pgbench(options=['-T', '50', '-c', '2', '--no-vacuum'])
pgbench.wait()
self.backup_node(
backup_dir, 'node', node, backup_type='page')
node.safe_psql(
'postgres',
'select pg_remove_snapshot(1)')
2019-01-25 18:37:21 +02:00
self.backup_node(
2019-02-11 19:14:00 +02:00
backup_dir, 'node', node, backup_type='page')
2019-01-25 18:37:21 +02:00
pgdata = self.pgdata_content(node.data_dir)
node.cleanup()
self.restore_node(
backup_dir, 'node',
2019-02-11 19:04:33 +02:00
node, options=["-j", "4"])
2019-01-25 18:37:21 +02:00
pgdata_restored = self.pgdata_content(node.data_dir)
self.compare_pgdata(pgdata, pgdata_restored)
# Clean after yourself
self.del_test_dir(module_name, fname)