test: add temporary semantic verifier
This commit is contained in:
parent
ac308b45a8
commit
5de89f22d4
1 changed files with 31 additions and 0 deletions
31
compose.yaml
31
compose.yaml
|
|
@ -19,3 +19,34 @@ services:
|
|||
timeout: 5s
|
||||
start_period: 15s
|
||||
retries: 3
|
||||
|
||||
beszel-verifier:
|
||||
image: python:3.11-alpine
|
||||
container_name: beszel-verifier
|
||||
restart: "no"
|
||||
depends_on:
|
||||
beszel:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
BESZEL_EMAIL: ${BESZEL_ADMIN_EMAIL}
|
||||
BESZEL_PASSWORD: ${BESZEL_ADMIN_PASSWORD}
|
||||
command:
|
||||
- python
|
||||
- -c
|
||||
- |
|
||||
import json, os, time, urllib.request
|
||||
base = "http://beszel:8090"
|
||||
body = json.dumps({"identity": os.environ["BESZEL_EMAIL"], "password": os.environ["BESZEL_PASSWORD"]}).encode()
|
||||
req = urllib.request.Request(base + "/api/collections/users/auth-with-password", data=body, headers={"Content-Type": "application/json"})
|
||||
with urllib.request.urlopen(req, timeout=10) as response:
|
||||
token = json.load(response)["token"]
|
||||
result = []
|
||||
for _ in range(12):
|
||||
req = urllib.request.Request(base + "/api/collections/systems/records?perPage=50", headers={"Authorization": token})
|
||||
with urllib.request.urlopen(req, timeout=10) as response:
|
||||
items = json.load(response)["items"]
|
||||
result = [{"name": item["name"], "status": item["status"]} for item in items]
|
||||
if result and all(item["status"] == "up" for item in result):
|
||||
break
|
||||
time.sleep(5)
|
||||
print(json.dumps({"verified_systems": result}, sort_keys=True), flush=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue