Monitor backups with Cronhub hook integration. Fix Healthchecks/Cronitor hooks to respect dry run.

This commit is contained in:
Dan Helfman
2019-11-07 10:08:44 -08:00
parent ac777965d0
commit 17fda7281a
11 changed files with 146 additions and 16 deletions
+32
View File
@@ -0,0 +1,32 @@
from flexmock import flexmock
from borgmatic.hooks import cronhub as module
def test_ping_cronhub_hits_ping_url_with_start_state():
ping_url = 'https://example.com/start/abcdef'
state = 'bork'
flexmock(module.requests).should_receive('get').with_args('https://example.com/bork/abcdef')
module.ping_cronhub(ping_url, 'config.yaml', dry_run=False, state=state)
def test_ping_cronhub_hits_ping_url_with_ping_state():
ping_url = 'https://example.com/ping/abcdef'
state = 'bork'
flexmock(module.requests).should_receive('get').with_args('https://example.com/bork/abcdef')
module.ping_cronhub(ping_url, 'config.yaml', dry_run=False, state=state)
def test_ping_cronhub_without_ping_url_does_not_raise():
flexmock(module.requests).should_receive('get').never()
module.ping_cronhub(ping_url=None, config_filename='config.yaml', dry_run=False, state='oops')
def test_ping_cronhub_dry_run_does_not_hit_ping_url():
ping_url = 'https://example.com'
flexmock(module.requests).should_receive('get').never()
module.ping_cronhub(ping_url, 'config.yaml', dry_run=True, state='yay')
+7
View File
@@ -15,3 +15,10 @@ def test_ping_cronitor_without_ping_url_does_not_raise():
flexmock(module.requests).should_receive('get').never()
module.ping_cronitor(ping_url=None, config_filename='config.yaml', dry_run=False, append='oops')
def test_ping_cronitor_dry_run_does_not_hit_ping_url():
ping_url = 'https://example.com'
flexmock(module.requests).should_receive('get').never()
module.ping_cronitor(ping_url, 'config.yaml', dry_run=True, append='yay')
+7
View File
@@ -31,3 +31,10 @@ def test_ping_healthchecks_hits_ping_url_with_append():
flexmock(module.requests).should_receive('get').with_args('{}/{}'.format(ping_url, append))
module.ping_healthchecks(ping_url, 'config.yaml', dry_run=False, append=append)
def test_ping_healthchecks_dry_run_does_not_hit_ping_url():
ping_url = 'https://example.com'
flexmock(module.requests).should_receive('get').never()
module.ping_healthchecks(ping_url, 'config.yaml', dry_run=True)