feat(update): scaffold MAJ silencieuse + canary par machine (DETTE-022, gated OFF, swap encore stub)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -83,3 +83,43 @@ class TestUpdateCheckEndpointEnabled:
|
||||
"/api/v1/agents/update/check?current_version=1.0.1",
|
||||
)
|
||||
assert resp.status_code == 401
|
||||
|
||||
|
||||
class TestUpdateCheckCanary:
|
||||
"""Canary : seul le poste canary se voit proposer la nouvelle version.
|
||||
|
||||
On n'utilise PAS RPA_AGENT_LATEST_VERSION (var legacy globale) : on pilote
|
||||
la version cible via la politique canary (stable + canary + allow-list).
|
||||
"""
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _enable_canary(self, monkeypatch):
|
||||
monkeypatch.setenv("RPA_AUTO_UPDATE_SERVER_ENABLED", "true")
|
||||
# Legacy OFF pour que la politique canary pilote la décision.
|
||||
monkeypatch.delenv("RPA_AGENT_LATEST_VERSION", raising=False)
|
||||
monkeypatch.setenv("RPA_AGENT_STABLE_VERSION", "1.0.1")
|
||||
monkeypatch.setenv("RPA_AGENT_CANARY_VERSION", "1.0.2")
|
||||
monkeypatch.setenv("RPA_AGENT_CANARY_MACHINES", "lea-4zbgwxty")
|
||||
|
||||
def test_poste_canary_recoit_la_nouvelle_version(self, client):
|
||||
resp = client.get(
|
||||
"/api/v1/agents/update/check"
|
||||
"?current_version=1.0.1&machine_id=lea-4zbgwxty",
|
||||
headers=_auth_headers(),
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert body["update_available"] is True
|
||||
assert body["latest_version"] == "1.0.2"
|
||||
|
||||
def test_poste_hors_canary_reste_a_jour_sur_stable(self, client):
|
||||
# Poste NON canary, déjà en 1.0.1 = stable → pas de MAJ (blast radius
|
||||
# borné : la 1.0.2 ne fuite pas hors de la liste canary).
|
||||
resp = client.get(
|
||||
"/api/v1/agents/update/check"
|
||||
"?current_version=1.0.1&machine_id=un-autre-poste",
|
||||
headers=_auth_headers(),
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert body["update_available"] is False
|
||||
|
||||
Reference in New Issue
Block a user