8000 tests: some fixes · postgrespro/pg_probackup@3813726 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3813726

Browse files
committed
tests: some fixes
1 parent 8dbc90a commit 3813726

File tree

2 files changed

+53
-5
lines changed

2 files changed

+53
-5
lines changed

tests/archive.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2638,13 +2638,13 @@ def test_archive_empty_history_file(self):
26382638
wal_dir = os.path.join(backup_dir, 'wal', 'node')
26392639

26402640
self.assertIn(
2641-
'WARNING: History file is corrupted: "{0}"'.format(os.path.join(wal_dir, '00000002.history')),
2641+
'WARNING: History file is corrupted or missing: "{0}"'.format(os.path.join(wal_dir, '00000002.history')),
26422642
log_content)
26432643
self.assertIn(
2644-
'WARNING: History file is corrupted: "{0}"'.format(os.path.join(wal_dir, '00000003.history')),
2644+
'WARNING: History file is corrupted or missing: "{0}"'.format(os.path.join(wal_dir, '00000003.history')),
26452645
log_content)
26462646
self.assertIn(
2647-
'WARNING: History file is corrupted: "{0}"'.format(os.path.join(wal_dir, '00000004.history')),
2647+
'WARNING: History file is corrupted or missing: "{0}"'.format(os.path.join(wal_dir, '00000004.history')),
26482648
log_content)
26492649

26502650
self.del_test_dir(module_name, fname)

tests/backup.py

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
55
import shutil
66
from distutils.dir_util import copy_tree
7-
from testgres import ProcessType
7+
from testgres import ProcessType, QueryException
88
import subprocess
99

1010

@@ -1576,7 +1576,7 @@ def test_basic_temp_slot_for_stream_backup(self):
15761576
set_replication=True,
15771577
initdb_params=['--data-checksums'],
15781578
pg_options={
1579-
'max_wal_size': '40MB'})
1579+
'max_wal_size': '40MB', 'default_transaction_read_only': 'on'})
15801580

15811581
self.init_pb(backup_dir)
15821582
self.add_instance(backup_dir, 'node', node)
@@ -3413,3 +3413,51 @@ def test_missing_replication_permission_1(self):
34133413

34143414
# Clean after yourself
34153415
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

Comments
 (0)
0