@@ -18,9 +18,6 @@ class BackupTest(ProbackupTest, unittest.TestCase):
18
18
# PGPRO-707
19
19
def test_backup_modes_archive (self ):
20
20
"""standart backup modes with ARCHIVE WAL method"""
21
- if not self .ptrack :
22
- return unittest .skip ('Skipped because ptrack support is disabled' )
23
-
24
21
fname = self .id ().split ('.' )[3 ]
25
22
node = self .make_simple_node (
26
23
base_dir = os .path .join (module_name , fname , 'node' ),
@@ -33,12 +30,7 @@ def test_backup_modes_archive(self):
33
30
self .set_archiving (backup_dir , 'node' , node )
34
31
node .slow_start ()
35
32
36
- if node .major_version >= 12 :
37
- node .safe_psql (
38
- "postgres" ,
39
- "CREATE EXTENSION ptrack" )
40
-
41
- backup_id = self .backup_node (backup_dir , 'node' , node )
33
+ full_backup_id = self .backup_node (backup_dir , 'node' , node )
42
34
show_backup = self .show_pb (backup_dir , 'node' )[0 ]
43
35
44
36
self .assertEqual (show_backup ['status' ], "OK" )
@@ -47,7 +39,7 @@ def test_backup_modes_archive(self):
47
39
# postmaster.pid and postmaster.opts shouldn't be copied
48
40
excluded = True
49
41
db_dir = os .path .join (
50
- backup_dir , "backups" , 'node' , backup_id , "database" )
42
+ backup_dir , "backups" , 'node' , full_backup_id , "database" )
51
43
52
44
for f in os .listdir (db_dir ):
53
45
if (
@@ -64,31 +56,30 @@ def test_backup_modes_archive(self):
64
56
page_backup_id = self .backup_node (
65
57
backup_dir , 'node' , node , backup_type = "page" )
66
58
67
- # print self.show_pb(node)
68
- show_backup = self .show_pb (backup_dir , 'node' )[1 ]
59
+ show_backup_1 = self .show_pb (backup_dir , 'node' )[1 ]
69
60
self .assertEqual (show_backup ['status' ], "OK" )
70
61
self .assertEqual (show_backup ['backup-mode' ], "PAGE" )
71
62
63
+ # delta backup mode
64
+ delta_backup_id = self .backup_node (
65
+ backup_dir , 'node' , node , backup_type = "delta" )
66
+
67
+ show_backup_2 = self .show_pb (backup_dir , 'node' )[2 ]
68
+ self .assertEqual (show_backup ['status' ], "OK" )
69
+ self .assertEqual (show_backup ['backup-mode' ], "DELTA" )
70
+
72
71
# Check parent backup
73
72
self .assertEqual (
74
- backup_id ,
73
+ full_backup_id ,
75
74
self .show_pb (
76
75
backup_dir , 'node' ,
77
- backup_id = show_backup ['id' ])["parent-backup-id" ])
78
-
79
- # ptrack backup mode
80
- self .backup_node (backup_dir , 'node' , node , backup_type = "ptrack" )
76
+ backup_id = show_backup_1 ['id' ])["parent-backup-id" ])
81
77
82
- show_backup = self .show_pb (backup_dir , 'node' )[2 ]
83
- self .assertEqual (show_backup ['status' ], "OK" )
84
- self .assertEqual (show_backup ['backup-mode' ], "PTRACK" )
85
-
86
- # Check parent backup
87
78
self .assertEqual (
88
79
page_backup_id ,
89
80
self .show_pb (
90
81
backup_dir , 'node' ,
91
- backup_id = show_backup ['id' ])["parent-backup-id" ])
82
+ backup_id = show_backup_2 ['id' ])["parent-backup-id" ])
92
83
93
84
# Clean after yourself
94
85
self .del_test_dir (module_name , fname )
@@ -118,10 +109,7 @@ def test_smooth_checkpoint(self):
118
109
119
110
# @unittest.skip("skip")
120
111
def test_incremental_backup_without_full (self ):
121
- """page-level backup without validated full backup"""
122
- if not self .ptrack :
123
- return unittest .skip ('Skipped because ptrack support is disabled' )
124
-
112
+ """page backup without validated full backup"""
125
113
fname = self .id ().split ('.' )[3 ]
126
114
node = self .make_simple_node (
127
115
base_dir = os .path .join (module_name , fname , 'node' ),
@@ -134,11 +122,6 @@ def test_incremental_backup_without_full(self):
134
122
self .set_archiving (backup_dir , 'node' , node )
135
123
node .slow_start ()
136
124
137
- if node .major_version >= 12 :
138
- node .safe_psql (
139
- "postgres" ,
140
- "CREATE EXTENSION ptrack" )
141
-
142
125
try :
143
126
self .backup_node (backup_dir , 'node' , node , backup_type = "page" )
144
127
# we should die here because exception is what we expect to happen
@@ -154,29 +137,10 @@ def test_incremental_backup_without_full(self):
154
137
"\n Unexpected Error Message: {0}\n CMD: {1}" .format (
155
138
repr (e .message ), self .cmd ))
156
139
157
- try :
158
- self .backup_node (backup_dir , 'node' , node , backup_type = "ptrack" )
159
- # we should die here because exception is what we expect to happen
160
- self .assertEqual (
161
- 1 , 0 ,
162
- "Expecting Error because page backup should not be possible "
163
- "without valid full backup.\n Output: {0} \n CMD: {1}" .format (
164
- repr (self .output ), self .cmd ))
165
- except ProbackupException as e :
166
- self .assertTrue (
167
- "WARNING: Valid full backup on current timeline 1 is not found" in e .message and
168
- "ERROR: Create new full backup before an incremental one" in e .message ,
169
- "\n Unexpected Error Message: {0}\n CMD: {1}" .format (
170
- repr (e .message ), self .cmd ))
171
-
172
140
self .assertEqual (
173
141
self .show_pb (backup_dir , 'node' )[0 ]['status' ],
174
142
"ERROR" )
175
143
176
- self .assertEqual (
177
- self .show_pb (backup_dir , 'node' )[1 ]['status' ],
178
- "ERROR" )
179
-
180
144
# Clean after yourself
181
145
self .del_test_dir (module_name , fname )
182
146
@@ -242,72 +206,27 @@ def test_incremental_backup_corrupt_full(self):
242
206
self .del_test_dir (module_name , fname )
243
207
244
208
# @unittest.skip("skip")
245
- def test_ptrack_threads (self ):
246
- """ptrack multi thread backup mode"""
247
- if not self .ptrack :
248
- return unittest .skip ('Skipped because ptrack support is disabled' )
249
-
250
- fname = self .id ().split ('.' )[3 ]
251
- node = self .make_simple_node (
252
- base_dir = os .path .join (module_name , fname , 'node' ),
253
- initdb_params = ['--data-checksums' ],
254
- ptrack_enable = True )
255
-
256
- backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
257
- self .init_pb (backup_dir )
258
- self .add_instance (backup_dir , 'node' , node )
259
- self .set_archiving (backup_dir , 'node' , node )
260
- node .slow_start ()
261
-
262
- if node .major_version >= 12 :
263
- node .safe_psql (
264
- "postgres" ,
265
- "CREATE EXTENSION ptrack" )
266
-
267
- self .backup_node (
268
- backup_dir , 'node' , node ,
269
- backup_type = "full" , options = ["-j" , "4" ])
270
- self .assertEqual (self .show_pb (backup_dir , 'node' )[0 ]['status' ], "OK" )
271
-
272
- self .backup_node (
273
- backup_dir , 'node' , node ,
274
- backup_type = "ptrack" , options = ["-j" , "4" ])
275
- self .assertEqual (self .show_pb (backup_dir , 'node' )[0 ]['status' ], "OK" )
276
-
277
- # Clean after yourself
278
- self .del_test_dir (module_name , fname )
279
-
280
- # @unittest.skip("skip")
281
- def test_ptrack_threads_stream (self ):
282
- """ptrack multi thread backup mode and stream"""
283
- if not self .ptrack :
284
- return unittest .skip ('Skipped because ptrack support is disabled' )
285
-
209
+ def test_delta_threads_stream (self ):
210
+ """delta multi thread backup mode and stream"""
286
211
fname = self .id ().split ('.' )[3 ]
287
212
node = self .make_simple_node (
288
213
base_dir = os .path .join (module_name , fname , 'node' ),
289
214
set_replication = True ,
290
- initdb_params = ['--data-checksums' ],
291
- ptrack_enable = True )
215
+ initdb_params = ['--data-checksums' ])
292
216
293
217
backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
294
218
self .init_pb (backup_dir )
295
219
self .add_instance (backup_dir , 'node' , node )
296
220
node .slow_start ()
297
221
298
- if node .major_version >= 12 :
299
- node .safe_psql (
300
- "postgres" ,
301
- "CREATE EXTENSION ptrack" )
302
-
303
222
self .backup_node (
304
223
backup_dir , 'node' , node , backup_type = "full" ,
305
224
options = ["-j" , "4" , "--stream" ])
306
225
307
226
self .assertEqual (self .show_pb (backup_dir , 'node' )[0 ]['status' ], "OK" )
308
227
self .backup_node (
309
228
backup_dir , 'node' , node ,
310
- backup_type = "ptrack " , options = ["-j" , "4" , "--stream" ])
229
+ backup_type = "delta " , options = ["-j" , "4" , "--stream" ])
311
230
self .assertEqual (self .show_pb (backup_dir , 'node' )[1 ]['status' ], "OK" )
312
231
313
232
# Clean after yourself
@@ -1459,76 +1378,6 @@ def test_drop_rel_during_backup_page(self):
1459
1378
# Clean after yourself
1460
1379
self .del_test_dir (module_name , fname )
1461
1380
1462
- # @unittest.skip("skip")
1463
- def test_drop_rel_during_backup_ptrack (self ):
1464
- """"""
1465
- if not self .ptrack :
1466
- return unittest .skip ('Skipped because ptrack support is disabled' )
1467
-
1468
- fname = self .id ().split ('.' )[3 ]
1469
- backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
1470
- node = self .make_simple_node (
1471
- base_dir = os .path .join (module_name , fname , 'node' ),
1472
- set_replication = True ,
1473
- ptrack_enable = self .ptrack ,
1474
- initdb_params = ['--data-checksums' ])
1475
-
1476
- self .init_pb (backup_dir )
1477
- self .add_instance (backup_dir , 'node' , node )
1478
- self .set_archiving (backup_dir , 'node' , node )
1479
- node .slow_start ()
1480
-
1481
- if node .major_version >= 12 :
1482
- node .safe_psql (
1483
- "postgres" ,
1484
- "CREATE EXTENSION ptrack" )
1485
-
1486
- node .safe_psql (
1487
- "postgres" ,
1488
- "create table t_heap as select i"
1489
- " as id from generate_series(0,100) i" )
1490
-
1491
- relative_path = node .safe_psql (
1492
- "postgres" ,
1493
- "select pg_relation_filepath('t_heap')" ).decode ('utf-8' ).rstrip ()
1494
-
1495
- absolute_path = os .path .join (node .data_dir , relative_path )
1496
-
1497
- # FULL backup
1498
- self .backup_node (backup_dir , 'node' , node , options = ['--stream' ])
1499
-
1500
- # PTRACK backup
1501
- gdb = self .backup_node (
1502
- backup_dir , 'node' , node , backup_type = 'ptrack' ,
1503
- gdb = True , options = ['--log-level-file=LOG' ])
1504
-
1505
- gdb .set_breakpoint ('backup_files' )
1506
- gdb .run_until_break ()
1507
-
1508
- # REMOVE file
1509
- os .remove (absolute_path )
1510
-
1511
- # File removed, we can proceed with backup
1512
- gdb .continue_execution_until_exit ()
1513
-
1514
- pgdata = self .pgdata_content (node .data_dir )
1515
-
1516
- with open (os .path .join (backup_dir , 'log' , 'pg_probackup.log' )) as f :
1517
- log_content = f .read ()
1518
- self .assertTrue (
1519
- 'LOG: File not found: "{0}"' .format (absolute_path ) in log_content ,
1520
- 'File "{0}" should be deleted but it`s not' .format (absolute_path ))
1521
-
1522
- node .cleanup ()
1523
- self .restore_node (backup_dir , 'node' , node , options = ["-j" , "4" ])
1524
-
1525
- # Physical comparison
1526
- pgdata_restored = self .pgdata_content (node .data_dir )
1527
- self .compare_pgdata (pgdata , pgdata_restored )
1528
-
1529
- # Clean after yourself
1530
- self .del_test_dir (module_name , fname )
1531
-
1532
1381
# @unittest.skip("skip")
1533
1382
def test_persistent_slot_for_stream_backup (self ):
1534
1383
""""""
@@ -1992,10 +1841,11 @@ def test_backup_with_least_privileges_role(self):
1992
1841
'postgres' ,
1993
1842
'CREATE DATABASE backupdb' )
1994
1843
1995
- if self .ptrack and node . major_version >= 12 :
1844
+ if self .ptrack :
1996
1845
node .safe_psql (
1997
1846
"backupdb" ,
1998
- "CREATE EXTENSION ptrack WITH SCHEMA pg_catalog" )
1847
+ "CREATE SCHEMA ptrack; "
1848
+ "CREATE EXTENSION ptrack WITH SCHEMA ptrack" )
1999
1849
2000
1850
# PG 9.5
2001
1851
if self .get_version (node ) < 90600 :
@@ -2105,33 +1955,14 @@ def test_backup_with_least_privileges_role(self):
2105
1955
)
2106
1956
2107
1957
if self .ptrack :
2108
- if node .major_version < 12 :
2109
- # Reviewer, NB: skip this test in case of old ptrack?
2110
- for fname in [
2111
- 'pg_catalog.oideq(oid, oid)' ,
2112
- 'pg_catalog.ptrack_version()' ,
2113
- 'pg_catalog.pg_ptrack_clear()' ,
2114
- 'pg_catalog.pg_ptrack_control_lsn()' ,
2115
- 'pg_catalog.pg_ptrack_get_and_clear_db(oid, oid)' ,
2116
- 'pg_catalog.pg_ptrack_get_and_clear(oid, oid)' ,
2117
- 'pg_catalog.pg_ptrack_get_block_2(oid, oid, oid, bigint)' ,
2118
- 'pg_catalog.pg_stop_backup()' ]:
2119
-
2120
- node .safe_psql (
2121
- "backupdb" ,
2122
- "GRANT EXECUTE ON FUNCTION {0} "
2123
- "TO backup" .format (fname ))
2124
- else :
2125
- fnames = [
2126
- 'pg_catalog.ptrack_get_pagemapset(pg_lsn)' ,
2127
- 'pg_catalog.ptrack_init_lsn()'
2128
- ]
2129
-
2130
- for fname in fnames :
2131
- node .safe_psql (
2132
- "backupdb" ,
2133
- "GRANT EXECUTE ON FUNCTION {0} "
2134
- "TO backup" .format (fname ))
1958
+ node .safe_psql (
1959
+ "backupdb" ,
1960
+ "GRANT USAGE ON SCHEMA ptrack TO backup" )
1961
+
1962
+ node .safe_psql (
1963
+ "backupdb" ,
1964
+ "GRANT EXECUTE ON FUNCTION ptrack.ptrack_get_pagemapset(pg_lsn) TO backup; "
1965
+ "GRANT EXECUTE ON FUNCTION 'ptrack.ptrack_init_lsn()' TO backup; " )
2135
1966
2136
1967
if ProbackupTest .enterprise :
2137
1968
node .safe_psql (
@@ -2391,7 +2222,7 @@ def test_backup_with_less_privileges_role(self):
2391
2222
'postgres' ,
2392
2223
'CREATE DATABASE backupdb' )
2393
2224
2394
- if self .ptrack and node . major_version >= 12 :
2225
+ if self .ptrack :
2395
2226
node .safe_psql (
2396
2227
'backupdb' ,
2397
2228
'CREATE EXTENSION ptrack' )
0 commit comments