|
3 | 3 | importgzip |
4 | 4 | importunittest |
5 | 5 | from .helpers.ptrack_helpersimportProbackupTest,ProbackupException,GdbException |
| 6 | +from .helpers.ptrack_helpersimporttail_file |
6 | 7 | fromdatetimeimportdatetime,timedelta |
7 | 8 | importsubprocess |
8 | 9 | fromsysimportexit |
@@ -2204,7 +2205,7 @@ def test_archive_get_prefetch_corruption(self): |
2204 | 2205 |
|
2205 | 2206 | self.backup_node(backup_dir,'node',node,options=['--stream']) |
2206 | 2207 |
|
2207 | | -node.pgbench_init(scale=50) |
| 2208 | +node.pgbench_init(scale=20) |
2208 | 2209 |
|
2209 | 2210 | replica=self.make_simple_node( |
2210 | 2211 | base_dir=os.path.join(self.module_name,self.fname,'replica')) |
@@ -2251,7 +2252,7 @@ def test_archive_get_prefetch_corruption(self): |
2251 | 2252 |
|
2252 | 2253 | # generate WAL, copy it into prefetch directory, then corrupt |
2253 | 2254 | # some segment |
2254 | | -node.pgbench_init(scale=20) |
| 2255 | +node.pgbench_init(scale=5) |
2255 | 2256 | sleep(20) |
2256 | 2257 |
|
2257 | 2258 | # now copy WAL files into prefetch directory and corrupt some of them |
@@ -2304,18 +2305,20 @@ def test_archive_get_prefetch_corruption(self): |
2304 | 2305 | os.remove(os.path.join(replica.logs_dir,'postgresql.log')) |
2305 | 2306 | replica.slow_start(replica=True) |
2306 | 2307 |
|
2307 | | -sleep(60) |
2308 | | - |
2309 | | -withopen(os.path.join(replica.logs_dir,'postgresql.log'),'r')asf: |
2310 | | -postgres_log_content=f.read() |
2311 | | - |
2312 | | -self.assertIn( |
2313 | | -'Prefetched WAL segment {0} is invalid, cannot use it'.format(filename), |
2314 | | -postgres_log_content) |
2315 | | - |
2316 | | -self.assertIn( |
2317 | | -'LOG: restored log file "{0}" from archive'.format(filename), |
2318 | | -postgres_log_content) |
| 2308 | +prefetch_line='Prefetched WAL segment {0} is invalid, cannot use it'.format(filename) |
| 2309 | +has_prefetch_line=False |
| 2310 | +restored_line='LOG: restored log file "{0}" from archive'.format(filename) |
| 2311 | +has_restored_line=False |
| 2312 | +forlineintail_file(os.path.join(replica.logs_dir,'postgresql.log')): |
| 2313 | +ifnothas_prefetch_line: |
| 2314 | +has_prefetch_line=prefetch_lineinline |
| 2315 | +ifnothas_restored_line: |
| 2316 | +has_restored_line=restored_lineinline |
| 2317 | +ifhas_prefetch_lineandhas_restored_line: |
| 2318 | +break |
| 2319 | + |
| 2320 | +self.assertTrue(has_prefetch_line) |
| 2321 | +self.assertTrue(has_restored_line) |
2319 | 2322 |
|
2320 | 2323 | # @unittest.skip("skip") |
2321 | 2324 | deftest_archive_show_partial_files_handling(self): |
|