Validate lab 3 release with accepted load evidence
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
"""date: 2026-11-06T08:22:40.085385+00:00 commit: b063c8780eabf63cdb9da3802f82440750308d6b"""
|
||||
|
||||
import http.client
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
|
||||
status = int(sys.argv[1])
|
||||
path = {502: "/bad", 503: "/none", 504: "/slow"}[status]
|
||||
if status != 503:
|
||||
for _ in range(60):
|
||||
conn = http.client.HTTPConnection("lb", 8080, timeout=2)
|
||||
conn.request("GET", "/health/ready")
|
||||
response = conn.getresponse()
|
||||
response.read()
|
||||
conn.close()
|
||||
if response.status == 200:
|
||||
break
|
||||
time.sleep(1)
|
||||
else:
|
||||
raise RuntimeError("Backend never became ready")
|
||||
else:
|
||||
time.sleep(5)
|
||||
for value in ['a"b', "a\\b", "a\tb", "x" * 200]:
|
||||
conn = http.client.HTTPConnection("lb", 8080, timeout=20)
|
||||
start = time.monotonic()
|
||||
conn.request("GET", path, headers={"X-Request-Id": value})
|
||||
response = conn.getresponse()
|
||||
payload = json.loads(response.read())
|
||||
assert response.status == status, response.status
|
||||
assert response.getheader("X-Request-Id") == value
|
||||
assert payload["error"]["request_id"] == value
|
||||
print(
|
||||
json.dumps(
|
||||
{
|
||||
"status": status,
|
||||
"request_id": value,
|
||||
"json_valid": True,
|
||||
"echo_matches": True,
|
||||
"seconds": round(time.monotonic() - start, 3),
|
||||
}
|
||||
),
|
||||
flush=True,
|
||||
)
|
||||
conn.close()
|
||||
@@ -0,0 +1,23 @@
|
||||
x-provenance: "date: 2026-11-06T08:22:40.085212+00:00 commit: b063c8780eabf63cdb9da3802f82440750308d6b"
|
||||
services:
|
||||
lb:
|
||||
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
|
||||
volumes: [../../../infra/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro]
|
||||
deploy:
|
||||
resources:
|
||||
limits: {cpus: "0.5", memory: 128m}
|
||||
api:
|
||||
image: mtusi-messenger:hlpipe-lab3-validation-20261106
|
||||
entrypoint: [python, /fixture/server.py]
|
||||
volumes: [./:/fixture:ro]
|
||||
deploy:
|
||||
resources:
|
||||
limits: {cpus: "0.5", memory: 128m}
|
||||
probe:
|
||||
image: mtusi-messenger:hlpipe-lab3-validation-20261106
|
||||
entrypoint: [python, /fixture/client.py]
|
||||
volumes: [./:/fixture:ro]
|
||||
profiles: [probe]
|
||||
deploy:
|
||||
resources:
|
||||
limits: {cpus: "0.5", memory: 128m}
|
||||
@@ -0,0 +1,24 @@
|
||||
"""date: 2026-11-06T08:22:40.085314+00:00 commit: b063c8780eabf63cdb9da3802f82440750308d6b"""
|
||||
|
||||
import http.server
|
||||
import time
|
||||
|
||||
|
||||
class Handler(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
if self.path == "/bad":
|
||||
self.wfile.write(b"NOT-HTTP\r\n\r\n")
|
||||
return
|
||||
if self.path == "/slow":
|
||||
time.sleep(12)
|
||||
return
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Length", "2")
|
||||
self.end_headers()
|
||||
self.wfile.write(b"OK")
|
||||
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
|
||||
|
||||
http.server.ThreadingHTTPServer(("0.0.0.0", 8080), Handler).serve_forever()
|
||||
Reference in New Issue
Block a user