mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2026-06-21 01:34:15 +02:00
clean data after run test
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# you need os for unittest to work
|
# you need os for unittest to work
|
||||||
import os
|
import os
|
||||||
|
import gc
|
||||||
from sys import exit, argv, version_info
|
from sys import exit, argv, version_info
|
||||||
import subprocess
|
import subprocess
|
||||||
import shutil
|
import shutil
|
||||||
@@ -1515,29 +1516,24 @@ class ProbackupTest(object):
|
|||||||
def get_bin_path(self, binary):
|
def get_bin_path(self, binary):
|
||||||
return testgres.get_bin_path(binary)
|
return testgres.get_bin_path(binary)
|
||||||
|
|
||||||
|
def clean_all(self):
|
||||||
|
for o in gc.get_referrers(testgres.PostgresNode):
|
||||||
|
if o.__class__ is testgres.PostgresNode:
|
||||||
|
o.cleanup()
|
||||||
|
|
||||||
def del_test_dir(self, module_name, fname, nodes=[]):
|
def del_test_dir(self, module_name, fname, nodes=[]):
|
||||||
""" Del testdir and optimistically try to del module dir"""
|
""" Del testdir and optimistically try to del module dir"""
|
||||||
try:
|
try:
|
||||||
testgres.clean_all()
|
self.clean_all()
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
raise e
|
||||||
|
|
||||||
if not nodes:
|
|
||||||
nodes = self.nodes
|
|
||||||
for node in list(nodes):
|
|
||||||
try:
|
|
||||||
if node.status() == 0:
|
|
||||||
node.stop()
|
|
||||||
except:
|
|
||||||
raise
|
|
||||||
finally:
|
|
||||||
if node in self.nodes:
|
|
||||||
self.nodes.remove(node)
|
|
||||||
|
|
||||||
shutil.rmtree(
|
shutil.rmtree(
|
||||||
os.path.join(
|
os.path.join(
|
||||||
self.tmp_path,
|
self.tmp_path,
|
||||||
module_name
|
module_name,
|
||||||
|
fname,
|
||||||
|
"backup"
|
||||||
),
|
),
|
||||||
ignore_errors=True
|
ignore_errors=True
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user