|
4 | 4 | from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
5 | 5 | import shutil
|
6 | 6 | from distutils.dir_util import copy_tree
|
7 |
| -from testgres import ProcessType |
| 7 | +from testgres import ProcessType, QueryException |
8 | 8 | import subprocess
|
9 | 9 |
|
10 | 10 |
|
@@ -1576,7 +1576,7 @@ def test_basic_temp_slot_for_stream_backup(self):
|
1576 | 1576 | set_replication=True,
|
1577 | 1577 | initdb_params=['--data-checksums'],
|
1578 | 1578 | pg_options={
|
1579 |
| - 'max_wal_size': '40MB'}) |
| 1579 | + 'max_wal_size': '40MB', 'default_transaction_read_only': 'on'}) |
1580 | 1580 |
|
1581 | 1581 | self.init_pb(backup_dir)
|
1582 | 1582 | self.add_instance(backup_dir, 'node', node)
|
@@ -3413,3 +3413,51 @@ def test_missing_replication_permission_1(self):
|
3413 | 3413 |
|
3414 | 3414 | # Clean after yourself
|
3415 | 3415 | self.del_test_dir(module_name, fname)
|
| 3416 | + |
| 3417 | + # @unittest.skip("skip") |
| 3418 | + def test_basic_backup_default_transaction_read_only(self): |
| 3419 | + """""" |
| 3420 | + fname = self.id().split('.')[3] |
| 3421 | + backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') |
| 3422 | + node = self.make_simple_node( |
| 3423 | + base_dir=os.path.join(module_name, fname, 'node'), |
| 3424 | + set_replication=True, |
| 3425 | + initdb_params=['--data-checksums'], |
| 3426 | + pg_options={'default_transaction_read_only': 'on'}) |
| 3427 | + |
| 3428 | + self.init_pb(backup_dir) |
| 3429 | + self.add_instance(backup_dir, 'node', node) |
| 3430 | + self.set_archiving(backup_dir, 'node', node) |
| 3431 | + node.slow_start() |
| 3432 | + |
| 3433 | + try: |
| 3434 | + node.safe_psql( |
| 3435 | + 'postgres', |
| 3436 | + 'create temp table t1()') |
| 3437 | + # we should die here because exception is what we expect to happen |
| 3438 | + self.assertEqual( |
| 3439 | + 1, 0, |
| 3440 | + "Expecting Error because incremental backup should not be possible " |
| 3441 | + "\n Output: {0} \n CMD: {1}".format( |
| 3442 | + repr(self.output), self.cmd)) |
| 3443 | + except QueryException as e: |
| 3444 | + self.assertIn( |
| 3445 | + "cannot execute CREATE TABLE in a read-only transaction", |
| 3446 | + e.message, |
| 3447 | + "\n Unexpected Error Message: {0}\n CMD: {1}".format( |
| 3448 | + repr(e.message), self.cmd)) |
| 3449 | + |
| 3450 | + # FULL backup |
| 3451 | + self.backup_node( |
| 3452 | + backup_dir, 'node', node, |
| 3453 | + options=['--stream', '--temp-slot']) |
| 3454 | + |
| 3455 | + # DELTA backup |
| 3456 | + self.backup_node( |
| 3457 | + backup_dir, 'node', node, backup_type='delta', options=['--stream']) |
| 3458 | + |
| 3459 | + # PAGE backup |
| 3460 | + self.backup_node(backup_dir, 'node', node, backup_type='page') |
| 3461 | + |
| 3462 | + # Clean after yourself |
| 3463 | + self.del_test_dir(module_name, fname) |
0 commit comments