Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
Desktop foundation / core (macos-latest) (push) Canceled after 0s
Desktop foundation / core (windows-latest) (push) Canceled after 0s
Linux / verify (push) Canceled after 0s
Linux / keyless-cuda (push) Canceled after 0s
Linux / static-cuda-package (push) Canceled after 0s
Linux / hosted-cuda-package (push) Canceled after 0s
Linux / linux-static-cli (push) Canceled after 0s
Linux / linux-cli-container (push) Canceled after 0s
Linux / release-cli (push) Canceled after 0s
63 lines
2.3 KiB
Python
63 lines
2.3 KiB
Python
"""Offline CI fault test: C# observer + isolated Rust node; no inference or SSH."""
|
|
import asyncio
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import secrets
|
|
|
|
|
|
async def main():
|
|
root = Path(__file__).resolve().parents[2]
|
|
binary = root / "desktop-core/target/debug" / ("strata-desktop.exe" if os.name == "nt" else "strata-desktop")
|
|
dll = root / "desktop/bin/Debug/net10.0/Strata.Desktop.dll"
|
|
env = os.environ.copy()
|
|
env.pop("STRATA_NODE_ENDPOINT", None)
|
|
env["STRATA_NODE_TOKEN"] = secrets.token_hex(32)
|
|
nodes = []
|
|
app = None
|
|
|
|
async def launch(address):
|
|
process = await asyncio.create_subprocess_exec(
|
|
str(binary), "node", "--listen", address, "--token-env", "STRATA_NODE_TOKEN",
|
|
env=env, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.DEVNULL,
|
|
)
|
|
nodes.append(process)
|
|
descriptor = json.loads(await asyncio.wait_for(process.stdout.readline(), 5))
|
|
return process, descriptor["endpoint"]
|
|
|
|
try:
|
|
node, endpoint = await launch("127.0.0.1:0")
|
|
env["STRATA_NODE_ENDPOINT"] = endpoint
|
|
app = await asyncio.create_subprocess_exec(
|
|
"dotnet", str(dll), "--self-check-reconnect", env=env,
|
|
stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
|
|
)
|
|
killed = restarted = False
|
|
while True:
|
|
line = await asyncio.wait_for(app.stdout.readline(), 28)
|
|
if not line:
|
|
break
|
|
message = line.decode().strip()
|
|
print(message, flush=True)
|
|
if message.startswith("{"):
|
|
phase = json.loads(message)["Phase"]
|
|
if phase == "ready" and not killed:
|
|
node.kill()
|
|
await node.wait()
|
|
killed = True
|
|
elif phase == "disconnected" and killed and not restarted:
|
|
await launch(endpoint.removeprefix("http://"))
|
|
restarted = True
|
|
code = await asyncio.wait_for(app.wait(), 5)
|
|
if code != 0 or not restarted:
|
|
raise RuntimeError("C# reconnect check failed")
|
|
finally:
|
|
for process in nodes + ([app] if app else []):
|
|
if process.returncode is None:
|
|
process.kill()
|
|
await process.wait()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|