mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-02-08 14:28:36 +02:00
Fix tests for retention policy. Compare WAL segments without timelineid
This commit is contained in:
parent
5aded200b8
commit
bf2830bad5
6
delete.c
6
delete.c
@ -349,12 +349,10 @@ delete_walfiles(XLogRecPtr oldest_lsn, TimeLineID oldest_tli, bool delete_all)
|
||||
* they were originally written, in case this worries you.
|
||||
*/
|
||||
if (IsXLogFileName(arcde->d_name) ||
|
||||
IsPartialXLogFileName(arcde->d_name) ||
|
||||
IsBackupHistoryFileName(arcde->d_name))
|
||||
IsPartialXLogFileName(arcde->d_name))
|
||||
{
|
||||
if (XLogRecPtrIsInvalid(oldest_lsn) ||
|
||||
strncmp(arcde->d_name, oldestSegmentNeeded,
|
||||
XLOG_FNAME_LEN) < 0)
|
||||
strcmp(arcde->d_name + 8, oldestSegmentNeeded + 8) < 0)
|
||||
{
|
||||
/*
|
||||
* Use the original file name again now, including any
|
||||
|
@ -89,7 +89,21 @@ class OptionTest(ProbackupTest, unittest.TestCase):
|
||||
self.clean_pb(node)
|
||||
self.assertEqual(self.init_pb(node), six.b(""))
|
||||
|
||||
# TODO: keep data generations
|
||||
# Command line parameters should override file values
|
||||
self.init_pb(node)
|
||||
with open(path.join(self.backup_dir(node), "pg_probackup.conf"), "a") as conf:
|
||||
conf.write("REDUNDANCY=1\n")
|
||||
|
||||
self.assertEqual(
|
||||
self.retention_show(node, ["--redundancy", "2"]),
|
||||
six.b("# retention policy\nREDUNDANCY=2\n")
|
||||
)
|
||||
|
||||
# User cannot send --system-identifier parameter via command line
|
||||
self.assertEqual(
|
||||
self.backup_pb(node, options=["--system-identifier", "123"]),
|
||||
six.b("ERROR: option system-identifier cannot be specified in command line\n")
|
||||
)
|
||||
|
||||
# invalid value in pg_probackup.conf
|
||||
with open(path.join(self.backup_dir(node), "pg_probackup.conf"), "a") as conf:
|
||||
|
@ -195,6 +195,14 @@ class ProbackupTest(object):
|
||||
|
||||
return self.run_pb(options + cmd_list)
|
||||
|
||||
def retention_show(self, node, options=[]):
|
||||
cmd_list = [
|
||||
"-B", self.backup_dir(node),
|
||||
"retention", "show",
|
||||
]
|
||||
|
||||
return self.run_pb(options + cmd_list)
|
||||
|
||||
def get_control_data(self, node):
|
||||
pg_controldata = node.get_bin_path("pg_controldata")
|
||||
out_data = {}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import unittest
|
||||
import os
|
||||
from datetime import datetime, timedelta
|
||||
from os import path
|
||||
from os import path, listdir
|
||||
from .pb_lib import ProbackupTest
|
||||
from testgres import stop_all
|
||||
|
||||
@ -35,9 +35,23 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
|
||||
self.assertEqual(len(self.show_pb(node)), 4)
|
||||
|
||||
# Purge backups
|
||||
self.retention_purge_pb(node)
|
||||
log = self.retention_purge_pb(node)
|
||||
self.assertEqual(len(self.show_pb(node)), 2)
|
||||
|
||||
# Check that WAL segments were deleted
|
||||
min_wal = None
|
||||
max_wal = None
|
||||
for line in log.splitlines():
|
||||
if line.startswith(b"INFO: removed min WAL segment"):
|
||||
min_wal = line[31:-1]
|
||||
elif line.startswith(b"INFO: removed max WAL segment"):
|
||||
max_wal = line[31:-1]
|
||||
for wal_name in listdir(path.join(self.backup_dir(node), "wal")):
|
||||
if not wal_name.endswith(".backup"):
|
||||
wal_name_b = wal_name.encode('ascii')
|
||||
self.assertEqual(wal_name_b[8:] > min_wal[8:], True)
|
||||
self.assertEqual(wal_name_b[8:] > max_wal[8:], True)
|
||||
|
||||
node.stop()
|
||||
|
||||
def test_retention_window_2(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user