зеркало из https://github.com/mozilla/normandy.git
Merge #2337
2337: Add heartbeat check for Remote Settings config r=tiftran a=leplatrem Co-authored-by: Mathieu Leplatre <mathieu@mozilla.com>
This commit is contained in:
Коммит
8cb199100a
|
@ -9,7 +9,7 @@ from django.db.utils import OperationalError, ProgrammingError
|
|||
|
||||
import requests.exceptions
|
||||
|
||||
from normandy.recipes import signing, geolocation
|
||||
from normandy.recipes import exports, signing, geolocation
|
||||
|
||||
|
||||
INFO_COULD_NOT_RETRIEVE_ACTIONS = "normandy.recipes.I001"
|
||||
|
@ -23,6 +23,7 @@ ERROR_INVALID_ACTION_SIGNATURE = "normandy.recipes.E004"
|
|||
ERROR_COULD_NOT_VERIFY_CERTIFICATE = "normandy.recipes.E005"
|
||||
ERROR_GEOIP_DB_NOT_AVAILABLE = "normandy.recipes.E006"
|
||||
ERROR_GEOIP_DB_UNEXPECTED_RESULT = "normandy.recipes.E007"
|
||||
ERROR_REMOTE_SETTINGS_INCORRECT_CONFIG = "normandy.recipes.E008"
|
||||
|
||||
|
||||
def actions_have_consistent_hashes(app_configs, **kwargs):
|
||||
|
@ -187,9 +188,24 @@ def geoip_db_is_available(app_configs, **kwargs):
|
|||
return errors
|
||||
|
||||
|
||||
def remotesettings_config_is_correct(app_configs, **kwargs):
|
||||
errors = []
|
||||
try:
|
||||
exports.RemoteSettings().check_config()
|
||||
except ImproperlyConfigured as e:
|
||||
errors.append(
|
||||
Error(
|
||||
f"Remote Settings config is incorrect: {e}",
|
||||
id=ERROR_REMOTE_SETTINGS_INCORRECT_CONFIG,
|
||||
)
|
||||
)
|
||||
return errors
|
||||
|
||||
|
||||
def register():
|
||||
register_check(actions_have_consistent_hashes)
|
||||
register_check(recipe_signatures_are_correct)
|
||||
register_check(action_signatures_are_correct)
|
||||
register_check(signatures_use_good_certificates)
|
||||
register_check(geoip_db_is_available)
|
||||
register_check(remotesettings_config_is_correct)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from datetime import timedelta
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.db.utils import ProgrammingError
|
||||
|
||||
import pytest
|
||||
|
@ -93,3 +94,12 @@ class TestActionSignatureAreCorrect:
|
|||
errors = checks.action_signatures_are_correct(None)
|
||||
assert len(errors) == 1
|
||||
assert errors[0].id == checks.WARNING_COULD_NOT_CHECK_SIGNATURES
|
||||
|
||||
|
||||
class TestRemoteSettingsConfigIsCorrect:
|
||||
def test_it_warns_if_remote_settings_config_is_incorrect(self, mocker):
|
||||
mock_check_config = mocker.patch("normandy.recipes.exports.RemoteSettings.check_config")
|
||||
mock_check_config.side_effect = ImproperlyConfigured("error for testing")
|
||||
errors = checks.remotesettings_config_is_correct(None)
|
||||
assert len(errors) == 1
|
||||
assert errors[0].id == checks.ERROR_REMOTE_SETTINGS_INCORRECT_CONFIG
|
||||
|
|
Загрузка…
Ссылка в новой задаче