|
2 | 2 | import os
|
3 | 3 | from time import sleep
|
4 | 4 | from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
| 5 | +from .helpers.cfs_helpers import find_by_name |
5 | 6 |
|
6 | 7 |
|
7 | 8 | module_name = 'backup'
|
@@ -345,7 +346,7 @@ def test_checksumm_fail_heal_via_ptrack(self):
|
345 | 346 | "Backup Status should be OK")
|
346 | 347 |
|
347 | 348 | # Clean after yourself
|
348 |
| - # self.del_test_dir(module_name, fname) |
| 349 | + self.del_test_dir(module_name, fname) |
349 | 350 |
|
350 | 351 | # @unittest.skip("skip")
|
351 | 352 | def test_checksumm_fail_heal_via_ptrack_fail(self):
|
@@ -418,4 +419,57 @@ def test_checksumm_fail_heal_via_ptrack_fail(self):
|
418 | 419 | "Backup Status should be ERROR")
|
419 | 420 |
|
420 | 421 | # Clean after yourself
|
421 |
| - # self.del_test_dir(module_name, fname) |
| 422 | + self.del_test_dir(module_name, fname) |
| 423 | + |
| 424 | + # @unittest.skip("skip") |
| 425 | + def test_tablespace_in_pgdata(self): |
| 426 | + """make node, corrupt some page, check that backup failed""" |
| 427 | + fname = self.id().split('.')[3] |
| 428 | + node = self.make_simple_node( |
| 429 | + base_dir="{0}/{1}/node".format(module_name, fname), |
| 430 | + set_replication=True, |
| 431 | + initdb_params=['--data-checksums'], |
| 432 | + pg_options={'wal_level': 'replica', 'max_wal_senders': '2'} |
| 433 | + ) |
| 434 | + backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') |
| 435 | + |
| 436 | + self.init_pb(backup_dir) |
| 437 | + self.add_instance(backup_dir, 'node', node) |
| 438 | + node.start() |
| 439 | + |
| 440 | + self.create_tblspace_in_node( |
| 441 | + node, 'tblspace1', |
| 442 | + tblspc_path=(os.path.join(node.data_dir, 'pg_clog', '100500')) |
| 443 | + ) |
| 444 | + |
| 445 | + node.safe_psql( |
| 446 | + "postgres", |
| 447 | + "create table t_heap tablespace tblspace1 as select 1 as id, " |
| 448 | + "md5(i::text) as text, " |
| 449 | + "md5(repeat(i::text,10))::tsvector as tsvector " |
| 450 | + "from generate_series(0,1000) i") |
| 451 | + |
| 452 | + self.backup_node( |
| 453 | + backup_dir, 'node', node, backup_type="full", |
| 454 | + options=["-j", "4", "--stream"]) |
| 455 | + |
| 456 | + relfilenode = node.safe_psql( |
| 457 | + "postgres", |
| 458 | + "select 't_heap'::regclass::oid" |
| 459 | + ).rstrip() |
| 460 | + |
| 461 | + list = [] |
| 462 | + for root, dirs, files in os.walk(backup_dir): |
| 463 | + for file in files: |
| 464 | + if file == relfilenode: |
| 465 | + path = os.path.join(root, file) |
| 466 | + list = list + [path] |
| 467 | + |
| 468 | + if len(list) > 0: |
| 469 | + message = "" |
| 470 | + for string in list: |
| 471 | + message = message + string + "\n" |
| 472 | + self.assertEqual( |
| 473 | + 1, 0, "Following file copied twice by backup:\n {1}".format( |
| 474 | + message) |
| 475 | + ) |
0 commit comments