|
@@ -15,7 +15,7 @@ def test_run_configuration_runs_actions_for_each_repository():
|
|
|
flexmock(module).should_receive('run_actions').and_return(expected_results[:1]).and_return(
|
|
|
expected_results[1:]
|
|
|
)
|
|
|
- config = {'location': {'repositories': ['foo', 'bar']}}
|
|
|
+ config = {'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]}}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1)}
|
|
|
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
@@ -75,7 +75,7 @@ def test_run_configuration_logs_actions_error():
|
|
|
expected_results = [flexmock()]
|
|
|
flexmock(module).should_receive('log_error_records').and_return(expected_results)
|
|
|
flexmock(module).should_receive('run_actions').and_raise(OSError)
|
|
|
- config = {'location': {'repositories': ['foo']}}
|
|
|
+ config = {'location': {'repositories': [{'path': 'foo'}]}}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False)}
|
|
|
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
@@ -91,7 +91,7 @@ def test_run_configuration_bails_for_actions_soft_failure():
|
|
|
flexmock(module).should_receive('run_actions').and_raise(error)
|
|
|
flexmock(module).should_receive('log_error_records').never()
|
|
|
flexmock(module.command).should_receive('considered_soft_failure').and_return(True)
|
|
|
- config = {'location': {'repositories': ['foo']}}
|
|
|
+ config = {'location': {'repositories': [{'path': 'foo'}]}}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
@@ -108,7 +108,7 @@ def test_run_configuration_logs_monitor_log_error():
|
|
|
expected_results = [flexmock()]
|
|
|
flexmock(module).should_receive('log_error_records').and_return(expected_results)
|
|
|
flexmock(module).should_receive('run_actions').and_return([])
|
|
|
- config = {'location': {'repositories': ['foo']}}
|
|
|
+ config = {'location': {'repositories': [{'path': 'foo'}]}}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
@@ -126,7 +126,7 @@ def test_run_configuration_bails_for_monitor_log_soft_failure():
|
|
|
flexmock(module).should_receive('log_error_records').never()
|
|
|
flexmock(module).should_receive('run_actions').and_return([])
|
|
|
flexmock(module.command).should_receive('considered_soft_failure').and_return(True)
|
|
|
- config = {'location': {'repositories': ['foo']}}
|
|
|
+ config = {'location': {'repositories': [{'path': 'foo'}]}}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
@@ -143,7 +143,7 @@ def test_run_configuration_logs_monitor_finish_error():
|
|
|
expected_results = [flexmock()]
|
|
|
flexmock(module).should_receive('log_error_records').and_return(expected_results)
|
|
|
flexmock(module).should_receive('run_actions').and_return([])
|
|
|
- config = {'location': {'repositories': ['foo']}}
|
|
|
+ config = {'location': {'repositories': [{'path': 'foo'}]}}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
@@ -161,7 +161,7 @@ def test_run_configuration_bails_for_monitor_finish_soft_failure():
|
|
|
flexmock(module).should_receive('log_error_records').never()
|
|
|
flexmock(module).should_receive('run_actions').and_return([])
|
|
|
flexmock(module.command).should_receive('considered_soft_failure').and_return(True)
|
|
|
- config = {'location': {'repositories': ['foo']}}
|
|
|
+ config = {'location': {'repositories': [{'path': 'foo'}]}}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
@@ -178,7 +178,7 @@ def test_run_configuration_logs_on_error_hook_error():
|
|
|
expected_results[:1]
|
|
|
).and_return(expected_results[1:])
|
|
|
flexmock(module).should_receive('run_actions').and_raise(OSError)
|
|
|
- config = {'location': {'repositories': ['foo']}}
|
|
|
+ config = {'location': {'repositories': [{'path': 'foo'}]}}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
@@ -194,7 +194,7 @@ def test_run_configuration_bails_for_on_error_hook_soft_failure():
|
|
|
expected_results = [flexmock()]
|
|
|
flexmock(module).should_receive('log_error_records').and_return(expected_results)
|
|
|
flexmock(module).should_receive('run_actions').and_raise(OSError)
|
|
|
- config = {'location': {'repositories': ['foo']}}
|
|
|
+ config = {'location': {'repositories': [{'path': 'foo'}]}}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
@@ -209,7 +209,7 @@ def test_run_configuration_retries_soft_error():
|
|
|
flexmock(module.command).should_receive('execute_hook')
|
|
|
flexmock(module).should_receive('run_actions').and_raise(OSError).and_return([])
|
|
|
flexmock(module).should_receive('log_error_records').and_return([flexmock()]).once()
|
|
|
- config = {'location': {'repositories': ['foo']}, 'storage': {'retries': 1}}
|
|
|
+ config = {'location': {'repositories': [{'path': 'foo'}]}, 'storage': {'retries': 1}}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
|
assert results == []
|
|
@@ -231,7 +231,7 @@ def test_run_configuration_retries_hard_error():
|
|
|
flexmock(module).should_receive('log_error_records').with_args(
|
|
|
'foo: Error running actions for repository', OSError,
|
|
|
).and_return(error_logs)
|
|
|
- config = {'location': {'repositories': ['foo']}, 'storage': {'retries': 1}}
|
|
|
+ config = {'location': {'repositories': [{'path': 'foo'}]}, 'storage': {'retries': 1}}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
|
assert results == error_logs
|
|
@@ -249,41 +249,41 @@ def test_run_configuration_repos_ordered():
|
|
|
flexmock(module).should_receive('log_error_records').with_args(
|
|
|
'bar: Error running actions for repository', OSError
|
|
|
).and_return(expected_results[1:]).ordered()
|
|
|
- config = {'location': {'repositories': ['foo', 'bar']}}
|
|
|
+ config = {'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]}}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
|
assert results == expected_results
|
|
|
|
|
|
|
|
|
-def test_run_configuration_retries_round_robbin():
|
|
|
- flexmock(module).should_receive('verbosity_to_log_level').and_return(logging.INFO)
|
|
|
- flexmock(module.borg_version).should_receive('local_borg_version').and_return(flexmock())
|
|
|
- flexmock(module.command).should_receive('execute_hook')
|
|
|
- flexmock(module).should_receive('run_actions').and_raise(OSError).times(4)
|
|
|
- flexmock(module).should_receive('log_error_records').with_args(
|
|
|
- 'foo: Error running actions for repository',
|
|
|
- OSError,
|
|
|
- levelno=logging.WARNING,
|
|
|
- log_command_error_output=True,
|
|
|
- ).and_return([flexmock()]).ordered()
|
|
|
- flexmock(module).should_receive('log_error_records').with_args(
|
|
|
- 'bar: Error running actions for repository',
|
|
|
- OSError,
|
|
|
- levelno=logging.WARNING,
|
|
|
- log_command_error_output=True,
|
|
|
- ).and_return([flexmock()]).ordered()
|
|
|
- foo_error_logs = [flexmock()]
|
|
|
- flexmock(module).should_receive('log_error_records').with_args(
|
|
|
- 'foo: Error running actions for repository', OSError
|
|
|
- ).and_return(foo_error_logs).ordered()
|
|
|
- bar_error_logs = [flexmock()]
|
|
|
- flexmock(module).should_receive('log_error_records').with_args(
|
|
|
- 'bar: Error running actions for repository', OSError
|
|
|
- ).and_return(bar_error_logs).ordered()
|
|
|
- config = {'location': {'repositories': ['foo', 'bar']}, 'storage': {'retries': 1}}
|
|
|
- arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
- results = list(module.run_configuration('test.yaml', config, arguments))
|
|
|
- assert results == foo_error_logs + bar_error_logs
|
|
|
+# def test_run_configuration_retries_round_robin():
|
|
|
+# flexmock(module).should_receive('verbosity_to_log_level').and_return(logging.INFO)
|
|
|
+# flexmock(module.borg_version).should_receive('local_borg_version').and_return(flexmock())
|
|
|
+# flexmock(module.command).should_receive('execute_hook')
|
|
|
+# flexmock(module).should_receive('run_actions').and_raise(OSError).times(4)
|
|
|
+# flexmock(module).should_receive('log_error_records').with_args(
|
|
|
+# 'foo: Error running actions for repository',
|
|
|
+# OSError,
|
|
|
+# levelno=logging.WARNING,
|
|
|
+# log_command_error_output=True,
|
|
|
+# ).and_return([flexmock()]).ordered()
|
|
|
+# flexmock(module).should_receive('log_error_records').with_args(
|
|
|
+# 'bar: Error running actions for repository',
|
|
|
+# OSError,
|
|
|
+# levelno=logging.WARNING,
|
|
|
+# log_command_error_output=True,
|
|
|
+# ).and_return([flexmock()]).ordered()
|
|
|
+# foo_error_logs = [flexmock()]
|
|
|
+# flexmock(module).should_receive('log_error_records').with_args(
|
|
|
+# 'foo: Error running actions for repository', OSError
|
|
|
+# ).and_return(foo_error_logs).ordered()
|
|
|
+# bar_error_logs = [flexmock()]
|
|
|
+# flexmock(module).should_receive('log_error_records').with_args(
|
|
|
+# 'bar: Error running actions for repository', OSError
|
|
|
+# ).and_return(bar_error_logs).ordered()
|
|
|
+# config = {'location': {'repositories': [{'path':'foo','path':'bar'}]}, 'storage': {'retries': 1}}
|
|
|
+# arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
+# results = list(module.run_configuration('test.yaml', config, arguments))
|
|
|
+# assert results == foo_error_logs + bar_error_logs
|
|
|
|
|
|
|
|
|
def test_run_configuration_retries_one_passes():
|
|
@@ -309,7 +309,10 @@ def test_run_configuration_retries_one_passes():
|
|
|
flexmock(module).should_receive('log_error_records').with_args(
|
|
|
'bar: Error running actions for repository', OSError
|
|
|
).and_return(error_logs).ordered()
|
|
|
- config = {'location': {'repositories': ['foo', 'bar']}, 'storage': {'retries': 1}}
|
|
|
+ config = {
|
|
|
+ 'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]},
|
|
|
+ 'storage': {'retries': 1},
|
|
|
+ }
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
|
assert results == error_logs
|
|
@@ -348,7 +351,10 @@ def test_run_configuration_retry_wait():
|
|
|
flexmock(module).should_receive('log_error_records').with_args(
|
|
|
'foo: Error running actions for repository', OSError
|
|
|
).and_return(error_logs).ordered()
|
|
|
- config = {'location': {'repositories': ['foo']}, 'storage': {'retries': 3, 'retry_wait': 10}}
|
|
|
+ config = {
|
|
|
+ 'location': {'repositories': [{'path': 'foo'}]},
|
|
|
+ 'storage': {'retries': 3, 'retry_wait': 10},
|
|
|
+ }
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
|
results = list(module.run_configuration('test.yaml', config, arguments))
|
|
|
assert results == error_logs
|
|
@@ -384,7 +390,7 @@ def test_run_configuration_retries_timeout_multiple_repos():
|
|
|
'bar: Error running actions for repository', OSError
|
|
|
).and_return(error_logs).ordered()
|
|
|
config = {
|
|
|
- 'location': {'repositories': ['foo', 'bar']},
|
|
|
+ 'location': {'repositories': [{'path': 'foo'}, {'path': 'bar'}]},
|
|
|
'storage': {'retries': 1, 'retry_wait': 10},
|
|
|
}
|
|
|
arguments = {'global': flexmock(monitoring_verbosity=1, dry_run=False), 'create': flexmock()}
|
|
@@ -409,7 +415,7 @@ def test_run_actions_runs_rcreate():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -431,7 +437,7 @@ def test_run_actions_runs_transfer():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -454,7 +460,7 @@ def test_run_actions_runs_create():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
assert result == (expected,)
|
|
@@ -477,7 +483,7 @@ def test_run_actions_runs_prune():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -499,7 +505,7 @@ def test_run_actions_runs_compact():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -522,7 +528,7 @@ def test_run_actions_runs_check_when_repository_enabled_for_checks():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -545,7 +551,7 @@ def test_run_actions_skips_check_when_repository_not_enabled_for_checks():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -567,7 +573,7 @@ def test_run_actions_runs_extract():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -589,7 +595,7 @@ def test_run_actions_runs_export_tar():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -611,7 +617,7 @@ def test_run_actions_runs_mount():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -633,7 +639,7 @@ def test_run_actions_runs_restore():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -656,7 +662,7 @@ def test_run_actions_runs_rlist():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
assert result == (expected,)
|
|
@@ -680,7 +686,7 @@ def test_run_actions_runs_list():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
assert result == (expected,)
|
|
@@ -704,7 +710,7 @@ def test_run_actions_runs_rinfo():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
assert result == (expected,)
|
|
@@ -728,7 +734,7 @@ def test_run_actions_runs_info():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
assert result == (expected,)
|
|
@@ -751,7 +757,7 @@ def test_run_actions_runs_break_lock():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -773,7 +779,7 @@ def test_run_actions_runs_borg():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|
|
@@ -800,7 +806,7 @@ def test_run_actions_runs_multiple_actions_in_argument_order():
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- repository='repo',
|
|
|
+ repository={'path': 'repo'},
|
|
|
)
|
|
|
)
|
|
|
|