1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-28 09:33:54 +02:00

[PBCKP-304] auto tests cleanup added to ptrack_helper.py

This commit is contained in:
Ivan Lazarev 2022-10-25 12:27:01 +03:00
parent fc8b89079b
commit bc945994de
3 changed files with 20 additions and 27 deletions

View File

@ -4,9 +4,8 @@ import random
import shutil
from .helpers.cfs_helpers import find_by_extensions, find_by_name, find_by_pattern, corrupt_file
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, is_test_result_ok
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
module_name = 'cfs_backup'
tblspace_name = 'cfs_tblspace'
@ -14,11 +13,10 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
# --- Begin --- #
@unittest.skipUnless(ProbackupTest.enterprise, 'skip')
def setUp(self):
self.fname = self.id().split('.')[3]
self.backup_dir = os.path.join(
self.tmp_path, module_name, self.fname, 'backup')
self.tmp_path, self.module_name, self.fname, 'backup')
self.node = self.make_simple_node(
base_dir="{0}/{1}/node".format(module_name, self.fname),
base_dir="{0}/{1}/node".format(self.module_name, self.fname),
set_replication=True,
ptrack_enable=True,
initdb_params=['--data-checksums'],
@ -1159,12 +1157,6 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
)
# # --- End ---#
@unittest.skipUnless(ProbackupTest.enterprise, 'skip')
def tearDown(self):
module_name = self.id().split('.')[1]
fname = self.id().split('.')[3]
if is_test_result_ok(self):
self.del_test_dir(module_name, fname)
#class CfsBackupEncTest(CfsBackupNoEncTest):

View File

@ -13,10 +13,7 @@ import unittest
import shutil
from .helpers.cfs_helpers import find_by_name
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, is_test_result_ok
module_name = 'cfs_restore'
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
tblspace_name = 'cfs_tblspace'
tblspace_name_new = 'cfs_tblspace_new'
@ -24,11 +21,10 @@ tblspace_name_new = 'cfs_tblspace_new'
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')
self.backup_dir = os.path.join(self.tmp_path, self.module_name, self.fname, 'backup')
self.node = self.make_simple_node(
base_dir="{0}/{1}/node".format(module_name, self.fname),
base_dir="{0}/{1}/node".format(self.module_name, self.fname),
set_replication=True,
initdb_params=['--data-checksums'],
pg_options={
@ -60,13 +56,6 @@ class CfsRestoreBase(ProbackupTest, unittest.TestCase):
def add_data_in_cluster(self):
pass
@unittest.skipUnless(ProbackupTest.enterprise, 'skip')
def tearDown(self):
module_name = self.id().split('.')[1]
fname = self.id().split('.')[3]
if is_test_result_ok(self):
self.del_test_dir(module_name, fname)
class CfsRestoreNoencEmptyTablespaceTest(CfsRestoreBase):
# @unittest.expectedFailure
@ -214,7 +203,7 @@ class CfsRestoreNoencTest(CfsRestoreBase):
self.node.cleanup()
shutil.rmtree(self.get_tblspace_path(self.node, tblspace_name))
node_new = self.make_simple_node(base_dir="{0}/{1}/node_new_location".format(module_name, self.fname))
node_new = self.make_simple_node(base_dir="{0}/{1}/node_new_location".format(self.module_name, self.fname))
node_new.cleanup()
try:
@ -257,7 +246,7 @@ class CfsRestoreNoencTest(CfsRestoreBase):
self.node.cleanup()
shutil.rmtree(self.get_tblspace_path(self.node, tblspace_name))
node_new = self.make_simple_node(base_dir="{0}/{1}/node_new_location".format(module_name, self.fname))
node_new = self.make_simple_node(base_dir="{0}/{1}/node_new_location".format(self.module_name, self.fname))
node_new.cleanup()
try:

View File

@ -204,6 +204,11 @@ class ProbackupTest(object):
def __init__(self, *args, **kwargs):
super(ProbackupTest, self).__init__(*args, **kwargs)
if isinstance(self, unittest.TestCase):
self.module_name = self.id().split('.')[1]
self.fname = self.id().split('.')[3]
if '-v' in argv or '--verbose' in argv:
self.verbose = True
else:
@ -367,6 +372,13 @@ class ProbackupTest(object):
os.environ["PGAPPNAME"] = "pg_probackup"
def tearDown(self):
if isinstance(self, unittest.TestCase):
module_name = self.id().split('.')[1]
fname = self.id().split('.')[3]
if is_test_result_ok(self):
self.del_test_dir(module_name, fname)
@property
def pg_config_version(self):
return self.version_to_num(