Stage B of review fixes: daemon state lock, image build check, RIPEstat retries
Job state is changed under one RLock, the Dockerfile copies all root modules and imports them at build time, RIPEstat requests go through a retrying session with the sourceapp parameter (ripestat_sourceapp) and a capped Retry-After. Adds the summary and marks review findings 5-10 fixed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d6b69d0842
commit
aaf41adc79
8 files changed
+164
-28
No files matched your search
@@ -10,6 +10,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import api_server
|
||||
import cidr_collector as cc
|
||||
import collector_daemon as daemon
|
||||
import db
|
||||
from storage import load_json, save_json_atomic
|
||||
|
||||
|
||||
@@ -95,3 +96,20 @@ def test_daemon_runs_requested_collection_once(env, monkeypatch):
|
||||
daemon.run_job("asn", scheduler)
|
||||
finally:
|
||||
daemon._run_locks["asn"].release()
|
||||
|
||||
|
||||
def test_backup_job_rotates_and_is_registered():
|
||||
# Задание backup зарегистрировано рядом с asn и fqdn и использует расписание по умолчанию
|
||||
assert daemon.COLLECTORS["backup"] is daemon.run_backup and "backup" in daemon.DEFAULT_CRONS
|
||||
assert "backup" in daemon.job_state
|
||||
|
||||
with open(cc.CONFIG_FILE, "w") as f:
|
||||
f.write('{"asns": [], "fqdns": [], "backup_keep": 2}')
|
||||
now = datetime.datetime.now()
|
||||
with db.session() as conn:
|
||||
for days in (1, 2, 3):
|
||||
db.backup_database(conn, now - datetime.timedelta(days=days), keep=10)
|
||||
daemon.run_backup() # keep=2 из config.json: остаются свежая копия и самая новая из старых
|
||||
backups = db.list_backups(cc.BACKUP_DIR)
|
||||
yesterday = (now - datetime.timedelta(days=1)).astimezone(datetime.timezone.utc).strftime("%Y%m%dT%H%M%SZ")
|
||||
assert len(backups) == 2 and backups[1].endswith(f"ripe-{yesterday}.db") and backups[0] > backups[1]
|
||||
Reference in new issue
Block a user