Rechner aus dem Pool nehmen: von Hand und als Wartung im Zeitplan
- Außerhalb des Pools: keine neuen Anfragen, nichts wird geladen; laufende
Anfragen enden, danach entlädt der Proxy die Modelle; Pins ruhen
- Von Hand: Tabelle pool_out, POST /omega/api/nodes/{name}/pool, CLI pool out/in/list,
Knöpfe auf Sparks & Modelle
- Geplant: Zeitplanart Wartung (Kind::Maintenance); Pins in einer Wartung sind ein Konflikt
- Modelle nur auf Rechnern außerhalb des Pools: 503 mit Grund, nicht in den Modelllisten
- Audit: node.out, node.in, maintenance.start, maintenance.end
- tests/multispark/pool_test.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
55116414e3
commit
18567382ef
13 files changed
+542
-28
No files matched your search
@@ -0,0 +1,88 @@
|
||||
"""Test: Rechner von Hand aus dem Pool nehmen und geplante Wartung über den Zeitplan."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
from common import KEY, P, ask, check, failures, ground_truth, http, status, where # noqa: E402
|
||||
|
||||
BIN = "../../target/debug/omega-proxy"
|
||||
|
||||
|
||||
def cli(*args):
|
||||
r = subprocess.run([BIN, "-c", "proxy.toml", *args], capture_output=True, text=True)
|
||||
out = (r.stdout + r.stderr).strip().splitlines()
|
||||
return r.returncode, out[-1] if out else ""
|
||||
|
||||
|
||||
def node(name):
|
||||
return next(n for n in status() if n["name"] == name)
|
||||
|
||||
|
||||
def wait(cond, secs):
|
||||
end = time.time() + secs
|
||||
while time.time() < end:
|
||||
if cond():
|
||||
return True
|
||||
time.sleep(0.5)
|
||||
return cond()
|
||||
|
||||
|
||||
print("1) Von Hand aus dem Pool: keine neuen Anfragen, Modelle werden entladen")
|
||||
st, _, _ = ask("llamacpp", "qwen3-0.6b")
|
||||
check(st == 200 and where("llamacpp", "qwen3-0.6b") == ["spark1"], "llamacpp/qwen3-0.6b auf spark1 geladen (nur spark1 hat llama.cpp)")
|
||||
code, out = cli("--as", "admin", "pool", "out", "spark1", "--reason", "Treiber-Update")
|
||||
print(f" {out}")
|
||||
check(code == 0, "spark1 aus dem Pool genommen")
|
||||
check(wait(lambda: (node("spark1")["out_of_pool"] or {}).get("reason") == "Treiber-Update", 10), "Statusseite zeigt den Grund")
|
||||
check(wait(lambda: not ground_truth()[1]["spark1"], 20), "Modelle auf spark1 entladen")
|
||||
st, _, body = ask("llamacpp", "qwen3-0.6b")
|
||||
print(f" {st} {json.loads(body).get('error', {}).get('message', body)[:140]}")
|
||||
check(st == 503 and b"nicht im Pool" in body, "Modell nur auf spark1: 503 mit Grund")
|
||||
st, b = http(f"{P}/llamacpp/v1/models", headers={"Authorization": f"Bearer {KEY}"})
|
||||
check(st == 200 and not json.loads(b)["data"], "Modellliste von llama.cpp leer, solange spark1 nicht im Pool ist")
|
||||
for _ in range(3):
|
||||
st, _, _ = ask("ollama", "smollm2:135m")
|
||||
check(st == 200 and where("ollama", "smollm2:135m") and "spark1" not in where("ollama", "smollm2:135m"),
|
||||
f"Ollama-Anfragen gehen an andere Rechner: {where('ollama', 'smollm2:135m')}")
|
||||
code, out = cli("--as", "admin", "pool", "list")
|
||||
check("spark1" in out and "Treiber-Update" in out, f"pool list: {out}")
|
||||
|
||||
print("2) Gepinnte Modelle ruhen außerhalb des Pools")
|
||||
code, out = cli("--as", "admin", "schedule", "pin", "llamacpp/qwen3-0.6b", "--note", "Dienst")
|
||||
check(code == 0, f"Pin auf spark1 angelegt, obwohl spark1 gerade von Hand herausgenommen ist: {out}")
|
||||
pin_id = out.split()[1].rstrip(":")
|
||||
check(wait(lambda: node("spark1")["suspended_pins"] == ["llamacpp/qwen3-0.6b"], 10), "Pin ruht")
|
||||
check(not ground_truth()[1]["spark1"], "und wird nicht geladen")
|
||||
|
||||
print("3) Wieder aufnehmen: der Pin wird geladen, Anfragen gehen wieder")
|
||||
code, out = cli("--as", "admin", "pool", "in", "spark1")
|
||||
check(code == 0, out)
|
||||
check(wait(lambda: "llamacpp:qwen3-0.6b" in ground_truth()[1]["spark1"], 40), "gepinntes Modell wieder geladen")
|
||||
st, _, _ = ask("llamacpp", "qwen3-0.6b")
|
||||
check(st == 200, "Anfrage an llama.cpp geht wieder")
|
||||
code, out = cli("--as", "admin", "pool", "in", "spark1")
|
||||
check(code != 0, f"zweites Aufnehmen abgelehnt: {out}")
|
||||
|
||||
print("4) Wartung im Zeitplan: Pins auf dem Rechner sind dann nicht möglich")
|
||||
code, out = cli("--as", "admin", "schedule", "maintenance", "spark1", "--until", "+1h", "--note", "Firmware")
|
||||
print(f" {out}")
|
||||
check(code != 0 and "fällt in die Wartung von spark1" in out, "Wartung gegen den dauerhaften Pin abgelehnt")
|
||||
cli("--as", "admin", "schedule", "remove", pin_id)
|
||||
code, out = cli("--as", "admin", "schedule", "maintenance", "spark2", "--until", "+20s", "--note", "Firmware")
|
||||
check(code == 0, f"Wartung für spark2 angelegt: {out}")
|
||||
code, out = cli("--as", "admin", "schedule", "pin", "ollama/smollm2:135m", "--node", "spark2", "--until", "+10m")
|
||||
check(code != 0 and "Wartung" in out, f"Pin auf spark2 während der Wartung abgelehnt: {out}")
|
||||
check(wait(lambda: (node("spark2")["out_of_pool"] or {}).get("manual") is False, 10), "spark2 ist laut Zeitplan in Wartung")
|
||||
check("Firmware" in node("spark2")["out_of_pool"]["reason"], "mit Anmerkung als Grund")
|
||||
for _ in range(3):
|
||||
ask("ollama", "qwen3:0.6b")
|
||||
check("spark2" not in where("ollama", "qwen3:0.6b"), f"keine Anfrage an spark2: {where('ollama', 'qwen3:0.6b')}")
|
||||
code, out = cli("--as", "admin", "pool", "in", "spark2")
|
||||
check(code != 0, f"Wartung laut Zeitplan lässt sich nicht von Hand beenden: {out}")
|
||||
check(wait(lambda: node("spark2")["out_of_pool"] is None, 35), "nach der Wartung wieder im Pool")
|
||||
|
||||
print("ERGEBNIS:", "alles bestanden" if not failures else f"{len(failures)} Fehler: {failures}")
|
||||
@@ -318,6 +318,33 @@ async function flows(fail) {
|
||||
expect(c.style.width.includes('100%'), 'freier Termin nicht in voller Breite: ' + c.style.width);
|
||||
for (const n of ['lage-a-', 'lage-b-', 'lage-c-']) await click(w, 'Entfernen', n + tag);
|
||||
});
|
||||
await step('admin nimmt spark3 aus dem Pool und wieder auf', async () => {
|
||||
const { w } = browser(admin, '#/status');
|
||||
await settle(w);
|
||||
const card = () => [...w.document.querySelectorAll('.card')].find((c) => c.querySelector('h2') && c.querySelector('h2').textContent === 'spark3');
|
||||
const button = (label) => [...card().querySelectorAll('button')].find((b) => b.textContent === label);
|
||||
button('Aus dem Pool nehmen').click();
|
||||
set(w, '#pool-reason', 'Rendertest-' + tag);
|
||||
await submit(w, '#pool-reason');
|
||||
expect(card().textContent.includes('nicht im Pool') && card().textContent.includes('Rendertest-' + tag), 'nicht herausgenommen: ' + card().textContent.slice(0, 200));
|
||||
button('Wieder aufnehmen').click();
|
||||
await settle(w);
|
||||
expect(card().textContent.includes('im Pool') && !card().textContent.includes('Rendertest-' + tag), 'nicht wieder aufgenommen');
|
||||
});
|
||||
await step('admin plant eine Wartung im Zeitplan', async () => {
|
||||
const { w } = browser(admin, '#/schedule');
|
||||
await settle(w);
|
||||
await click(w, 'Neuer Eintrag');
|
||||
check(w, 'input[name="s-kind"][value="maintenance"]');
|
||||
check(w, 'input[name="s-maint-node"][value="spark3"]');
|
||||
set(w, '#s-from', '2027-03-02T07:00');
|
||||
set(w, '#s-until', '2027-03-02T09:00');
|
||||
set(w, '#s-note', 'wartung-' + tag);
|
||||
await submit(w, '#s-note');
|
||||
const row = [...w.document.querySelectorAll('tbody tr')].find((tr) => tr.textContent.includes('wartung-' + tag));
|
||||
expect(row && row.textContent.includes('Wartung') && row.textContent.includes('spark3'), 'Eintrag fehlt: ' + ((w.document.querySelector('.overlay .notice') || {}).textContent));
|
||||
await click(w, 'Entfernen', 'wartung-' + tag);
|
||||
});
|
||||
await step('dozent teilt ein gemeinsames Kontingent mit Modellen, Wochentagen und Gültigkeit zu', async () => {
|
||||
const { w } = browser(dozent, '#/group/ki-praktikum');
|
||||
await settle(w);
|
||||
|
||||
Reference in new issue
Block a user