You've already forked pg_probackup
mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2026-06-21 01:34:15 +02:00
[NOJIRA] remove distutils
This commit is contained in:
@@ -8,7 +8,6 @@ from datetime import datetime, timedelta
|
||||
import subprocess
|
||||
from sys import exit
|
||||
from time import sleep
|
||||
from distutils.dir_util import copy_tree
|
||||
|
||||
|
||||
class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
@@ -1243,10 +1242,6 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
self.add_instance(backup_dir, 'replica', replica)
|
||||
self.set_archiving(backup_dir, 'replica', replica, replica=True)
|
||||
|
||||
copy_tree(
|
||||
os.path.join(backup_dir, 'wal', 'master'),
|
||||
os.path.join(backup_dir, 'wal', 'replica'))
|
||||
|
||||
replica.slow_start(replica=True)
|
||||
|
||||
# FULL backup replica
|
||||
|
||||
@@ -4,7 +4,6 @@ import re
|
||||
from time import sleep, time
|
||||
from .helpers.ptrack_helpers import base36enc, ProbackupTest, ProbackupException
|
||||
import shutil
|
||||
from distutils.dir_util import copy_tree
|
||||
from testgres import ProcessType, QueryException
|
||||
import subprocess
|
||||
|
||||
@@ -2330,14 +2329,13 @@ class BackupTest(ProbackupTest, unittest.TestCase):
|
||||
# bgwriter_pid = node.auxiliary_pids[ProcessType.BackgroundWriter][0]
|
||||
# gdb_checkpointer = self.gdb_attach(bgwriter_pid)
|
||||
|
||||
copy_tree(
|
||||
os.path.join(backup_dir, 'wal', 'node'),
|
||||
os.path.join(backup_dir, 'wal', 'replica'))
|
||||
|
||||
replica.slow_start(replica=True)
|
||||
|
||||
# self.switch_wal_segment(node)
|
||||
# self.switch_wal_segment(node)
|
||||
# make sure replica will archive wal segment with backup start point
|
||||
lsn = self.switch_wal_segment(node, and_tx=True)
|
||||
replica.poll_query_until(f"select pg_last_wal_replay_lsn() >= '{lsn}'")
|
||||
replica.execute('CHECKPOINT')
|
||||
replica.poll_query_until(f"select redo_lsn >= '{lsn}' from pg_control_checkpoint()")
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'replica', replica,
|
||||
|
||||
@@ -1701,29 +1701,26 @@ class ProbackupTest(object):
|
||||
num = num * 100 + int(re.sub(r"[^\d]", "", part))
|
||||
return num
|
||||
|
||||
def switch_wal_segment(self, node):
|
||||
def switch_wal_segment(self, node, sleep_seconds=1, and_tx=False):
|
||||
"""
|
||||
Execute pg_switch_wal/xlog() in given node
|
||||
Execute pg_switch_wal() in given node
|
||||
|
||||
Args:
|
||||
node: an instance of PostgresNode or NodeConnection class
|
||||
"""
|
||||
if isinstance(node, testgres.PostgresNode):
|
||||
if self.version_to_num(
|
||||
node.safe_psql('postgres', 'show server_version').decode('utf-8')
|
||||
) >= self.version_to_num('10.0'):
|
||||
node.safe_psql('postgres', 'select pg_switch_wal()')
|
||||
else:
|
||||
node.safe_psql('postgres', 'select pg_switch_xlog()')
|
||||
with node.connect('postgres') as con:
|
||||
if and_tx:
|
||||
con.execute('select txid_current()')
|
||||
con.execute('select pg_switch_wal()')
|
||||
lsn = con.execute('select pg_switch_wal()')[0][0]
|
||||
else:
|
||||
if self.version_to_num(
|
||||
node.execute('show server_version')[0][0]
|
||||
) >= self.version_to_num('10.0'):
|
||||
node.execute('select pg_switch_wal()')
|
||||
else:
|
||||
node.execute('select pg_switch_xlog()')
|
||||
node.execute('select pg_switch_wal()')
|
||||
lsn = node.execute('select pg_switch_wal()')[0][0]
|
||||
|
||||
sleep(1)
|
||||
if sleep_seconds > 0:
|
||||
sleep(sleep_seconds)
|
||||
return lsn
|
||||
|
||||
def wait_until_replica_catch_with_master(self, master, replica):
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, idx_ptrac
|
||||
from datetime import datetime, timedelta
|
||||
import subprocess
|
||||
import time
|
||||
from distutils.dir_util import copy_tree
|
||||
from testgres import ProcessType
|
||||
from time import sleep
|
||||
|
||||
@@ -718,10 +717,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
self.set_replica(master, replica, synchronous=True)
|
||||
self.set_archiving(backup_dir, 'replica', replica, replica=True)
|
||||
|
||||
copy_tree(
|
||||
os.path.join(backup_dir, 'wal', 'master'),
|
||||
os.path.join(backup_dir, 'wal', 'replica'))
|
||||
|
||||
replica.slow_start(replica=True)
|
||||
|
||||
self.switch_wal_segment(master)
|
||||
@@ -980,10 +975,6 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
self.set_replica(master, replica, synchronous=True)
|
||||
self.set_archiving(backup_dir, 'replica', replica, replica=True)
|
||||
|
||||
copy_tree(
|
||||
os.path.join(backup_dir, 'wal', 'master'),
|
||||
os.path.join(backup_dir, 'wal', 'replica'))
|
||||
|
||||
replica.slow_start(replica=True)
|
||||
|
||||
self.switch_wal_segment(master)
|
||||
|
||||
@@ -3,7 +3,6 @@ import unittest
|
||||
from datetime import datetime, timedelta
|
||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
||||
from time import sleep
|
||||
from distutils.dir_util import copy_tree
|
||||
|
||||
|
||||
class RetentionTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user