@@ -71,7 +71,12 @@ def test_retention_window_2(self):
7171 self .set_archiving (backup_dir , 'node' , node )
7272 node .start ()
7373
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 :
7580 conf .write ("retention-redundancy = 1\n " )
7681 conf .write ("retention-window = 1\n " )
7782
@@ -86,7 +91,9 @@ def test_retention_window_2(self):
8691 for backup in os .listdir (backups ):
8792 if backup == 'pg_probackup.conf' :
8893 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 :
9097 conf .write ("recovery_time='{:%Y-%m-%d %H:%M:%S}'\n " .format (
9198 datetime .now () - timedelta (days = days_delta )))
9299 days_delta -= 1
@@ -107,7 +114,8 @@ def test_retention_window_2(self):
107114 def test_retention_wal (self ):
108115 """purge backups using window-based retention policy"""
109116 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 ),
111119 initdb_params = ['--data-checksums' ],
112120 pg_options = {'wal_level' : 'replica' }
113121 )
@@ -119,13 +127,17 @@ def test_retention_wal(self):
119127
120128 node .safe_psql (
121129 "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" )
123133
124134 # Take FULL BACKUP
125135 self .backup_node (backup_dir , 'node' , node )
126136 node .safe_psql (
127137 "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" )
129141
130142 self .backup_node (backup_dir , 'node' , node )
131143
@@ -134,18 +146,21 @@ def test_retention_wal(self):
134146 for backup in os .listdir (backups ):
135147 if backup == 'pg_probackup.conf' :
136148 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 :
138152 conf .write ("recovery_time='{:%Y-%m-%d %H:%M:%S}'\n " .format (
139153 datetime .now () - timedelta (days = days_delta )))
140154 days_delta -= 1
141155
142156 # Make backup to be keeped
143157 self .backup_node (backup_dir , 'node' , node , backup_type = "page" )
144158
145- self .assertEqual (len (self .show_pb (backup_dir , 'node' )), 4 )
159+ self .assertEqual (len (self .show_pb (backup_dir , 'node' )), 3 )
146160
147161 # Purge backups
148- self .delete_expired (backup_dir , 'node' )
162+ self .delete_expired (
163+ backup_dir , 'node' , options = ['--retention-window=2' ])
149164 self .assertEqual (len (self .show_pb (backup_dir , 'node' )), 2 )
150165
151166 # Clean after yourself
0 commit comments