marvis docker container, ignore ueransim
This commit is contained in:
@@ -3,6 +3,16 @@ import uuid
|
||||
import time
|
||||
from typing import Dict, Optional
|
||||
|
||||
from app.config import (
|
||||
CONTAINER_HOST,
|
||||
CONTAINER_RUNTIME,
|
||||
UERANSIM_CONTAINER_NAME,
|
||||
UERANSIM_ENV_FILE,
|
||||
UERANSIM_IMAGE,
|
||||
UERANSIM_NETWORK_MODE,
|
||||
UERANSIM_PRIVILEGED,
|
||||
)
|
||||
|
||||
_tasks: Dict[str, dict] = {}
|
||||
|
||||
|
||||
@@ -28,31 +38,39 @@ async def run_test(task_id: str) -> None:
|
||||
def log(msg: str, type: str = "info") -> None:
|
||||
task["logs"].append({"msg": msg, "type": type, "ts": time.strftime("%H:%M:%S")})
|
||||
|
||||
log("▸ Checking UERANSIM Docker image…", "run")
|
||||
runtime_cmd = [CONTAINER_RUNTIME]
|
||||
if CONTAINER_HOST:
|
||||
runtime_cmd.extend(["--host", CONTAINER_HOST])
|
||||
|
||||
log(f"▸ Checking UERANSIM image via {CONTAINER_RUNTIME}…", "run")
|
||||
check = await asyncio.create_subprocess_exec(
|
||||
"docker", "images", "-q", "ueransim",
|
||||
*runtime_cmd, "images", "-q", UERANSIM_IMAGE,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
out, _ = await check.communicate()
|
||||
if not out.strip():
|
||||
log("✗ UERANSIM image not found.", "err")
|
||||
log(" SSH to host and run: bash /opt/p5g-marvis/build-ueransim.sh", "err")
|
||||
log(" Build it with `docker compose build ueransim` or set MARVIS_UERANSIM_IMAGE.", "err")
|
||||
task["status"] = "error"
|
||||
return
|
||||
|
||||
log(" UERANSIM image ready", "ok")
|
||||
log("▸ Starting test container — allow up to 60s…", "run")
|
||||
|
||||
env_file = "/opt/p5g-marvis/config/ueransim.env"
|
||||
|
||||
try:
|
||||
run_cmd = [*runtime_cmd, "run", "--rm", "--name", UERANSIM_CONTAINER_NAME]
|
||||
if UERANSIM_NETWORK_MODE:
|
||||
run_cmd.append(f"--network={UERANSIM_NETWORK_MODE}")
|
||||
if UERANSIM_PRIVILEGED:
|
||||
run_cmd.append("--privileged")
|
||||
run_cmd.extend([
|
||||
"--env-file", UERANSIM_ENV_FILE,
|
||||
UERANSIM_IMAGE,
|
||||
])
|
||||
|
||||
proc = await asyncio.create_subprocess_exec(
|
||||
"docker", "run", "--rm",
|
||||
"--network=host",
|
||||
"--privileged",
|
||||
"--env-file", env_file,
|
||||
"ueransim",
|
||||
*run_cmd,
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.STDOUT,
|
||||
)
|
||||
@@ -81,7 +99,7 @@ async def run_test(task_id: str) -> None:
|
||||
log("✓ Emulated data session completed successfully", "ok")
|
||||
task["status"] = "done"
|
||||
elif proc.returncode == 2:
|
||||
log("⚠ Credentials not configured — edit /opt/p5g-marvis/config/ueransim.env", "warn")
|
||||
log(f"⚠ Credentials not configured — edit {UERANSIM_ENV_FILE}", "warn")
|
||||
task["status"] = "error"
|
||||
else:
|
||||
log(f"✗ Test exited with code {proc.returncode}", "err")
|
||||
|
||||
Reference in New Issue
Block a user