Withhold addresses after the database is recreated without a backup

When ripe.db is corrupted and no valid backup exists, a new empty database
is created with a db_recreated.json marker; /addresses and /addresses/diff
answer 503 until the collector gathers data again, /health reports
db_recreated. Tests now isolate all state files via conftest.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5 committed 2026-09-21 09:56:43 +03:00
1 parent 46d56654d8
commit 0155fd3f38
13 files changed
+226 -32

No files matched your search

+4 -4
View File
@@ -56,12 +56,12 @@ def test_corrupted_storage_is_preserved(files):
assert not path.exists()
assert len(list(files.glob("data.json.corrupt-*"))) == 1
# Битая база: убирается в сторону, ошибка отдаётся как StorageError
# Битая база без копий: оригинал убран в сторону, создана новая пустая база и поставлена метка пересоздания
(files / "ripe.db").write_bytes(b"this is not a sqlite database" * 100)
with pytest.raises(StorageError):
db.connect()
assert not (files / "ripe.db").exists()
with db.session() as conn:
assert db.get_values(conn) == []
assert len(list(files.glob("ripe.db.corrupt-*"))) == 1
assert (files / "db_recreated.json").exists()
def test_post_schedule_auth(files, monkeypatch):