Skip to content

Commit 9834bab

Browse files
author
vshepard
committedMay 2, 2024
Add s3 tests
1 parent 2b9c9b1 commit 9834bab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+14339
-20420
lines changed
 

‎tests/CVE_2018_1058_test.py

+18-35
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import os
22
import unittest
3-
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
3+
from .helpers.ptrack_helpers import ProbackupTest
44

5-
class CVE_2018_1058(ProbackupTest, unittest.TestCase):
5+
class CVE_2018_1058(ProbackupTest):
66

77
# @unittest.skip("skip")
88
def test_basic_default_search_path(self):
99
""""""
10-
backup_dir = os.path.join(self.tmp_path, self.module_name, self.fname, 'backup')
11-
node = self.make_simple_node(
12-
base_dir=os.path.join(self.module_name, self.fname, 'node'),
13-
set_replication=True)
10+
node = self.pg_node.make_simple('node', checksum=False, set_replication=True)
1411

15-
self.init_pb(backup_dir)
16-
self.add_instance(backup_dir, 'node', node)
12+
self.pb.init()
13+
self.pb.add_instance('node', node)
1714
node.slow_start()
1815

1916
node.safe_psql(
@@ -26,19 +23,16 @@ def test_basic_default_search_path(self):
2623
"END "
2724
"$$ LANGUAGE plpgsql")
2825

29-
self.backup_node(backup_dir, 'node', node, backup_type='full', options=['--stream'])
26+
self.pb.backup_node('node', node, backup_type='full', options=['--stream'])
3027

3128
# @unittest.skip("skip")
3229
def test_basic_backup_modified_search_path(self):
3330
""""""
34-
backup_dir = os.path.join(self.tmp_path, self.module_name, self.fname, 'backup')
35-
node = self.make_simple_node(
36-
base_dir=os.path.join(self.module_name, self.fname, 'node'),
37-
set_replication=True)
38-
self.set_auto_conf(node, options={'search_path': 'public,pg_catalog'})
31+
node = self.pg_node.make_simple('node', checksum=False, set_replication=True)
32+
node.set_auto_conf(options={'search_path': 'public,pg_catalog'})
3933

40-
self.init_pb(backup_dir)
41-
self.add_instance(backup_dir, 'node', node)
34+
self.pb.init()
35+
self.pb.add_instance('node', node)
4236
node.slow_start()
4337

4438
node.safe_psql(
@@ -62,7 +56,7 @@ def test_basic_backup_modified_search_path(self):
6256
"$$ LANGUAGE plpgsql; "
6357
"CREATE VIEW public.pg_proc AS SELECT proname FROM public.pg_proc()")
6458

65-
self.backup_node(backup_dir, 'node', node, backup_type='full', options=['--stream'])
59+
self.pb.backup_node('node', node, backup_type='full', options=['--stream'])
6660

6761
log_file = os.path.join(node.logs_dir, 'postgresql.log')
6862
with open(log_file, 'r') as f:
@@ -73,10 +67,8 @@ def test_basic_backup_modified_search_path(self):
7367
# @unittest.skip("skip")
7468
def test_basic_checkdb_modified_search_path(self):
7569
""""""
76-
node = self.make_simple_node(
77-
base_dir=os.path.join(self.module_name, self.fname, 'node'),
78-
initdb_params=['--data-checksums'])
79-
self.set_auto_conf(node, options={'search_path': 'public,pg_catalog'})
70+
node = self.pg_node.make_simple('node')
71+
node.set_auto_conf(options={'search_path': 'public,pg_catalog'})
8072
node.slow_start()
8173

8274
node.safe_psql(
@@ -110,20 +102,11 @@ def test_basic_checkdb_modified_search_path(self):
110102
"CREATE VIEW public.pg_namespace AS SELECT * FROM public.pg_namespace();"
111103
)
112104

113-
try:
114-
self.checkdb_node(
105+
self.pb.checkdb_node(
115106
options=[
116107
'--amcheck',
117108
'--skip-block-validation',
118-
'-d', 'postgres', '-p', str(node.port)])
119-
self.assertEqual(
120-
1, 0,
121-
"Expecting Error because amcheck{,_next} not installed\n"
122-
" Output: {0} \n CMD: {1}".format(
123-
repr(self.output), self.cmd))
124-
except ProbackupException as e:
125-
self.assertIn(
126-
"WARNING: Extension 'amcheck' or 'amcheck_next' are not installed in database postgres",
127-
e.message,
128-
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
129-
repr(e.message), self.cmd))
109+
'-d', 'postgres', '-p', str(node.port)],
110+
expect_error="because amcheck{,_next} not installed")
111+
self.assertMessage(contains=
112+
"WARNING: Extension 'amcheck' or 'amcheck_next' are not installed in database postgres")

‎tests/Readme.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,22 @@ Run long (time consuming) tests:
4545
export PG_PROBACKUP_LONG=ON
4646
4747
Usage:
48-
sudo echo 0 > /proc/sys/kernel/yama/ptrace_scope
48+
49+
sudo sysctl kernel.yama.ptrace_scope=0 # only active until the next reboot
50+
or
51+
sudo sed -i 's/ptrace_scope = 1/ptrace_scope = 0/' /etc/sysctl.d/10-ptrace.conf # set permanently, needs a reboot to take effect
52+
# see https://www.kernel.org/doc/Documentation/security/Yama.txt for possible implications of setting this parameter permanently
4953
pip install testgres
5054
export PG_CONFIG=/path/to/pg_config
5155
python -m unittest [-v] tests[.specific_module][.class.test]
5256
```
53-
57+
# Environment variables
58+
| Variable | Possible values | Required | Default value | Description |
59+
| - |------------------------------------| - | - |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
60+
| KEEP_LOGS | Any | No | Not set | If this variable is set to '1', 'y' or 'Y' then test logs are kept after the successful execution of a test, otherwise test logs are deleted upon the successful execution of a test |
61+
| PG_PROBACKUP_S3_TEST | Not set, minio, VK | No | Not set | If set, specifies the type of the S3 storage for the tests, otherwise signifies to the tests that the storage is not an S3 one |
62+
| PG_PROBACKUP_S3_CONFIG_FILE | Not set, path to config file, True | No | Not set | Specifies the path to an S3 configuration file. If set, all commands will include --s3-config-file='path'. If 'True', the default configuration file at ./s3/tests/s3.conf will be used |
63+
| PGPROBACKUP_TMP_DIR | File path | No | tmp_dirs | The root of the temporary directory hierarchy where tests store data and logs. Relative paths start from the `tests` directory. |
5464
# Troubleshooting FAQ
5565

5666
## Python tests failure

0 commit comments

Comments
 (0)
Failed to load comments.