actually test port restores
This commit is contained in:
parent
384182172a
commit
e2d82e9bba
3 changed files with 10 additions and 67 deletions
|
@ -13,6 +13,7 @@ services:
|
|||
POSTGRES_USER: postgres2
|
||||
ports:
|
||||
- "5433:5432"
|
||||
command: -p 5433
|
||||
mysql:
|
||||
image: docker.io/mariadb:10.5
|
||||
environment:
|
||||
|
@ -25,6 +26,7 @@ services:
|
|||
MYSQL_DATABASE: test
|
||||
ports:
|
||||
- "3307:3306"
|
||||
command: --port=3307
|
||||
mongodb:
|
||||
image: docker.io/mongo:5.0.5
|
||||
environment:
|
||||
|
@ -37,6 +39,7 @@ services:
|
|||
MONGO_INITDB_ROOT_PASSWORD: test2
|
||||
ports:
|
||||
- "27018:27017"
|
||||
command: --port=27018
|
||||
tests:
|
||||
image: docker.io/alpine:3.13
|
||||
environment:
|
||||
|
|
|
@ -114,7 +114,7 @@ hooks:
|
|||
password: test
|
||||
format: {postgresql_dump_format}
|
||||
restore_hostname: postgresql2
|
||||
restore_port: 5432
|
||||
restore_port: 5433
|
||||
restore_username: postgres2
|
||||
restore_password: test2
|
||||
mysql_databases:
|
||||
|
@ -123,7 +123,7 @@ hooks:
|
|||
username: root
|
||||
password: test
|
||||
restore_hostname: mysql2
|
||||
restore_port: 3306
|
||||
restore_port: 3307
|
||||
restore_username: root
|
||||
restore_password: test2
|
||||
mongodb_databases:
|
||||
|
@ -134,7 +134,7 @@ hooks:
|
|||
authentication_database: admin
|
||||
format: {mongodb_dump_format}
|
||||
restore_hostname: mongodb2
|
||||
restore_port: 27017
|
||||
restore_port: 27018
|
||||
restore_username: root2
|
||||
restore_password: test2
|
||||
sqlite_databases:
|
||||
|
@ -147,7 +147,7 @@ hooks:
|
|||
config_file.write(config)
|
||||
|
||||
|
||||
def write_custom_restore_configuration_for_cli_arguments(
|
||||
def write_simple_custom_restore_configuration(
|
||||
source_directory,
|
||||
config_path,
|
||||
repository_path,
|
||||
|
@ -233,14 +233,11 @@ def test_database_dump_and_restore_with_restore_cli_arguments():
|
|||
repository_path = os.path.join(temporary_directory, 'test.borg')
|
||||
borgmatic_source_directory = os.path.join(temporary_directory, '.borgmatic')
|
||||
|
||||
# Write out a special file to ensure that it gets properly excluded and Borg doesn't hang on it.
|
||||
os.mkfifo(os.path.join(temporary_directory, 'special_file'))
|
||||
|
||||
original_working_directory = os.getcwd()
|
||||
|
||||
try:
|
||||
config_path = os.path.join(temporary_directory, 'test.yaml')
|
||||
write_custom_restore_configuration_for_cli_arguments(
|
||||
write_simple_custom_restore_configuration(
|
||||
temporary_directory, config_path, repository_path, borgmatic_source_directory
|
||||
)
|
||||
|
||||
|
@ -275,7 +272,7 @@ def test_database_dump_and_restore_with_restore_cli_arguments():
|
|||
'--hostname',
|
||||
'postgresql2',
|
||||
'--port',
|
||||
'5432',
|
||||
'5433',
|
||||
'--username',
|
||||
'postgres2',
|
||||
'--password',
|
||||
|
@ -287,15 +284,12 @@ def test_database_dump_and_restore_with_restore_cli_arguments():
|
|||
shutil.rmtree(temporary_directory)
|
||||
|
||||
|
||||
def test_database_dump_and_restore_to_different_hostname_port_username_password():
|
||||
def test_database_dump_and_restore_with_restore_configuration_options():
|
||||
# Create a Borg repository.
|
||||
temporary_directory = tempfile.mkdtemp()
|
||||
repository_path = os.path.join(temporary_directory, 'test.borg')
|
||||
borgmatic_source_directory = os.path.join(temporary_directory, '.borgmatic')
|
||||
|
||||
# Write out a special file to ensure that it gets properly excluded and Borg doesn't hang on it.
|
||||
os.mkfifo(os.path.join(temporary_directory, 'special_file'))
|
||||
|
||||
original_working_directory = os.getcwd()
|
||||
|
||||
try:
|
||||
|
|
|
@ -800,60 +800,6 @@ def test_restore_database_dump_without_connection_params_uses_restore_params_in_
|
|||
)
|
||||
|
||||
|
||||
def test_restore_database_dump_with_no_passwords_runs_pg_restore_without_password():
|
||||
database_config = [{'name': 'foo', 'username': 'postgres', 'schemas': None}]
|
||||
extract_process = flexmock(stdout=flexmock())
|
||||
|
||||
flexmock(module).should_receive('make_dump_path')
|
||||
flexmock(module.dump).should_receive('make_database_dump_filename')
|
||||
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
||||
(
|
||||
'pg_restore',
|
||||
'--no-password',
|
||||
'--if-exists',
|
||||
'--exit-on-error',
|
||||
'--clean',
|
||||
'--dbname',
|
||||
'foo',
|
||||
'--username',
|
||||
'postgres',
|
||||
),
|
||||
processes=[extract_process],
|
||||
output_log_level=logging.DEBUG,
|
||||
input_file=extract_process.stdout,
|
||||
extra_environment={'PGSSLMODE': 'disable'},
|
||||
).once()
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
(
|
||||
'psql',
|
||||
'--no-password',
|
||||
'--no-psqlrc',
|
||||
'--quiet',
|
||||
'--username',
|
||||
'postgres',
|
||||
'--dbname',
|
||||
'foo',
|
||||
'--command',
|
||||
'ANALYZE',
|
||||
),
|
||||
extra_environment={'PGSSLMODE': 'disable'},
|
||||
).once()
|
||||
|
||||
module.restore_database_dump(
|
||||
database_config,
|
||||
'test.yaml',
|
||||
{},
|
||||
dry_run=False,
|
||||
extract_process=extract_process,
|
||||
connection_params={
|
||||
'hostname': None,
|
||||
'port': None,
|
||||
'username': None,
|
||||
'password': None,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_restore_database_dump_runs_pg_restore_with_options():
|
||||
database_config = [
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue