Update
DevPlace CI / test (push) Failing after 1h28m53s

This commit is contained in:
2026-09-03 08:47:57 +02:00
parent 70ceb3cf81
commit 3d07a478c3
41 changed files with 1643 additions and 130 deletions
+56
View File
@@ -107,3 +107,59 @@ def test_http_ingress_proxy(app_server):
httpd.shutdown()
get_table("instances").delete(uid=uid)
refresh_snapshot()
def test_http_ingress_proxy_injects_a_base_into_the_root_document_only(app_server):
import http.server
import socket
import socketserver
import threading
sock = socket.socket()
sock.bind(("127.0.0.1", 0))
port = sock.getsockname()[1]
sock.close()
class Handler(http.server.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-Type", "text/html; charset=utf-8")
self.end_headers()
self.wfile.write(
b"<!doctype html><html><head><title>t</title></head>"
b"<body><script src='app.js'></script></body></html>"
)
def log_message(self, *args):
pass
httpd = socketserver.TCPServer(("127.0.0.1", port), Handler)
thread = threading.Thread(target=httpd.serve_forever, daemon=True)
thread.start()
slug = f"base{port}"
uid = f"basetest-{port}"
get_table("instances").insert(
{
"uid": uid,
"name": "ingress-base",
"project_uid": "ingtest",
"status": "running",
"ingress_slug": slug,
"ingress_port": 8000,
"ports_json": f'[{{"host": {port}, "container": 8000, "proto": "tcp"}}]',
"deleted_at": None,
"deleted_by": None,
}
)
refresh_snapshot()
try:
root = requests.get(f"{BASE_URL}/p/{slug}")
assert root.status_code == 200, root.text
assert f'<base href="/p/{slug}/">' in root.text
nested = requests.get(f"{BASE_URL}/p/{slug}/static/webview/pre/index.html")
assert nested.status_code == 200, nested.text
assert "<base" not in nested.text
finally:
httpd.shutdown()
get_table("instances").delete(uid=uid)
refresh_snapshot()
+73
View File
@@ -1082,3 +1082,76 @@ def test_republishing_a_live_tunnel_keeps_its_certificate():
assert again["uid"] == row["uid"]
assert again["status"] == tunnels.STATUS_ACTIVE
assert again["last_error"] == ""
def _editor_listener():
import socket
sock = socket.socket()
sock.bind(("127.0.0.1", 0))
sock.listen(8)
return sock
def _workspace_json(slug: str, key: str) -> dict:
import requests
return requests.get(
f"{BASE_URL}/projects/{slug}/workspace",
headers={"Accept": "application/json", "X-API-KEY": key},
timeout=HTTP_TIMEOUT,
).json()
def test_workspace_json_reports_the_phase_from_a_live_editor_probe(app_server, seeded_db):
owner = _seeded_user("bob_test")
project = _http_project(owner["uid"], "WS Phase Http")
sock = _editor_listener()
port = sock.getsockname()[1]
try:
_instance(
project_uid=project["uid"],
workspace_owner_uid=owner["uid"],
editor_port=editor.EDITOR_DEFAULT_PORT,
ports_json=(
f'[{{"host": {port}, "container": {editor.EDITOR_DEFAULT_PORT}, '
'"proto": "tcp"}]'
),
)
body = _workspace_json(project["slug"], owner["api_key"])
assert body["workspace"]["phase"] == provision.PHASE_READY
assert body["workspace"]["phase_label"] == "Ready"
assert body["workspace"]["editor_ready"] is True
assert body["workspace"]["owner_uid"] == owner["uid"]
assert body["editor_url"].endswith("/code/")
finally:
sock.close()
body = _workspace_json(project["slug"], owner["api_key"])
assert body["workspace"]["phase"] == provision.PHASE_STARTING
assert body["workspace"]["phase_label"] == "Starting"
assert body["workspace"]["editor_ready"] is False
assert body["workspace"]["status"] == "running"
def test_editor_proxy_refuses_a_stopped_workspace_as_plain_text(app_server, seeded_db):
import requests
owner = _seeded_user("bob_test")
project = _http_project(owner["uid"], "WS Proxy Stopped")
instance = _instance(
project_uid=project["uid"],
workspace_owner_uid=owner["uid"],
status="stopped",
desired_state="stopped",
)
response = requests.get(
f"{BASE_URL}/projects/{project['slug']}/containers/instances/{instance['uid']}/code/",
headers={"X-API-KEY": owner["api_key"]},
timeout=HTTP_TIMEOUT,
)
assert response.status_code == 409, response.text[:400]
assert response.headers["content-type"].startswith("text/plain")
assert "not running" in response.text