add test for healthchecks
Signed-off-by: Soumik Dutta <shalearkane@gmail.com>
This commit is contained in:
parent
1573d68fe2
commit
45256ae33f
5 changed files with 28 additions and 19 deletions
|
@ -153,6 +153,7 @@ def run_configuration(config_filename, config, arguments):
|
||||||
error_repository = repository_path
|
error_repository = repository_path
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if using_primary_action:
|
||||||
# send logs irrespective of error
|
# send logs irrespective of error
|
||||||
dispatch.call_hooks(
|
dispatch.call_hooks(
|
||||||
'ping_monitor',
|
'ping_monitor',
|
||||||
|
|
|
@ -10,7 +10,6 @@ MONITOR_STATE_TO_CRONHUB = {
|
||||||
monitor.State.START: 'start',
|
monitor.State.START: 'start',
|
||||||
monitor.State.FINISH: 'finish',
|
monitor.State.FINISH: 'finish',
|
||||||
monitor.State.FAIL: 'fail',
|
monitor.State.FAIL: 'fail',
|
||||||
monitor.State.LOG: 'log',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ MONITOR_STATE_TO_CRONITOR = {
|
||||||
monitor.State.START: 'run',
|
monitor.State.START: 'run',
|
||||||
monitor.State.FINISH: 'complete',
|
monitor.State.FINISH: 'complete',
|
||||||
monitor.State.FAIL: 'fail',
|
monitor.State.FAIL: 'fail',
|
||||||
monitor.State.LOG: 'ok',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,6 @@ from borgmatic.hooks import monitor
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
MONITOR_STATE_TO_NTFY = {
|
|
||||||
monitor.State.START: None,
|
|
||||||
monitor.State.FINISH: None,
|
|
||||||
monitor.State.FAIL: None,
|
|
||||||
monitor.State.LOG: None,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def initialize_monitor(
|
def initialize_monitor(
|
||||||
ping_url, config_filename, monitoring_log_level, dry_run
|
ping_url, config_filename, monitoring_log_level, dry_run
|
||||||
|
|
|
@ -184,6 +184,23 @@ def test_ping_monitor_hits_ping_url_for_fail_state():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_ping_monitor_hits_ping_url_for_log_state():
|
||||||
|
hook_config = {'ping_url': 'https://example.com'}
|
||||||
|
payload = 'data'
|
||||||
|
flexmock(module).should_receive('format_buffered_logs_for_payload').and_return(payload)
|
||||||
|
flexmock(module.requests).should_receive('post').with_args(
|
||||||
|
'https://example.com/log', data=payload.encode('utf'), verify=True
|
||||||
|
).and_return(flexmock(ok=True))
|
||||||
|
|
||||||
|
module.ping_monitor(
|
||||||
|
hook_config,
|
||||||
|
'config.yaml',
|
||||||
|
state=module.monitor.State.LOG,
|
||||||
|
monitoring_log_level=1,
|
||||||
|
dry_run=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_ping_monitor_with_ping_uuid_hits_corresponding_url():
|
def test_ping_monitor_with_ping_uuid_hits_corresponding_url():
|
||||||
hook_config = {'ping_url': 'abcd-efgh-ijkl-mnop'}
|
hook_config = {'ping_url': 'abcd-efgh-ijkl-mnop'}
|
||||||
payload = 'data'
|
payload = 'data'
|
||||||
|
|
Loading…
Reference in a new issue