@@ -35,7 +35,9 @@ def test_backup_via_unpriviledged_user(self):
35
35
base_dir = "{0}/{1}/node" .format (module_name , fname ),
36
36
set_replication = True ,
37
37
initdb_params = ['--data-checksums' ],
38
- pg_options = {'wal_level' : 'replica' , 'max_wal_senders' : '2' }
38
+ pg_options = {
39
+ 'wal_level' : 'replica' ,
40
+ 'max_wal_senders' : '2' }
39
41
)
40
42
backup_dir = os .path .join (self .tmp_path , module_name , fname , 'backup' )
41
43
self .init_pb (backup_dir )
@@ -107,10 +109,70 @@ def test_backup_via_unpriviledged_user(self):
107
109
"postgres" ,
108
110
"GRANT EXECUTE ON FUNCTION "
109
111
"pg_stop_backup(boolean, boolean) TO backup" )
112
+ # Do this for ptrack backups
113
+ node .safe_psql (
114
+ "postgres" ,
115
+ "GRANT EXECUTE ON FUNCTION pg_stop_backup() TO backup" )
116
+
117
+ self .backup_node (
118
+ backup_dir , 'node' , node , options = ['-U' , 'backup' ])
119
+
120
+ node .safe_psql ("postgres" , "CREATE DATABASE test1" )
110
121
111
122
self .backup_node (
112
123
backup_dir , 'node' , node , options = ['-U' , 'backup' ])
113
124
125
+ node .safe_psql (
126
+ "test1" , "create table t1 as select generate_series(0,100)" )
127
+
128
+ node .append_conf ("postgresql.auto.conf" , "ptrack_enable = 'on'" )
129
+ node .restart ()
130
+
131
+ try :
132
+ self .backup_node (
133
+ backup_dir , 'node' , node , options = ['-U' , 'backup' ])
134
+ self .assertEqual (
135
+ 1 , 0 ,
136
+ "Expecting Error due to missing grant on clearing ptrack_files." )
137
+ except ProbackupException as e :
138
+ self .assertIn (
139
+ "ERROR: must be superuser or replication role to clear ptrack files\n "
140
+ "query was: SELECT pg_catalog.pg_ptrack_clear()" , e .message ,
141
+ '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
142
+ repr (e .message ), self .cmd ))
143
+
144
+ time .sleep (1 )
145
+
146
+ try :
147
+ self .backup_node (
148
+ backup_dir , 'node' , node ,
149
+ backup_type = 'ptrack' , options = ['-U' , 'backup' ])
150
+ self .assertEqual (
151
+ 1 , 0 ,
152
+ "Expecting Error due to missing grant on clearing ptrack_files." )
153
+ except ProbackupException as e :
154
+ self .assertIn (
155
+ "ERROR: must be superuser or replication role read ptrack files\n "
156
+ "query was: select pg_catalog.pg_ptrack_control_lsn()" , e .message ,
157
+ '\n Unexpected Error Message: {0}\n CMD: {1}' .format (
158
+ repr (e .message ), self .cmd ))
159
+
160
+ node .safe_psql (
161
+ "postgres" ,
162
+ "ALTER ROLE backup REPLICATION" )
163
+
164
+ time .sleep (1 )
165
+
166
+ # FULL
167
+ self .backup_node (
168
+ backup_dir , 'node' , node ,
169
+ options = ['-U' , 'backup' ])
170
+
171
+ # PTRACK
172
+ self .backup_node (
173
+ backup_dir , 'node' , node ,
174
+ backup_type = 'ptrack' , options = ['-U' , 'backup' ])
175
+
114
176
# Clean after yourself
115
177
self .del_test_dir (module_name , fname )
116
178
0 commit comments