fix: address rotation-revocation narrow verify findings
Name restarting both the LB and the replicas when the LB has no ready replica, state the measured 25 s bound of the LB metrics port, narrow the missing files of a held identity to its certificate, and cover refusals and signals during CRL issue with fast tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -469,6 +469,7 @@ def test_require_ready(stand: RunStand) -> None:
|
||||
def test_require_files(name: str, stand: RunStand) -> None:
|
||||
_ready(stand)
|
||||
(stand.pki_dir / name).unlink()
|
||||
stand.missing = {"relay"}
|
||||
with pytest.raises(rotation.NotReady, match=f"no {name}"):
|
||||
stand.require(set())
|
||||
|
||||
@@ -563,7 +564,7 @@ def test_require_of_revoked_owner(status: str, stand: RunStand) -> None:
|
||||
|
||||
LB_HINT = (
|
||||
"run make run_docker first; if the LB still has no ready replica: docker "
|
||||
"compose restart api"
|
||||
"compose restart haproxy api"
|
||||
)
|
||||
|
||||
|
||||
@@ -593,6 +594,11 @@ LB_HINT = (
|
||||
{"api", "api-client"},
|
||||
"run make rotate_leaf IDENTITY=api-client first",
|
||||
),
|
||||
(
|
||||
"haproxy",
|
||||
{"api-client", "haproxy"},
|
||||
"run make rotate_leaf IDENTITY=api-client first",
|
||||
),
|
||||
("api", {"api"}, "run make rotate_leaf IDENTITY=api first"),
|
||||
("relay", {"api-client"}, "run make run_docker first"),
|
||||
("haproxy", {"relay"}, LB_HINT),
|
||||
@@ -636,6 +642,51 @@ def test_recreated_stand_directory(stand: RunStand) -> None:
|
||||
assert f"$(held_missing){'; '.join(rotation.RECREATED_STEPS)}" in script
|
||||
|
||||
|
||||
@pytest.mark.parametrize("missing", ["worker", "openbao", "api"])
|
||||
@pytest.mark.parametrize(
|
||||
"command",
|
||||
[
|
||||
"leaf relay",
|
||||
"leaf openbao",
|
||||
"leaf api",
|
||||
"revoke relay",
|
||||
"renew",
|
||||
"secret postgres/worker",
|
||||
],
|
||||
)
|
||||
def test_command_in_a_recreated_stand_directory(
|
||||
command: str,
|
||||
missing: str,
|
||||
stand: RunStand,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
capsys: pytest.CaptureFixture[str],
|
||||
) -> None:
|
||||
"""Сценарий «Каталог стенда создан заново»: сертификата удержанной нет —
|
||||
каждая команда читает статус PKI и отказывает с цепочкой до изменений: код
|
||||
2, кроме чтения статуса не запущено ничего, `.env` прежний."""
|
||||
_ready(stand, worker=("running", None, NEW))
|
||||
stand.on(
|
||||
"pki.sh status",
|
||||
f"leaf {missing}: MISSING, held until infra/pki/pki.sh rotate "
|
||||
f"{missing} (x)\n",
|
||||
)
|
||||
stand.env_file = stand.pki_dir / ".env"
|
||||
env = "POSTGRES_WORKER_PASSWORD=0123456789abcdef\n"
|
||||
stand.env_file.write_text(env)
|
||||
monkeypatch.delenv("POSTGRES_WORKER_PASSWORD", raising=False)
|
||||
name, *args = command.split()
|
||||
call = getattr(rotation, f"cmd_{name}")
|
||||
assert rotation.execute(stand, lambda: call(stand, *args)) == 2 # noqa: PLR2004
|
||||
steps = "; ".join(rotation.RECREATED_STEPS)
|
||||
assert capsys.readouterr().out == (
|
||||
f"rotation: no files of the revoked {missing} in the stand directory: "
|
||||
f"run infra/pki/pki.sh rotate {missing}; {steps}; nothing changed\n"
|
||||
)
|
||||
assert stand.changed is False
|
||||
assert [c.text.split("pki.sh ")[-1] for c in stand.calls] == ["status"]
|
||||
assert stand.env_file.read_text() == env
|
||||
|
||||
|
||||
def _rollout_refuses(stand: RunStand) -> None:
|
||||
stand.on("rolling-update.sh", (2, "", "error: replica x is not UP\n"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user