You've already forked pg_probackup
mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-09-16 09:26:30 +02:00
tests minor fixes
This commit is contained in:
@@ -2,8 +2,6 @@ import unittest
|
|||||||
import os
|
import os
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class BackupTest(ProbackupTest, unittest.TestCase):
|
class BackupTest(ProbackupTest, unittest.TestCase):
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteTest(ProbackupTest, unittest.TestCase):
|
class DeleteTest(ProbackupTest, unittest.TestCase):
|
||||||
|
@@ -2,9 +2,7 @@ import unittest
|
|||||||
import os
|
import os
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class FalsePositive(ProbackupTest, unittest.TestCase):
|
class FalsePositive(ProbackupTest, unittest.TestCase):
|
||||||
|
@@ -1,10 +1,6 @@
|
|||||||
import unittest
|
|
||||||
from sys import exit
|
|
||||||
import os
|
import os
|
||||||
from os import path
|
import unittest
|
||||||
from .helpers.ptrack_helpers import dir_files, ProbackupTest, ProbackupException
|
from .helpers.ptrack_helpers import dir_files, ProbackupTest, ProbackupException
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class InitTest(ProbackupTest, unittest.TestCase):
|
class InitTest(ProbackupTest, unittest.TestCase):
|
||||||
@@ -67,7 +63,7 @@ class InitTest(ProbackupTest, unittest.TestCase):
|
|||||||
backup_dir = os.path.join(self.tmp_path, self.module_name, fname, 'backup')
|
backup_dir = os.path.join(self.tmp_path, self.module_name, fname, 'backup')
|
||||||
node = self.make_simple_node(base_dir="{0}/{1}/node".format(self.module_name, fname))
|
node = self.make_simple_node(base_dir="{0}/{1}/node".format(self.module_name, fname))
|
||||||
try:
|
try:
|
||||||
self.run_pb(["init", "-B", path.relpath("%s/backup" % node.base_dir, self.dir_path)])
|
self.run_pb(["init", "-B", os.path.relpath("%s/backup" % node.base_dir, self.dir_path)])
|
||||||
self.assertEqual(1, 0, 'Expecting Error due to initialization with non-absolute path in --backup-path. Output: {0} \n CMD: {1}'.format(
|
self.assertEqual(1, 0, 'Expecting Error due to initialization with non-absolute path in --backup-path. Output: {0} \n CMD: {1}'.format(
|
||||||
repr(self.output), self.cmd))
|
repr(self.output), self.cmd))
|
||||||
except ProbackupException as e:
|
except ProbackupException as e:
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class OptionTest(ProbackupTest, unittest.TestCase):
|
class OptionTest(ProbackupTest, unittest.TestCase):
|
||||||
|
@@ -2,9 +2,7 @@ import os
|
|||||||
import unittest
|
import unittest
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, idx_ptrack
|
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, idx_ptrack
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class CheckSystemID(ProbackupTest, unittest.TestCase):
|
class CheckSystemID(ProbackupTest, unittest.TestCase):
|
||||||
|
@@ -2,9 +2,7 @@ import os
|
|||||||
import unittest
|
import unittest
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, idx_ptrack
|
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, idx_ptrack
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class ArchiveCheck(ProbackupTest, unittest.TestCase):
|
class ArchiveCheck(ProbackupTest, unittest.TestCase):
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleTest(ProbackupTest, unittest.TestCase):
|
class SimpleTest(ProbackupTest, unittest.TestCase):
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleTest(ProbackupTest, unittest.TestCase):
|
class SimpleTest(ProbackupTest, unittest.TestCase):
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from testgres import clean_all, stop_all
|
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleTest(ProbackupTest, unittest.TestCase):
|
class SimpleTest(ProbackupTest, unittest.TestCase):
|
||||||
@@ -10,11 +8,6 @@ class SimpleTest(ProbackupTest, unittest.TestCase):
|
|||||||
super(SimpleTest, self).__init__(*args, **kwargs)
|
super(SimpleTest, self).__init__(*args, **kwargs)
|
||||||
self.module_name = 'ptrack_move_to_tablespace'
|
self.module_name = 'ptrack_move_to_tablespace'
|
||||||
|
|
||||||
# @classmethod
|
|
||||||
# def tearDownClass(cls):
|
|
||||||
# clean_all()
|
|
||||||
# shutil.rmtree(os.path.join(self.tmp_path, self.module_name), ignore_errors=True)
|
|
||||||
|
|
||||||
# @unittest.skip("skip")
|
# @unittest.skip("skip")
|
||||||
# @unittest.expectedFailure
|
# @unittest.expectedFailure
|
||||||
def test_ptrack_recovery(self):
|
def test_ptrack_recovery(self):
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from sys import exit
|
from sys import exit
|
||||||
from testgres import clean_all, stop_all
|
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleTest(ProbackupTest, unittest.TestCase):
|
class SimpleTest(ProbackupTest, unittest.TestCase):
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleTest(ProbackupTest, unittest.TestCase):
|
class SimpleTest(ProbackupTest, unittest.TestCase):
|
||||||
@@ -10,11 +8,6 @@ class SimpleTest(ProbackupTest, unittest.TestCase):
|
|||||||
super(SimpleTest, self).__init__(*args, **kwargs)
|
super(SimpleTest, self).__init__(*args, **kwargs)
|
||||||
self.module_name = 'ptrack_vacuum'
|
self.module_name = 'ptrack_vacuum'
|
||||||
|
|
||||||
# @classmethod
|
|
||||||
# def tearDownClass(cls):
|
|
||||||
# clean_all()
|
|
||||||
# shutil.rmtree(os.path.join(self.tmp_path, self.module_name), ignore_errors=True)
|
|
||||||
|
|
||||||
# @unittest.skip("skip")
|
# @unittest.skip("skip")
|
||||||
# @unittest.expectedFailure
|
# @unittest.expectedFailure
|
||||||
def test_ptrack_vacuum(self):
|
def test_ptrack_vacuum(self):
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleTest(ProbackupTest, unittest.TestCase):
|
class SimpleTest(ProbackupTest, unittest.TestCase):
|
||||||
@@ -10,11 +8,6 @@ class SimpleTest(ProbackupTest, unittest.TestCase):
|
|||||||
super(SimpleTest, self).__init__(*args, **kwargs)
|
super(SimpleTest, self).__init__(*args, **kwargs)
|
||||||
self.module_name = 'ptrack_vacuum_bits_frozen'
|
self.module_name = 'ptrack_vacuum_bits_frozen'
|
||||||
|
|
||||||
# @classmethod
|
|
||||||
# def tearDownClass(cls):
|
|
||||||
# clean_all()
|
|
||||||
# shutil.rmtree(os.path.join(self.tmp_path, self.module_name), ignore_errors=True)
|
|
||||||
|
|
||||||
# @unittest.skip("skip")
|
# @unittest.skip("skip")
|
||||||
# @unittest.expectedFailure
|
# @unittest.expectedFailure
|
||||||
def test_ptrack_vacuum_bits_frozen(self):
|
def test_ptrack_vacuum_bits_frozen(self):
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleTest(ProbackupTest, unittest.TestCase):
|
class SimpleTest(ProbackupTest, unittest.TestCase):
|
||||||
@@ -10,11 +8,6 @@ class SimpleTest(ProbackupTest, unittest.TestCase):
|
|||||||
super(SimpleTest, self).__init__(*args, **kwargs)
|
super(SimpleTest, self).__init__(*args, **kwargs)
|
||||||
self.module_name = 'ptrack_vacuum_bits_visibility'
|
self.module_name = 'ptrack_vacuum_bits_visibility'
|
||||||
|
|
||||||
# @classmethod
|
|
||||||
# def tearDownClass(cls):
|
|
||||||
# clean_all()
|
|
||||||
# shutil.rmtree(os.path.join(self.tmp_path, self.module_name), ignore_errors=True)
|
|
||||||
|
|
||||||
# @unittest.skip("skip")
|
# @unittest.skip("skip")
|
||||||
# @unittest.expectedFailure
|
# @unittest.expectedFailure
|
||||||
def test_ptrack_vacuum_bits_visibility(self):
|
def test_ptrack_vacuum_bits_visibility(self):
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleTest(ProbackupTest, unittest.TestCase):
|
class SimpleTest(ProbackupTest, unittest.TestCase):
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
from .helpers.ptrack_helpers import ProbackupTest, idx_ptrack
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleTest(ProbackupTest, unittest.TestCase):
|
class SimpleTest(ProbackupTest, unittest.TestCase):
|
||||||
@@ -10,11 +8,6 @@ class SimpleTest(ProbackupTest, unittest.TestCase):
|
|||||||
super(SimpleTest, self).__init__(*args, **kwargs)
|
super(SimpleTest, self).__init__(*args, **kwargs)
|
||||||
self.module_name = 'ptrack_vacuum_truncate'
|
self.module_name = 'ptrack_vacuum_truncate'
|
||||||
|
|
||||||
# @classmethod
|
|
||||||
# def tearDownClass(self):
|
|
||||||
# clean_all()
|
|
||||||
# shutil.rmtree(os.path.join(self.tmp_path, self.module_name), ignore_errors=True)
|
|
||||||
|
|
||||||
# @unittest.skip("skip")
|
# @unittest.skip("skip")
|
||||||
# @unittest.expectedFailure
|
# @unittest.expectedFailure
|
||||||
def test_ptrack_vacuum_truncate(self):
|
def test_ptrack_vacuum_truncate(self):
|
||||||
|
@@ -1,12 +1,8 @@
|
|||||||
import unittest
|
|
||||||
import os
|
import os
|
||||||
|
import unittest
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, idx_ptrack
|
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, idx_ptrack
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
import subprocess
|
import subprocess
|
||||||
from sys import exit
|
|
||||||
import time
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class ReplicaTest(ProbackupTest, unittest.TestCase):
|
class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||||
@@ -15,11 +11,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
|||||||
super(ReplicaTest, self).__init__(*args, **kwargs)
|
super(ReplicaTest, self).__init__(*args, **kwargs)
|
||||||
self.module_name = 'replica'
|
self.module_name = 'replica'
|
||||||
|
|
||||||
# @classmethod
|
|
||||||
# def tearDownClass(cls):
|
|
||||||
# clean_all()
|
|
||||||
# shutil.rmtree(os.path.join(self.tmp_path, self.module_name), ignore_errors=True)
|
|
||||||
|
|
||||||
# @unittest.skip("skip")
|
# @unittest.skip("skip")
|
||||||
# @unittest.expectedFailure
|
# @unittest.expectedFailure
|
||||||
def test_replica_stream_full_backup(self):
|
def test_replica_stream_full_backup(self):
|
||||||
|
@@ -1,10 +1,8 @@
|
|||||||
import unittest
|
|
||||||
import os
|
import os
|
||||||
|
import unittest
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
import subprocess
|
import subprocess
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from sys import exit
|
|
||||||
|
|
||||||
|
|
||||||
class RestoreTest(ProbackupTest, unittest.TestCase):
|
class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||||
|
@@ -1,10 +1,7 @@
|
|||||||
import unittest
|
|
||||||
import os
|
import os
|
||||||
|
import unittest
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from os import path, listdir
|
|
||||||
from .helpers.ptrack_helpers import ProbackupTest
|
from .helpers.ptrack_helpers import ProbackupTest
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class RetentionTest(ProbackupTest, unittest.TestCase):
|
class RetentionTest(ProbackupTest, unittest.TestCase):
|
||||||
@@ -52,7 +49,7 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
|
|||||||
min_wal = line[31:-1]
|
min_wal = line[31:-1]
|
||||||
elif line.startswith("INFO: removed max WAL segment"):
|
elif line.startswith("INFO: removed max WAL segment"):
|
||||||
max_wal = line[31:-1]
|
max_wal = line[31:-1]
|
||||||
for wal_name in listdir(os.path.join(backup_dir, 'wal', 'node')):
|
for wal_name in os.listdir(os.path.join(backup_dir, 'wal', 'node')):
|
||||||
if not wal_name.endswith(".backup"):
|
if not wal_name.endswith(".backup"):
|
||||||
#wal_name_b = wal_name.encode('ascii')
|
#wal_name_b = wal_name.encode('ascii')
|
||||||
self.assertEqual(wal_name[8:] > min_wal[8:], True)
|
self.assertEqual(wal_name[8:] > min_wal[8:], True)
|
||||||
@@ -85,12 +82,12 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
|
|||||||
# Make backup to be keeped
|
# Make backup to be keeped
|
||||||
self.backup_node(backup_dir, 'node', node)
|
self.backup_node(backup_dir, 'node', node)
|
||||||
|
|
||||||
backups = path.join(backup_dir, 'backups', 'node')
|
backups = os.path.join(backup_dir, 'backups', 'node')
|
||||||
days_delta = 5
|
days_delta = 5
|
||||||
for backup in listdir(backups):
|
for backup in os.listdir(backups):
|
||||||
if backup == 'pg_probackup.conf':
|
if backup == 'pg_probackup.conf':
|
||||||
continue
|
continue
|
||||||
with open(path.join(backups, backup, "backup.control"), "a") as conf:
|
with open(os.path.join(backups, backup, "backup.control"), "a") as conf:
|
||||||
conf.write("recovery_time='{:%Y-%m-%d %H:%M:%S}'\n".format(
|
conf.write("recovery_time='{:%Y-%m-%d %H:%M:%S}'\n".format(
|
||||||
datetime.now() - timedelta(days=days_delta)))
|
datetime.now() - timedelta(days=days_delta)))
|
||||||
days_delta -= 1
|
days_delta -= 1
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
import unittest
|
|
||||||
import os
|
import os
|
||||||
from os import path
|
import unittest
|
||||||
from .helpers.ptrack_helpers import ProbackupTest
|
from .helpers.ptrack_helpers import ProbackupTest
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
|
|
||||||
class OptionTest(ProbackupTest, unittest.TestCase):
|
class OptionTest(ProbackupTest, unittest.TestCase):
|
||||||
@@ -55,7 +52,7 @@ class OptionTest(ProbackupTest, unittest.TestCase):
|
|||||||
backup_id = self.backup_node(backup_dir, 'node', node)
|
backup_id = self.backup_node(backup_dir, 'node', node)
|
||||||
|
|
||||||
# delete file which belong to backup
|
# delete file which belong to backup
|
||||||
file = path.join(backup_dir, "backups", "node", backup_id, "database", "postgresql.conf")
|
file = os.path.join(backup_dir, "backups", "node", backup_id, "database", "postgresql.conf")
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
|
|
||||||
self.validate_pb(backup_dir, 'node', backup_id)
|
self.validate_pb(backup_dir, 'node', backup_id)
|
||||||
|
@@ -1,10 +1,8 @@
|
|||||||
import unittest
|
|
||||||
import os
|
import os
|
||||||
|
import unittest
|
||||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from testgres import stop_all, clean_all
|
|
||||||
import subprocess
|
import subprocess
|
||||||
from sys import exit
|
|
||||||
|
|
||||||
|
|
||||||
class ValidateTest(ProbackupTest, unittest.TestCase):
|
class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||||
|
Reference in New Issue
Block a user