@@ -163,6 +163,87 @@ def test_merge_compressed_backups(self):
163
163
node .cleanup ()
164
164
self .del_test_dir (module_name , fname )
165
165
166
+ def test_merge_compressed_and_uncompressed_backups (self ):
167
+ """
168
+ Test MERGE command with compressed and uncompressed backups
169
+ """
170
+ fname = self .id ().split ("." )[3 ]
171
+ backup_dir = os .path .join (self .tmp_path , module_name , fname , "backup" )
172
+
173
+ # Initialize instance and backup directory
174
+ node = self .make_simple_node (
175
+ base_dir = "{0}/{1}/node" .format (module_name , fname ),
176
+ initdb_params = ["--data-checksums" ],
177
+ pg_options = {
178
+ 'autovacuum' : 'off'
179
+ }
180
+ )
181
+
182
+ self .init_pb (backup_dir )
183
+ self .add_instance (backup_dir , "node" , node )
184
+ self .set_archiving (backup_dir , "node" , node )
185
+ node .slow_start ()
186
+
187
+ # Fill with data
188
+ node .pgbench_init (scale = 5 )
189
+
190
+ # Do compressed FULL backup
191
+ self .backup_node (backup_dir , "node" , node , options = [
192
+ '--compress-algorithm=zlib' , '--stream' ])
193
+ show_backup = self .show_pb (backup_dir , "node" )[0 ]
194
+
195
+ self .assertEqual (show_backup ["status" ], "OK" )
196
+ self .assertEqual (show_backup ["backup-mode" ], "FULL" )
197
+
198
+ # Change data
199
+ pgbench = node .pgbench (options = ['-T' , '20' , '-c' , '2' , '--no-vacuum' ])
200
+ pgbench .wait ()
201
+
202
+ # Do compressed DELTA backup
203
+ self .backup_node (
204
+ backup_dir , "node" , node , backup_type = "delta" ,
205
+ options = ['--compress-algorithm=zlib' , '--stream' ])
206
+ show_backup = self .show_pb (backup_dir , "node" )[1 ]
207
+
208
+ self .assertEqual (show_backup ["status" ], "OK" )
209
+ self .assertEqual (show_backup ["backup-mode" ], "DELTA" )
210
+
211
+ # Change data
212
+ pgbench = node .pgbench (options = ['-T' , '20' , '-c' , '2' , '--no-vacuum' ])
213
+ pgbench .wait ()
214
+
215
+ # Do not compressed PAGE backup
216
+ self .backup_node (
217
+ backup_dir , "node" , node , backup_type = "page" ,
218
+ options = ['--compress-algorithm=zlib' ])
219
+
220
+ pgdata = self .pgdata_content (node .data_dir )
221
+
222
+ show_backup = self .show_pb (backup_dir , "node" )[2 ]
223
+ page_id = show_backup ["id" ]
224
+
225
+ self .assertEqual (show_backup ["status" ], "OK" )
226
+ self .assertEqual (show_backup ["backup-mode" ], "PAGE" )
227
+
228
+ # Merge all backups
229
+ self .merge_backup (backup_dir , "node" , page_id )
230
+ show_backups = self .show_pb (backup_dir , "node" )
231
+
232
+ self .assertEqual (len (show_backups ), 1 )
233
+ self .assertEqual (show_backups [0 ]["status" ], "OK" )
234
+ self .assertEqual (show_backups [0 ]["backup-mode" ], "FULL" )
235
+
236
+ # Drop node and restore it
237
+ node .cleanup ()
238
+ self .restore_node (backup_dir , 'node' , node )
239
+
240
+ pgdata_restored = self .pgdata_content (node .data_dir )
241
+ self .compare_pgdata (pgdata , pgdata_restored )
242
+
243
+ # Clean after yourself
244
+ node .cleanup ()
245
+ self .del_test_dir (module_name , fname )
246
+
166
247
# @unittest.skip("skip")
167
248
def test_merge_tablespaces (self ):
168
249
"""
0 commit comments