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:
bors[bot] 2022-01-24 23:17:15 +00:00 коммит произвёл GitHub
Родитель 946a509fe1 11b11695d5
Коммит 8cb199100a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 27 добавлений и 1 удалений

Просмотреть файл

@ -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