Merge "Protect against empty request health check"
This commit is contained in:
commit
e20f031cd1
|
@ -582,7 +582,16 @@ def _assess_status():
|
||||||
health = None
|
health = None
|
||||||
if service_running('vault'):
|
if service_running('vault'):
|
||||||
health = vault.get_vault_health()
|
health = vault.get_vault_health()
|
||||||
|
else:
|
||||||
|
status_set('blocked', 'Vault service not running')
|
||||||
|
return
|
||||||
|
|
||||||
|
if health.get('version'):
|
||||||
application_version_set(health.get('version'))
|
application_version_set(health.get('version'))
|
||||||
|
else:
|
||||||
|
application_version_set('Unknown')
|
||||||
|
status_set('blocked', 'Vault health check failed')
|
||||||
|
return
|
||||||
|
|
||||||
_missing_interfaces = []
|
_missing_interfaces = []
|
||||||
_incomplete_interfaces = []
|
_incomplete_interfaces = []
|
||||||
|
|
|
@ -315,6 +315,25 @@ class TestHandlers(unit_tests.test_utils.CharmTestCase):
|
||||||
incomplete_interfaces=mock.ANY),
|
incomplete_interfaces=mock.ANY),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@patch.object(handlers.vault, 'get_vault_health')
|
||||||
|
def test_assess_status_service_not_running(self, get_vault_health):
|
||||||
|
self.is_flag_set.return_value = False
|
||||||
|
self.service_running.return_value = False
|
||||||
|
handlers._assess_status()
|
||||||
|
self.status_set.assert_called_with(
|
||||||
|
'blocked', 'Vault service not running')
|
||||||
|
|
||||||
|
@patch.object(handlers.vault, 'get_vault_health')
|
||||||
|
def test_assess_status_empty_health(self, get_vault_health):
|
||||||
|
self.is_flag_set.return_value = False
|
||||||
|
self.service_running.return_value = True
|
||||||
|
get_vault_health.return_value = {}
|
||||||
|
handlers._assess_status()
|
||||||
|
self.application_version_set.assert_called_with(
|
||||||
|
'Unknown')
|
||||||
|
self.status_set.assert_called_with(
|
||||||
|
'blocked', 'Vault health check failed')
|
||||||
|
|
||||||
def test_assess_status_invalid_channel(self):
|
def test_assess_status_invalid_channel(self):
|
||||||
statuses = {
|
statuses = {
|
||||||
'snap.channel.invalid': True,
|
'snap.channel.invalid': True,
|
||||||
|
|
Loading…
Reference in New Issue