Skip to content

Commit

Permalink
Add s3 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vshepard committed May 3, 2024
1 parent 2b9c9b1 commit 90f7b7a
Show file tree
Hide file tree
Showing 55 changed files with 14,440 additions and 20,634 deletions.
53 changes: 18 additions & 35 deletions tests/CVE_2018_1058_test.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import os
import unittest
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
from .helpers.ptrack_helpers import ProbackupTest

class CVE_2018_1058(ProbackupTest, unittest.TestCase):
class CVE_2018_1058(ProbackupTest):

# @unittest.skip("skip")
def test_basic_default_search_path(self):
""""""
backup_dir = os.path.join(self.tmp_path, self.module_name, self.fname, 'backup')
node = self.make_simple_node(
base_dir=os.path.join(self.module_name, self.fname, 'node'),
set_replication=True)
node = self.pg_node.make_simple('node', checksum=False, set_replication=True)

self.init_pb(backup_dir)
self.add_instance(backup_dir, 'node', node)
self.pb.init()
self.pb.add_instance('node', node)
node.slow_start()

node.safe_psql(
Expand All @@ -26,19 +23,16 @@ def test_basic_default_search_path(self):
"END "
"$$ LANGUAGE plpgsql")

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

# @unittest.skip("skip")
def test_basic_backup_modified_search_path(self):
""""""
backup_dir = os.path.join(self.tmp_path, self.module_name, self.fname, 'backup')
node = self.make_simple_node(
base_dir=os.path.join(self.module_name, self.fname, 'node'),
set_replication=True)
self.set_auto_conf(node, options={'search_path': 'public,pg_catalog'})
node = self.pg_node.make_simple('node', checksum=False, set_replication=True)
node.set_auto_conf(options={'search_path': 'public,pg_catalog'})

self.init_pb(backup_dir)
self.add_instance(backup_dir, 'node', node)
self.pb.init()
self.pb.add_instance('node', node)
node.slow_start()

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

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

log_file = os.path.join(node.logs_dir, 'postgresql.log')
with open(log_file, 'r') as f:
Expand All @@ -73,10 +67,8 @@ def test_basic_backup_modified_search_path(self):
# @unittest.skip("skip")
def test_basic_checkdb_modified_search_path(self):
""""""
node = self.make_simple_node(
base_dir=os.path.join(self.module_name, self.fname, 'node'),
initdb_params=['--data-checksums'])
self.set_auto_conf(node, options={'search_path': 'public,pg_catalog'})
node = self.pg_node.make_simple('node')
node.set_auto_conf(options={'search_path': 'public,pg_catalog'})
node.slow_start()

node.safe_psql(
Expand Down Expand Up @@ -110,20 +102,11 @@ def test_basic_checkdb_modified_search_path(self):
"CREATE VIEW public.pg_namespace AS SELECT * FROM public.pg_namespace();"
)

try:
self.checkdb_node(
self.pb.checkdb_node(
options=[
'--amcheck',
'--skip-block-validation',
'-d', 'postgres', '-p', str(node.port)])
self.assertEqual(
1, 0,
"Expecting Error because amcheck{,_next} not installed\n"
" Output: {0} \n CMD: {1}".format(
repr(self.output), self.cmd))
except ProbackupException as e:
self.assertIn(
"WARNING: Extension 'amcheck' or 'amcheck_next' are not installed in database postgres",
e.message,
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
repr(e.message), self.cmd))
'-d', 'postgres', '-p', str(node.port)],
expect_error="because amcheck{,_next} not installed")
self.assertMessage(contains=
"WARNING: Extension 'amcheck' or 'amcheck_next' are not installed in database postgres")
14 changes: 12 additions & 2 deletions tests/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,22 @@ Run long (time consuming) tests:
export PG_PROBACKUP_LONG=ON
Usage:
sudo echo 0 > /proc/sys/kernel/yama/ptrace_scope
sudo sysctl kernel.yama.ptrace_scope=0 # only active until the next reboot
or
sudo sed -i 's/ptrace_scope = 1/ptrace_scope = 0/' /etc/sysctl.d/10-ptrace.conf # set permanently, needs a reboot to take effect
# see https://www.kernel.org/doc/Documentation/security/Yama.txt for possible implications of setting this parameter permanently
pip install testgres
export PG_CONFIG=/path/to/pg_config
python -m unittest [-v] tests[.specific_module][.class.test]
```

# Environment variables
| Variable | Possible values | Required | Default value | Description |
| - |------------------------------------| - | - |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 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 |
| 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 |
| 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 |
| 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. |
# Troubleshooting FAQ

## Python tests failure
Expand Down
10 changes: 3 additions & 7 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from . import init_test, merge_test, option_test, show_test, compatibility_test, \
backup_test, delete_test, delta_test, restore_test, validate_test, \
retention_test, pgpro560_test, pgpro589_test, pgpro2068_test, false_positive_test, replica_test, \
compression_test, page_test, ptrack_test, archive_test, exclude_test, cfs_backup_test, cfs_restore_test, \
cfs_validate_backup_test, auth_test, time_stamp_test, logging_test, \
retention_test, pgpro560_test, pgpro589_test, false_positive_test, replica_test, \
compression_test, page_test, ptrack_test, archive_test, exclude_test, \
auth_test, time_stamp_test, logging_test, \
locking_test, remote_test, external_test, config_test, checkdb_test, set_backup_test, incr_restore_test, \
catchup_test, CVE_2018_1058_test, time_consuming_test

Expand Down Expand Up @@ -35,9 +35,6 @@ def load_tests(loader, tests, pattern):
suite.addTests(loader.loadTestsFromModule(compatibility_test))
suite.addTests(loader.loadTestsFromModule(checkdb_test))
suite.addTests(loader.loadTestsFromModule(config_test))
suite.addTests(loader.loadTestsFromModule(cfs_backup_test))
suite.addTests(loader.loadTestsFromModule(cfs_restore_test))
suite.addTests(loader.loadTestsFromModule(cfs_validate_backup_test))
suite.addTests(loader.loadTestsFromModule(compression_test))
suite.addTests(loader.loadTestsFromModule(delete_test))
suite.addTests(loader.loadTestsFromModule(delta_test))
Expand All @@ -53,7 +50,6 @@ def load_tests(loader, tests, pattern):
suite.addTests(loader.loadTestsFromModule(page_test))
suite.addTests(loader.loadTestsFromModule(pgpro560_test))
suite.addTests(loader.loadTestsFromModule(pgpro589_test))
suite.addTests(loader.loadTestsFromModule(pgpro2068_test))
suite.addTests(loader.loadTestsFromModule(remote_test))
suite.addTests(loader.loadTestsFromModule(replica_test))
suite.addTests(loader.loadTestsFromModule(restore_test))
Expand Down
Loading

0 comments on commit 90f7b7a

Please sign in to comment.