Skip to content

Commit 211159e

Browse files
author
Ivan Lazarev
committed
[PBCKP-304] auto tests cleanup added to ptrack_helper.py
1 parent 383a1a8 commit 211159e

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

tests/cfs_backup.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import shutil
55

66
from .helpers.cfs_helpers import find_by_extensions, find_by_name, find_by_pattern, corrupt_file
7-
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, is_test_result_ok
7+
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
88

99
tblspace_name = 'cfs_tblspace'
1010

@@ -13,9 +13,6 @@ class CfsBackupNoEncTest(ProbackupTest, unittest.TestCase):
1313
# --- Begin --- #
1414
@unittest.skipUnless(ProbackupTest.enterprise, 'skip')
1515
def setUp(self):
16-
self.module_name = self.id().split('.')[1]
17-
self.fname = self.id().split('.')[3]
18-
1916
self.backup_dir = os.path.join(
2017
self.tmp_path, self.module_name, self.fname, 'backup')
2118
self.node = self.make_simple_node(
@@ -1160,15 +1157,9 @@ def test_broken_file_pg_compression_into_tablespace_dir(self):
11601157
)
11611158

11621159
# # --- End ---#
1163-
@unittest.skipUnless(ProbackupTest.enterprise, 'skip')
1164-
def tearDown(self):
1165-
module_name = self.id().split('.')[1]
1166-
fname = self.id().split('.')[3]
1167-
if is_test_result_ok(self):
1168-
self.del_test_dir(module_name, fname)
11691160

11701161

1171-
#class CfsBackupEncTest(CfsBackupNoEncTest):
1162+
# class CfsBackupEncTest(CfsBackupNoEncTest):
11721163
# # --- Begin --- #
11731164
# def setUp(self):
11741165
# os.environ["PG_CIPHER_KEY"] = "super_secret_cipher_key"

tests/cfs_restore.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,14 @@
1313
import shutil
1414

1515
from .helpers.cfs_helpers import find_by_name
16-
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, is_test_result_ok
16+
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
1717

1818
tblspace_name = 'cfs_tblspace'
1919
tblspace_name_new = 'cfs_tblspace_new'
2020

2121

2222
class CfsRestoreBase(ProbackupTest, unittest.TestCase):
2323
def setUp(self):
24-
self.module_name = self.id().split('.')[1]
25-
self.fname = self.id().split('.')[3]
26-
2724
self.backup_dir = os.path.join(self.tmp_path, self.module_name, self.fname, 'backup')
2825

2926
self.node = self.make_simple_node(
@@ -59,13 +56,6 @@ def setUp(self):
5956
def add_data_in_cluster(self):
6057
pass
6158

62-
@unittest.skipUnless(ProbackupTest.enterprise, 'skip')
63-
def tearDown(self):
64-
module_name = self.id().split('.')[1]
65-
fname = self.id().split('.')[3]
66-
if is_test_result_ok(self):
67-
self.del_test_dir(module_name, fname)
68-
6959

7060
class CfsRestoreNoencEmptyTablespaceTest(CfsRestoreBase):
7161
# @unittest.expectedFailure

tests/helpers/ptrack_helpers.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,16 @@ class ProbackupTest(object):
201201
# Class attributes
202202
enterprise = is_enterprise()
203203
enable_nls = is_nls_enabled()
204+
module_name = None
205+
fname = None
204206

205207
def __init__(self, *args, **kwargs):
206208
super(ProbackupTest, self).__init__(*args, **kwargs)
209+
210+
if isinstance(self, unittest.TestCase):
211+
self.module_name = self.id().split('.')[1]
212+
self.fname = self.id().split('.')[3]
213+
207214
if '-v' in argv or '--verbose' in argv:
208215
self.verbose = True
209216
else:
@@ -367,6 +374,13 @@ def __init__(self, *args, **kwargs):
367374

368375
os.environ["PGAPPNAME"] = "pg_probackup"
369376

377+
def tearDown(self):
378+
if isinstance(self, unittest.TestCase):
379+
module_name = self.id().split('.')[1]
380+
fname = self.id().split('.')[3]
381+
if is_test_result_ok(self):
382+
self.del_test_dir(module_name, fname)
383+
370384
@property
371385
def pg_config_version(self):
372386
return self.version_to_num(

0 commit comments

Comments
 (0)