|
@@ -117,6 +117,9 @@ def test_database_names_to_dump_with_all_and_format_lists_databases_with_hostnam
|
|
|
flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
|
|
|
|
|
+ '/path/to/working/dir'
|
|
|
|
|
+ )
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
(
|
|
(
|
|
|
'psql',
|
|
'psql',
|
|
@@ -131,6 +134,7 @@ def test_database_names_to_dump_with_all_and_format_lists_databases_with_hostnam
|
|
|
'1234',
|
|
'1234',
|
|
|
),
|
|
),
|
|
|
environment=object,
|
|
environment=object,
|
|
|
|
|
+ working_directory='/path/to/working/dir',
|
|
|
).and_return('foo,test,\nbar,test,"stuff and such"')
|
|
).and_return('foo,test,\nbar,test,"stuff and such"')
|
|
|
|
|
|
|
|
assert module.database_names_to_dump(database, {}, flexmock(), dry_run=False) == (
|
|
assert module.database_names_to_dump(database, {}, flexmock(), dry_run=False) == (
|
|
@@ -144,6 +148,7 @@ def test_database_names_to_dump_with_all_and_format_lists_databases_with_usernam
|
|
|
flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
(
|
|
(
|
|
|
'psql',
|
|
'psql',
|
|
@@ -156,6 +161,7 @@ def test_database_names_to_dump_with_all_and_format_lists_databases_with_usernam
|
|
|
'postgres',
|
|
'postgres',
|
|
|
),
|
|
),
|
|
|
environment=object,
|
|
environment=object,
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return('foo,test,\nbar,test,"stuff and such"')
|
|
).and_return('foo,test,\nbar,test,"stuff and such"')
|
|
|
|
|
|
|
|
assert module.database_names_to_dump(database, {}, flexmock(), dry_run=False) == (
|
|
assert module.database_names_to_dump(database, {}, flexmock(), dry_run=False) == (
|
|
@@ -169,9 +175,11 @@ def test_database_names_to_dump_with_all_and_format_lists_databases_with_options
|
|
|
flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
('psql', '--list', '--no-password', '--no-psqlrc', '--csv', '--tuples-only', '--harder'),
|
|
('psql', '--list', '--no-password', '--no-psqlrc', '--csv', '--tuples-only', '--harder'),
|
|
|
environment=object,
|
|
environment=object,
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return('foo,test,\nbar,test,"stuff and such"')
|
|
).and_return('foo,test,\nbar,test,"stuff and such"')
|
|
|
|
|
|
|
|
assert module.database_names_to_dump(database, {}, flexmock(), dry_run=False) == (
|
|
assert module.database_names_to_dump(database, {}, flexmock(), dry_run=False) == (
|
|
@@ -201,6 +209,7 @@ def test_database_names_to_dump_with_all_and_psql_command_uses_custom_command():
|
|
|
flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
flexmock(module.borgmatic.hooks.credential.parse).should_receive(
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
flexmock(module).should_receive('execute_command_and_capture_output').with_args(
|
|
|
(
|
|
(
|
|
|
'docker',
|
|
'docker',
|
|
@@ -216,6 +225,7 @@ def test_database_names_to_dump_with_all_and_psql_command_uses_custom_command():
|
|
|
'--tuples-only',
|
|
'--tuples-only',
|
|
|
),
|
|
),
|
|
|
environment=object,
|
|
environment=object,
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return('foo,text').once()
|
|
).and_return('foo,text').once()
|
|
|
|
|
|
|
|
assert module.database_names_to_dump(database, {}, flexmock(), dry_run=False) == ('foo',)
|
|
assert module.database_names_to_dump(database, {}, flexmock(), dry_run=False) == ('foo',)
|
|
@@ -255,6 +265,7 @@ def test_dump_data_sources_runs_pg_dump_for_each_database():
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
|
|
|
|
|
for name, process in zip(('foo', 'bar'), processes):
|
|
for name, process in zip(('foo', 'bar'), processes):
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
@@ -272,6 +283,7 @@ def test_dump_data_sources_runs_pg_dump_for_each_database():
|
|
|
shell=True,
|
|
shell=True,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
run_to_completion=False,
|
|
run_to_completion=False,
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return(process).once()
|
|
).and_return(process).once()
|
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
|
'/run/borgmatic',
|
|
'/run/borgmatic',
|
|
@@ -428,6 +440,7 @@ def test_dump_data_sources_runs_pg_dump_with_hostname_and_port():
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
|
|
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -448,6 +461,7 @@ def test_dump_data_sources_runs_pg_dump_with_hostname_and_port():
|
|
|
shell=True,
|
|
shell=True,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
run_to_completion=False,
|
|
run_to_completion=False,
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return(process).once()
|
|
).and_return(process).once()
|
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
|
'/run/borgmatic',
|
|
'/run/borgmatic',
|
|
@@ -492,6 +506,7 @@ def test_dump_data_sources_runs_pg_dump_with_username_and_password():
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
|
|
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -510,6 +525,7 @@ def test_dump_data_sources_runs_pg_dump_with_username_and_password():
|
|
|
shell=True,
|
|
shell=True,
|
|
|
environment={'PGPASSWORD': 'trustsome1', 'PGSSLMODE': 'disable'},
|
|
environment={'PGPASSWORD': 'trustsome1', 'PGSSLMODE': 'disable'},
|
|
|
run_to_completion=False,
|
|
run_to_completion=False,
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return(process).once()
|
|
).and_return(process).once()
|
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
|
'/run/borgmatic',
|
|
'/run/borgmatic',
|
|
@@ -552,6 +568,7 @@ def test_dump_data_sources_with_username_injection_attack_gets_escaped():
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
|
|
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -570,6 +587,7 @@ def test_dump_data_sources_with_username_injection_attack_gets_escaped():
|
|
|
shell=True,
|
|
shell=True,
|
|
|
environment={'PGPASSWORD': 'trustsome1', 'PGSSLMODE': 'disable'},
|
|
environment={'PGPASSWORD': 'trustsome1', 'PGSSLMODE': 'disable'},
|
|
|
run_to_completion=False,
|
|
run_to_completion=False,
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return(process).once()
|
|
).and_return(process).once()
|
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
|
'/run/borgmatic',
|
|
'/run/borgmatic',
|
|
@@ -610,6 +628,7 @@ def test_dump_data_sources_runs_pg_dump_with_directory_format():
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
flexmock(module.dump).should_receive('create_parent_directory_for_dump')
|
|
flexmock(module.dump).should_receive('create_parent_directory_for_dump')
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump').never()
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump').never()
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
|
|
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -625,6 +644,7 @@ def test_dump_data_sources_runs_pg_dump_with_directory_format():
|
|
|
),
|
|
),
|
|
|
shell=True,
|
|
shell=True,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return(flexmock()).once()
|
|
).and_return(flexmock()).once()
|
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
|
'/run/borgmatic',
|
|
'/run/borgmatic',
|
|
@@ -668,6 +688,7 @@ def test_dump_data_sources_runs_pg_dump_with_string_compression():
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
|
|
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -686,6 +707,7 @@ def test_dump_data_sources_runs_pg_dump_with_string_compression():
|
|
|
shell=True,
|
|
shell=True,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
run_to_completion=False,
|
|
run_to_completion=False,
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return(processes[0]).once()
|
|
).and_return(processes[0]).once()
|
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
|
'/run/borgmatic',
|
|
'/run/borgmatic',
|
|
@@ -729,6 +751,7 @@ def test_dump_data_sources_runs_pg_dump_with_integer_compression():
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
|
|
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -747,6 +770,7 @@ def test_dump_data_sources_runs_pg_dump_with_integer_compression():
|
|
|
shell=True,
|
|
shell=True,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
run_to_completion=False,
|
|
run_to_completion=False,
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return(processes[0]).once()
|
|
).and_return(processes[0]).once()
|
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
|
'/run/borgmatic',
|
|
'/run/borgmatic',
|
|
@@ -790,6 +814,7 @@ def test_dump_data_sources_runs_pg_dump_with_options():
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
|
|
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -807,6 +832,7 @@ def test_dump_data_sources_runs_pg_dump_with_options():
|
|
|
shell=True,
|
|
shell=True,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
run_to_completion=False,
|
|
run_to_completion=False,
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return(process).once()
|
|
).and_return(process).once()
|
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
|
'/run/borgmatic',
|
|
'/run/borgmatic',
|
|
@@ -847,12 +873,14 @@ def test_dump_data_sources_runs_pg_dumpall_for_all_databases():
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
|
|
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('pg_dumpall', '--no-password', '--clean', '--if-exists', '>', 'databases/localhost/all'),
|
|
('pg_dumpall', '--no-password', '--clean', '--if-exists', '>', 'databases/localhost/all'),
|
|
|
shell=True,
|
|
shell=True,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
run_to_completion=False,
|
|
run_to_completion=False,
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return(process).once()
|
|
).and_return(process).once()
|
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
|
'/run/borgmatic',
|
|
'/run/borgmatic',
|
|
@@ -893,6 +921,7 @@ def test_dump_data_sources_runs_non_default_pg_dump():
|
|
|
'resolve_credential',
|
|
'resolve_credential',
|
|
|
).replace_with(lambda value, config: value)
|
|
).replace_with(lambda value, config: value)
|
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
flexmock(module.dump).should_receive('create_named_pipe_for_dump')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
|
|
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -911,6 +940,7 @@ def test_dump_data_sources_runs_non_default_pg_dump():
|
|
|
shell=True,
|
|
shell=True,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
run_to_completion=False,
|
|
run_to_completion=False,
|
|
|
|
|
+ working_directory=None,
|
|
|
).and_return(process).once()
|
|
).and_return(process).once()
|
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
flexmock(module.dump).should_receive('write_data_source_dumps_metadata').with_args(
|
|
|
'/run/borgmatic',
|
|
'/run/borgmatic',
|
|
@@ -947,6 +977,7 @@ def test_restore_data_source_dump_runs_pg_restore():
|
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
|
flexmock(module).should_receive('make_dump_path')
|
|
flexmock(module).should_receive('make_dump_path')
|
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
(
|
|
(
|
|
|
'pg_restore',
|
|
'pg_restore',
|
|
@@ -961,6 +992,7 @@ def test_restore_data_source_dump_runs_pg_restore():
|
|
|
output_log_level=logging.DEBUG,
|
|
output_log_level=logging.DEBUG,
|
|
|
input_file=extract_process.stdout,
|
|
input_file=extract_process.stdout,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -974,6 +1006,7 @@ def test_restore_data_source_dump_runs_pg_restore():
|
|
|
'ANALYZE',
|
|
'ANALYZE',
|
|
|
),
|
|
),
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
|
|
|
|
|
module.restore_data_source_dump(
|
|
module.restore_data_source_dump(
|
|
@@ -1004,6 +1037,7 @@ def test_restore_data_source_dump_runs_pg_restore_with_hostname_and_port():
|
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
|
flexmock(module).should_receive('make_dump_path')
|
|
flexmock(module).should_receive('make_dump_path')
|
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
(
|
|
(
|
|
|
'pg_restore',
|
|
'pg_restore',
|
|
@@ -1022,6 +1056,7 @@ def test_restore_data_source_dump_runs_pg_restore_with_hostname_and_port():
|
|
|
output_log_level=logging.DEBUG,
|
|
output_log_level=logging.DEBUG,
|
|
|
input_file=extract_process.stdout,
|
|
input_file=extract_process.stdout,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -1039,6 +1074,7 @@ def test_restore_data_source_dump_runs_pg_restore_with_hostname_and_port():
|
|
|
'ANALYZE',
|
|
'ANALYZE',
|
|
|
),
|
|
),
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
|
|
|
|
|
module.restore_data_source_dump(
|
|
module.restore_data_source_dump(
|
|
@@ -1071,6 +1107,7 @@ def test_restore_data_source_dump_runs_pg_restore_with_username_and_password():
|
|
|
)
|
|
)
|
|
|
flexmock(module).should_receive('make_dump_path')
|
|
flexmock(module).should_receive('make_dump_path')
|
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
(
|
|
(
|
|
|
'pg_restore',
|
|
'pg_restore',
|
|
@@ -1087,6 +1124,7 @@ def test_restore_data_source_dump_runs_pg_restore_with_username_and_password():
|
|
|
output_log_level=logging.DEBUG,
|
|
output_log_level=logging.DEBUG,
|
|
|
input_file=extract_process.stdout,
|
|
input_file=extract_process.stdout,
|
|
|
environment={'PGPASSWORD': 'trustsome1', 'PGSSLMODE': 'disable'},
|
|
environment={'PGPASSWORD': 'trustsome1', 'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -1102,6 +1140,7 @@ def test_restore_data_source_dump_runs_pg_restore_with_username_and_password():
|
|
|
'ANALYZE',
|
|
'ANALYZE',
|
|
|
),
|
|
),
|
|
|
environment={'PGPASSWORD': 'trustsome1', 'PGSSLMODE': 'disable'},
|
|
environment={'PGPASSWORD': 'trustsome1', 'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
|
|
|
|
|
module.restore_data_source_dump(
|
|
module.restore_data_source_dump(
|
|
@@ -1145,6 +1184,7 @@ def test_restore_data_source_dump_with_connection_params_uses_connection_params_
|
|
|
)
|
|
)
|
|
|
flexmock(module).should_receive('make_dump_path')
|
|
flexmock(module).should_receive('make_dump_path')
|
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
(
|
|
(
|
|
|
'pg_restore',
|
|
'pg_restore',
|
|
@@ -1165,6 +1205,7 @@ def test_restore_data_source_dump_with_connection_params_uses_connection_params_
|
|
|
output_log_level=logging.DEBUG,
|
|
output_log_level=logging.DEBUG,
|
|
|
input_file=extract_process.stdout,
|
|
input_file=extract_process.stdout,
|
|
|
environment={'PGPASSWORD': 'clipassword', 'PGSSLMODE': 'disable'},
|
|
environment={'PGPASSWORD': 'clipassword', 'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -1184,6 +1225,7 @@ def test_restore_data_source_dump_with_connection_params_uses_connection_params_
|
|
|
'ANALYZE',
|
|
'ANALYZE',
|
|
|
),
|
|
),
|
|
|
environment={'PGPASSWORD': 'clipassword', 'PGSSLMODE': 'disable'},
|
|
environment={'PGPASSWORD': 'clipassword', 'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
|
|
|
|
|
module.restore_data_source_dump(
|
|
module.restore_data_source_dump(
|
|
@@ -1227,6 +1269,7 @@ def test_restore_data_source_dump_without_connection_params_uses_restore_params_
|
|
|
)
|
|
)
|
|
|
flexmock(module).should_receive('make_dump_path')
|
|
flexmock(module).should_receive('make_dump_path')
|
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
(
|
|
(
|
|
|
'pg_restore',
|
|
'pg_restore',
|
|
@@ -1247,6 +1290,7 @@ def test_restore_data_source_dump_without_connection_params_uses_restore_params_
|
|
|
output_log_level=logging.DEBUG,
|
|
output_log_level=logging.DEBUG,
|
|
|
input_file=extract_process.stdout,
|
|
input_file=extract_process.stdout,
|
|
|
environment={'PGPASSWORD': 'restorepassword', 'PGSSLMODE': 'disable'},
|
|
environment={'PGPASSWORD': 'restorepassword', 'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -1266,6 +1310,7 @@ def test_restore_data_source_dump_without_connection_params_uses_restore_params_
|
|
|
'ANALYZE',
|
|
'ANALYZE',
|
|
|
),
|
|
),
|
|
|
environment={'PGPASSWORD': 'restorepassword', 'PGSSLMODE': 'disable'},
|
|
environment={'PGPASSWORD': 'restorepassword', 'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
|
|
|
|
|
module.restore_data_source_dump(
|
|
module.restore_data_source_dump(
|
|
@@ -1301,6 +1346,7 @@ def test_restore_data_source_dump_runs_pg_restore_with_options():
|
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
|
flexmock(module).should_receive('make_dump_path')
|
|
flexmock(module).should_receive('make_dump_path')
|
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
(
|
|
(
|
|
|
'pg_restore',
|
|
'pg_restore',
|
|
@@ -1316,6 +1362,7 @@ def test_restore_data_source_dump_runs_pg_restore_with_options():
|
|
|
output_log_level=logging.DEBUG,
|
|
output_log_level=logging.DEBUG,
|
|
|
input_file=extract_process.stdout,
|
|
input_file=extract_process.stdout,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -1330,6 +1377,7 @@ def test_restore_data_source_dump_runs_pg_restore_with_options():
|
|
|
'ANALYZE',
|
|
'ANALYZE',
|
|
|
),
|
|
),
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
|
|
|
|
|
module.restore_data_source_dump(
|
|
module.restore_data_source_dump(
|
|
@@ -1358,6 +1406,7 @@ def test_restore_data_source_dump_runs_psql_for_all_database_dump():
|
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
|
flexmock(module).should_receive('make_dump_path')
|
|
flexmock(module).should_receive('make_dump_path')
|
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
(
|
|
(
|
|
|
'psql',
|
|
'psql',
|
|
@@ -1368,10 +1417,12 @@ def test_restore_data_source_dump_runs_psql_for_all_database_dump():
|
|
|
output_log_level=logging.DEBUG,
|
|
output_log_level=logging.DEBUG,
|
|
|
input_file=extract_process.stdout,
|
|
input_file=extract_process.stdout,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
('psql', '--no-password', '--no-psqlrc', '--quiet', '--command', 'ANALYZE'),
|
|
('psql', '--no-password', '--no-psqlrc', '--quiet', '--command', 'ANALYZE'),
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
|
|
|
|
|
module.restore_data_source_dump(
|
|
module.restore_data_source_dump(
|
|
@@ -1400,12 +1451,14 @@ def test_restore_data_source_dump_runs_psql_for_plain_database_dump():
|
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
|
flexmock(module).should_receive('make_dump_path')
|
|
flexmock(module).should_receive('make_dump_path')
|
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
('psql', '--no-password', '--no-psqlrc', '--dbname', 'foo'),
|
|
('psql', '--no-password', '--no-psqlrc', '--dbname', 'foo'),
|
|
|
processes=[extract_process],
|
|
processes=[extract_process],
|
|
|
output_log_level=logging.DEBUG,
|
|
output_log_level=logging.DEBUG,
|
|
|
input_file=extract_process.stdout,
|
|
input_file=extract_process.stdout,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -1419,6 +1472,7 @@ def test_restore_data_source_dump_runs_psql_for_plain_database_dump():
|
|
|
'ANALYZE',
|
|
'ANALYZE',
|
|
|
),
|
|
),
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
|
|
|
|
|
module.restore_data_source_dump(
|
|
module.restore_data_source_dump(
|
|
@@ -1454,6 +1508,7 @@ def test_restore_data_source_dump_runs_non_default_pg_restore_and_psql():
|
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
|
flexmock(module).should_receive('make_dump_path')
|
|
flexmock(module).should_receive('make_dump_path')
|
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
(
|
|
(
|
|
|
'docker',
|
|
'docker',
|
|
@@ -1473,6 +1528,7 @@ def test_restore_data_source_dump_runs_non_default_pg_restore_and_psql():
|
|
|
output_log_level=logging.DEBUG,
|
|
output_log_level=logging.DEBUG,
|
|
|
input_file=extract_process.stdout,
|
|
input_file=extract_process.stdout,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -1491,6 +1547,7 @@ def test_restore_data_source_dump_runs_non_default_pg_restore_and_psql():
|
|
|
'ANALYZE',
|
|
'ANALYZE',
|
|
|
),
|
|
),
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
|
|
|
|
|
module.restore_data_source_dump(
|
|
module.restore_data_source_dump(
|
|
@@ -1545,6 +1602,7 @@ def test_restore_data_source_dump_without_extract_process_restores_from_disk():
|
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
|
flexmock(module).should_receive('make_dump_path')
|
|
flexmock(module).should_receive('make_dump_path')
|
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('/dump/path')
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('/dump/path')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
(
|
|
(
|
|
|
'pg_restore',
|
|
'pg_restore',
|
|
@@ -1560,6 +1618,7 @@ def test_restore_data_source_dump_without_extract_process_restores_from_disk():
|
|
|
output_log_level=logging.DEBUG,
|
|
output_log_level=logging.DEBUG,
|
|
|
input_file=None,
|
|
input_file=None,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -1573,6 +1632,7 @@ def test_restore_data_source_dump_without_extract_process_restores_from_disk():
|
|
|
'ANALYZE',
|
|
'ANALYZE',
|
|
|
),
|
|
),
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
|
|
|
|
|
module.restore_data_source_dump(
|
|
module.restore_data_source_dump(
|
|
@@ -1600,6 +1660,7 @@ def test_restore_data_source_dump_with_schemas_restores_schemas():
|
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
flexmock(module).should_receive('make_environment').and_return({'PGSSLMODE': 'disable'})
|
|
|
flexmock(module).should_receive('make_dump_path')
|
|
flexmock(module).should_receive('make_dump_path')
|
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('/dump/path')
|
|
flexmock(module.dump).should_receive('make_data_source_dump_filename').and_return('/dump/path')
|
|
|
|
|
+ flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(None)
|
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
flexmock(module).should_receive('execute_command_with_processes').with_args(
|
|
|
(
|
|
(
|
|
|
'pg_restore',
|
|
'pg_restore',
|
|
@@ -1619,6 +1680,7 @@ def test_restore_data_source_dump_with_schemas_restores_schemas():
|
|
|
output_log_level=logging.DEBUG,
|
|
output_log_level=logging.DEBUG,
|
|
|
input_file=None,
|
|
input_file=None,
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
flexmock(module).should_receive('execute_command').with_args(
|
|
|
(
|
|
(
|
|
@@ -1632,6 +1694,7 @@ def test_restore_data_source_dump_with_schemas_restores_schemas():
|
|
|
'ANALYZE',
|
|
'ANALYZE',
|
|
|
),
|
|
),
|
|
|
environment={'PGSSLMODE': 'disable'},
|
|
environment={'PGSSLMODE': 'disable'},
|
|
|
|
|
+ working_directory=None,
|
|
|
).once()
|
|
).once()
|
|
|
|
|
|
|
|
module.restore_data_source_dump(
|
|
module.restore_data_source_dump(
|