|
@@ -297,6 +297,114 @@ def test_restore_database_dump_runs_mongorestore_with_username_and_password():
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
+def test_restore_database_dump_with_connection_params_uses_connection_params_for_restore():
|
|
|
|
+ database_config = [
|
|
|
|
+ {
|
|
|
|
+ 'name': 'foo',
|
|
|
|
+ 'username': 'mongo',
|
|
|
|
+ 'password': 'trustsome1',
|
|
|
|
+ 'authentication_database': 'admin',
|
|
|
|
+ '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(
|
|
|
|
+ [
|
|
|
|
+ 'mongorestore',
|
|
|
|
+ '--archive',
|
|
|
|
+ '--drop',
|
|
|
|
+ '--db',
|
|
|
|
+ 'foo',
|
|
|
|
+ '--host',
|
|
|
|
+ 'clihost',
|
|
|
|
+ '--port',
|
|
|
|
+ 'cliport',
|
|
|
|
+ '--username',
|
|
|
|
+ 'cliusername',
|
|
|
|
+ '--password',
|
|
|
|
+ 'clipassword',
|
|
|
|
+ '--authenticationDatabase',
|
|
|
|
+ 'admin',
|
|
|
|
+ ],
|
|
|
|
+ processes=[extract_process],
|
|
|
|
+ output_log_level=logging.DEBUG,
|
|
|
|
+ input_file=extract_process.stdout,
|
|
|
|
+ ).once()
|
|
|
|
+
|
|
|
|
+ module.restore_database_dump(
|
|
|
|
+ database_config,
|
|
|
|
+ 'test.yaml',
|
|
|
|
+ {},
|
|
|
|
+ dry_run=False,
|
|
|
|
+ extract_process=extract_process,
|
|
|
|
+ connection_params={
|
|
|
|
+ 'hostname': 'clihost',
|
|
|
|
+ 'port': 'cliport',
|
|
|
|
+ 'username': 'cliusername',
|
|
|
|
+ 'password': 'clipassword',
|
|
|
|
+ },
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def test_restore_database_dump_without_connection_params_uses_restore_params_in_config_for_restore():
|
|
|
|
+ database_config = [
|
|
|
|
+ {
|
|
|
|
+ 'name': 'foo',
|
|
|
|
+ 'username': 'mongo',
|
|
|
|
+ 'password': 'trustsome1',
|
|
|
|
+ 'authentication_database': 'admin',
|
|
|
|
+ 'schemas': None,
|
|
|
|
+ 'restore_hostname': 'restorehost',
|
|
|
|
+ 'restore_port': 'restoreport',
|
|
|
|
+ 'restore_username': 'restoreuser',
|
|
|
|
+ 'restore_password': 'restorepass',
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ 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(
|
|
|
|
+ [
|
|
|
|
+ 'mongorestore',
|
|
|
|
+ '--archive',
|
|
|
|
+ '--drop',
|
|
|
|
+ '--db',
|
|
|
|
+ 'foo',
|
|
|
|
+ '--host',
|
|
|
|
+ 'restorehost',
|
|
|
|
+ '--port',
|
|
|
|
+ 'restoreport',
|
|
|
|
+ '--username',
|
|
|
|
+ 'restoreuser',
|
|
|
|
+ '--password',
|
|
|
|
+ 'restorepass',
|
|
|
|
+ '--authenticationDatabase',
|
|
|
|
+ 'admin',
|
|
|
|
+ ],
|
|
|
|
+ processes=[extract_process],
|
|
|
|
+ output_log_level=logging.DEBUG,
|
|
|
|
+ input_file=extract_process.stdout,
|
|
|
|
+ ).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_mongorestore_with_options():
|
|
def test_restore_database_dump_runs_mongorestore_with_options():
|
|
database_config = [{'name': 'foo', 'restore_options': '--harder', 'schemas': None}]
|
|
database_config = [{'name': 'foo', 'restore_options': '--harder', 'schemas': None}]
|
|
extract_process = flexmock(stdout=flexmock())
|
|
extract_process = flexmock(stdout=flexmock())
|