@@ -71,7 +71,12 @@ def test_retention_window_2(self):
71
71
self .set_archiving (backup_dir , 'node' , node )
72
72
node .start ()
73
73
74
- with open (os .path .join (backup_dir , 'backups' , 'node' , "pg_probackup.conf" ), "a" ) as conf :
74
+ with open (
75
+ os .path .join (
76
+ backup_dir ,
77
+ 'backups' ,
78
+ 'node' ,
79
+ "pg_probackup.conf" ), "a" ) as conf :
75
80
conf .write ("retention-redundancy = 1\n " )
76
81
conf .write ("retention-window = 1\n " )
77
82
@@ -86,7 +91,9 @@ def test_retention_window_2(self):
86
91
for backup in os .listdir (backups ):
87
92
if backup == 'pg_probackup.conf' :
88
93
continue
89
- with open (os .path .join (backups , backup , "backup.control" ), "a" ) as conf :
94
+ with open (
95
+ os .path .join (
96
+ backups , backup , "backup.control" ), "a" ) as conf :
90
97
conf .write ("recovery_time='{:%Y-%m-%d %H:%M:%S}'\n " .format (
91
98
datetime .now () - timedelta (days = days_delta )))
92
99
days_delta -= 1
@@ -107,7 +114,8 @@ def test_retention_window_2(self):
107
114
def test_retention_wal (self ):
108
115
"""purge backups using window-based retention policy"""
109
116
fname = self .id ().split ('.' )[3 ]
110
- node = self .make_simple_node (base_dir = "{0}/{1}/node" .format (module_name , fname ),
117
+ node = self .make_simple_node (
118
+ base_dir = "{0}/{1}/node" .format (module_name , fname ),
111
119
initdb_params = ['--data-checksums' ],
112
120
pg_options = {'wal_level' : 'replica' }
113
121
)
@@ -119,13 +127,17 @@ def test_retention_wal(self):
119
127
120
128
node .safe_psql (
121
129
"postgres" ,
122
- "create table t_heap as select i as id, md5(i::text) as text, md5(repeat(i::text,10))::tsvector as tsvector from generate_series(0,100500) i" )
130
+ "create table t_heap as select i as id, md5(i::text) as text, "
131
+ "md5(repeat(i::text,10))::tsvector as tsvector "
132
+ "from generate_series(0,100500) i" )
123
133
124
134
# Take FULL BACKUP
125
135
self .backup_node (backup_dir , 'node' , node )
126
136
node .safe_psql (
127
137
"postgres" ,
128
- "insert into t_heap select i as id, md5(i::text) as text, md5(repeat(i::text,10))::tsvector as tsvector from generate_series(0,100500) i" )
138
+ "insert into t_heap select i as id, md5(i::text) as text, "
139
+ "md5(repeat(i::text,10))::tsvector as tsvector "
140
+ "from generate_series(0,100500) i" )
129
141
130
142
self .backup_node (backup_dir , 'node' , node )
131
143
@@ -134,18 +146,21 @@ def test_retention_wal(self):
134
146
for backup in os .listdir (backups ):
135
147
if backup == 'pg_probackup.conf' :
136
148
continue
137
- with open (os .path .join (backups , backup , "backup.control" ), "a" ) as conf :
149
+ with open (
150
+ os .path .join (
151
+ backups , backup , "backup.control" ), "a" ) as conf :
138
152
conf .write ("recovery_time='{:%Y-%m-%d %H:%M:%S}'\n " .format (
139
153
datetime .now () - timedelta (days = days_delta )))
140
154
days_delta -= 1
141
155
142
156
# Make backup to be keeped
143
157
self .backup_node (backup_dir , 'node' , node , backup_type = "page" )
144
158
145
- self .assertEqual (len (self .show_pb (backup_dir , 'node' )), 4 )
159
+ self .assertEqual (len (self .show_pb (backup_dir , 'node' )), 3 )
146
160
147
161
# Purge backups
148
- self .delete_expired (backup_dir , 'node' )
162
+ self .delete_expired (
163
+ backup_dir , 'node' , options = ['--retention-window=2' ])
149
164
self .assertEqual (len (self .show_pb (backup_dir , 'node' )), 2 )
150
165
151
166
# Clean after yourself
0 commit comments