Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4dc078e5bb | ||
|
|
f67af8c4a8 | ||
|
|
ef048336ae | ||
|
|
c25b180021 | ||
|
|
5293d93a30 | ||
|
|
54851fc191 | ||
|
|
1b5e10bbd0 | ||
|
|
bd3d409836 | ||
|
|
7eb0e5186d | ||
|
|
78d06d0ba0 |
No files matched your search
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## 从这里开始
|
## 从这里开始
|
||||||
|
|
||||||
先阅读 [Ubuntu 22.04 本地部署运行手册](docs/DEPLOYMENT-RUNBOOK.md)、[后端本地部署](docs/BACKEND-DEPLOYMENT.md)、[样机硬件评估报告](docs/POC-HARDWARE-BASELINE.md) 和 [源码版本核对](docs/SOURCE-RECONCILIATION.md)。当前可以启动 PostgreSQL、Redis、MinIO 和平台后端;平台前端、管理端 AI-only 模式和统一网关仍在后续阶段。
|
先阅读 [Ubuntu 22.04 本地部署运行手册](docs/DEPLOYMENT-RUNBOOK.md)、[后端本地部署](docs/BACKEND-DEPLOYMENT.md)、[平台前端本地部署](docs/FRONTEND-DEPLOYMENT.md)、[管理端本地部署](docs/ADMIN-DEPLOYMENT.md)、[Tripo 零积分压测方案](docs/TRIPO-ZERO-COST-BENCHMARK.md)、[2026-08-13 POC 性能报告](results/reports/POC-PERFORMANCE-REPORT-2026-08-13.md)、[样机硬件评估报告](docs/POC-HARDWARE-BASELINE.md) 和 [源码版本核对](docs/SOURCE-RECONCILIATION.md)。当前可以启动 PostgreSQL、Redis、MinIO、平台后端、平台前端和 AI SoulMate 管理端;统一网关仍在后续阶段。
|
||||||
|
|
||||||
本仓库是 AI SoulMate 私有化部署的编排与留档仓库,用于固定源码版本、记录硬件基线、建设部署配置并沉淀压测结果。业务源码仍保留在各自仓库中,不复制源码、不改写原有 Git 历史。
|
本仓库是 AI SoulMate 私有化部署的编排与留档仓库,用于固定源码版本、记录硬件基线、建设部署配置并沉淀压测结果。业务源码仍保留在各自仓库中,不复制源码、不改写原有 Git 历史。
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
- 当前 HP ZCentral 4R 样机适合做单机适配、功能跑通和容量边界测试,不作为生产高可用样板。
|
- 当前 HP ZCentral 4R 样机适合做单机适配、功能跑通和容量边界测试,不作为生产高可用样板。
|
||||||
- 第一阶段在中心服务器部署平台后端、平台前端、AI SoulMate 管理端、PostgreSQL、Redis、本地对象存储和统一网关。
|
- 第一阶段在中心服务器部署平台后端、平台前端、AI SoulMate 管理端、PostgreSQL、Redis、本地对象存储和统一网关。
|
||||||
- Tripo 暂时继续走外部 API,因此这是“业务数据和基础设施本地化”,不是完全离线部署。
|
- Tripo 生产生成仍走外部 API,因此这是“业务数据和基础设施本地化”,不是完全离线部署;本地性能测试使用零外连、零积分的 `mock` 模式。
|
||||||
- 农场端 `ai-soulmate-client` 暂不部署到中心服务器,后续放到靠近打印机的工作站。
|
- 农场端 `ai-soulmate-client` 暂不部署到中心服务器,后续放到靠近打印机的工作站。
|
||||||
- 网关能力是必需的,但现有 `nginx-server` 的公网域名和固定路由不能原样交付,需要在本仓库形成私有部署配置。
|
- 网关能力是必需的,但现有 `nginx-server` 的公网域名和固定路由不能原样交付,需要在本仓库形成私有部署配置。
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
- `docs/CROSS-COMPUTER-HANDOFF.md`:换电脑继续工作的状态、重建 Git 和接管清单。
|
- `docs/CROSS-COMPUTER-HANDOFF.md`:换电脑继续工作的状态、重建 Git 和接管清单。
|
||||||
- `decisions/`:影响交付方式的架构决策。
|
- `decisions/`:影响交付方式的架构决策。
|
||||||
- `inventory/`:参与部署的源码版本清单。
|
- `inventory/`:参与部署的源码版本清单。
|
||||||
- `compose/`:基础设施和平台后端 Compose 编排。
|
- `compose/`:基础设施、平台后端和平台前端 Compose 编排。
|
||||||
- `scripts/`:硬件与运行状态采集脚本。
|
- `scripts/`:硬件与运行状态采集脚本。
|
||||||
- `benchmark/`:压测场景和单次运行元数据模板。
|
- `benchmark/`:压测场景和单次运行元数据模板。
|
||||||
- `results/`:压测报告与不入库的原始数据。
|
- `results/`:压测报告与不入库的原始数据。
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import argparse
|
||||||
|
import ipaddress
|
||||||
|
import json
|
||||||
|
import pathlib
|
||||||
|
import socket
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
|
||||||
|
class NoRedirectHandler(urllib.request.HTTPRedirectHandler):
|
||||||
|
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def validate_base_url(raw_url):
|
||||||
|
parsed = urllib.parse.urlsplit(raw_url)
|
||||||
|
if parsed.scheme not in {"http", "https"} or not parsed.hostname:
|
||||||
|
raise ValueError("Base URL must use http or https and include a host.")
|
||||||
|
if parsed.username or parsed.password or parsed.query or parsed.fragment:
|
||||||
|
raise ValueError("Credentials, query strings, and fragments are forbidden.")
|
||||||
|
if parsed.path not in {"", "/"}:
|
||||||
|
raise ValueError("Base URL must not include an API path.")
|
||||||
|
if parsed.hostname == "localhost":
|
||||||
|
addresses = [ipaddress.ip_address("127.0.0.1")]
|
||||||
|
else:
|
||||||
|
addresses = [
|
||||||
|
ipaddress.ip_address(item[4][0])
|
||||||
|
for item in socket.getaddrinfo(
|
||||||
|
parsed.hostname, parsed.port, type=socket.SOCK_STREAM
|
||||||
|
)
|
||||||
|
]
|
||||||
|
if not addresses or any(
|
||||||
|
not (address.is_loopback or address.is_private or address.is_link_local)
|
||||||
|
for address in addresses
|
||||||
|
):
|
||||||
|
raise ValueError("Refusing to send a bearer token to a non-local host.")
|
||||||
|
return raw_url.rstrip("/")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description="Close a local benchmark session.")
|
||||||
|
parser.add_argument("--base-url", default="http://127.0.0.1:3001")
|
||||||
|
parser.add_argument("--headers-file", required=True)
|
||||||
|
parser.add_argument("--timeout", type=float, default=5.0)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
try:
|
||||||
|
base_url = validate_base_url(args.base_url)
|
||||||
|
headers = json.loads(
|
||||||
|
pathlib.Path(args.headers_file).read_text(encoding="utf-8")
|
||||||
|
)
|
||||||
|
if not isinstance(headers, dict) or not isinstance(
|
||||||
|
headers.get("Authorization"), str
|
||||||
|
):
|
||||||
|
raise ValueError("Temporary headers file is invalid.")
|
||||||
|
opener = urllib.request.build_opener(
|
||||||
|
urllib.request.ProxyHandler({}), NoRedirectHandler()
|
||||||
|
)
|
||||||
|
request = urllib.request.Request(
|
||||||
|
base_url + "/api/auth/logout",
|
||||||
|
data=b"{}",
|
||||||
|
headers=headers,
|
||||||
|
method="POST",
|
||||||
|
)
|
||||||
|
with opener.open(request, timeout=args.timeout) as response:
|
||||||
|
response.read(1024)
|
||||||
|
if not 200 <= response.status < 300:
|
||||||
|
raise RuntimeError(f"Logout returned HTTP {response.status}.")
|
||||||
|
except (
|
||||||
|
OSError,
|
||||||
|
ValueError,
|
||||||
|
RuntimeError,
|
||||||
|
json.JSONDecodeError,
|
||||||
|
socket.gaierror,
|
||||||
|
urllib.error.URLError,
|
||||||
|
) as exc:
|
||||||
|
raise SystemExit(str(exc)) from exc
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import argparse
|
||||||
|
import datetime
|
||||||
|
import ipaddress
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
import secrets
|
||||||
|
import socket
|
||||||
|
import time
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
|
||||||
|
MAX_RESPONSE_BYTES = 2 * 1024 * 1024
|
||||||
|
|
||||||
|
|
||||||
|
class NoRedirectHandler(urllib.request.HTTPRedirectHandler):
|
||||||
|
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Create one local benchmark user and a temporary bearer header file."
|
||||||
|
)
|
||||||
|
parser.add_argument("--base-url", default="http://127.0.0.1:3001")
|
||||||
|
parser.add_argument("--headers-output", required=True)
|
||||||
|
parser.add_argument("--metadata-output", required=True)
|
||||||
|
parser.add_argument("--timeout", type=float, default=10.0)
|
||||||
|
parser.add_argument("--deployment-commit", default="unknown")
|
||||||
|
parser.add_argument("--deployment-dirty", default="unknown")
|
||||||
|
parser.add_argument("--source-commit", default="unknown")
|
||||||
|
parser.add_argument("--backend-image", default="unknown")
|
||||||
|
parser.add_argument("--backend-image-id", default="unknown")
|
||||||
|
parser.add_argument("--backend-container-started-at", default="unknown")
|
||||||
|
parser.add_argument("--requests-per-level", type=int, default=0)
|
||||||
|
parser.add_argument("--repeat-count", type=int, default=0)
|
||||||
|
parser.add_argument("--concurrencies", default="")
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def validate_base_url(raw_url):
|
||||||
|
parsed = urllib.parse.urlsplit(raw_url)
|
||||||
|
if parsed.scheme not in {"http", "https"} or not parsed.hostname:
|
||||||
|
raise ValueError("Base URL must use http or https and include a host.")
|
||||||
|
if parsed.username or parsed.password or parsed.query or parsed.fragment:
|
||||||
|
raise ValueError("Credentials, query strings, and fragments are forbidden.")
|
||||||
|
if parsed.path not in {"", "/"}:
|
||||||
|
raise ValueError("Base URL must not include an API path.")
|
||||||
|
if parsed.hostname == "localhost":
|
||||||
|
addresses = [ipaddress.ip_address("127.0.0.1")]
|
||||||
|
else:
|
||||||
|
addresses = [
|
||||||
|
ipaddress.ip_address(item[4][0])
|
||||||
|
for item in socket.getaddrinfo(
|
||||||
|
parsed.hostname, parsed.port, type=socket.SOCK_STREAM
|
||||||
|
)
|
||||||
|
]
|
||||||
|
if not addresses or any(
|
||||||
|
not (address.is_loopback or address.is_private or address.is_link_local)
|
||||||
|
for address in addresses
|
||||||
|
):
|
||||||
|
raise ValueError("Refusing to create a benchmark session on a non-local host.")
|
||||||
|
return raw_url.rstrip("/")
|
||||||
|
|
||||||
|
|
||||||
|
def request_json(opener, timeout, method, url, body=None):
|
||||||
|
headers = {
|
||||||
|
"Accept": "application/json",
|
||||||
|
"User-Agent": "ai-soulmate-local-business-benchmark/1",
|
||||||
|
}
|
||||||
|
data = None
|
||||||
|
if body is not None:
|
||||||
|
data = json.dumps(body, separators=(",", ":")).encode("utf-8")
|
||||||
|
headers["Content-Type"] = "application/json"
|
||||||
|
request = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||||
|
started = time.perf_counter()
|
||||||
|
try:
|
||||||
|
with opener.open(request, timeout=timeout) as response:
|
||||||
|
raw_body = response.read(MAX_RESPONSE_BYTES + 1)
|
||||||
|
if len(raw_body) > MAX_RESPONSE_BYTES:
|
||||||
|
raise RuntimeError("Benchmark setup response exceeded 2 MiB.")
|
||||||
|
payload = json.loads(raw_body.decode("utf-8"))
|
||||||
|
if not isinstance(payload, dict):
|
||||||
|
raise RuntimeError("Benchmark setup returned a non-object JSON response.")
|
||||||
|
return response.status, payload, round(
|
||||||
|
(time.perf_counter() - started) * 1000, 3
|
||||||
|
)
|
||||||
|
except urllib.error.HTTPError as exc:
|
||||||
|
exc.close()
|
||||||
|
raise RuntimeError(f"{method} {url} returned HTTP {exc.code}.") from exc
|
||||||
|
|
||||||
|
|
||||||
|
def write_private_json(path, payload):
|
||||||
|
output_path = pathlib.Path(path)
|
||||||
|
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
output_path.write_text(
|
||||||
|
json.dumps(payload, ensure_ascii=False, indent=2) + "\n", encoding="utf-8"
|
||||||
|
)
|
||||||
|
os.chmod(output_path, 0o600)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = parse_args()
|
||||||
|
if args.timeout <= 0 or args.timeout > 60:
|
||||||
|
raise SystemExit("--timeout must be between 0 and 60 seconds.")
|
||||||
|
try:
|
||||||
|
base_url = validate_base_url(args.base_url)
|
||||||
|
opener = urllib.request.build_opener(
|
||||||
|
urllib.request.ProxyHandler({}), NoRedirectHandler()
|
||||||
|
)
|
||||||
|
health_status, health, health_latency = request_json(
|
||||||
|
opener, args.timeout, "GET", base_url + "/api/health"
|
||||||
|
)
|
||||||
|
mode = str(health.get("tripo_mode") or "").strip().lower()
|
||||||
|
profile = str(health.get("tripo_mock_profile") or "").strip()
|
||||||
|
if (
|
||||||
|
health_status != 200
|
||||||
|
or mode != "mock"
|
||||||
|
or not profile
|
||||||
|
or profile == "not-selected"
|
||||||
|
):
|
||||||
|
raise RuntimeError("Backend did not confirm an explicit Tripo mock profile.")
|
||||||
|
|
||||||
|
username = f"bench_business_{int(time.time())}_{secrets.token_hex(4)}"
|
||||||
|
password = "Bm!9" + secrets.token_urlsafe(18)
|
||||||
|
register_status, registration, register_latency = request_json(
|
||||||
|
opener,
|
||||||
|
args.timeout,
|
||||||
|
"POST",
|
||||||
|
base_url + "/api/auth/register",
|
||||||
|
{
|
||||||
|
"username": username,
|
||||||
|
"password": password,
|
||||||
|
"password_confirm": password,
|
||||||
|
"register_via": "account",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
token = registration.get("access_token")
|
||||||
|
user = registration.get("user")
|
||||||
|
if register_status != 200 or not isinstance(token, str) or not token:
|
||||||
|
raise RuntimeError("Registration did not return a bearer token.")
|
||||||
|
if not isinstance(user, dict) or not user.get("id"):
|
||||||
|
raise RuntimeError("Registration did not return a user ID.")
|
||||||
|
|
||||||
|
write_private_json(
|
||||||
|
args.headers_output,
|
||||||
|
{
|
||||||
|
"Accept": "application/json",
|
||||||
|
"Authorization": f"Bearer {token}",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"User-Agent": "ai-soulmate-local-business-benchmark/1",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
write_private_json(
|
||||||
|
args.metadata_output,
|
||||||
|
{
|
||||||
|
"schema_version": 1,
|
||||||
|
"created_at_utc": datetime.datetime.now(
|
||||||
|
datetime.timezone.utc
|
||||||
|
).isoformat(),
|
||||||
|
"base_url": base_url,
|
||||||
|
"tripo_mode": mode,
|
||||||
|
"tripo_mock_profile": profile,
|
||||||
|
"health_latency_ms": health_latency,
|
||||||
|
"registration_latency_ms": register_latency,
|
||||||
|
"user_id": str(user["id"]),
|
||||||
|
"deployment_commit": args.deployment_commit,
|
||||||
|
"deployment_dirty": args.deployment_dirty.lower() == "true",
|
||||||
|
"source_commit": args.source_commit,
|
||||||
|
"backend_image": args.backend_image,
|
||||||
|
"backend_image_id": args.backend_image_id,
|
||||||
|
"backend_container_started_at": args.backend_container_started_at,
|
||||||
|
"requests_per_level": args.requests_per_level,
|
||||||
|
"repeat_count": args.repeat_count,
|
||||||
|
"concurrencies": [
|
||||||
|
int(value)
|
||||||
|
for value in args.concurrencies.split(",")
|
||||||
|
if value.strip()
|
||||||
|
],
|
||||||
|
"test_account_persisted": True,
|
||||||
|
"plaintext_credentials_persisted": False,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
except (OSError, ValueError, RuntimeError, json.JSONDecodeError) as exc:
|
||||||
|
raise SystemExit(str(exc)) from exc
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import argparse
|
||||||
|
import concurrent.futures
|
||||||
|
import datetime
|
||||||
|
import ipaddress
|
||||||
|
import json
|
||||||
|
import math
|
||||||
|
import pathlib
|
||||||
|
import socket
|
||||||
|
import statistics
|
||||||
|
import time
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
|
||||||
|
class NoRedirectHandler(urllib.request.HTTPRedirectHandler):
|
||||||
|
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser(description="Run a bounded HTTP benchmark against a local service.")
|
||||||
|
parser.add_argument("--url", required=True)
|
||||||
|
parser.add_argument("--method", default="GET", choices=("GET", "HEAD", "POST"))
|
||||||
|
parser.add_argument("--requests", type=int, default=100)
|
||||||
|
parser.add_argument("--concurrency", type=int, default=1)
|
||||||
|
parser.add_argument("--timeout", type=float, default=10.0)
|
||||||
|
parser.add_argument("--warmup", type=int, default=0)
|
||||||
|
parser.add_argument("--expected-status", type=int, action="append")
|
||||||
|
parser.add_argument("--body-file")
|
||||||
|
parser.add_argument("--headers-file")
|
||||||
|
parser.add_argument("--output")
|
||||||
|
parser.add_argument("--allow-failures", action="store_true")
|
||||||
|
parser.add_argument("--max-response-bytes", type=int, default=64 * 1024)
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def validate_target(raw_url):
|
||||||
|
parsed = urllib.parse.urlsplit(raw_url)
|
||||||
|
if parsed.scheme not in {"http", "https"} or not parsed.hostname:
|
||||||
|
raise ValueError("URL must use http or https and include a host.")
|
||||||
|
if parsed.username or parsed.password or parsed.query or parsed.fragment:
|
||||||
|
raise ValueError("Credentials, query strings, and fragments are not allowed in benchmark URLs.")
|
||||||
|
if parsed.hostname == "localhost":
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
addresses = {item[4][0] for item in socket.getaddrinfo(parsed.hostname, parsed.port)}
|
||||||
|
except socket.gaierror as exc:
|
||||||
|
raise ValueError(f"Unable to resolve benchmark host: {parsed.hostname}") from exc
|
||||||
|
for address in addresses:
|
||||||
|
candidate = ipaddress.ip_address(address)
|
||||||
|
if not (candidate.is_loopback or candidate.is_private or candidate.is_link_local):
|
||||||
|
raise ValueError(f"Refusing to benchmark non-local address: {address}")
|
||||||
|
|
||||||
|
|
||||||
|
def percentile(values, percentage):
|
||||||
|
if not values:
|
||||||
|
return None
|
||||||
|
ordered = sorted(values)
|
||||||
|
rank = max(1, math.ceil((percentage / 100) * len(ordered)))
|
||||||
|
return round(ordered[rank - 1], 3)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = parse_args()
|
||||||
|
if not 1 <= args.requests <= 1_000_000:
|
||||||
|
raise SystemExit("--requests must be between 1 and 1000000")
|
||||||
|
if not 1 <= args.concurrency <= 256:
|
||||||
|
raise SystemExit("--concurrency must be between 1 and 256")
|
||||||
|
if args.warmup < 0 or args.timeout <= 0:
|
||||||
|
raise SystemExit("--warmup must be non-negative and --timeout must be positive")
|
||||||
|
if not 1 <= args.max_response_bytes <= 64 * 1024 * 1024:
|
||||||
|
raise SystemExit("--max-response-bytes must be between 1 byte and 64 MiB")
|
||||||
|
|
||||||
|
validate_target(args.url)
|
||||||
|
body = pathlib.Path(args.body_file).read_bytes() if args.body_file else None
|
||||||
|
headers = {}
|
||||||
|
if args.headers_file:
|
||||||
|
headers = json.loads(pathlib.Path(args.headers_file).read_text(encoding="utf-8"))
|
||||||
|
if not isinstance(headers, dict) or not all(isinstance(key, str) and isinstance(value, str) for key, value in headers.items()):
|
||||||
|
raise SystemExit("--headers-file must contain a JSON object of string values")
|
||||||
|
|
||||||
|
expected_statuses = set(args.expected_status or range(200, 400))
|
||||||
|
opener = urllib.request.build_opener(
|
||||||
|
urllib.request.ProxyHandler({}),
|
||||||
|
NoRedirectHandler(),
|
||||||
|
)
|
||||||
|
|
||||||
|
def application_code(response_body):
|
||||||
|
if not response_body:
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
parsed_body = json.loads(response_body)
|
||||||
|
except (UnicodeDecodeError, json.JSONDecodeError):
|
||||||
|
return None
|
||||||
|
if isinstance(parsed_body, dict) and parsed_body.get("code") is not None:
|
||||||
|
return str(parsed_body["code"])
|
||||||
|
return None
|
||||||
|
|
||||||
|
def request_once():
|
||||||
|
request = urllib.request.Request(args.url, data=body, headers=headers, method=args.method)
|
||||||
|
started = time.perf_counter()
|
||||||
|
try:
|
||||||
|
with opener.open(request, timeout=args.timeout) as response:
|
||||||
|
response_body = response.read(args.max_response_bytes + 1)
|
||||||
|
if len(response_body) > args.max_response_bytes:
|
||||||
|
return response.status, (time.perf_counter() - started) * 1000, "ResponseTooLarge", None, response.headers.get("Retry-After")
|
||||||
|
retry_after = response.headers.get("Retry-After")
|
||||||
|
return response.status, (time.perf_counter() - started) * 1000, None, application_code(response_body), retry_after
|
||||||
|
except urllib.error.HTTPError as exc:
|
||||||
|
response_body = exc.read(args.max_response_bytes + 1)
|
||||||
|
if len(response_body) > args.max_response_bytes:
|
||||||
|
response_body = b""
|
||||||
|
error_name = "ResponseTooLarge"
|
||||||
|
else:
|
||||||
|
error_name = None
|
||||||
|
retry_after = exc.headers.get("Retry-After")
|
||||||
|
return exc.code, (time.perf_counter() - started) * 1000, error_name, application_code(response_body), retry_after
|
||||||
|
except Exception as exc:
|
||||||
|
return None, (time.perf_counter() - started) * 1000, type(exc).__name__, None, None
|
||||||
|
|
||||||
|
for _ in range(args.warmup):
|
||||||
|
request_once()
|
||||||
|
|
||||||
|
started_at = datetime.datetime.now(datetime.timezone.utc)
|
||||||
|
started = time.perf_counter()
|
||||||
|
with concurrent.futures.ThreadPoolExecutor(max_workers=args.concurrency) as executor:
|
||||||
|
results = list(executor.map(lambda _: request_once(), range(args.requests)))
|
||||||
|
duration_seconds = time.perf_counter() - started
|
||||||
|
|
||||||
|
latencies = [latency for _, latency, _, _, _ in results]
|
||||||
|
statuses = {}
|
||||||
|
errors = {}
|
||||||
|
response_codes = {}
|
||||||
|
retry_after_values = {}
|
||||||
|
successful = 0
|
||||||
|
for status, _, error, response_code, retry_after in results:
|
||||||
|
if status is not None:
|
||||||
|
statuses[str(status)] = statuses.get(str(status), 0) + 1
|
||||||
|
if status in expected_statuses and error is None:
|
||||||
|
successful += 1
|
||||||
|
if error:
|
||||||
|
errors[error] = errors.get(error, 0) + 1
|
||||||
|
if retry_after:
|
||||||
|
retry_after_values[retry_after] = retry_after_values.get(retry_after, 0) + 1
|
||||||
|
if response_code is not None:
|
||||||
|
response_codes[response_code] = response_codes.get(response_code, 0) + 1
|
||||||
|
|
||||||
|
report = {
|
||||||
|
"schema_version": 1,
|
||||||
|
"started_at_utc": started_at.isoformat(),
|
||||||
|
"target": args.url,
|
||||||
|
"method": args.method,
|
||||||
|
"requests": args.requests,
|
||||||
|
"concurrency": args.concurrency,
|
||||||
|
"timeout_seconds": args.timeout,
|
||||||
|
"warmup_requests": args.warmup,
|
||||||
|
"body_bytes": len(body or b""),
|
||||||
|
"custom_headers_supplied": bool(headers),
|
||||||
|
"max_response_bytes": args.max_response_bytes,
|
||||||
|
"duration_seconds": round(duration_seconds, 6),
|
||||||
|
"requests_per_second": round(args.requests / duration_seconds, 3),
|
||||||
|
"successful_requests": successful,
|
||||||
|
"failed_requests": args.requests - successful,
|
||||||
|
"status_counts": statuses,
|
||||||
|
"transport_error_counts": errors,
|
||||||
|
"application_code_counts": response_codes,
|
||||||
|
"retry_after_counts": retry_after_values,
|
||||||
|
"latency_ms": {
|
||||||
|
"min": round(min(latencies), 3),
|
||||||
|
"mean": round(statistics.fmean(latencies), 3),
|
||||||
|
"p50": percentile(latencies, 50),
|
||||||
|
"p95": percentile(latencies, 95),
|
||||||
|
"p99": percentile(latencies, 99),
|
||||||
|
"max": round(max(latencies), 3),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
rendered = json.dumps(report, ensure_ascii=False, indent=2)
|
||||||
|
print(rendered)
|
||||||
|
if args.output:
|
||||||
|
output_path = pathlib.Path(args.output)
|
||||||
|
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
output_path.write_text(rendered + "\n", encoding="utf-8")
|
||||||
|
|
||||||
|
if not args.allow_failures and successful != args.requests:
|
||||||
|
raise SystemExit(2)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -13,11 +13,30 @@ hardware_profile:
|
|||||||
|
|
||||||
software:
|
software:
|
||||||
deployment_commit: ""
|
deployment_commit: ""
|
||||||
server_commit: "24769465d3ac2cb840c5266c8c0def2aacb641aa"
|
server_commit: ""
|
||||||
admin_commit: "40bd686128010fbbc6c33f6156a7a3cda5336b3a"
|
admin_commit: ""
|
||||||
client_commit: null
|
client_commit: null
|
||||||
image_digests: {}
|
image_digests: {}
|
||||||
database_migration: ""
|
database_migration: ""
|
||||||
|
tripo_mode: "mock"
|
||||||
|
external_paid_calls_allowed: false
|
||||||
|
|
||||||
|
tripo_mock:
|
||||||
|
profile: "replace-with-compose-env-value"
|
||||||
|
api_generation: "v2-poc"
|
||||||
|
account_usage_tier: "unknown"
|
||||||
|
source_url: "https://developers.tripo3d.com/zh/docs/rate-limits"
|
||||||
|
source_checked_at: "2026-08-12"
|
||||||
|
account_concurrency:
|
||||||
|
h_series_3d: 10
|
||||||
|
p_series_3d: 5
|
||||||
|
image_generation: 1
|
||||||
|
animation: 10
|
||||||
|
model_postprocess: 5
|
||||||
|
mesh_operations: 10
|
||||||
|
queue_delay_seconds: 2
|
||||||
|
run_delay_seconds: 8
|
||||||
|
local_application_queue_enabled: false
|
||||||
|
|
||||||
workload:
|
workload:
|
||||||
scenario_id: ""
|
scenario_id: ""
|
||||||
@@ -27,12 +46,13 @@ workload:
|
|||||||
request_mix: {}
|
request_mix: {}
|
||||||
object_sizes: []
|
object_sizes: []
|
||||||
includes_tripo: false
|
includes_tripo: false
|
||||||
|
uses_tripo_mock: true
|
||||||
|
|
||||||
configuration:
|
configuration:
|
||||||
application_profile: ""
|
application_profile: ""
|
||||||
container_limits: {}
|
container_limits: {}
|
||||||
database_pool_size: null
|
database_pool_size: null
|
||||||
worker_count: null
|
worker_count: 1
|
||||||
changed_parameters: []
|
changed_parameters: []
|
||||||
|
|
||||||
result:
|
result:
|
||||||
@@ -49,4 +69,3 @@ result:
|
|||||||
artifacts:
|
artifacts:
|
||||||
raw_directory: ""
|
raw_directory: ""
|
||||||
report_path: ""
|
report_path: ""
|
||||||
|
|
||||||
@@ -0,0 +1,345 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import argparse
|
||||||
|
import datetime
|
||||||
|
import ipaddress
|
||||||
|
import json
|
||||||
|
import pathlib
|
||||||
|
import secrets
|
||||||
|
import socket
|
||||||
|
import time
|
||||||
|
import urllib.error
|
||||||
|
import urllib.parse
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
|
||||||
|
MAX_RESPONSE_BYTES = 2 * 1024 * 1024
|
||||||
|
TERMINAL_STATUSES = {"COMPLETED", "FAILED", "CANCELLED"}
|
||||||
|
|
||||||
|
|
||||||
|
class NoRedirectHandler(urllib.request.HTTPRedirectHandler):
|
||||||
|
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class SmokeFailure(RuntimeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Run one zero-credit user registration and text-to-3D smoke flow."
|
||||||
|
)
|
||||||
|
parser.add_argument("--base-url", default="http://127.0.0.1:3001")
|
||||||
|
parser.add_argument("--timeout", type=float, default=10.0)
|
||||||
|
parser.add_argument("--poll-interval", type=float, default=1.0)
|
||||||
|
parser.add_argument("--deadline", type=float, default=90.0)
|
||||||
|
parser.add_argument("--output")
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def private_addresses(hostname, port):
|
||||||
|
if hostname == "localhost":
|
||||||
|
return [ipaddress.ip_address("127.0.0.1")]
|
||||||
|
try:
|
||||||
|
return [
|
||||||
|
ipaddress.ip_address(item[4][0])
|
||||||
|
for item in socket.getaddrinfo(hostname, port, type=socket.SOCK_STREAM)
|
||||||
|
]
|
||||||
|
except (socket.gaierror, ValueError) as exc:
|
||||||
|
raise SmokeFailure(f"Unable to resolve local target host: {hostname}") from exc
|
||||||
|
|
||||||
|
|
||||||
|
def is_private_address(address):
|
||||||
|
return address.is_loopback or address.is_private or address.is_link_local
|
||||||
|
|
||||||
|
|
||||||
|
def validate_base_url(raw_url):
|
||||||
|
parsed = urllib.parse.urlsplit(raw_url)
|
||||||
|
if parsed.scheme not in {"http", "https"} or not parsed.hostname:
|
||||||
|
raise SmokeFailure("Base URL must use http or https and include a host.")
|
||||||
|
if parsed.username or parsed.password or parsed.query or parsed.fragment:
|
||||||
|
raise SmokeFailure("Credentials, query strings, and fragments are forbidden in the base URL.")
|
||||||
|
if parsed.path not in {"", "/"}:
|
||||||
|
raise SmokeFailure("Base URL must not include an API path.")
|
||||||
|
addresses = private_addresses(parsed.hostname, parsed.port)
|
||||||
|
if not addresses or any(not is_private_address(address) for address in addresses):
|
||||||
|
raise SmokeFailure("Refusing to run the smoke flow against a non-local address.")
|
||||||
|
return raw_url.rstrip("/")
|
||||||
|
|
||||||
|
|
||||||
|
def read_json_response(response):
|
||||||
|
raw_body = response.read(MAX_RESPONSE_BYTES + 1)
|
||||||
|
if len(raw_body) > MAX_RESPONSE_BYTES:
|
||||||
|
raise SmokeFailure("Server response exceeded the 2 MiB safety limit.")
|
||||||
|
try:
|
||||||
|
payload = json.loads(raw_body.decode("utf-8"))
|
||||||
|
except (UnicodeDecodeError, json.JSONDecodeError) as exc:
|
||||||
|
raise SmokeFailure("Server returned a non-JSON response.") from exc
|
||||||
|
if not isinstance(payload, dict):
|
||||||
|
raise SmokeFailure("Server returned a non-object JSON response.")
|
||||||
|
return payload
|
||||||
|
|
||||||
|
|
||||||
|
def storage_location(raw_url):
|
||||||
|
value = str(raw_url or "").strip()
|
||||||
|
result = {"present": bool(value), "scheme": None, "host": None, "local": False}
|
||||||
|
if not value:
|
||||||
|
return result
|
||||||
|
if value.startswith("oss://") or value.startswith("models/"):
|
||||||
|
result.update({"scheme": "oss", "host": "internal", "local": True})
|
||||||
|
return result
|
||||||
|
parsed = urllib.parse.urlsplit(value)
|
||||||
|
result["scheme"] = parsed.scheme or "relative"
|
||||||
|
result["host"] = parsed.hostname
|
||||||
|
if parsed.scheme not in {"http", "https"} or not parsed.hostname:
|
||||||
|
return result
|
||||||
|
if "tripo" in parsed.hostname.lower():
|
||||||
|
return result
|
||||||
|
try:
|
||||||
|
addresses = private_addresses(parsed.hostname, parsed.port)
|
||||||
|
except SmokeFailure:
|
||||||
|
return result
|
||||||
|
result["local"] = bool(addresses) and all(is_private_address(address) for address in addresses)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
class LocalApi:
|
||||||
|
def __init__(self, base_url, timeout):
|
||||||
|
self.base_url = base_url
|
||||||
|
self.timeout = timeout
|
||||||
|
self.opener = urllib.request.build_opener(
|
||||||
|
urllib.request.ProxyHandler({}), NoRedirectHandler()
|
||||||
|
)
|
||||||
|
|
||||||
|
def request(self, method, path, body=None, bearer=None):
|
||||||
|
if not path.startswith("/"):
|
||||||
|
raise SmokeFailure("Internal request path must start with a slash.")
|
||||||
|
headers = {
|
||||||
|
"Accept": "application/json",
|
||||||
|
"User-Agent": "ai-soulmate-zero-credit-smoke/1",
|
||||||
|
}
|
||||||
|
data = None
|
||||||
|
if body is not None:
|
||||||
|
data = json.dumps(body, separators=(",", ":")).encode("utf-8")
|
||||||
|
headers["Content-Type"] = "application/json"
|
||||||
|
if bearer:
|
||||||
|
headers["Authorization"] = f"Bearer {bearer}"
|
||||||
|
request = urllib.request.Request(
|
||||||
|
self.base_url + path, data=data, headers=headers, method=method
|
||||||
|
)
|
||||||
|
started = time.perf_counter()
|
||||||
|
try:
|
||||||
|
with self.opener.open(request, timeout=self.timeout) as response:
|
||||||
|
if not 200 <= response.status < 300:
|
||||||
|
raise SmokeFailure(f"{method} {path} returned HTTP {response.status}.")
|
||||||
|
return response.status, read_json_response(response), round(
|
||||||
|
(time.perf_counter() - started) * 1000, 3
|
||||||
|
)
|
||||||
|
except urllib.error.HTTPError as exc:
|
||||||
|
exc.close()
|
||||||
|
raise SmokeFailure(f"{method} {path} returned HTTP {exc.code}.") from exc
|
||||||
|
except (urllib.error.URLError, TimeoutError, OSError) as exc:
|
||||||
|
raise SmokeFailure(f"{method} {path} failed at the transport layer.") from exc
|
||||||
|
|
||||||
|
|
||||||
|
def numeric_credits(payload):
|
||||||
|
value = payload.get("credits")
|
||||||
|
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
||||||
|
raise SmokeFailure("User profile did not contain numeric credits.")
|
||||||
|
return int(value)
|
||||||
|
|
||||||
|
|
||||||
|
def write_report(report, output):
|
||||||
|
rendered = json.dumps(report, ensure_ascii=False, indent=2)
|
||||||
|
print(rendered)
|
||||||
|
if output:
|
||||||
|
output_path = pathlib.Path(output)
|
||||||
|
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
output_path.write_text(rendered + "\n", encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = parse_args()
|
||||||
|
if args.timeout <= 0 or args.poll_interval <= 0 or args.deadline <= 0:
|
||||||
|
raise SystemExit("Timeout, poll interval, and deadline must be positive.")
|
||||||
|
if args.timeout > 60 or args.deadline > 600:
|
||||||
|
raise SystemExit("Timeout must be at most 60 seconds and deadline at most 600 seconds.")
|
||||||
|
|
||||||
|
started_at = datetime.datetime.now(datetime.timezone.utc)
|
||||||
|
report = {
|
||||||
|
"schema_version": 1,
|
||||||
|
"started_at_utc": started_at.isoformat(),
|
||||||
|
"base_url": None,
|
||||||
|
"valid": False,
|
||||||
|
"zero_credit_verified": False,
|
||||||
|
"local_storage_verified": False,
|
||||||
|
"steps": {},
|
||||||
|
}
|
||||||
|
current_step = "validate_target"
|
||||||
|
try:
|
||||||
|
base_url = validate_base_url(args.base_url)
|
||||||
|
report["base_url"] = base_url
|
||||||
|
api = LocalApi(base_url, args.timeout)
|
||||||
|
|
||||||
|
current_step = "verify_mock_mode"
|
||||||
|
health_status, health, health_ms = api.request("GET", "/api/health")
|
||||||
|
tripo_mode = str(health.get("tripo_mode") or "").strip().lower()
|
||||||
|
mock_profile = str(health.get("tripo_mock_profile") or "").strip()
|
||||||
|
report["steps"]["verify_mock_mode"] = {
|
||||||
|
"http_status": health_status,
|
||||||
|
"latency_ms": health_ms,
|
||||||
|
"service_status": health.get("status"),
|
||||||
|
"tripo_mode": tripo_mode,
|
||||||
|
"tripo_mock_profile": mock_profile,
|
||||||
|
}
|
||||||
|
if tripo_mode != "mock" or not mock_profile or mock_profile == "not-selected":
|
||||||
|
raise SmokeFailure("Backend health did not confirm an explicit Tripo mock profile.")
|
||||||
|
|
||||||
|
username = f"bench_{int(time.time())}_{secrets.token_hex(4)}"
|
||||||
|
password = "Bm!9" + secrets.token_urlsafe(18)
|
||||||
|
current_step = "register"
|
||||||
|
register_status, registration, register_ms = api.request(
|
||||||
|
"POST",
|
||||||
|
"/api/auth/register",
|
||||||
|
{
|
||||||
|
"username": username,
|
||||||
|
"password": password,
|
||||||
|
"password_confirm": password,
|
||||||
|
"register_via": "account",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
token = registration.get("access_token")
|
||||||
|
user = registration.get("user")
|
||||||
|
if not isinstance(token, str) or not token or not isinstance(user, dict):
|
||||||
|
raise SmokeFailure("Registration response omitted the access token or user object.")
|
||||||
|
user_id = str(user.get("id") or "")
|
||||||
|
if not user_id:
|
||||||
|
raise SmokeFailure("Registration response omitted the user ID.")
|
||||||
|
report["steps"]["register"] = {
|
||||||
|
"http_status": register_status,
|
||||||
|
"latency_ms": register_ms,
|
||||||
|
"user_id": user_id,
|
||||||
|
}
|
||||||
|
|
||||||
|
current_step = "profile_before"
|
||||||
|
profile_status, profile_before, profile_before_ms = api.request(
|
||||||
|
"GET", "/api/user/profile", bearer=token
|
||||||
|
)
|
||||||
|
credits_before = numeric_credits(profile_before)
|
||||||
|
report["steps"]["profile_before"] = {
|
||||||
|
"http_status": profile_status,
|
||||||
|
"latency_ms": profile_before_ms,
|
||||||
|
"credits": credits_before,
|
||||||
|
"assets_count": profile_before.get("assets_count"),
|
||||||
|
}
|
||||||
|
|
||||||
|
current_step = "submit"
|
||||||
|
submit_status, submitted, submit_ms = api.request(
|
||||||
|
"POST",
|
||||||
|
"/api/studio/submit-text-3d",
|
||||||
|
{
|
||||||
|
"prompt": "A small geometric calibration object for local benchmark validation",
|
||||||
|
"with_texture": True,
|
||||||
|
"model_version": "v3.1-20260211",
|
||||||
|
"render_image": True,
|
||||||
|
"result_format": "GLB",
|
||||||
|
},
|
||||||
|
bearer=token,
|
||||||
|
)
|
||||||
|
job_id = str(submitted.get("job_id") or "")
|
||||||
|
if not job_id:
|
||||||
|
raise SmokeFailure("Submission response omitted the job ID.")
|
||||||
|
submit_credits = submitted.get("credits_used")
|
||||||
|
report["steps"]["submit"] = {
|
||||||
|
"http_status": submit_status,
|
||||||
|
"latency_ms": submit_ms,
|
||||||
|
"job_id": job_id,
|
||||||
|
"credits_used": submit_credits,
|
||||||
|
}
|
||||||
|
|
||||||
|
current_step = "poll_job"
|
||||||
|
polling_started = time.monotonic()
|
||||||
|
observations = []
|
||||||
|
poll_count = 0
|
||||||
|
terminal = None
|
||||||
|
last_poll_ms = None
|
||||||
|
while time.monotonic() - polling_started < args.deadline:
|
||||||
|
_, polled, last_poll_ms = api.request(
|
||||||
|
"GET", f"/api/studio/job/{urllib.parse.quote(job_id, safe='')}", bearer=token
|
||||||
|
)
|
||||||
|
poll_count += 1
|
||||||
|
status_name = str(polled.get("status") or "UNKNOWN").upper()
|
||||||
|
if not observations or observations[-1]["status"] != status_name:
|
||||||
|
observations.append(
|
||||||
|
{
|
||||||
|
"status": status_name,
|
||||||
|
"elapsed_seconds": round(time.monotonic() - polling_started, 3),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if status_name in TERMINAL_STATUSES:
|
||||||
|
terminal = polled
|
||||||
|
break
|
||||||
|
time.sleep(args.poll_interval)
|
||||||
|
if terminal is None:
|
||||||
|
raise SmokeFailure("Job did not reach a terminal state before the deadline.")
|
||||||
|
if str(terminal.get("status") or "").upper() != "COMPLETED":
|
||||||
|
raise SmokeFailure("Job reached a non-success terminal state.")
|
||||||
|
|
||||||
|
model_storage = storage_location(
|
||||||
|
terminal.get("selected_model_url") or terminal.get("model_url")
|
||||||
|
)
|
||||||
|
preview_storage = storage_location(terminal.get("preview_url"))
|
||||||
|
terminal_credits = terminal.get("credits_used")
|
||||||
|
report["steps"]["poll_job"] = {
|
||||||
|
"poll_count": poll_count,
|
||||||
|
"duration_seconds": round(time.monotonic() - polling_started, 3),
|
||||||
|
"last_poll_latency_ms": last_poll_ms,
|
||||||
|
"status_observations": observations,
|
||||||
|
"terminal_status": terminal.get("status"),
|
||||||
|
"credits_used": terminal_credits,
|
||||||
|
"asset_id": terminal.get("asset_id"),
|
||||||
|
"model_storage": model_storage,
|
||||||
|
"preview_storage": preview_storage,
|
||||||
|
}
|
||||||
|
|
||||||
|
current_step = "profile_after"
|
||||||
|
profile_after_status, profile_after, profile_after_ms = api.request(
|
||||||
|
"GET", "/api/user/profile", bearer=token
|
||||||
|
)
|
||||||
|
credits_after = numeric_credits(profile_after)
|
||||||
|
report["steps"]["profile_after"] = {
|
||||||
|
"http_status": profile_after_status,
|
||||||
|
"latency_ms": profile_after_ms,
|
||||||
|
"credits": credits_after,
|
||||||
|
"credits_delta": credits_after - credits_before,
|
||||||
|
"assets_count": profile_after.get("assets_count"),
|
||||||
|
}
|
||||||
|
|
||||||
|
report["zero_credit_verified"] = (
|
||||||
|
submit_credits == 0 and terminal_credits == 0 and credits_after == credits_before
|
||||||
|
)
|
||||||
|
report["local_storage_verified"] = (
|
||||||
|
model_storage["present"]
|
||||||
|
and model_storage["local"]
|
||||||
|
and preview_storage["present"]
|
||||||
|
and preview_storage["local"]
|
||||||
|
)
|
||||||
|
report["valid"] = report["zero_credit_verified"] and report["local_storage_verified"]
|
||||||
|
if not report["zero_credit_verified"]:
|
||||||
|
raise SmokeFailure("The business flow did not preserve the user's credit balance.")
|
||||||
|
if not report["local_storage_verified"]:
|
||||||
|
raise SmokeFailure("The completed job did not return local model and preview storage.")
|
||||||
|
except SmokeFailure as exc:
|
||||||
|
report["failed_step"] = current_step
|
||||||
|
report["error"] = str(exc)
|
||||||
|
|
||||||
|
report["duration_seconds"] = round(
|
||||||
|
(datetime.datetime.now(datetime.timezone.utc) - started_at).total_seconds(), 3
|
||||||
|
)
|
||||||
|
write_report(report, args.output)
|
||||||
|
if not report["valid"]:
|
||||||
|
raise SystemExit(2)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import argparse
|
||||||
|
import collections
|
||||||
|
import json
|
||||||
|
import pathlib
|
||||||
|
import re
|
||||||
|
import statistics
|
||||||
|
|
||||||
|
|
||||||
|
FILE_PATTERN = re.compile(r"^(?P<scenario>.+)-c(?P<concurrency>\d+)-r(?P<repeat>\d+)\.json$")
|
||||||
|
|
||||||
|
|
||||||
|
def median(values):
|
||||||
|
return round(statistics.median(values), 3) if values else None
|
||||||
|
|
||||||
|
|
||||||
|
def merge_counts(reports, key):
|
||||||
|
merged = collections.Counter()
|
||||||
|
for report in reports:
|
||||||
|
merged.update(report.get(key) or {})
|
||||||
|
return dict(sorted(merged.items()))
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Aggregate repeated authenticated business benchmark results."
|
||||||
|
)
|
||||||
|
parser.add_argument("directory")
|
||||||
|
parser.add_argument("--markdown-output", required=True)
|
||||||
|
parser.add_argument("--json-output", required=True)
|
||||||
|
parser.add_argument("--require-concurrency-one-success", action="store_true")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
directory = pathlib.Path(args.directory)
|
||||||
|
grouped = collections.defaultdict(list)
|
||||||
|
for path in sorted(directory.glob("*-c*-r*.json")):
|
||||||
|
match = FILE_PATTERN.match(path.name)
|
||||||
|
if not match:
|
||||||
|
continue
|
||||||
|
payload = json.loads(path.read_text(encoding="utf-8"))
|
||||||
|
if not isinstance(payload.get("concurrency"), int):
|
||||||
|
continue
|
||||||
|
grouped[(match.group("scenario"), payload["concurrency"])].append(payload)
|
||||||
|
if not grouped:
|
||||||
|
raise SystemExit(f"No business benchmark result files found in: {directory}")
|
||||||
|
|
||||||
|
rows = []
|
||||||
|
baseline_valid = True
|
||||||
|
for (scenario, concurrency), reports in sorted(grouped.items()):
|
||||||
|
requests = sum(int(report.get("requests") or 0) for report in reports)
|
||||||
|
successes = sum(int(report.get("successful_requests") or 0) for report in reports)
|
||||||
|
failures = sum(int(report.get("failed_requests") or 0) for report in reports)
|
||||||
|
success_percent = round(100 * successes / requests, 3) if requests else 0
|
||||||
|
rps_values = [float(report["requests_per_second"]) for report in reports]
|
||||||
|
p95_values = [float(report["latency_ms"]["p95"]) for report in reports]
|
||||||
|
p99_values = [float(report["latency_ms"]["p99"]) for report in reports]
|
||||||
|
duration_seconds = round(
|
||||||
|
sum(float(report.get("duration_seconds") or 0) for report in reports), 3
|
||||||
|
)
|
||||||
|
row = {
|
||||||
|
"scenario": scenario,
|
||||||
|
"concurrency": concurrency,
|
||||||
|
"repeats": len(reports),
|
||||||
|
"requests": requests,
|
||||||
|
"successful_requests": successes,
|
||||||
|
"failed_requests": failures,
|
||||||
|
"success_percent": success_percent,
|
||||||
|
"duration_seconds_total": duration_seconds,
|
||||||
|
"rps_median": median(rps_values),
|
||||||
|
"rps_min": round(min(rps_values), 3),
|
||||||
|
"rps_max": round(max(rps_values), 3),
|
||||||
|
"run_p95_median_ms": median(p95_values),
|
||||||
|
"run_p99_worst_ms": round(max(p99_values), 3),
|
||||||
|
"status_counts": merge_counts(reports, "status_counts"),
|
||||||
|
"transport_error_counts": merge_counts(
|
||||||
|
reports, "transport_error_counts"
|
||||||
|
),
|
||||||
|
}
|
||||||
|
rows.append(row)
|
||||||
|
if concurrency == 1 and failures:
|
||||||
|
baseline_valid = False
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
"schema_version": 1,
|
||||||
|
"baseline_concurrency_one_valid": baseline_valid,
|
||||||
|
"groups": rows,
|
||||||
|
}
|
||||||
|
json_path = pathlib.Path(args.json_output)
|
||||||
|
json_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
json_path.write_text(
|
||||||
|
json.dumps(payload, ensure_ascii=False, indent=2) + "\n", encoding="utf-8"
|
||||||
|
)
|
||||||
|
|
||||||
|
lines = [
|
||||||
|
"| 场景 | 并发 | 重复 | 请求 | 成功率 | RPS 中位数(范围) | 每轮 P95 中位数 ms | 最差一轮 P99 ms | 状态码 | 传输错误 |",
|
||||||
|
"| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | --- | --- |",
|
||||||
|
]
|
||||||
|
for row in rows:
|
||||||
|
status_counts = json.dumps(row["status_counts"], ensure_ascii=False)
|
||||||
|
transport_error_counts = json.dumps(
|
||||||
|
row["transport_error_counts"], ensure_ascii=False
|
||||||
|
)
|
||||||
|
lines.append(
|
||||||
|
"| {scenario} | {concurrency} | {repeats} | {requests} | {success_percent:.3f}% | "
|
||||||
|
"{rps_median} ({rps_min}-{rps_max}) | {run_p95_median_ms} | "
|
||||||
|
"{run_p99_worst_ms} | `{status_counts}` | `{transport_error_counts}` |".format(
|
||||||
|
scenario=row["scenario"],
|
||||||
|
concurrency=row["concurrency"],
|
||||||
|
repeats=row["repeats"],
|
||||||
|
requests=row["requests"],
|
||||||
|
success_percent=row["success_percent"],
|
||||||
|
rps_median=row["rps_median"],
|
||||||
|
rps_min=row["rps_min"],
|
||||||
|
rps_max=row["rps_max"],
|
||||||
|
run_p95_median_ms=row["run_p95_median_ms"],
|
||||||
|
run_p99_worst_ms=row["run_p99_worst_ms"],
|
||||||
|
status_counts=status_counts,
|
||||||
|
transport_error_counts=transport_error_counts,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
markdown_path = pathlib.Path(args.markdown_output)
|
||||||
|
markdown_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
markdown_path.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
||||||
|
|
||||||
|
if args.require_concurrency_one_success and not baseline_valid:
|
||||||
|
raise SystemExit("Concurrency-one correctness baseline contained failures.")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description="Summarize HTTP benchmark JSON files as Markdown.")
|
||||||
|
parser.add_argument("directory")
|
||||||
|
parser.add_argument("--output")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
directory = pathlib.Path(args.directory)
|
||||||
|
rows = []
|
||||||
|
for path in sorted(directory.glob("*.json")):
|
||||||
|
payload = json.loads(path.read_text(encoding="utf-8"))
|
||||||
|
if (
|
||||||
|
payload.get("schema_version") != 1
|
||||||
|
or not isinstance(payload.get("concurrency"), int)
|
||||||
|
or not isinstance(payload.get("latency_ms"), dict)
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
latency = payload.get("latency_ms") or {}
|
||||||
|
rows.append(
|
||||||
|
(
|
||||||
|
path.stem,
|
||||||
|
payload.get("concurrency"),
|
||||||
|
payload.get("requests"),
|
||||||
|
payload.get("successful_requests"),
|
||||||
|
payload.get("failed_requests"),
|
||||||
|
payload.get("requests_per_second"),
|
||||||
|
latency.get("p50"),
|
||||||
|
latency.get("p95"),
|
||||||
|
latency.get("p99"),
|
||||||
|
latency.get("max"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if not rows:
|
||||||
|
raise SystemExit(f"No benchmark JSON files found in: {directory}")
|
||||||
|
|
||||||
|
lines = [
|
||||||
|
"| 场景 | 并发 | 请求数 | 成功 | 失败 | RPS | P50 ms | P95 ms | P99 ms | 最大 ms |",
|
||||||
|
"| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |",
|
||||||
|
]
|
||||||
|
for row in rows:
|
||||||
|
lines.append("| " + " | ".join(str(value) for value in row) + " |")
|
||||||
|
rendered = "\n".join(lines) + "\n"
|
||||||
|
print(rendered, end="")
|
||||||
|
if args.output:
|
||||||
|
output_path = pathlib.Path(args.output)
|
||||||
|
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
output_path.write_text(rendered, encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"id": "start",
|
||||||
|
"type": "start"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "end",
|
||||||
|
"type": "end"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"edges": [
|
||||||
|
{
|
||||||
|
"source": "start",
|
||||||
|
"target": "end"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -33,6 +33,35 @@ BACKEND_BIND_ADDRESS=127.0.0.1
|
|||||||
BACKEND_HOST_PORT=3001
|
BACKEND_HOST_PORT=3001
|
||||||
BACKEND_MEMORY_LIMIT=4g
|
BACKEND_MEMORY_LIMIT=4g
|
||||||
BACKEND_CPU_LIMIT=2.0
|
BACKEND_CPU_LIMIT=2.0
|
||||||
|
BACKEND_UPLOADS_VOLUME_NAME=ai-soulmate-backend-uploads
|
||||||
|
BACKEND_LOGS_VOLUME_NAME=ai-soulmate-backend-logs
|
||||||
|
FRONTEND_IMAGE=ai-soulmate-frontend:replace-with-source-commit
|
||||||
|
FRONTEND_BIND_ADDRESS=127.0.0.1
|
||||||
|
FRONTEND_HOST_PORT=8080
|
||||||
|
FRONTEND_MEMORY_LIMIT=1g
|
||||||
|
FRONTEND_CPU_LIMIT=1.0
|
||||||
|
TRIPO3D_MODE=disabled
|
||||||
|
TRIPO3D_MOCK_PROFILE=not-selected
|
||||||
|
|
||||||
|
ADMIN_COMPOSE_PROJECT_NAME=ai-soulmate-admin
|
||||||
|
ADMIN_BACKEND_IMAGE=ai-soulmate-admin-backend:replace-with-source-commit
|
||||||
|
ADMIN_FRONTEND_IMAGE=ai-soulmate-admin-frontend:replace-with-source-commit
|
||||||
|
ADMIN_POSTGRES_DB=mlkj_admin
|
||||||
|
ADMIN_BACKEND_BIND_ADDRESS=127.0.0.1
|
||||||
|
ADMIN_BACKEND_HOST_PORT=8088
|
||||||
|
ADMIN_FRONTEND_BIND_ADDRESS=127.0.0.1
|
||||||
|
ADMIN_FRONTEND_HOST_PORT=8081
|
||||||
|
ADMIN_BACKEND_MEMORY_LIMIT=2g
|
||||||
|
ADMIN_BACKEND_CPU_LIMIT=1.5
|
||||||
|
AI_SOULMATE_ADMIN_AUTO_DISPATCH_ON_PAID=true
|
||||||
|
ADMIN_FRONTEND_MEMORY_LIMIT=512m
|
||||||
|
ADMIN_FRONTEND_CPU_LIMIT=0.5
|
||||||
|
ADMIN_INITIAL_USERNAME=localadmin
|
||||||
|
ADMIN_INITIAL_PASSWORD=
|
||||||
|
ADMIN_JWT_SECRET=replace-with-a-random-value
|
||||||
|
ADMIN_MAVEN_IMAGE=maven:3.9-eclipse-temurin-21
|
||||||
|
ADMIN_JRE_IMAGE=eclipse-temurin:21-jre
|
||||||
|
ADMIN_NODE_IMAGE=node:22-bookworm-slim
|
||||||
|
|
||||||
APP_ENV=production
|
APP_ENV=production
|
||||||
SECRET_KEY=replace-with-a-random-value
|
SECRET_KEY=replace-with-a-random-value
|
||||||
@@ -42,6 +71,21 @@ CDK_CODE_PEPPER=replace-with-a-random-value
|
|||||||
MLKJ_INTEGRATION_KEY=replace-with-a-random-value
|
MLKJ_INTEGRATION_KEY=replace-with-a-random-value
|
||||||
MLKJ_INTEGRATION_SECRET=replace-with-a-random-value
|
MLKJ_INTEGRATION_SECRET=replace-with-a-random-value
|
||||||
PRINT_CLIENT_SHARED_TOKEN=replace-with-a-random-value
|
PRINT_CLIENT_SHARED_TOKEN=replace-with-a-random-value
|
||||||
|
PRINT_DEFAULT_TARGET_CLIENT_ID=farm-workstation-001
|
||||||
|
PRINT_ALLOWED_CLIENT_ID=farm-workstation-001
|
||||||
|
PRINT_EXTERNAL_TOOLS_HOST_PATH=/srv/ai-soulmate/runtime/external-tools-production-20260416
|
||||||
|
PRINT_LOCAL_PROFILES_HOST_PATH=/srv/ai-soulmate/runtime/u1-profiles
|
||||||
|
PRINT_SLICER_TIMEOUT_SECONDS=900
|
||||||
|
PRINT_SLICER_CMD_TEMPLATE=python /app/scripts/slice_with_orca.py {input_path} {output_dir} {material} {height}
|
||||||
|
PRINT_ORCA_SLICER_BINARY=/app/external-tools/bin/Snapmaker_Orca_Linux_AppImage_Ubuntu2404_V2.3.0_Beta.AppImage
|
||||||
|
PRINT_ORCA_APPIMAGE_EXTRACT_AND_RUN=true
|
||||||
|
PRINT_ORCA_PRINTER_PROFILE=/app/external-tools/bin/squashfs-root/resources/profiles/Snapmaker/machine/Snapmaker U1 (0.4 nozzle).json
|
||||||
|
PRINT_ORCA_MATERIAL_PROFILE_MAP={"default":"/app/external-tools/bin/squashfs-root/resources/profiles/Snapmaker/filament/Snapmaker PLA @U1.json","PLA":"/app/external-tools/bin/squashfs-root/resources/profiles/Snapmaker/filament/Snapmaker PLA @U1.json","PLA_WHITE":"/app/external-tools/bin/squashfs-root/resources/profiles/Snapmaker/filament/Snapmaker PLA @U1.json"}
|
||||||
|
PRINT_ORCA_HEIGHT_PROFILE_MAP={"default":"/app/local-profiles/u1-compatible-generic-process.json"}
|
||||||
|
PRINT_ORCA_DEFAULT_TOOL_COMMAND=T0
|
||||||
|
PRINT_ORCA_TOOL_COMMAND_MAP={"PLA":"T0","PLA_WHITE":"T0"}
|
||||||
|
PRINT_ORCA_FIRST_LAYER_BED_TEMPERATURE_MAP={"PLA":"65","PLA_WHITE":"65"}
|
||||||
|
PRINT_ORCA_BED_TEMPERATURE_MAP={"PLA":"60","PLA_WHITE":"60"}
|
||||||
|
|
||||||
OSS_PUBLIC_ENDPOINT=http://127.0.0.1:9000
|
OSS_PUBLIC_ENDPOINT=http://127.0.0.1:9000
|
||||||
CORS_ALLOWED_ORIGINS=http://localhost:8080,http://127.0.0.1:8080
|
CORS_ALLOWED_ORIGINS=http://localhost:8080,http://127.0.0.1:8080
|
||||||
@@ -50,3 +94,12 @@ FRONTEND_URL=http://127.0.0.1:8080
|
|||||||
TRIPO3D_API_KEY=
|
TRIPO3D_API_KEY=
|
||||||
TRIPO3D_BASE_URL=https://api.tripo3d.com/v2/openapi
|
TRIPO3D_BASE_URL=https://api.tripo3d.com/v2/openapi
|
||||||
TRIPO3D_DEFAULT_MODEL_VERSION=v3.1-20260211
|
TRIPO3D_DEFAULT_MODEL_VERSION=v3.1-20260211
|
||||||
|
TRIPO3D_MOCK_QUEUE_DELAY_SECONDS=2
|
||||||
|
TRIPO3D_MOCK_RUN_DELAY_SECONDS=8
|
||||||
|
TRIPO3D_MOCK_H_CONCURRENCY=10
|
||||||
|
TRIPO3D_MOCK_P_CONCURRENCY=5
|
||||||
|
TRIPO3D_MOCK_IMAGE_CONCURRENCY=1
|
||||||
|
TRIPO3D_MOCK_ANIMATION_CONCURRENCY=10
|
||||||
|
TRIPO3D_MOCK_POSTPROCESS_CONCURRENCY=5
|
||||||
|
TRIPO3D_MOCK_MESH_CONCURRENCY=10
|
||||||
|
TRIPO3D_MOCK_TASK_RETENTION_SECONDS=3600
|
||||||
+11
-3
@@ -1,6 +1,6 @@
|
|||||||
# Compose 状态
|
# Compose 状态
|
||||||
|
|
||||||
当前提交基础设施 POC 与平台后端:PostgreSQL、Redis、MinIO 和 FastAPI 后端。平台前端、管理端和网关仍在后续阶段。
|
当前提交基础设施 POC 与平台应用:PostgreSQL、Redis、MinIO、FastAPI 后端、Vue 平台前端和 AI SoulMate 本地管理端。统一网关仍在后续阶段。
|
||||||
|
|
||||||
## 运行基础设施
|
## 运行基础设施
|
||||||
|
|
||||||
@@ -17,11 +17,19 @@ compose/.env 只放在服务器,已经被 .gitignore 忽略。生成后执行
|
|||||||
|
|
||||||
按照 `docs/BACKEND-DEPLOYMENT.md` 生成后端密钥、创建 MinIO 应用账号、构建提交绑定的镜像并执行连接验收。
|
按照 `docs/BACKEND-DEPLOYMENT.md` 生成后端密钥、创建 MinIO 应用账号、构建提交绑定的镜像并执行连接验收。
|
||||||
|
|
||||||
|
## 运行平台前端
|
||||||
|
|
||||||
|
按照 `docs/FRONTEND-DEPLOYMENT.md` 构建提交绑定的前端镜像,并验证静态页面与同源后端代理。
|
||||||
|
|
||||||
|
## 运行管理端
|
||||||
|
|
||||||
|
按照 `docs/ADMIN-DEPLOYMENT.md` 创建独立的本地管理库,构建 `mlkj-admin` 的 `local-deployment` 分支并验证 AI SoulMate-only 菜单与本地数据连接。
|
||||||
|
|
||||||
## 当前门槛
|
## 当前门槛
|
||||||
|
|
||||||
- 平台后端仍需完成 MinIO 预签名上传、下载和浏览器 CORS 联调。
|
- 平台后端仍需完成 MinIO 预签名上传、下载和浏览器 CORS 联调。
|
||||||
- 平台前端仍需生成生产镜像并接入本地后端。
|
- 平台前端仍需完成浏览器登录、预签名对象上传和主要页面联调。
|
||||||
- mlkj-admin 仍需实现 AI SoulMate-only 启动模式,避免初始化无关业务数据库和默认账号。
|
- 管理端仍需完成浏览器登录以及用户、订单、资产、CDK 和模型归档的业务联调。
|
||||||
- nginx-server 的公网路由不能原样复用;完成业务镜像后再使用环境无关的网关模板或客户现有网关。
|
- nginx-server 的公网路由不能原样复用;完成业务镜像后再使用环境无关的网关模板或客户现有网关。
|
||||||
|
|
||||||
上述门槛完成并记录镜像 digest、迁移版本和恢复演练后,才能形成完整的可交付应用编排。
|
上述门槛完成并记录镜像 digest、迁移版本和恢复演练后,才能形成完整的可交付应用编排。
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
name: ${ADMIN_COMPOSE_PROJECT_NAME:-ai-soulmate-admin}
|
||||||
|
|
||||||
|
services:
|
||||||
|
admin-backend:
|
||||||
|
image: ${ADMIN_BACKEND_IMAGE:?ADMIN_BACKEND_IMAGE is required}
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
POLY_ADMIN_BACKEND_PORT: "8088"
|
||||||
|
JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv6Addresses=false
|
||||||
|
POLY_ADMIN_JDBC_URL: jdbc:postgresql://postgres:5432/${ADMIN_POSTGRES_DB:?ADMIN_POSTGRES_DB is required}?currentSchema=public
|
||||||
|
POLY_ADMIN_DB_USER: ${POSTGRES_USER:?POSTGRES_USER is required}
|
||||||
|
POLY_ADMIN_DB_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
|
||||||
|
AI_SOULMATE_JDBC_URL: jdbc:postgresql://postgres:5432/${POSTGRES_DB:?POSTGRES_DB is required}?currentSchema=public
|
||||||
|
AI_SOULMATE_DB_USER: ${POSTGRES_USER:?POSTGRES_USER is required}
|
||||||
|
AI_SOULMATE_DB_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
|
||||||
|
MLKJ_JDBC_URL: jdbc:postgresql://postgres:5432/${ADMIN_POSTGRES_DB:?ADMIN_POSTGRES_DB is required}?currentSchema=public
|
||||||
|
MLKJ_DB_USER: ${POSTGRES_USER:?POSTGRES_USER is required}
|
||||||
|
MLKJ_DB_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
|
||||||
|
BCJH_JDBC_URL: jdbc:postgresql://postgres:5432/${ADMIN_POSTGRES_DB:?ADMIN_POSTGRES_DB is required}?currentSchema=public
|
||||||
|
BCJH_DB_USER: ${POSTGRES_USER:?POSTGRES_USER is required}
|
||||||
|
BCJH_DB_PASSWORD: ${POSTGRES_PASSWORD:?POSTGRES_PASSWORD is required}
|
||||||
|
POLY_ADMIN_DB_POOL_MAX_SIZE: "3"
|
||||||
|
AI_SOULMATE_DB_POOL_MAX_SIZE: "3"
|
||||||
|
MLKJ_DB_POOL_MAX_SIZE: "1"
|
||||||
|
BCJH_DB_POOL_MAX_SIZE: "1"
|
||||||
|
POLY_ADMIN_DB_POOL_MIN_IDLE: "0"
|
||||||
|
POLY_ADMIN_DB_POOL_CONNECTION_TIMEOUT_MS: "5000"
|
||||||
|
POLY_ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET:?ADMIN_JWT_SECRET is required}
|
||||||
|
POLY_ADMIN_JWT_EXPIRES_SECONDS: "86400"
|
||||||
|
POLY_ADMIN_INITIAL_USERNAME: ${ADMIN_INITIAL_USERNAME:?ADMIN_INITIAL_USERNAME is required}
|
||||||
|
POLY_ADMIN_INITIAL_PASSWORD: ${ADMIN_INITIAL_PASSWORD:-}
|
||||||
|
AI_SOULMATE_CDK_CODE_PEPPER: ${CDK_CODE_PEPPER:?CDK_CODE_PEPPER is required}
|
||||||
|
AI_SOULMATE_ADMIN_API_BASE: http://backend:3000
|
||||||
|
AI_SOULMATE_ADMIN_AUTO_DISPATCH_ON_PAID: ${AI_SOULMATE_ADMIN_AUTO_DISPATCH_ON_PAID:-false}
|
||||||
|
AI_SOULMATE_STORAGE_PROVIDER: minio
|
||||||
|
AI_SOULMATE_STORAGE_ENDPOINT: http://minio:9000
|
||||||
|
AI_SOULMATE_STORAGE_BUCKET: ${MINIO_BUCKET:?MINIO_BUCKET is required}
|
||||||
|
AI_SOULMATE_STORAGE_ACCESS_KEY: ${MINIO_APP_ACCESS_KEY:?MINIO_APP_ACCESS_KEY is required}
|
||||||
|
AI_SOULMATE_STORAGE_SECRET_KEY: ${MINIO_APP_SECRET_KEY:?MINIO_APP_SECRET_KEY is required}
|
||||||
|
AI_SOULMATE_MODEL_DOWNLOAD_ALLOWED_HOSTS: ""
|
||||||
|
POLY_TRAFFIC_INGEST_ENABLED: "false"
|
||||||
|
POLY_RUNTIME_LOGS_ENABLED: "false"
|
||||||
|
TZ: ${TZ:-Asia/Shanghai}
|
||||||
|
ports:
|
||||||
|
- "${ADMIN_BACKEND_BIND_ADDRESS:-127.0.0.1}:${ADMIN_BACKEND_HOST_PORT:-8088}:8088"
|
||||||
|
mem_limit: ${ADMIN_BACKEND_MEMORY_LIMIT:-2g}
|
||||||
|
cpus: ${ADMIN_BACKEND_CPU_LIMIT:-1.5}
|
||||||
|
security_opt:
|
||||||
|
- no-new-privileges:true
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: 10m
|
||||||
|
max-file: "3"
|
||||||
|
networks:
|
||||||
|
- internal
|
||||||
|
|
||||||
|
admin-frontend:
|
||||||
|
image: ${ADMIN_FRONTEND_IMAGE:?ADMIN_FRONTEND_IMAGE is required}
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
FRONTEND_PORT: "9527"
|
||||||
|
API_TARGET: http://admin-backend:8088
|
||||||
|
ports:
|
||||||
|
- "${ADMIN_FRONTEND_BIND_ADDRESS:?ADMIN_FRONTEND_BIND_ADDRESS is required}:${ADMIN_FRONTEND_HOST_PORT:-8081}:9527"
|
||||||
|
depends_on:
|
||||||
|
- admin-backend
|
||||||
|
mem_limit: ${ADMIN_FRONTEND_MEMORY_LIMIT:-512m}
|
||||||
|
cpus: ${ADMIN_FRONTEND_CPU_LIMIT:-0.5}
|
||||||
|
security_opt:
|
||||||
|
- no-new-privileges:true
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: 10m
|
||||||
|
max-file: "3"
|
||||||
|
networks:
|
||||||
|
- internal
|
||||||
|
|
||||||
|
networks:
|
||||||
|
internal:
|
||||||
|
name: ${DOCKER_NETWORK_NAME:-ai-soulmate-internal}
|
||||||
|
external: true
|
||||||
@@ -15,6 +15,19 @@ services:
|
|||||||
MLKJ_INTEGRATION_KEY: ${MLKJ_INTEGRATION_KEY:?MLKJ_INTEGRATION_KEY is required}
|
MLKJ_INTEGRATION_KEY: ${MLKJ_INTEGRATION_KEY:?MLKJ_INTEGRATION_KEY is required}
|
||||||
MLKJ_INTEGRATION_SECRET: ${MLKJ_INTEGRATION_SECRET:?MLKJ_INTEGRATION_SECRET is required}
|
MLKJ_INTEGRATION_SECRET: ${MLKJ_INTEGRATION_SECRET:?MLKJ_INTEGRATION_SECRET is required}
|
||||||
PRINT_CLIENT_SHARED_TOKEN: ${PRINT_CLIENT_SHARED_TOKEN:?PRINT_CLIENT_SHARED_TOKEN is required}
|
PRINT_CLIENT_SHARED_TOKEN: ${PRINT_CLIENT_SHARED_TOKEN:?PRINT_CLIENT_SHARED_TOKEN is required}
|
||||||
|
PRINT_DEFAULT_TARGET_CLIENT_ID: ${PRINT_DEFAULT_TARGET_CLIENT_ID:?PRINT_DEFAULT_TARGET_CLIENT_ID is required}
|
||||||
|
PRINT_ALLOWED_CLIENT_ID: ${PRINT_ALLOWED_CLIENT_ID:?PRINT_ALLOWED_CLIENT_ID is required}
|
||||||
|
PRINT_SLICER_TIMEOUT_SECONDS: ${PRINT_SLICER_TIMEOUT_SECONDS:?PRINT_SLICER_TIMEOUT_SECONDS is required}
|
||||||
|
PRINT_SLICER_CMD_TEMPLATE: ${PRINT_SLICER_CMD_TEMPLATE:?PRINT_SLICER_CMD_TEMPLATE is required}
|
||||||
|
PRINT_ORCA_SLICER_BINARY: ${PRINT_ORCA_SLICER_BINARY:?PRINT_ORCA_SLICER_BINARY is required}
|
||||||
|
PRINT_ORCA_APPIMAGE_EXTRACT_AND_RUN: ${PRINT_ORCA_APPIMAGE_EXTRACT_AND_RUN:?PRINT_ORCA_APPIMAGE_EXTRACT_AND_RUN is required}
|
||||||
|
PRINT_ORCA_PRINTER_PROFILE: ${PRINT_ORCA_PRINTER_PROFILE:?PRINT_ORCA_PRINTER_PROFILE is required}
|
||||||
|
PRINT_ORCA_MATERIAL_PROFILE_MAP: ${PRINT_ORCA_MATERIAL_PROFILE_MAP:?PRINT_ORCA_MATERIAL_PROFILE_MAP is required}
|
||||||
|
PRINT_ORCA_HEIGHT_PROFILE_MAP: ${PRINT_ORCA_HEIGHT_PROFILE_MAP:?PRINT_ORCA_HEIGHT_PROFILE_MAP is required}
|
||||||
|
PRINT_ORCA_DEFAULT_TOOL_COMMAND: ${PRINT_ORCA_DEFAULT_TOOL_COMMAND:?PRINT_ORCA_DEFAULT_TOOL_COMMAND is required}
|
||||||
|
PRINT_ORCA_TOOL_COMMAND_MAP: ${PRINT_ORCA_TOOL_COMMAND_MAP:?PRINT_ORCA_TOOL_COMMAND_MAP is required}
|
||||||
|
PRINT_ORCA_FIRST_LAYER_BED_TEMPERATURE_MAP: ${PRINT_ORCA_FIRST_LAYER_BED_TEMPERATURE_MAP:?PRINT_ORCA_FIRST_LAYER_BED_TEMPERATURE_MAP is required}
|
||||||
|
PRINT_ORCA_BED_TEMPERATURE_MAP: ${PRINT_ORCA_BED_TEMPERATURE_MAP:?PRINT_ORCA_BED_TEMPERATURE_MAP is required}
|
||||||
OSS_PROVIDER: minio
|
OSS_PROVIDER: minio
|
||||||
OSS_ENDPOINT: http://minio:9000
|
OSS_ENDPOINT: http://minio:9000
|
||||||
OSS_BUCKET_NAME: ${MINIO_BUCKET:?MINIO_BUCKET is required}
|
OSS_BUCKET_NAME: ${MINIO_BUCKET:?MINIO_BUCKET is required}
|
||||||
@@ -25,9 +38,20 @@ services:
|
|||||||
CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS:?CORS_ALLOWED_ORIGINS is required}
|
CORS_ALLOWED_ORIGINS: ${CORS_ALLOWED_ORIGINS:?CORS_ALLOWED_ORIGINS is required}
|
||||||
AI_SOULMATE_PUBLIC_URL: ${AI_SOULMATE_PUBLIC_URL:?AI_SOULMATE_PUBLIC_URL is required}
|
AI_SOULMATE_PUBLIC_URL: ${AI_SOULMATE_PUBLIC_URL:?AI_SOULMATE_PUBLIC_URL is required}
|
||||||
FRONTEND_URL: ${FRONTEND_URL:?FRONTEND_URL is required}
|
FRONTEND_URL: ${FRONTEND_URL:?FRONTEND_URL is required}
|
||||||
|
TRIPO3D_MODE: ${TRIPO3D_MODE:-disabled}
|
||||||
|
TRIPO3D_MOCK_PROFILE: ${TRIPO3D_MOCK_PROFILE:-not-selected}
|
||||||
TRIPO3D_API_KEY: ${TRIPO3D_API_KEY:-}
|
TRIPO3D_API_KEY: ${TRIPO3D_API_KEY:-}
|
||||||
TRIPO3D_BASE_URL: ${TRIPO3D_BASE_URL:-https://api.tripo3d.com/v2/openapi}
|
TRIPO3D_BASE_URL: ${TRIPO3D_BASE_URL:-https://api.tripo3d.com/v2/openapi}
|
||||||
TRIPO3D_DEFAULT_MODEL_VERSION: ${TRIPO3D_DEFAULT_MODEL_VERSION:-v3.1-20260211}
|
TRIPO3D_DEFAULT_MODEL_VERSION: ${TRIPO3D_DEFAULT_MODEL_VERSION:-v3.1-20260211}
|
||||||
|
TRIPO3D_MOCK_QUEUE_DELAY_SECONDS: ${TRIPO3D_MOCK_QUEUE_DELAY_SECONDS:-2}
|
||||||
|
TRIPO3D_MOCK_RUN_DELAY_SECONDS: ${TRIPO3D_MOCK_RUN_DELAY_SECONDS:-8}
|
||||||
|
TRIPO3D_MOCK_H_CONCURRENCY: ${TRIPO3D_MOCK_H_CONCURRENCY:-10}
|
||||||
|
TRIPO3D_MOCK_P_CONCURRENCY: ${TRIPO3D_MOCK_P_CONCURRENCY:-5}
|
||||||
|
TRIPO3D_MOCK_IMAGE_CONCURRENCY: ${TRIPO3D_MOCK_IMAGE_CONCURRENCY:-1}
|
||||||
|
TRIPO3D_MOCK_ANIMATION_CONCURRENCY: ${TRIPO3D_MOCK_ANIMATION_CONCURRENCY:-10}
|
||||||
|
TRIPO3D_MOCK_POSTPROCESS_CONCURRENCY: ${TRIPO3D_MOCK_POSTPROCESS_CONCURRENCY:-5}
|
||||||
|
TRIPO3D_MOCK_MESH_CONCURRENCY: ${TRIPO3D_MOCK_MESH_CONCURRENCY:-10}
|
||||||
|
TRIPO3D_MOCK_TASK_RETENTION_SECONDS: ${TRIPO3D_MOCK_TASK_RETENTION_SECONDS:-3600}
|
||||||
PAYMENT_V2_ENABLED: "false"
|
PAYMENT_V2_ENABLED: "false"
|
||||||
ALLOW_DEV_VERIFICATION_CODE_RESPONSE: "false"
|
ALLOW_DEV_VERIFICATION_CODE_RESPONSE: "false"
|
||||||
UPLOAD_DIR: /app/uploads
|
UPLOAD_DIR: /app/uploads
|
||||||
@@ -37,6 +61,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- backend_uploads:/app/uploads
|
- backend_uploads:/app/uploads
|
||||||
- backend_logs:/app/logs
|
- backend_logs:/app/logs
|
||||||
|
- ${PRINT_EXTERNAL_TOOLS_HOST_PATH:?PRINT_EXTERNAL_TOOLS_HOST_PATH is required}:/app/external-tools:ro
|
||||||
|
- ${PRINT_LOCAL_PROFILES_HOST_PATH:?PRINT_LOCAL_PROFILES_HOST_PATH is required}:/app/local-profiles:ro
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test:
|
||||||
- CMD
|
- CMD
|
||||||
@@ -62,11 +88,33 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
image: ${FRONTEND_IMAGE:?FRONTEND_IMAGE is required}
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "${FRONTEND_BIND_ADDRESS:?FRONTEND_BIND_ADDRESS is required}:${FRONTEND_HOST_PORT:-8080}:8080"
|
||||||
|
depends_on:
|
||||||
|
backend:
|
||||||
|
condition: service_healthy
|
||||||
|
mem_limit: ${FRONTEND_MEMORY_LIMIT:-1g}
|
||||||
|
cpus: ${FRONTEND_CPU_LIMIT:-1.0}
|
||||||
|
security_opt:
|
||||||
|
- no-new-privileges:true
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: 10m
|
||||||
|
max-file: "3"
|
||||||
|
networks:
|
||||||
|
- internal
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
backend_uploads:
|
backend_uploads:
|
||||||
name: ai-soulmate-backend-uploads
|
name: ${BACKEND_UPLOADS_VOLUME_NAME:-ai-soulmate-backend-uploads}
|
||||||
|
external: true
|
||||||
backend_logs:
|
backend_logs:
|
||||||
name: ai-soulmate-backend-logs
|
name: ${BACKEND_LOGS_VOLUME_NAME:-ai-soulmate-backend-logs}
|
||||||
|
external: true
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
internal:
|
internal:
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# AI SoulMate 管理端本地部署
|
||||||
|
|
||||||
|
本地管理端只展示 `AI_SOULMATE` 与基础 `CONSOLE`,不连接官网或壁材京华云数据库。管理端自身数据使用同一 PostgreSQL 实例中的独立 `mlkj_admin` 数据库;AI SoulMate 业务查询连接本地 `ai_soulmate` 数据库;模型归档读取本地 MinIO。
|
||||||
|
|
||||||
|
## 源码
|
||||||
|
|
||||||
|
源码必须使用 `mlkj-admin` 仓库的 `local-deployment` 分支。该分支增加 MinIO 客户端和本地菜单配置,不修改远程 `main`。
|
||||||
|
|
||||||
|
## 顺序
|
||||||
|
|
||||||
|
1. 运行 `configure-admin-env.sh` 写入提交绑定镜像名与本地监听地址。
|
||||||
|
2. 运行 `set-admin-credentials.sh`,在终端中无回显设置初始管理员密码。
|
||||||
|
3. 运行 `initialize-admin-database.sh` 创建并初始化本地 `mlkj_admin` 数据库。
|
||||||
|
4. 运行 `build-admin-images.sh` 构建 Java 后端与 Node 前端镜像。
|
||||||
|
5. 运行 `start-admin.sh` 和 `verify-admin.sh`。
|
||||||
|
6. 验收成功后运行 `clear-admin-bootstrap-password.sh`,从环境文件和容器中移除一次性初始密码。
|
||||||
|
|
||||||
|
管理端前端默认监听局域网 `8081`,Java 后端只绑定 `127.0.0.1:8088`。不要把 PostgreSQL、管理端 Java 端口或 MinIO 控制台暴露到路由器公网。
|
||||||
|
|
||||||
|
初始管理员只在数据库不存在 `SUPER_ADMIN` 时创建。部署完成后不要通过修改环境变量来改密码,应登录管理端使用管理员功能完成账号治理。
|
||||||
@@ -18,10 +18,11 @@ cd /srv/ai-soulmate-local-deployment
|
|||||||
./scripts/configure-backend-env.sh \
|
./scripts/configure-backend-env.sh \
|
||||||
compose/.env \
|
compose/.env \
|
||||||
/srv/ai-soulmate/sources/ai-soulmate-server \
|
/srv/ai-soulmate/sources/ai-soulmate-server \
|
||||||
192.168.3.102
|
192.168.3.102 \
|
||||||
|
farm-workstation-001
|
||||||
```
|
```
|
||||||
|
|
||||||
脚本保留已有基础设施密码,补齐后端密钥,文件权限保持为 `600`,并且不会把密钥打印到终端。Tripo Key 默认留空;健康检查不依赖 Tripo,联调 Tripo 前再通过受控方式注入已轮换的新 Key。
|
脚本保留已有基础设施密码,补齐后端密钥和打印客户端允许的 `client_id`,文件权限保持为 `600`,并且不会把密钥打印到终端。农场端使用的 `AI_SOULMATE_CLIENT_ID` 必须与此处第四个参数一致。Tripo Key 默认留空;健康检查不依赖 Tripo,联调 Tripo 前再通过受控方式注入已轮换的新 Key。
|
||||||
|
|
||||||
## 重建 MinIO 配置
|
## 重建 MinIO 配置
|
||||||
|
|
||||||
@@ -42,14 +43,12 @@ docker compose --env-file compose/.env \
|
|||||||
compose/.env \
|
compose/.env \
|
||||||
/srv/ai-soulmate/sources/ai-soulmate-server
|
/srv/ai-soulmate/sources/ai-soulmate-server
|
||||||
|
|
||||||
docker compose --env-file compose/.env \
|
./scripts/start-backend.sh compose/.env
|
||||||
-f compose/docker-compose.backend.yml \
|
|
||||||
up -d
|
|
||||||
|
|
||||||
./scripts/verify-backend.sh compose/.env
|
./scripts/verify-backend.sh compose/.env
|
||||||
```
|
```
|
||||||
|
|
||||||
构建脚本拒绝错误分支、受跟踪源码改动以及与源码提交不一致的镜像标签。后端验证会检查 HTTP 健康状态,以及容器到 PostgreSQL、Redis 和 MinIO Bucket 的实际连接。
|
构建脚本拒绝错误分支、受跟踪源码改动以及与源码提交不一致的镜像标签。启动和验证脚本显式使用独立的 Compose 项目名,防止基础设施被误判为后端的孤立容器。后端验证会检查 HTTP 健康状态,以及容器到 PostgreSQL、Redis 和 MinIO Bucket 的实际连接。
|
||||||
|
|
||||||
## 当前网络边界
|
## 当前网络边界
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
# AI SoulMate Client 工作站硬件基线报告
|
||||||
|
|
||||||
|
- 采集时间:2026-08-10 15:37(Asia/Shanghai)
|
||||||
|
- 采集对象:AI SoulMate Client(农场端)工作站
|
||||||
|
- 主机名:`HP`
|
||||||
|
- 采集方式:通过 Tailscale + SSH 执行 Windows 本机只读命令
|
||||||
|
- 使用阶段:本地部署适配、功能跑通与轻量压力测试
|
||||||
|
|
||||||
|
## 1. 结论
|
||||||
|
|
||||||
|
这台工作站可以用于 AI SoulMate Client 农场端的功能部署和低并发验证,但不适合本地三维模型推理,也不适合作为高并发或长期生产环境的性能代表机。
|
||||||
|
|
||||||
|
当前主要限制是 **2 核 4 线程 CPU 和 8GB 单条内存**。Windows 在采集时只剩约 2.56GiB 可用内存,而 Client 还需要运行 PostgreSQL、Java 后端、前端/Nginx 和容器运行时。因此本次应采用轻量资源限制、避免在工作站本地反复构建镜像,并优先把内存升级到 16GB。
|
||||||
|
|
||||||
|
当前判定:
|
||||||
|
|
||||||
|
- 功能跑通:已完成 WSL2、Docker Desktop 和 Client 三容器的首次部署;当前需要补充开机自启动、休眠策略和长稳验证。
|
||||||
|
- Client 低并发 POC:可以,需限制容器资源并持续观察内存。
|
||||||
|
- Client 容量结论:暂不能给出,需部署后按固定场景压测。
|
||||||
|
- Tripo 3D:继续调用外部 API;本机不承担模型推理。
|
||||||
|
- 客户生产方案:不能直接照搬这台工作站的配置与测试数字。
|
||||||
|
|
||||||
|
## 2. 实测硬件清单
|
||||||
|
|
||||||
|
| 项目 | 实测结果 | 适配判断 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 整机 | Lenovo Baiying `NUC13 Yes`,x64 物理机 | 小型农场端工作站形态 |
|
||||||
|
| 操作系统 | Windows 11 家庭中文版,64 位,版本 `10.0.26200` | 可使用 WSL2 + Docker Desktop |
|
||||||
|
| BIOS | `YSDLP03.107` | 已开启 CPU 虚拟化能力 |
|
||||||
|
| CPU | AMD Athlon Gold 3150C with Radeon Graphics,2 核 4 线程,标称最大 2.4GHz | 功能验证可用;构建和并发能力较弱 |
|
||||||
|
| 虚拟化 | Firmware virtualization = `True`,SLAT = `True` | 满足 WSL2 的硬件前提 |
|
||||||
|
| 内存 | 1 × 8GB DDR4-2666,实际配置频率 2400MHz,系统可识别约 7.45GiB | 当前最大风险;建议升级到 16GB |
|
||||||
|
| GPU | AMD Radeon Vega 3 集成显卡,系统报告 512MiB 显存,1920×1080 | 只用于显示;无 CUDA,不承担本地 3D 推理 |
|
||||||
|
| 系统盘 | Netac G537N2 256G SATA SSD,物理容量约 238.5GiB | POC 可用;镜像、日志和模型文件需限额 |
|
||||||
|
| SSD 健康 | Windows 报告 `Healthy / OK` | 未见直接故障信号,但不是完整 SMART/寿命检测 |
|
||||||
|
| 有线网卡 | Realtek PCIe GbE Family Controller | 建议正式运行时使用千兆有线网络 |
|
||||||
|
| 无线网卡 | Realtek 8821CE 802.11ac | 当前可用,吞吐和稳定性不宜作为生产基线 |
|
||||||
|
|
||||||
|
## 3. 存储与当前资源
|
||||||
|
|
||||||
|
| 盘符 | 总容量 | 可用空间 | 当前用途建议 |
|
||||||
|
| --- | ---: | ---: | --- |
|
||||||
|
| `C:` | 约 150.05GiB | 约 110.49GiB | Windows 与应用程序 |
|
||||||
|
| `D:` | 约 87.32GiB | 约 87.23GiB | 优先用于 Client 数据、Docker 数据和部署文件 |
|
||||||
|
|
||||||
|
采集瞬间 CPU 负载约 27%,可用物理内存约 2.56GiB。瞬时值不能代表稳定负载,但说明 8GB 内存余量较小。部署时应保证磁盘至少保留 20GiB 可用空间,并设置日志轮转和 Docker 镜像清理流程。
|
||||||
|
|
||||||
|
## 4. 网络与远程维护
|
||||||
|
|
||||||
|
| 项目 | 状态 |
|
||||||
|
| --- | --- |
|
||||||
|
| 局域网 WLAN 地址 | `192.168.3.162` |
|
||||||
|
| Tailscale 地址 | `100.111.151.72` |
|
||||||
|
| Tailscale 主机名 | `ai-soulmate-workstation` |
|
||||||
|
| SSH | 已启用并验证密钥登录 |
|
||||||
|
| 中心服务器 Tailscale | `100.81.206.1`(`ai-soulmate-lab`) |
|
||||||
|
| 中心服务器业务地址 | `192.168.3.102`,已通过 Tailscale 子网路由访问 |
|
||||||
|
|
||||||
|
农场端即使换到其他网络,Tailscale 地址通常仍保持不变;局域网地址可能变化。远程运维应优先使用:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
ssh -i "$env:USERPROFILE\.ssh\id_ed25519_ai_soulmate_workstation" hedon@100.111.151.72
|
||||||
|
```
|
||||||
|
|
||||||
|
不要把 SSH 22 端口直接暴露到公网。局域网和 Tailscale 防火墙规则应继续限制来源范围。
|
||||||
|
|
||||||
|
## 5. 容器运行前置状态
|
||||||
|
|
||||||
|
| 检查项 | 当前状态 | 下一步 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| BIOS 虚拟化 | 已启用 | 无需修改 BIOS |
|
||||||
|
| SLAT | 支持 | 满足 WSL2 前提 |
|
||||||
|
| `VirtualMachinePlatform` | 未启用 | 启用后重启 |
|
||||||
|
| `Microsoft-Windows-Subsystem-Linux` | 未启用 | 启用后安装/更新 WSL2 |
|
||||||
|
| Docker CLI | 未安装 | WSL2 就绪后安装 Docker Desktop |
|
||||||
|
| Docker Engine | 未运行 | 安装后验证 `hello-world` 与 Compose |
|
||||||
|
|
||||||
|
以上四项是硬件采集时的初始状态。随后已完成前置环境安装并复核:
|
||||||
|
|
||||||
|
- `HypervisorPresent=True`。
|
||||||
|
- WSL 与 `VirtualMachinePlatform` 均为 `Enabled`。
|
||||||
|
- WSL 版本 `2.7.11.0`,默认 WSL 版本为 `2`。
|
||||||
|
- Docker Desktop `4.85.0`,Docker Engine `29.6.2`,Compose `v5.3.1`。
|
||||||
|
- Docker 使用 Linux 引擎,报告可用内存约 3.55GiB、4 个逻辑 CPU。
|
||||||
|
- 已通过 `docker run --rm hello-world`,并配置镜像源 `https://docker.m.daocloud.io/`。
|
||||||
|
|
||||||
|
因此,工作站已经具备运行 Client Linux 容器的基础条件。随后已启动 Client PostgreSQL 15、Java 后端和前端三容器,页面、登录及 `farm-workstation-001` 心跳曾验证通过;演示打印机和演示订单已清理。
|
||||||
|
|
||||||
|
本报告生成后的最终远程检查中,工作站 Tailscale 显示离线,可能与息屏或休眠有关,但原因尚未最终确认。当前还没有 Client 镜像 digest、长稳、断线恢复或容量证据,因此不能把“首次运行成功”解释为持续在线或生产可用。
|
||||||
|
|
||||||
|
## 6. Client 部署资源建议
|
||||||
|
|
||||||
|
在 8GB 内存不升级的前提下,建议采用以下 POC 起始预算:
|
||||||
|
|
||||||
|
| 组件 | CPU 上限起点 | 内存上限起点 | 说明 |
|
||||||
|
| --- | ---: | ---: | --- |
|
||||||
|
| Client PostgreSQL | 0.5 CPU | 512MiB | 只存农场端本地业务数据 |
|
||||||
|
| Client Java 后端 | 1.0 CPU | 1024MiB | JVM 堆建议先限制在 512MiB 左右 |
|
||||||
|
| Client 前端/Nginx | 0.25 CPU | 128MiB | 使用生产静态文件,不运行 Vite 开发服务器 |
|
||||||
|
| WSL2/容器总预算 | 不超过 1.5 CPU | 约 3GiB | 为 Windows、SSH、Tailscale 和打印程序保留余量 |
|
||||||
|
|
||||||
|
这些值只是防止工作站失去响应的起始保护值,不是性能调优结论。镜像构建的峰值内存会明显高于运行时,优先在中心服务器或开发机完成构建,再把固定版本镜像传到工作站。
|
||||||
|
|
||||||
|
## 7. 风险与优先级
|
||||||
|
|
||||||
|
| 优先级 | 风险 | 影响 | 处理建议 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| P0 | 仅 8GB 内存 | Docker、Java、数据库与 Windows 争用内存,可能卡顿或 OOM | 最优先升级到 16GB;升级前严格限制资源 |
|
||||||
|
| P0 | 工作站息屏/休眠后可能离线 | Client、Tailscale 和 Docker Desktop 可能无法持续提供农场服务 | 设置接通电源不休眠、Docker 开机启动,并增加重启后健康巡检 |
|
||||||
|
| P1 | 2 核 4 线程低功耗 CPU | 构建慢,多任务和并发能力有限 | 避免本机构建;低并发逐级加压 |
|
||||||
|
| P1 | 单块 256GB SSD | Client 数据、镜像、日志共享容量且无冗余 | 使用 `D:`、限制日志并备份业务数据 |
|
||||||
|
| P1 | 当前使用 Wi-Fi | 文件上传和打印任务可能受无线抖动影响 | 能接网线时改用千兆以太网 |
|
||||||
|
| P1 | 集成 GPU、无 CUDA | 无法代表本地 AI 推理工作站 | Tripo 继续走 API,本机只运行业务 Client |
|
||||||
|
| P2 | 未采集温度与完整 SMART | 暂不能判断长时间满载散热与 SSD 寿命 | 压测阶段补采温度、磁盘延迟与错误计数 |
|
||||||
|
|
||||||
|
## 8. 推荐实施顺序
|
||||||
|
|
||||||
|
1. 设置工作站接通电源时不休眠,并验证 Tailscale、Docker Desktop 和 Client 三容器开机后自动可用。
|
||||||
|
2. 固定 Client 实际源码提交、镜像 digest 和 `.env` 配置摘要,真实密钥只保存在工作站。
|
||||||
|
3. 复核工作站到中心服务器 `192.168.3.102:8080` 的平台 API、心跳和任务同步。
|
||||||
|
4. 完成模型/文件下载、订单同步、断线恢复和重复任务幂等测试。
|
||||||
|
5. 记录空闲资源基线,再进行低并发、逐级加压和长稳测试。
|
||||||
|
6. 最后接入快造 U1,单独验证 PIN、动态 IP 发现、单机/多机打印队列和状态回传。
|
||||||
|
|
||||||
|
## 9. 报告边界
|
||||||
|
|
||||||
|
本报告不记录序列号、MAC 地址、账号、密钥或环境变量秘密。本次只使用 Windows 系统可读取的硬件和健康状态,没有拆机,也没有执行内存压力测试、完整 SSD SMART 检测、温度采集或长时间负载测试。因此“SSD Healthy”只表示当前 Windows 存储状态未报告故障,不等同于生产级寿命保证。
|
||||||
@@ -107,7 +107,7 @@ backup_directory="$(printf '%s\n' "$backup_output" | sed -n 's/^Infrastructure b
|
|||||||
|
|
||||||
## 5. 业务部署门槛
|
## 5. 业务部署门槛
|
||||||
|
|
||||||
后端本地容器的配置、构建、启动和连接验收见 `docs/BACKEND-DEPLOYMENT.md`。后端先绑定回环地址,数据库和 Redis 不向局域网开放;MinIO API 只绑定批准的局域网地址,控制台保持回环绑定。
|
后端本地容器的配置、构建、启动和连接验收见 `docs/BACKEND-DEPLOYMENT.md`,平台前端见 `docs/FRONTEND-DEPLOYMENT.md`。后端先绑定回环地址,数据库和 Redis 不向局域网开放;前端和 MinIO API 只绑定批准的局域网地址,MinIO 控制台保持回环绑定。
|
||||||
|
|
||||||
平台后端已有独立镜像、无源码挂载的 Compose、资源上限、日志轮换、健康检查和 MinIO provider。继续完成以下业务门槛:
|
平台后端已有独立镜像、无源码挂载的 Compose、资源上限、日志轮换、健康检查和 MinIO provider。继续完成以下业务门槛:
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# AI SoulMate 平台前端本地部署
|
||||||
|
|
||||||
|
平台前端使用多阶段镜像构建 Vue 静态资源,并由镜像内的 Nginx 提供页面。浏览器使用同源 `/api`、`/uploads` 和 `/ws` 路径,Nginx 在 Docker 内部网络中代理到 `backend:3000`,因此不会把用户电脑的 `localhost` 当成服务器。
|
||||||
|
|
||||||
|
## 构建镜像
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /srv/ai-soulmate-local-deployment
|
||||||
|
./scripts/configure-backend-env.sh \
|
||||||
|
compose/.env \
|
||||||
|
/srv/ai-soulmate/sources/ai-soulmate-server \
|
||||||
|
192.168.3.102
|
||||||
|
|
||||||
|
./scripts/build-frontend-image.sh \
|
||||||
|
compose/.env \
|
||||||
|
/srv/ai-soulmate/sources/ai-soulmate-server
|
||||||
|
```
|
||||||
|
|
||||||
|
配置脚本将前端镜像标签绑定到源码提交,并把前端监听地址设为当前服务器的局域网地址。构建脚本拒绝错误分支、未提交的受跟踪文件和不匹配的镜像标签。
|
||||||
|
|
||||||
|
## 启动与验收
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/start-frontend.sh compose/.env
|
||||||
|
./scripts/verify-frontend.sh compose/.env
|
||||||
|
```
|
||||||
|
|
||||||
|
验证脚本同时检查前端 `/health`、Vue 页面挂载点和经过前端 Nginx 代理的 `/api/health`,最后一项必须确认数据库为 `connected`。
|
||||||
|
|
||||||
|
当前 POC 地址为 `http://192.168.3.102:8080`。该地址只应用于受控局域网功能联调,不代表正式交付入口。正式交付应由统一网关提供 TLS,并为浏览器、管理端和农场工作站定义明确的访问策略。
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# 本地 U1 切片运行时
|
||||||
|
|
||||||
|
本地部署使用从生产环境**只读复制并校验**的 `external-tools` 运行时。生产服务器未被修改,二进制包不提交到 Git。
|
||||||
|
|
||||||
|
## 校验记录
|
||||||
|
|
||||||
|
- 归档:`external-tools-production-20260416.tar.gz`
|
||||||
|
- 归档 SHA256:`820a4cea7f6e0914846c8dac61be803b1116c44f25205c3048a7762a8475e3af`
|
||||||
|
- 本地运行时:`/srv/ai-soulmate/runtime/external-tools-production-20260416`
|
||||||
|
- AppRun SHA256:`951984442c0b416fd14714ac5f271f427d84566f533ec43fe719598875e3fb6c`
|
||||||
|
- AppImage SHA256:`d3676edc0e5385deb537a44e87496a4c7b631007884bad5234dcc4f5c8d8b09b`
|
||||||
|
- U1 profile 数量:`73`
|
||||||
|
|
||||||
|
## U1 配置
|
||||||
|
|
||||||
|
- 机器:`Snapmaker/machine/Snapmaker U1 (0.4 nozzle).json`
|
||||||
|
- 白色 PLA:`Snapmaker/filament/Snapmaker PLA @U1.json`
|
||||||
|
- 官方工艺:`Snapmaker/process/0.20 Standard @Snapmaker U1 (0.4 nozzle).json`
|
||||||
|
- 本地工艺:`/app/local-profiles/u1-compatible-generic-process.json`
|
||||||
|
- 切片器:`/app/external-tools/bin/Snapmaker_Orca_Linux_AppImage_Ubuntu2404_V2.3.0_Beta.AppImage`
|
||||||
|
|
||||||
|
Compose 将运行时挂载为 `/app/external-tools:ro`,将本地派生过程挂载为 `/app/local-profiles:ro`。生产式调用必须设置 `APPIMAGE_EXTRACT_AND_RUN=true`;直接调用 `AppRun` 已验证会失败。官方 U1 工艺在当前 Orca CLI 版本中返回 `127`,因此本地先使用通用 Snapmaker 工艺并将兼容机型改为 U1;这不修改原始 profile。
|
||||||
|
|
||||||
|
## 部署要求
|
||||||
|
|
||||||
|
服务器上完成解压后,运行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/prepare-u1-local-profile.sh
|
||||||
|
|
||||||
|
./scripts/configure-backend-env.sh \
|
||||||
|
compose/.env \
|
||||||
|
/srv/ai-soulmate/sources/ai-soulmate-server \
|
||||||
|
192.168.3.102 \
|
||||||
|
farm-workstation-001
|
||||||
|
|
||||||
|
docker compose --env-file compose/.env \
|
||||||
|
-f compose/docker-compose.backend.yml config --quiet
|
||||||
|
```
|
||||||
|
|
||||||
|
准备脚本只读取外部工具中的通用 Snapmaker 工艺,并生成 `/srv/ai-soulmate/runtime/u1-profiles/u1-compatible-generic-process.json`。该文件不包含生产密钥,也不提交到 Git。
|
||||||
|
|
||||||
|
不要把运行时目录、归档或任何生产密钥提交到 Git。首次真实打印前,客户端应保持 `download_only` 或 `upload_only`,确认 G-code 后再单独批准启动。
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
# Tripo 零积分软硬件适配压测方案
|
||||||
|
|
||||||
|
## 1. 目的
|
||||||
|
|
||||||
|
本方案用于在不调用 Tripo 真实生成接口、不消耗 Tripo 生成积分的前提下,验证 AI SoulMate 用户端、管理端、中心服务器和 Client 农场端在当前软硬件环境中的性能、稳定性与任务排队行为。
|
||||||
|
|
||||||
|
本阶段使用后端内置的 `mock` 模式模拟 Tripo 任务生命周期。该模式不会向 Tripo 或其他 Tripo 地址发送网络请求,模拟任务的本地平台计费为 0,因此暂时不需要配置或更换 Tripo API key。只有进入真实 Tripo 联调阶段时才需要 API key,并应先用少量请求验证账户额度与实际限制。
|
||||||
|
|
||||||
|
部署时必须显式选择 `rate-limits-page` 或 `model-pages-conservative` profile,选择值和六类并发配置要随每次测试结果一起留档。当前实现只承诺生成提交与任务查询不会调用 Tripo;历史任务中的 Tripo 外链代理属于另一条读取链路,不能把“零生成计费调用”扩大解释成“容器绝无任何公网数据包”。正式压测会避开历史外链代理,并单独记录网络边界。
|
||||||
|
|
||||||
|
## 2. 测试边界
|
||||||
|
|
||||||
|
本轮包括:
|
||||||
|
|
||||||
|
- AI SoulMate 用户端、管理端及其后端接口。
|
||||||
|
- 中心服务器上的 PostgreSQL、Redis、MinIO 和 Docker 容器。
|
||||||
|
- Client 工作站上的前端、后端、独立 PostgreSQL,以及与中心服务器之间的心跳和任务同步链路。
|
||||||
|
- Tripo `mock` 模式下的任务提交、状态流转、结果落入 MinIO、并发拒绝及本地队列行为。
|
||||||
|
|
||||||
|
本轮不包括:
|
||||||
|
|
||||||
|
- Tripo 真实模型生成、真实计费、真实公网延迟和真实上游模型耗时。
|
||||||
|
- 阿里云提示词翻译、提示词优化等其他云服务。压测请求必须绕过或关闭这些外部调用,避免产生费用,也避免其网络波动污染本地基线。
|
||||||
|
- 快造 U1 的 PIN 配对、动态 IP 发现和真实打印。打印机接入在平台基线稳定后单独测试。
|
||||||
|
|
||||||
|
因此,本轮结果只能说明本地平台与当前硬件的承载能力,不能直接等同于 Tripo 的真实生成吞吐量。
|
||||||
|
|
||||||
|
## 3. Tripo 官方限制与本地配置
|
||||||
|
|
||||||
|
Tripo 的请求速率限制按 API key 计算;任务并发限制按账户及任务类别计算,不是整个系统共用一个固定并发数。根据 [Tripo 官方速率限制与并发控制文档](https://developers.tripo3d.com/zh/docs/rate-limits),专门限流页在 2026-08-12 显示的默认基线如下:
|
||||||
|
|
||||||
|
| 任务类别 | 官方页面当前公开并发数 | 本地 mock 配置项 |
|
||||||
|
| --- | ---: | --- |
|
||||||
|
| H 系列 3D 生成 | 10 | `TRIPO3D_MOCK_H_CONCURRENCY` |
|
||||||
|
| P 系列 3D 生成 | 5 | `TRIPO3D_MOCK_P_CONCURRENCY` |
|
||||||
|
| 图像生成 | 1 | `TRIPO3D_MOCK_IMAGE_CONCURRENCY` |
|
||||||
|
| 动画 | 10 | `TRIPO3D_MOCK_ANIMATION_CONCURRENCY` |
|
||||||
|
| 模型后处理 | 5 | `TRIPO3D_MOCK_POSTPROCESS_CONCURRENCY` |
|
||||||
|
| 网格操作 | 10 | `TRIPO3D_MOCK_MESH_CONCURRENCY` |
|
||||||
|
|
||||||
|
这些值只是本次 v2 POC 测试 profile 的默认基线,不是当前账户合同额度。官方 H3.1、P1 和 Animation 模型详情页又分别显示 `3` 个并行任务,并说明额度取决于用量层级;这可能涉及 API 版本、模型或套餐口径差异。正式联调时必须以当前官方文档、账户实际配额以及接口真实返回为准。本地 mock 的各类别并发配置均可调整,用于复现不同客户方案或账户等级,不能把某次配置值写成产品的永久上限;迁移到 v3 API 时应另建 profile,并优先用保守的 `3` 并发做首次验证。
|
||||||
|
|
||||||
|
Tripo 的“请求速率限制”和“运行任务并发限制”也不是同一概念。上游任务并发达到限制时,官方接口可能返回 HTTP `429`、业务码 `2000`,并可能携带 `Retry-After`。调用方应记录并遵循 `Retry-After`,采用有限次数、带抖动的退避重试,不能无间隔循环请求。
|
||||||
|
|
||||||
|
官方页面没有声明一个适用于所有账户的固定最大排队长度。因此,本方案不假设、不报告“Tripo 最多可排队 N 个任务”。如需得出真实账户的上游并发或排队结论,应在获准使用积分后做小规模实测,并保留响应码、响应头、任务状态和时间戳作为依据。
|
||||||
|
|
||||||
|
## 4. 两层并发与队列必须分开
|
||||||
|
|
||||||
|
系统中至少存在两层不同的容量控制:
|
||||||
|
|
||||||
|
1. **AI SoulMate 本地任务队列**:由本地应用、数据库和 Redis 管理。它决定平台能接收多少用户请求、任务等待多久、是否丢失或重复,以及 Client 农场端的同步速度。
|
||||||
|
2. **Tripo 上游运行并发**:由 Tripo 按账户和任务类别控制。它决定同一类别能够同时在 Tripo 侧运行多少任务,超过限制可能直接得到 HTTP `429`、业务码 `2000`。
|
||||||
|
|
||||||
|
本地队列可以容纳的任务数不等于 Tripo 并发数;Tripo 某类别仍有空闲槽位也不代表本地服务器没有瓶颈。报告必须分别给出:
|
||||||
|
|
||||||
|
- 本地接收量、队列深度、等待时间、出队速率和失败量。
|
||||||
|
- 模拟的各类别上游活动任务数、被拒绝量、`429/2000` 数量和 `Retry-After`。
|
||||||
|
- 两层之间的调度效率,例如上游有空位但本地任务未及时提交的时间占比。
|
||||||
|
|
||||||
|
## 5. Mock 模式的 POC 限制
|
||||||
|
|
||||||
|
当前 mock 任务状态保存在后端进程内存中,适合单进程 POC 和压测链路验证,但有以下限制:
|
||||||
|
|
||||||
|
- 后端容器或进程重启后,未完成的 mock 任务状态会丢失。
|
||||||
|
- 多后端副本之间不共享 mock 状态,不能据此验证正式集群的一致性。
|
||||||
|
- mock 的等待时间和运行时间是配置值,不代表 Tripo 真实模型耗时。
|
||||||
|
- mock 可以验证调度、结果上传和错误处理,但不能验证 Tripo 生成质量或公网服务稳定性。
|
||||||
|
|
||||||
|
正式多实例压测前,应把任务状态和并发租约迁移到 PostgreSQL 或 Redis,并增加幂等键、租约超时和崩溃恢复机制。在此之前,测试记录必须标记为“单后端进程 POC”。
|
||||||
|
|
||||||
|
## 6. 测试阶段
|
||||||
|
|
||||||
|
### 阶段 0:冻结环境与确认安全开关
|
||||||
|
|
||||||
|
- 记录三台设备的名称、IP、CPU、内存、磁盘、网络、操作系统、Docker/WSL 版本和源代码提交号。
|
||||||
|
- 确认后端为 `TRIPO3D_MODE=mock`,健康接口返回的模式也是 `mock`。
|
||||||
|
- 确认压测环境未配置可被当前流程使用的 Tripo API key,或通过网络日志确认没有 Tripo 外连。
|
||||||
|
- 确认阿里云提示词翻译/优化不在测试请求路径中。
|
||||||
|
- 保存数据库、Redis 和 MinIO 的可恢复备份。
|
||||||
|
|
||||||
|
在中心服务器部署新镜像后,必须按以下顺序启用并验证。`configure-backend-env.sh` 在 mode 已是 `mock` 时也会再次清空 API key 并恢复 loopback 阻断地址,避免重复配置误切回真实上游:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/enable-tripo-mock.sh compose/.env rate-limits-page
|
||||||
|
./scripts/configure-backend-env.sh compose/.env /srv/ai-soulmate/sources/ai-soulmate-server 192.168.3.102 farm-workstation-001
|
||||||
|
./scripts/enable-tripo-mock.sh compose/.env rate-limits-page
|
||||||
|
./scripts/build-backend-image.sh compose/.env /srv/ai-soulmate/sources/ai-soulmate-server
|
||||||
|
./scripts/build-frontend-image.sh compose/.env /srv/ai-soulmate/sources/ai-soulmate-server
|
||||||
|
./scripts/start-backend.sh compose/.env
|
||||||
|
./scripts/start-frontend.sh compose/.env
|
||||||
|
./scripts/verify-backend.sh compose/.env
|
||||||
|
./scripts/verify-frontend.sh compose/.env
|
||||||
|
./scripts/verify-tripo-mock.sh compose/.env
|
||||||
|
```
|
||||||
|
|
||||||
|
首次基线同时用 `model-pages-conservative` 再跑一次敏感性测试。切换 profile 只会修改 `.env`,不会自动改变已运行容器;切换后必须执行 `docker compose --project-name "$(sed -n 's/^BACKEND_COMPOSE_PROJECT_NAME=//p' compose/.env | head -n 1)" --env-file compose/.env -f compose/docker-compose.backend.yml up -d --force-recreate backend`,再运行 `verify-tripo-mock.sh`。每次执行都必须把实际 profile、六类并发、queue/run delay、源代码提交和镜像摘要写入运行元数据,不能直接沿用模板默认值。
|
||||||
|
|
||||||
|
### 阶段 1:空闲基线
|
||||||
|
|
||||||
|
- 在无业务流量状态连续采集至少 15 分钟。
|
||||||
|
- 记录各设备和容器的 CPU、内存、磁盘、网络、进程数、连接数、重启次数和健康状态。
|
||||||
|
- 得到后续负载测试的资源增量参照值。
|
||||||
|
|
||||||
|
### 阶段 2:基础接口与存储基线
|
||||||
|
|
||||||
|
- 分别测试用户端、管理端的健康检查、登录、列表查询、详情查询和静态资源。
|
||||||
|
- 单独测试 PostgreSQL 查询、Redis 读写及 MinIO 小文件和模型文件上传/下载。
|
||||||
|
- 先做单请求正确性检查,再逐级提升并发,避免错误请求形成无效高负载。
|
||||||
|
|
||||||
|
### 阶段 3:Tripo mock 单任务闭环
|
||||||
|
|
||||||
|
先运行公开用户端的零积分端到端冒烟测试。脚本只接受本机、私网或链路本地地址,禁用系统代理与 HTTP 重定向;它在内存中创建随机账号和密码,输出中不会写入密码或 Bearer token。测试会比较生成前后的用户积分、检查提交和完成结果的 `credits_used=0`,并确认模型和预览均指向本地对象存储:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/run-user-e2e-smoke.sh compose/.env
|
||||||
|
```
|
||||||
|
|
||||||
|
每次执行会保留一个带 `bench_` 前缀的隔离测试用户、一个本地 mock 资产和对应任务记录,以便管理端核对。原始 JSON 只记录随机用户 ID、任务 ID、状态转换、耗时、积分数值和脱敏后的存储位置摘要,不记录账号密码、访问 token 或带签名参数的完整 MinIO URL。
|
||||||
|
|
||||||
|
- 每个任务类别至少完成一次提交、排队、运行、完成和结果读取。
|
||||||
|
- 验证模拟模型/图片能够写入本地 MinIO,数据库任务状态、结果地址和本地积分均正确。
|
||||||
|
- 验证失败任务、超时任务、重复请求和容器重启后的 POC 限制表现。
|
||||||
|
|
||||||
|
### 阶段 4:分类并发和拒绝行为
|
||||||
|
|
||||||
|
- 逐项验证 H、P、图像、动画、后处理和网格操作的独立并发池。
|
||||||
|
- 在单类别内从 1 并发逐级增加到该类别配置上限,再增加 1 至 2 个请求验证 HTTP `429`、业务码 `2000` 和 `Retry-After`。
|
||||||
|
- 同时运行两个不同类别,验证它们不会错误地占用同一个全局并发池。
|
||||||
|
- 调整本地 mock 并发配置,复测不同客户配额场景并记录配置快照。
|
||||||
|
|
||||||
|
当前公开用户端可完整走通 H/P 3D 与图像生成路径;动画、后处理和网格操作尚无对应的公开业务提交接口。后 3 类只使用容器内 `tools/tripo_mock_benchmark.py` 验证分类池、状态时间、`429/2000` 和本地 MinIO 结果,不能表述为前端端到端能力。公开业务端到端报告应只统计实际可达的 H/P 3D 与图像链路。
|
||||||
|
|
||||||
|
### 阶段 5:本地排队与端到端链路
|
||||||
|
|
||||||
|
- 让进入平台的任务量高于模拟上游可运行量,观察本地队列深度、等待时间和退避重试。
|
||||||
|
- 验证中心服务器到 Client 工作站的心跳、任务同步、领取、状态回传和断线恢复。
|
||||||
|
- 检查任务是否出现丢失、重复领取、乱序完成或状态永久卡住。
|
||||||
|
- 此阶段仅模拟“任务到达农场端”,不向快造 U1 发起真实打印。
|
||||||
|
|
||||||
|
### 阶段 6:阶梯负载与稳定性
|
||||||
|
|
||||||
|
- 使用固定测试数据,按低、中、高和饱和负载逐级增加并发,每级保持足够时间达到稳定状态。
|
||||||
|
- 找出首次出现明显延迟陡升、错误率增长、队列持续积压或资源耗尽的负载点。
|
||||||
|
- 在安全负载下做长时间稳定性测试,并验证服务重启、网络短时中断和恢复后的数据一致性。
|
||||||
|
- 达到任一停止条件时立即停止增压,不以设备失去响应作为“极限值”。
|
||||||
|
|
||||||
|
当前自动 HTTP 套件只对用户后端与管理后端健康接口执行 `1/5/10/20/40` 阶梯并发,它用于测量框架、代理和基础数据库连通性开销,不代表登录、列表、生成或订单接口的业务容量。套件会把负载期间逐秒容器 CPU、内存、网络、磁盘 I/O、PID、主机 1 分钟负载和可用内存写入 `resources-during-load.csv`;最终客户容量结论仍必须补充带认证的业务接口和长时间稳定性测试。
|
||||||
|
|
||||||
|
### 阶段 7:打印机专项测试
|
||||||
|
|
||||||
|
平台基线和 mock 任务闭环稳定后,再接入快造 U1。打印机阶段单独记录 PIN 配对、IP 变化、发现机制、连接恢复、单机/多机并行打印和打印队列,不与本轮 Tripo mock 容量结论混合。
|
||||||
|
|
||||||
|
## 7. 必须采集的指标
|
||||||
|
|
||||||
|
在将健康检查结果解释为业务容量前,先运行已认证本地业务接口基线:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
BUSINESS_BENCHMARK_REQUESTS_PER_LEVEL=500 \
|
||||||
|
BUSINESS_BENCHMARK_REPEATS=3 \
|
||||||
|
./scripts/run-business-benchmark-suite.sh \
|
||||||
|
compose/.env \
|
||||||
|
business-baseline-$(date +%Y%m%d-%H%M%S)
|
||||||
|
```
|
||||||
|
|
||||||
|
该套件只注册一个随机 `bench_business_` 测试账号,复用 Bearer Token 测试工作流校验、用户资料、项目列表、地址列表和设备列表。请求会经过 JWT 和 PostgreSQL;套件先验证 Redis 健康,Redis 可用时认证链会更新同一用户的滑动会话键。它不会调用 Tripo、对象存储、阿里云或支付。测试账号会留在数据库中供管理端核验;临时明文密码与 Token 不写入结果,Header 文件只放在 `/dev/shm` 并在脚本退出时删除,退出时还会尝试注销 Redis 会话,但已签发 JWT 不具备服务端强制撤销机制。
|
||||||
|
|
||||||
|
所有并发请求复用一个账号,直连 `127.0.0.1` 后端,列表数据量很小。因此结果只代表“单账号热点型、已认证后端 API 短时基线”,不代表多用户分布、前端/Nginx/Tailscale 链路或真实大数据量。资源采样的名义间隔为 1 秒,实际间隔以 CSV 时间戳为准;phase 是采样启动时的近似标签,短场景可能没有独立样本,不能据此精确归因单档峰值。短时阶梯测试只能称为业务 API 基线;稳定容量仍需长时间稳态和独立重复验证。
|
||||||
|
|
||||||
|
| 层级 | 指标 |
|
||||||
|
| --- | --- |
|
||||||
|
| 请求 | 请求总数、成功数、吞吐量、错误率、超时率、HTTP 状态码分布、P50/P90/P95/P99/最大延迟 |
|
||||||
|
| 本地队列 | 入队速率、出队速率、当前/最大队列深度、平均/P95/最大等待时间、积压持续时间、丢失/重复任务数 |
|
||||||
|
| Tripo mock | 各类别活动任务数、配置上限、接受数、`429/2000` 数、`Retry-After` 值、重试次数、模拟运行时间 |
|
||||||
|
| 业务闭环 | 提交到完成总耗时、结果写入耗时、状态一致性、幂等命中、失败恢复、用户/管理端可见时间 |
|
||||||
|
| Client 链路 | 心跳成功率和延迟、任务同步延迟、领取/回传耗时、断线时长、恢复耗时、待处理任务数 |
|
||||||
|
| PostgreSQL | 活跃/等待连接、事务吞吐、查询延迟、慢查询、锁等待、死锁、缓存命中、数据库增长量 |
|
||||||
|
| Redis | 操作速率、连接数、内存、命中率、过期/淘汰键、阻塞客户端、队列相关键数量 |
|
||||||
|
| MinIO | 上传/下载吞吐、首字节和完成延迟、失败率、对象数、存储增长量、磁盘使用率 |
|
||||||
|
| 设备/容器 | CPU、内存、交换区、磁盘吞吐/延迟/空间、网络吞吐/丢包、容器重启、OOM、温度与降频(可获取时) |
|
||||||
|
|
||||||
|
所有指标必须带统一时区的时间戳,并关联测试批次、代码提交、镜像摘要、环境配置、并发模型、请求数据集和测试持续时间。平均值不能代替尾延迟,报告至少保留 P95 和 P99。
|
||||||
|
|
||||||
|
## 8. 停止条件与结论口径
|
||||||
|
|
||||||
|
建议在出现以下任一情况时停止继续增压:
|
||||||
|
|
||||||
|
- 持续错误率或超时率超过测试预先设定的阈值。
|
||||||
|
- P95/P99 延迟连续多个采样窗口恶化且不能恢复。
|
||||||
|
- 本地队列只增不减,已无法在合理时间内清空。
|
||||||
|
- CPU 长时间饱和、内存接近耗尽、发生 OOM、磁盘空间不足或磁盘延迟异常。
|
||||||
|
- 数据丢失、重复执行、状态不一致或关键服务反复重启。
|
||||||
|
|
||||||
|
最终报告应给出“稳定运行区间”“出现退化的起点”和“明确不可接受区间”,不要只给一个没有持续时间和错误率背景的最高并发数字。对外提供客户配置建议时,还应保留安全余量,并明确 Tripo 上游配额、真实生成耗时和打印机数量需要另行校准。
|
||||||
|
|
||||||
|
## 9. 进入真实 Tripo 联调的前置条件
|
||||||
|
|
||||||
|
只有在以下条件全部满足后才进入真实联调:
|
||||||
|
|
||||||
|
- 本地用户端、管理端、中心基础设施和 Client 链路的基线测试通过。
|
||||||
|
- mock 模式下的分类并发、拒绝、退避、本地排队和恢复行为符合预期。
|
||||||
|
- 已确认实际 Tripo 账户的模型权限、套餐、余额和各类别并发配额。
|
||||||
|
- 已设置严格的请求数量上限、预算上限和人工停止开关。
|
||||||
|
- 已准备专用 API key,并保证它不会写入 Git、日志或测试报告。
|
||||||
|
|
||||||
|
届时先做最小数量的冒烟请求,再逐步扩大;不能直接用真实 API 执行本方案中的饱和压测。
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
# AI SoulMate POC benchmark evidence manifest
|
||||||
|
#
|
||||||
|
# Generated: 2026-08-13 (Asia/Shanghai)
|
||||||
|
# Source: /srv/ai-soulmate-local-deployment/results/raw
|
||||||
|
# Algorithm: SHA-256
|
||||||
|
# File count: 122
|
||||||
|
#
|
||||||
|
# Raw files remain ignored by Git. This tracked manifest detects later changes
|
||||||
|
# to the locally copied evidence; it is not a digital signature or trusted timestamp.
|
||||||
|
|
||||||
|
0c69e57ec9db2445e672b456da825b0897662465214d88dfbaa60364374b39a7 business-baseline-20260813/address-list-c10-r1.json
|
||||||
|
b033e1e80cf77ed97b1480bf7bdf2141974e3da82e99b78749d52cd86667eabf business-baseline-20260813/address-list-c10-r2.json
|
||||||
|
95589bb736e2dc4dacac7a64842f821e7564833521bb25ffb8c404ac8fc03b7c business-baseline-20260813/address-list-c10-r3.json
|
||||||
|
2cfa1ce51241309f45544cfe541ce6057c454ffdafd210ff0f8d8a7ef345f6bf business-baseline-20260813/address-list-c1-r1.json
|
||||||
|
919a5a198f3e3ff13a89b606eb2d470d4b98ab9fd777f88318cf0f78604f7e3c business-baseline-20260813/address-list-c1-r2.json
|
||||||
|
03fb7b7aa986ca4bffa253713e390828b29aa6eb7fe785eca640e4c7076c923d business-baseline-20260813/address-list-c1-r3.json
|
||||||
|
fb2f21a1d082b319b5585115cc1c5fc6c1e521e81aec5f863193d8255236c3cb business-baseline-20260813/address-list-c20-r1.json
|
||||||
|
81e8d5768f9c323973fbd16023c36c1a65de0a235bdc59591d951d1bcb152ab1 business-baseline-20260813/address-list-c20-r2.json
|
||||||
|
d75040ec651bddca8c9b0a0404933307658f7c2285f19c2bcd274dd3cf6b24cd business-baseline-20260813/address-list-c20-r3.json
|
||||||
|
9f0a1ef8bf6ca402fe62ac88c69e4037df73b9b7f943cdd19daacef46efa45cd business-baseline-20260813/address-list-c40-r1.json
|
||||||
|
3f935a104ab4a8491c10327b43b934bae074aaf730e784408e7664abd451349d business-baseline-20260813/address-list-c40-r2.json
|
||||||
|
1267823d6cf41aac545f16a75d4c27ecf95d2822ed2c5d2733c727b73fde3d08 business-baseline-20260813/address-list-c40-r3.json
|
||||||
|
b7b842aa56e6069420617cb28a5d0440f7709257a84630957714136b91c331c2 business-baseline-20260813/address-list-c5-r1.json
|
||||||
|
0d18288faf8f1cea355bc4951bb2430275f4df61aaeeec86bc0f8d2cda67a332 business-baseline-20260813/address-list-c5-r2.json
|
||||||
|
4bf32cc061671d2a88a58d42837e3b2db2e76960336461f9acee2b7d28dbfca0 business-baseline-20260813/address-list-c5-r3.json
|
||||||
|
d37df1a5c59589d366146ea923cf120af8c590ec1356e06510046c9e8ae029d5 business-baseline-20260813/address-list-c80-r1.json
|
||||||
|
9a9328454d54b468e9856149d543d7ccb59aedf09aeab0fec4e76615c90d3c69 business-baseline-20260813/address-list-c80-r2.json
|
||||||
|
ee088fa855f1b300a92ea3dabf195743bced319be13c2cfd97327b57ee515162 business-baseline-20260813/address-list-c80-r3.json
|
||||||
|
88a03bfd764fb14c151862c0ecfbca4aba3c972da4305f5b3994166358e8f187 business-baseline-20260813/device-list-c10-r1.json
|
||||||
|
f34ed6f24c83b9765357006669ddda7585657e5758954d70bff5fff3bb55d568 business-baseline-20260813/device-list-c10-r2.json
|
||||||
|
901312087bbc567ba6b27c50958e4045e949712a9cf35b4eb0fc5fbd7ee65bb0 business-baseline-20260813/device-list-c10-r3.json
|
||||||
|
9471a09782943a8234d7288eff993e1a7f6114a32386c6e7bb75ab357bfc3612 business-baseline-20260813/device-list-c1-r1.json
|
||||||
|
65ebe6f0862ae64dc818fdf9243b45db224c3e5e082e1077975a1bc16da905fd business-baseline-20260813/device-list-c1-r2.json
|
||||||
|
e96932793d9aa79f6c56c058f564d6fad52e2222e8be7b148d77e65190dd0e52 business-baseline-20260813/device-list-c1-r3.json
|
||||||
|
f7d527502d0a2907ace024730e8963a946926b0c0882e188a13798c125b7b013 business-baseline-20260813/device-list-c20-r1.json
|
||||||
|
71b33aabe75c854432a5ab5c0609e0ed1043d1995d8814e7cc9effb021769fb5 business-baseline-20260813/device-list-c20-r2.json
|
||||||
|
03606a1f9e12c6ed456caabc621a43eb896351282bbcde4bf61eb0509e279146 business-baseline-20260813/device-list-c20-r3.json
|
||||||
|
9e85a70b240e6befd3f2abd950c35320dbbc7379bf187339b7cbffa67ccdb94f business-baseline-20260813/device-list-c40-r1.json
|
||||||
|
3bc7309490b67d6c43913ba25523965450bf5d4fd4147c3e9ddb37881b53614a business-baseline-20260813/device-list-c40-r2.json
|
||||||
|
48a370f2348c4f2a64fba2fe4f915764b222c2985b3fe34fb5fcd1609d66e6db business-baseline-20260813/device-list-c40-r3.json
|
||||||
|
5e8aef9aede487e8834d049349364f10d828e28244c326106019ff3db9b43b4c business-baseline-20260813/device-list-c5-r1.json
|
||||||
|
7e947c0ea615be2322601a6f3212bf744a8499ddf67aea8fd16ca9c5dced8bc2 business-baseline-20260813/device-list-c5-r2.json
|
||||||
|
4cf4078211a6f4b5c24b8d162f01b089c3a1a53f26fd882ea6ab3da9f87dc57f business-baseline-20260813/device-list-c5-r3.json
|
||||||
|
c3f75f05984ae54cbb2f2647f18fdd0aa193dd3aae4f7b2840c36573718e7642 business-baseline-20260813/device-list-c80-r1.json
|
||||||
|
d1458cef2f6e7b81c74f523b7bcf9231eb4d56cc3cc03da13d473e689fdbbb02 business-baseline-20260813/device-list-c80-r2.json
|
||||||
|
a742dd3431b2fb9b295d06ccac55c9ead67fed73165d158f46f07071e8dd2c93 business-baseline-20260813/device-list-c80-r3.json
|
||||||
|
1f86949ccfe51190597825f42ed7609897ac95291abc03e7a454520effe4412a business-baseline-20260813/projects-list-c10-r1.json
|
||||||
|
5113e5478fd4d3813c6887b71cfb4f40defe4225c1884242c89e2b4c3bcb95f5 business-baseline-20260813/projects-list-c10-r2.json
|
||||||
|
c07c979f8f088e8c7b5df954d79e8430ecd9528040b787dc9915f1a14ee77857 business-baseline-20260813/projects-list-c10-r3.json
|
||||||
|
2df3188fbd0a05a33a07bc9cf01806066a73fd5381541163d53a26c17989c840 business-baseline-20260813/projects-list-c1-r1.json
|
||||||
|
1bcaaf217fdde04984333be60382d711e2693080572cf6c1d0ae2198147e4f56 business-baseline-20260813/projects-list-c1-r2.json
|
||||||
|
5d876cbcf2c1d72888d670cdc56449c873a4c3ce425144593bcae47d18f5f528 business-baseline-20260813/projects-list-c1-r3.json
|
||||||
|
ca6677f53d4cbd4b12e564ecff8d7df49b8e68a16ec53debb08e5ce5dd74490e business-baseline-20260813/projects-list-c20-r1.json
|
||||||
|
4fc875177317787c768525ef6487d10748281abca672e818608200fc130264ce business-baseline-20260813/projects-list-c20-r2.json
|
||||||
|
8c56c837d6cf3e33b1396ff9ab4b36b8a2c6881ba14b1eb15cfcac34d3088b22 business-baseline-20260813/projects-list-c20-r3.json
|
||||||
|
b9183cf160d97bdcd7b2944c4c771272011bbe8ffbd3c9e8dc5bd9cb0dd8808c business-baseline-20260813/projects-list-c40-r1.json
|
||||||
|
1795e1987d9dc0aa7276ca17e13a5d450e415d2d918237cb89a0070433682b26 business-baseline-20260813/projects-list-c40-r2.json
|
||||||
|
bbd384d229b11ba238501c8396745fb7caab98c059565da44e8e677c3365997c business-baseline-20260813/projects-list-c40-r3.json
|
||||||
|
dbd6ab36f7b22a38a446c58a6b3cb579231c3c08c4db7618a543ab3c9fd49daa business-baseline-20260813/projects-list-c5-r1.json
|
||||||
|
cc4b37b267cf0e74adcf8645b8a9f8cf177d0b2247eeabaf3dc1b9ab861d000a business-baseline-20260813/projects-list-c5-r2.json
|
||||||
|
45ab3a0ee17ed4574d84138c83e3cdf0395cb30b815677f7bcc35363a3a830a9 business-baseline-20260813/projects-list-c5-r3.json
|
||||||
|
0951acbeb821a2ca93b79b6bc286f27062c8d82ed339d55f918b954bb46664d7 business-baseline-20260813/projects-list-c80-r1.json
|
||||||
|
aee014f8e1b3db72f7ddba8a8d5bd0bd23996737e191e76f714d23f20cc9e99f business-baseline-20260813/projects-list-c80-r2.json
|
||||||
|
b3040fbb6aaaa6ef904bee7013af38515b4aa94249ca11ad19f45f0aeffc5810 business-baseline-20260813/projects-list-c80-r3.json
|
||||||
|
db005025e74902570a9d1b49a0bafb9ef5d71690c63c8e22f96c78e18b16363b business-baseline-20260813/resources-during-load.csv
|
||||||
|
58f09baa45eac9a7edea97239a399eeacaf094a87557b143fd892f92ab48f321 business-baseline-20260813/session-metadata.json
|
||||||
|
9b297a254eb885fb505efce08b7844624dce516a11a5484a58d959602a948f67 business-baseline-20260813/snapshot-after.txt
|
||||||
|
50b7443dc869b9be9f30f8452bcd67c4bb8019cc2f830ed7b46ed566acdee6f0 business-baseline-20260813/snapshot-before.txt
|
||||||
|
6a97352e59ff2cd92f9c33f1625867f650a3b2887bd27c49e88e80e0673ee367 business-baseline-20260813/summary.json
|
||||||
|
be56624975d28533cc2d5bb1253ad8757b552a9725f8e34cd13c37cac46ff046 business-baseline-20260813/summary.md
|
||||||
|
54a40ce4beba0841f75530a5423c5f6c38df04fb32dc15a0c83636e2a70c0552 business-baseline-20260813/user-profile-c10-r1.json
|
||||||
|
26cb3e3f33c92d30264b3de8cabcb881b64c2cfc1a15c49d3b07bae573a66e1a business-baseline-20260813/user-profile-c10-r2.json
|
||||||
|
b0c07129af8fb164fd7546f567a062454a733a7e066de19386ba5c006e45122d business-baseline-20260813/user-profile-c10-r3.json
|
||||||
|
a53d60e5c71feba642d44c7d543d4f13e894a1a1f68d422a98c5c22f97be85be business-baseline-20260813/user-profile-c1-r1.json
|
||||||
|
29b728c4c50deb7fd13986dfa8e3fd4f83960c245be2b3e2ed3369984e187715 business-baseline-20260813/user-profile-c1-r2.json
|
||||||
|
fd48dc74b3480a129200d425071cd2b1accb54c144e430f13c2c866619992080 business-baseline-20260813/user-profile-c1-r3.json
|
||||||
|
6225c948dc22a17c7b355e8a8a6695b82b836319a6ef2558cd04d300684ac066 business-baseline-20260813/user-profile-c20-r1.json
|
||||||
|
9641312b6f550c1fac0c6a0241a3901f9b6d93f7692e1c68b3a299a4c46c2178 business-baseline-20260813/user-profile-c20-r2.json
|
||||||
|
05e545af9d0443a3612b39bcfbdc05d91776bf2fe0700f82f037d9da4eeaf40c business-baseline-20260813/user-profile-c20-r3.json
|
||||||
|
4e3d07836c2f09ff09476d7c7fde9fb9b1855175fc0180a18363befb710cd431 business-baseline-20260813/user-profile-c40-r1.json
|
||||||
|
ecce772cc41d36fcc78a55390734a6e62889ca61b5f0732012307451bd0d87bd business-baseline-20260813/user-profile-c40-r2.json
|
||||||
|
1202533b05d066f74d2971182ec9e78081428808613275f1d0715cc609097734 business-baseline-20260813/user-profile-c40-r3.json
|
||||||
|
4931bb3ae1a535fec4d5acfdf83b53bf1a13d57366801bbb0971373b67262099 business-baseline-20260813/user-profile-c5-r1.json
|
||||||
|
4d35f4b103b80abe1e3a6526fc9ef08909e430af81f9fafb92004ea4a095609f business-baseline-20260813/user-profile-c5-r2.json
|
||||||
|
464438b5cd8cebdbff6375e65f52b90633c9b35e0f752eb8ccdbce4237e5b2eb business-baseline-20260813/user-profile-c5-r3.json
|
||||||
|
5a9b823d71e1eddc01d95cd1664851d26cc533379fdb059d5a02592c35ba1444 business-baseline-20260813/user-profile-c80-r1.json
|
||||||
|
ce1043c9df1919ba5b67fb4f420f571b3d76d5f515cc8f34766063f5a1fdb2c9 business-baseline-20260813/user-profile-c80-r2.json
|
||||||
|
443ed9eb204ae6ca20a5a12b2660382aa77d7b04abfd0cb02b73f00735fcecbf business-baseline-20260813/user-profile-c80-r3.json
|
||||||
|
e2bab2427f8e893cdf55881e97b17ce09f3e13909ae59e17956bff351c13352b business-baseline-20260813/workflow-validate-c10-r1.json
|
||||||
|
8c9a842bc24e05728265d1c5e760e7eb30b5545e0a60a9cc34e6dbbce7901bc0 business-baseline-20260813/workflow-validate-c10-r2.json
|
||||||
|
8ce7e565ce9786d3a16384af9fdf85edea105c2d47decc1a7dab0e9eaf2e8f03 business-baseline-20260813/workflow-validate-c10-r3.json
|
||||||
|
c854aa1c6e8968f715ba2e9cd9764f5621779db8a6de16169aca9dc42353b4de business-baseline-20260813/workflow-validate-c1-r1.json
|
||||||
|
b12b96a02c1a76b2a79664ee17e22511356607c3073e4aeced94a61b9ba2cfdd business-baseline-20260813/workflow-validate-c1-r2.json
|
||||||
|
b3013e261e16a23366da4e0868aa5c7d8a6db57cd36e7a982fddd227a4dea544 business-baseline-20260813/workflow-validate-c1-r3.json
|
||||||
|
0a890ffcbf8330bfea1a406d17aab898320d7c68f60bc632e8a300f842305b6c business-baseline-20260813/workflow-validate-c20-r1.json
|
||||||
|
4b37a9004a21ca1ebeefa2977de5c5115659e97b04133f00620da834082a6754 business-baseline-20260813/workflow-validate-c20-r2.json
|
||||||
|
0de9acd2681225101df0faa43e3452d0faaf75d51c58baf2087a4e6f9d90f37e business-baseline-20260813/workflow-validate-c20-r3.json
|
||||||
|
1394c2e2e84e3bdf31b4419fad07efc3a862ece3ae41d311d9b84699589d7af2 business-baseline-20260813/workflow-validate-c40-r1.json
|
||||||
|
8445c8ec250bb1ebf5fb9745b36d8118239d420b55f5630e90c92c035ffe2e76 business-baseline-20260813/workflow-validate-c40-r2.json
|
||||||
|
c782acafddb57ebc080f567f7f685768219000ba59dc5896f98af5cdd232d6b6 business-baseline-20260813/workflow-validate-c40-r3.json
|
||||||
|
258f47c2d8b01bc7f62b27cf0d482b77e9cf23a115f276731a6f78eeafe2b60e business-baseline-20260813/workflow-validate-c5-r1.json
|
||||||
|
9547ebc4659343096af5700d0cea539354fca22911b09b929b43df053b502d97 business-baseline-20260813/workflow-validate-c5-r2.json
|
||||||
|
1f1cf3436142f5006d947f4f2f738a592cb288b32b279860c01d86287df7579b business-baseline-20260813/workflow-validate-c5-r3.json
|
||||||
|
3bf642007ff4dfb722a4f0aa20b2f6bb129614103db46edc2db80c867f26708e business-baseline-20260813/workflow-validate-c80-r1.json
|
||||||
|
20f1100307da88f6bf1f96f74b7084b25996a3b67ee9fac3f2da10b23d63dafe business-baseline-20260813/workflow-validate-c80-r2.json
|
||||||
|
c63449e1c8253f1e7e37391e505c067587debf905f8b2ee9b0cd294cb1f822f8 business-baseline-20260813/workflow-validate-c80-r3.json
|
||||||
|
8624ada1846c4a936adb369c4af5cd7e6451fa746d9ed4dcc8f4aba439d78972 e2e-conservative-20260813/resources-during-user-e2e.csv
|
||||||
|
03588948f6fd8d2563687a8fbf7229ea07edeb6900e558cd94992890bdd9769a e2e-conservative-20260813/user-e2e-smoke.json
|
||||||
|
dde24553c0e49a2efe8e22e688b1f51826b5e5d17a049f2b9893993326650937 e2e-conservative-20260813/user-e2e-snapshot-after.txt
|
||||||
|
e8e1ab1d1c549361a0456e7d8521f70597bc53d2638c6d6007ed9b9a2683ba12 e2e-conservative-20260813/user-e2e-snapshot-before.txt
|
||||||
|
18b9780a8c862483a775f7d000dd253905dfd70d4655f5f5c37eaeb8ce546f82 health-baseline-20260813/admin-health-c1.json
|
||||||
|
fe745ebca9c94b1322af6ed22c34e144e0860b816615e3c70fcf5b166290769c health-baseline-20260813/admin-health-c10.json
|
||||||
|
7e8063a9f21b5feb997b3818fcad9741d5e9429763bbf8fea306d64161fdd4b6 health-baseline-20260813/admin-health-c20.json
|
||||||
|
94ec6b94554233be9fe9e6dc34da84ff06b56d378ac52f64ace5395f6a38ca73 health-baseline-20260813/admin-health-c40.json
|
||||||
|
2c277dae73a91ab6ed750495789af1584d8434d0a0e36456269a97031365fd89 health-baseline-20260813/admin-health-c5.json
|
||||||
|
70384eb082dc2f9a2a4f1a49f414144b2847f7dd01983be7fe3fedd9766d431f health-baseline-20260813/resources-during-load.csv
|
||||||
|
b8cc38b67450ef3a5f4fdb7436e204daba3995a6b2911ba9da609e1c1ae33fd7 health-baseline-20260813/snapshot-after.txt
|
||||||
|
d3f48211f490d02fbe1a1f1920e361f3b603bbb06b3db0f3caefe8674ec10940 health-baseline-20260813/snapshot-before.txt
|
||||||
|
aaa8a7c942891b19e71bcb6ddbe373724ccee32c2dd270548d92412658286bbd health-baseline-20260813/summary.md
|
||||||
|
533be155fedc26dc3d1747079eb5ab166f5f99035f26794a9c43e56d6e9aaef5 health-baseline-20260813/user-health-c1.json
|
||||||
|
cb40bed48c9c6c1ff702b3927f5c35651ae5995c80b91c4e6ce4fd906c4cd288 health-baseline-20260813/user-health-c10.json
|
||||||
|
efdc1b0601fa600bc485e1626e9cac5b6defed8dd0ec027fd0fe33275b46caf4 health-baseline-20260813/user-health-c20.json
|
||||||
|
ec3a877770ddd0e006e3b784f68627760d7f611e2047bca6f02690a38337f30c health-baseline-20260813/user-health-c40.json
|
||||||
|
a9f1337d82d1f4e12ae8cebc5f5280c0fe254bb47f6342fc2634298269c65fd0 health-baseline-20260813/user-health-c5.json
|
||||||
|
c1ff07a2066dcd43f44ca06803773b2feebe7427f8852ffcc4b25bae4b9fc485 tripo-conservative-20260813/resources-during-tripo-mock.csv
|
||||||
|
806ebb6206fd202d1efb53c2800c1f3065d9cdff80b4dc12f4fb2f632bb74825 tripo-conservative-20260813/tripo-mock-model-pages-conservative.json
|
||||||
|
684b708daf9a0fc9c5bb4836c0b85e177555e070141c192ef595eacd542844d8 tripo-conservative-20260813/tripo-mock-snapshot-after.txt
|
||||||
|
18bd9262bc2f430347a769b05ec209f8ed5155cd982e24b852176fe19997c895 tripo-conservative-20260813/tripo-mock-snapshot-before.txt
|
||||||
|
ecb8dd312310d5ef0716f43f90e0fcaf4dbed4c7ba6629b7112c5055fd11ec36 tripo-rate-limits-20260813/resources-during-tripo-mock.csv
|
||||||
|
c204a102b8afd59c4d9400034a77c81d95a505db1e5a2859ea2a95df1917b102 tripo-rate-limits-20260813/tripo-mock-rate-limits-page.json
|
||||||
|
99ab629538e0d6d3d96347ea954307b7a5475247684dcbed902830cb39fdc542 tripo-rate-limits-20260813/tripo-mock-snapshot-after.txt
|
||||||
|
a4aba40035e6aa750982b92618aa62002b5efd8cf85ab05e0e5cf4694f5bea64 tripo-rate-limits-20260813/tripo-mock-snapshot-before.txt
|
||||||
@@ -0,0 +1,403 @@
|
|||||||
|
# AI SoulMate 本地部署 POC 软硬件适配与性能报告
|
||||||
|
|
||||||
|
- 报告日期:2026-08-13
|
||||||
|
- 测试时区:Asia/Shanghai(UTC+8)
|
||||||
|
- 被测节点:HP ZCentral 4R 中心服务器
|
||||||
|
- 报告性质:单机 POC、短时容量基线与零真实 Tripo 积分功能验证
|
||||||
|
- 结论适用范围:仅适用于本报告记录的硬件、代码、容器配置、数据集和请求路径
|
||||||
|
|
||||||
|
## 1. 执行摘要
|
||||||
|
|
||||||
|
本轮完成了中心服务器上的 AI SoulMate 用户端、AI SoulMate 管理端、PostgreSQL、Redis 和 MinIO 本地化运行验收,并在不配置真实 Tripo API Key 的情况下完成了用户生成闭环、Tripo 分类并发契约测试及已认证业务接口短时压测。
|
||||||
|
|
||||||
|
核心结果:
|
||||||
|
|
||||||
|
- 用户端、管理端、PostgreSQL、Redis 和 MinIO 在测试结束后的复核中均正常;用户健康接口报告数据库已连接,管理端 Actuator 报告 `UP`。
|
||||||
|
- 5 个已认证轻量业务场景按并发 `1/5/10/20/40/80`、每档 500 个计入统计的请求、重复 3 次,共有 `45,000` 个请求计入结果;全部返回 HTTP 200,无传输错误或超时。另有每轮 5 个预热请求,不计入统计。
|
||||||
|
- 吞吐在并发 10–20 左右进入平台区。并发 20 的各场景 P95 中位数为 `79.29–86.35ms`;到并发 40 时升至 `198.86–220.86ms`,同时多数场景吞吐下降;并发 80 的 P95 进一步升至 `518.43–567.91ms`,且没有形成有意义的吞吐增长。
|
||||||
|
- 在当前“单后端进程、单测试账号、轻量数据、本机直连”的条件下,下一阶段应测试 **10/15/20 个同时在途 HTTP 请求**,其中 c20 是本轮已经测过的候选上沿。并发 40 只作为短时突发候选,并发 80 不建议常态运行。这里不是“并发用户数”,也不是生产容量承诺。
|
||||||
|
- Tripo 测试使用本地 Mock,真实 API Key 为空,上游地址为不可外联的回环哨兵。两套 profile 分别接受 41 和 25 个模拟任务,刻意的 6 个“限额+1”请求均产生状态 429、业务码 2000 和 `Retry-After: 10` 的服务层契约异常;专项测试另行验证了 HTTP handler 映射。所有接受任务完成、`consumed_credit=0`,并返回本地 MinIO 模型与预览 URL。
|
||||||
|
- 单次用户端生成闭环完成:约 2.04 秒观察到运行态、约 10.20 秒完成,用户积分 `100 → 100`、资产 `0 → 1`。本轮没有使用真实 Tripo 生成接口,因此没有消耗本轮生成积分;该结论不等同于对 Tripo 账户账单的外部审计。
|
||||||
|
|
||||||
|
### 1.1 结论矩阵
|
||||||
|
|
||||||
|
| 范围 | 状态 | 本轮可下结论 | 本轮不可下结论 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| 中心用户端 | 已验证 | 页面、代理、后端、数据库、Redis、MinIO 连通;已认证轻量 API 短时基线通过 | 多用户生产容量、真实大数据量、长稳 SLA |
|
||||||
|
| AI SoulMate 管理端 | 部分验证 | 页面可访问、健康为 `UP`、此前人工登录成功 | 已认证列表、统计、登录并发和报表容量 |
|
||||||
|
| Tripo 集成 | 本地 Mock 已验证 | 零真实 Key 测试路径、分类限额、429 契约、状态流转、本地落盘 | 真实账户额度、真实排队、生成耗时、质量与 Tripo SLA |
|
||||||
|
| Client 农场端 | 功能曾验证 | 工作站曾运行独立 PostgreSQL、Java 后端和前端;页面、登录、心跳曾通过 | 当前在线状态、长稳、订单同步容量、多打印机能力 |
|
||||||
|
| 快造 U1 | 未验证 | 暂无 | PIN 配对、动态 IP、断线恢复、打印队列和多机并行 |
|
||||||
|
| 停电恢复 | 人工观察 | 非计划停电后重新开机,中心服务恢复可用 | 正式 RTO/RPO、在途任务恢复和数据完整性证明 |
|
||||||
|
|
||||||
|
## 2. 三台设备与测试位置
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
PC["主电脑\n远程操作\n100.88.179.28"]
|
||||||
|
SERVER["中心服务器 hp\n用户端 + Admin\nPostgreSQL + Redis + MinIO\n100.81.206.1 / 192.168.3.102"]
|
||||||
|
CLIENT["联想百应工作站\nClient + 独立 PostgreSQL\n100.111.151.72"]
|
||||||
|
PRINTER["快造 U1\n待接入"]
|
||||||
|
PC -->|"Tailscale / SSH / 浏览器"| SERVER
|
||||||
|
PC -.->|"Tailscale / SSH"| CLIENT
|
||||||
|
CLIENT -->|"平台 API"| SERVER
|
||||||
|
CLIENT -.->|"同局域网 Wi-Fi、PIN/发现待验证"| PRINTER
|
||||||
|
```
|
||||||
|
|
||||||
|
| 设备 | 角色 | 本轮实际情况 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 主电脑 | 操作与观察 | 用于 SSH、浏览器、代码检查和证据归档;不运行被测服务 |
|
||||||
|
| HP 中心服务器 | 主要被测系统 | 运行用户前后端、管理前后端、PostgreSQL、Redis、MinIO;业务压测也从该机发起 |
|
||||||
|
| 联想百应工作站 | Client 农场端 | 曾运行 Client 三容器;本轮 45,000 请求不经过该工作站,最终复核时 Tailscale 显示离线 |
|
||||||
|
|
||||||
|
业务压测直接请求中心服务器 `http://127.0.0.1:3001`。因此结果没有包含用户前端 Nginx、浏览器、Tailscale、Wi-Fi、主电脑、Client 或公网链路时延;这会使结果相对真实远程访问更乐观。
|
||||||
|
|
||||||
|
## 3. 软硬件与版本基线
|
||||||
|
|
||||||
|
### 3.1 中心服务器
|
||||||
|
|
||||||
|
| 项目 | 本轮基线 |
|
||||||
|
| --- | --- |
|
||||||
|
| 设备 | HP ZCentral 4R Workstation,物理机 |
|
||||||
|
| CPU | Intel Xeon W-2225,4 核 8 线程,单路 |
|
||||||
|
| 内存 | 32GB ECC DDR4,单条;2GiB Swap |
|
||||||
|
| 存储 | 单块约 1TB Samsung NVMe,ext4;无 RAID |
|
||||||
|
| GPU | 无已验证 NVIDIA/CUDA 环境;本轮不做本地三维模型推理 |
|
||||||
|
| 操作系统 | Ubuntu 22.04.5 LTS |
|
||||||
|
| 本轮内核 | `6.8.0-136-generic` |
|
||||||
|
| Docker / Compose | Docker Engine `29.7.1`;Docker Compose `5.4.0` |
|
||||||
|
| 部署仓库提交 | `c25b180021c6a0b44c7b9b5afc1bafb00a082855` |
|
||||||
|
| 用户服务源码提交 | `2a5d552fab354ec5c68ecfb97e72fa2e47418a92` |
|
||||||
|
| 用户后端镜像 | `ai-soulmate-backend:2a5d552fab35`;`sha256:918c5f462dcec040b82fc9370899242a1ae78e41112e94bc30511178421b29a3` |
|
||||||
|
| 用户前端镜像 ID | `sha256:4400cd750f65e4820ae9be37a583b3039fe1a0e4e9c72ca06d5a0137d217c806` |
|
||||||
|
| Admin 源码/镜像标签 | `3164f6f2f08c73401e9fdd1a2d34deb8c334460f` / `3164f6f2f08c` |
|
||||||
|
|
||||||
|
旧硬件基线中的内核 `5.19.0-32` 和“Docker 待安装”是 2026-08-05 的历史状态;本表使用 2026-08-13 的运行时复核值。
|
||||||
|
|
||||||
|
### 3.2 基础镜像
|
||||||
|
|
||||||
|
| 镜像 | 本轮运行节点解析摘要 |
|
||||||
|
| --- | --- |
|
||||||
|
| PostgreSQL | `postgres:16-alpine@sha256:57c72fd2a128e416c7fcc499958864df5301e940bca0a56f58fddf30ffc07777` |
|
||||||
|
| Redis | `redis:7-alpine@sha256:e7723ff73d963f5cc6d9c4643ea3d989527a402a319239054e9472a7fb9219a2` |
|
||||||
|
| MinIO | `minio/minio@sha256:14cea493d9a34af32f524e538b8346cf79f3321eff8e708c1e2960462bd8936e` |
|
||||||
|
|
||||||
|
### 3.3 容器资源上限与入口
|
||||||
|
|
||||||
|
| 服务 | CPU 上限 | 内存上限 | 宿主机入口 |
|
||||||
|
| --- | ---: | ---: | --- |
|
||||||
|
| 用户后端 | 2.0 | 4GiB | `127.0.0.1:3001` |
|
||||||
|
| 用户前端 | 1.0 | 1GiB | `192.168.3.102:8080` |
|
||||||
|
| Admin 后端 | 1.5 | 2GiB | `127.0.0.1:8088` |
|
||||||
|
| Admin 前端 | 0.5 | 512MiB | `192.168.3.102:8081` |
|
||||||
|
| PostgreSQL | 2.0 | 2GiB | `127.0.0.1:5432` |
|
||||||
|
| Redis | 1.0 | 512MiB | `127.0.0.1:6379` |
|
||||||
|
| MinIO | 2.0 | 1GiB | `192.168.3.102:9000`;控制台仅回环 `9001` |
|
||||||
|
|
||||||
|
这些数值是容器的最大约束,不是物理资源预留。CPU 上限总和大于 4 个物理核,服务同时繁忙时仍会争用主机 CPU。用户后端启动命令为单个 `uvicorn main:app --host 0.0.0.0 --port 3000` 进程,没有配置多 worker。
|
||||||
|
|
||||||
|
PostgreSQL、Redis 和 MinIO 均使用本机 Docker 命名卷,数据保存在中心服务器本地磁盘;不是连接云数据库、云 Redis 或云 OSS。PostgreSQL 与 Redis 只绑定回环地址,MinIO API 为 Client/浏览器文件访问绑定局域网地址。
|
||||||
|
|
||||||
|
### 3.4 Client 工作站
|
||||||
|
|
||||||
|
工作站的采集基线为 AMD Athlon Gold 3150C(2 核 4 线程)、8GB 内存、256GB SATA SSD、Windows 11。Docker Desktop Linux 引擎可见 4 个逻辑 CPU、约 3.55GiB 内存。该机适合 Client 功能适配和低并发验证,不适合本地模型推理或代表高并发农场端。
|
||||||
|
|
||||||
|
Client 后续已完成过以下状态:
|
||||||
|
|
||||||
|
- 独立 PostgreSQL 15、Java 后端、Vue/Nginx 前端三容器启动;
|
||||||
|
- 清理了 5 台演示打印机和 50 条演示订单,保留本地商家基础数据;
|
||||||
|
- 页面与登录可用,`farm-workstation-001` 心跳曾成功;
|
||||||
|
- 前端本地端口 `3010`,后端 `127.0.0.1:3002`,数据库 `127.0.0.1:15433`;
|
||||||
|
- Client 通过平台地址访问中心服务,不直连中心 PostgreSQL、Redis 或 MinIO。
|
||||||
|
|
||||||
|
本轮最终检查时工作站 Tailscale 显示离线、最近出现约 21 分钟前,可能与息屏/休眠有关,但原因尚未最终确认。因此本报告不把工作站描述为“当前在线”,也不据此判断 Docker 一定停止。
|
||||||
|
|
||||||
|
## 4. 零真实 Tripo 积分安全边界
|
||||||
|
|
||||||
|
本轮生成相关测试采用以下强制条件:
|
||||||
|
|
||||||
|
1. `TRIPO3D_MODE=mock`;
|
||||||
|
2. `TRIPO3D_API_KEY` 为空;
|
||||||
|
3. `TRIPO3D_BASE_URL=http://127.0.0.1:9/tripo-mock-blocked`,是不可外联的回环哨兵;
|
||||||
|
4. Mock 提交和查询在创建 `aiohttp` 外部会话前短路;
|
||||||
|
5. 容器内校验确认 `billable_credits(...) == 0`;
|
||||||
|
6. 用户 E2E 对比生成前后积分并验证本地 MinIO 地址;
|
||||||
|
7. 测试请求不调用阿里云提示词优化/翻译、支付、短信、邮件或 OAuth 路径。
|
||||||
|
|
||||||
|
源码专项测试结果为 `23 passed`。测试结束后再次执行 `verify-tripo-mock.sh`,容器运行时仍为 `mock/rate-limits-page`,API Key 为空、回环哨兵有效。
|
||||||
|
|
||||||
|
因此,可以确认本轮被测生成路径没有创建真实 Tripo 生成请求,应用侧积分未减少。本报告不把该结果扩大为“生产系统的任何路径都绝无公网流量”,也不代替 Tripo 控制台的账单审计;历史模型外链代理是不同的读取路径,本轮没有调用。
|
||||||
|
|
||||||
|
## 5. 验收与测试方法
|
||||||
|
|
||||||
|
### 5.1 测试前后验收
|
||||||
|
|
||||||
|
中心服务器执行并通过:
|
||||||
|
|
||||||
|
- `verify-backend.sh`:用户后端、PostgreSQL、Redis、MinIO;
|
||||||
|
- `verify-frontend.sh`:用户静态页面和前端代理到后端;
|
||||||
|
- `verify-infra.sh`:PostgreSQL、Redis、MinIO 和 MinIO 初始化;
|
||||||
|
- `verify-admin.sh`:Admin 页面、Actuator、AI SoulMate 模块配置和本地数据库;
|
||||||
|
- `verify-tripo-mock.sh`:Mock 模式、空 Key、回环哨兵、profile 和零计费不变量。
|
||||||
|
|
||||||
|
测试后当前容器实例的 `RestartCount` 均为 0;PostgreSQL 的 `ai_soulmate` 与 `mlkj_admin` 统计均为 `deadlocks=0`、`xact_rollback=0`;Redis 为 `rejected_connections=0`、`evicted_keys=0`。这些是当前容器/数据库统计窗口,不是整个设备历史的永久证明。
|
||||||
|
|
||||||
|
### 5.2 已认证业务压测
|
||||||
|
|
||||||
|
| 项目 | 配置 |
|
||||||
|
| --- | --- |
|
||||||
|
| 目标 | `http://127.0.0.1:3001`,中心服务器本机直连 |
|
||||||
|
| 测试账号 | 1 个随机 `bench_business_` 账号,复用同一 JWT |
|
||||||
|
| 场景 | 工作流校验、用户资料、项目列表、地址列表、设备列表 |
|
||||||
|
| 并发档 | `1, 5, 10, 20, 40, 80` |
|
||||||
|
| 每档请求 | 500 |
|
||||||
|
| 重复 | 每场景、每并发重复 3 次 |
|
||||||
|
| 计入统计的请求 | 5 场景 × 6 并发 × 500 × 3 = 45,000;另有每轮 5 个预热请求 |
|
||||||
|
| 结果 | 45,000 成功;0 非 200;0 传输错误 |
|
||||||
|
|
||||||
|
所有请求都会经过 JWT、PostgreSQL 用户查询;Redis 可用时更新同一账号的滑动会话键。项目、地址和设备列表为空或很小。单账号会形成同一 Redis 键和用户行的热点,这一部分可能比多账号更悲观;本机直连、小响应和小数据集又会比真实生产更乐观。
|
||||||
|
|
||||||
|
每个单次负载阶段只有约数秒,预热是 5 个请求而不是 5 分钟。本轮是短时阶梯基线,不是 15–30 分钟稳态测试,更不是 2–4 小时长稳测试。
|
||||||
|
|
||||||
|
## 6. 已认证业务接口结果
|
||||||
|
|
||||||
|
### 6.1 跨场景汇总
|
||||||
|
|
||||||
|
| 同时在途请求 | 各场景 RPS 中位数范围 | 各场景 P95 中位数范围 | 最差单轮 P99 | 解读 |
|
||||||
|
| ---: | ---: | ---: | ---: | --- |
|
||||||
|
| 1 | 122.956–132.724 | 8.474–9.083ms | 11.580ms | 单请求基线 |
|
||||||
|
| 5 | 270.668–278.109 | 22.907–24.229ms | 75.555ms | 吞吐快速上升 |
|
||||||
|
| 10 | 281.836–306.095 | 40.412–44.666ms | 162.845ms | 低延迟观测区上沿 |
|
||||||
|
| 20 | 271.189–307.557 | 79.288–86.350ms | 338.333ms | 吞吐进入平台区;长稳候选上沿 |
|
||||||
|
| 40 | 241.489–272.116 | 198.862–220.859ms | 289.071ms | 多数吞吐回落,延迟显著增长 |
|
||||||
|
| 80 | 250.894–280.624 | 518.434–567.906ms | 760.671ms | 无实质吞吐收益,不建议常态运行 |
|
||||||
|
|
||||||
|
### 6.2 分场景完整数据
|
||||||
|
|
||||||
|
表中 RPS 和 P95 为 3 次运行的中位数,P99 为 3 次运行中的最差值。
|
||||||
|
|
||||||
|
| 场景 | 并发 | 请求数 | 成功率 | RPS 中位 | P95 中位 ms | 最差 P99 ms |
|
||||||
|
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
| 地址列表 | 1 | 1,500 | 100% | 126.574 | 8.892 | 10.457 |
|
||||||
|
| 地址列表 | 5 | 1,500 | 100% | 273.421 | 23.108 | 26.627 |
|
||||||
|
| 地址列表 | 10 | 1,500 | 100% | 303.646 | 40.412 | 46.703 |
|
||||||
|
| 地址列表 | 20 | 1,500 | 100% | 307.557 | 79.563 | 84.906 |
|
||||||
|
| 地址列表 | 40 | 1,500 | 100% | 260.590 | 219.476 | 289.071 |
|
||||||
|
| 地址列表 | 80 | 1,500 | 100% | 261.953 | 518.434 | 732.056 |
|
||||||
|
| 设备列表 | 1 | 1,500 | 100% | 127.207 | 8.903 | 11.580 |
|
||||||
|
| 设备列表 | 5 | 1,500 | 100% | 272.359 | 23.195 | 26.533 |
|
||||||
|
| 设备列表 | 10 | 1,500 | 100% | 304.423 | 42.322 | 48.689 |
|
||||||
|
| 设备列表 | 20 | 1,500 | 100% | 285.531 | 83.736 | 92.593 |
|
||||||
|
| 设备列表 | 40 | 1,500 | 100% | 251.141 | 213.005 | 257.722 |
|
||||||
|
| 设备列表 | 80 | 1,500 | 100% | 250.894 | 567.906 | 725.798 |
|
||||||
|
| 项目列表 | 1 | 1,500 | 100% | 128.615 | 8.834 | 11.196 |
|
||||||
|
| 项目列表 | 5 | 1,500 | 100% | 278.109 | 22.907 | 26.125 |
|
||||||
|
| 项目列表 | 10 | 1,500 | 100% | 298.365 | 43.104 | 46.906 |
|
||||||
|
| 项目列表 | 20 | 1,500 | 100% | 297.658 | 79.288 | 86.119 |
|
||||||
|
| 项目列表 | 40 | 1,500 | 100% | 272.116 | 198.862 | 277.906 |
|
||||||
|
| 项目列表 | 80 | 1,500 | 100% | 280.624 | 535.488 | 760.671 |
|
||||||
|
| 用户资料 | 1 | 1,500 | 100% | 122.956 | 9.083 | 11.275 |
|
||||||
|
| 用户资料 | 5 | 1,500 | 100% | 270.668 | 24.229 | 27.679 |
|
||||||
|
| 用户资料 | 10 | 1,500 | 100% | 281.836 | 44.666 | 49.214 |
|
||||||
|
| 用户资料 | 20 | 1,500 | 100% | 271.189 | 86.350 | 92.595 |
|
||||||
|
| 用户资料 | 40 | 1,500 | 100% | 241.489 | 220.859 | 253.889 |
|
||||||
|
| 用户资料 | 80 | 1,500 | 100% | 252.274 | 526.906 | 662.460 |
|
||||||
|
| 工作流校验 | 1 | 1,500 | 100% | 132.724 | 8.474 | 10.365 |
|
||||||
|
| 工作流校验 | 5 | 1,500 | 100% | 272.118 | 23.208 | 75.555 |
|
||||||
|
| 工作流校验 | 10 | 1,500 | 100% | 306.095 | 44.257 | 162.845 |
|
||||||
|
| 工作流校验 | 20 | 1,500 | 100% | 273.936 | 84.652 | 338.333 |
|
||||||
|
| 工作流校验 | 40 | 1,500 | 100% | 251.889 | 211.117 | 239.715 |
|
||||||
|
| 工作流校验 | 80 | 1,500 | 100% | 260.332 | 565.266 | 733.850 |
|
||||||
|
|
||||||
|
### 6.3 容量和“排队”解读
|
||||||
|
|
||||||
|
- `c1–10`:P95 不超过约 44.7ms,可称为本轮的低延迟观测区。
|
||||||
|
- `c20`:P95 仍低于 100ms,但吞吐相对 c10 没有持续增长,且工作流最差单轮 P99 达 338.3ms;适合作为下一轮长稳测试候选上沿,不是已经认证的生产上限。
|
||||||
|
- `c40`:按同一场景配对,五个场景 P95 相对 c20 增加约 2.5–2.8 倍,同时多数场景吞吐回落,可称为“出现明显等待或资源争用迹象”。
|
||||||
|
- `c80`:P95 再增加到约 0.52–0.57 秒,最差 P99 0.76 秒,吞吐基本持平;不建议作为当前常态运行档。
|
||||||
|
|
||||||
|
本轮没有直接采集应用队列深度或每个请求的排队时间,因此不能声称已经测得真实“队列长度”或严格的数学排队拐点。延迟和吞吐只说明 c20 以后等待开始主导。主机内存仍充足,后端和 PostgreSQL 的采样 CPU 也未持续触及各自上限,现象更像单进程、认证数据库交互、连接/会话热点或其他软件侧等待;没有 profiler、连接池等待和慢 SQL 证据,不能进一步断言根因。
|
||||||
|
|
||||||
|
### 6.4 下一轮候选档位
|
||||||
|
|
||||||
|
| 目标 | 下一轮测试建议 |
|
||||||
|
| --- | --- |
|
||||||
|
| 要求 P95 < 50ms | 从 10 个同时在途请求开始设计 |
|
||||||
|
| 要求 P95 < 100ms | 测试 10/15/20,c20 作为本轮已测候选上沿 |
|
||||||
|
| 允许 P95 < 250ms | 40 只能作为短时突发候选,必须先做长稳与恢复验证 |
|
||||||
|
| 当前不建议区 | 80 个同时在途请求 |
|
||||||
|
|
||||||
|
面向客户时不能写成“支持 20 个并发用户”或“每秒支持 300 个用户”。正确表述是:在本报告测试条件下,c20 是下一轮单实例轻量已认证 API 长稳测试的候选上沿,而不是已经确认的运行容量;生产容量仍需多账号、真实数据、真实网络和长稳测试。
|
||||||
|
|
||||||
|
## 7. Tripo Mock 分类并发与任务生命周期
|
||||||
|
|
||||||
|
Tripo 官方专门限流页与部分模型页的公开口径并不完全一致,且实际额度可能受模型和 usage tier 影响。本轮保留两套可配置 profile 做敏感性验证:
|
||||||
|
|
||||||
|
- [Tripo Rate Limits](https://developers.tripo3d.com/zh/docs/rate-limits)
|
||||||
|
- [Tripo Task Lifecycle](https://developers.tripo3d.com/zh/docs/task-lifecycle)
|
||||||
|
- [Tripo H3.1 Model](https://developers.tripo3d.com/zh/models/v3-1)
|
||||||
|
- [Tripo P1 Model](https://developers.tripo3d.com/zh/models/p1)
|
||||||
|
|
||||||
|
来源核对日期为 2026-08-12。profile 是本地模拟配置,不是对当前账户额度的测量。
|
||||||
|
|
||||||
|
### 7.1 两套 profile 结果
|
||||||
|
|
||||||
|
| 本地 profile | H/P/图像/动画/后处理/网格 | 尝试 | 接受 | 刻意溢出拒绝 | 全部完成 | 模拟积分 | 本地对象存储 | 总历时 |
|
||||||
|
| --- | --- | ---: | ---: | ---: | ---: | --- | --- | ---: |
|
||||||
|
| `rate-limits-page` | 10/5/1/10/5/10 | 47 | 41 | 6,每类 1 | 41/41 | 41/41 为 0 | 模型 41/41、预览 41/41 | 10.475s |
|
||||||
|
| `model-pages-conservative` | 3/3/1/3/5/10 | 31 | 25 | 6,每类 1 | 25/25 | 25/25 为 0 | 模型 25/25、预览 25/25 | 10.408s |
|
||||||
|
|
||||||
|
容器内驱动器直接调用服务层,每个溢出请求都产生状态 429、顶层业务码 2000 和 `Retry-After: 10` 的并发异常;它并不是一次真实 HTTP 请求。专项测试另行验证了应用 handler 会把该异常映射为 HTTP 429。这里的 10 秒来自本地人为配置的 2 秒排队延迟和 8 秒运行延迟,并向上取整;不是 Tripo 的真实等待时间。
|
||||||
|
|
||||||
|
41 和 25 是同一 Mock 进程内跨六类累计接受任务数,不是“同时支持 41/25 个真实用户”。动画、后处理和网格类别使用容器内服务驱动器验证分类池;它们没有经过公开用户前端端到端接口。
|
||||||
|
|
||||||
|
### 7.2 单次用户生成闭环
|
||||||
|
|
||||||
|
| 步骤 | 结果 |
|
||||||
|
| --- | --- |
|
||||||
|
| 健康与安全开关 | HTTP 200;`tripo_mode=mock`;profile 为 `model-pages-conservative` |
|
||||||
|
| 注册 | HTTP 200;229.905ms |
|
||||||
|
| 生成前 | 积分 100;资产 0 |
|
||||||
|
| 文本生成 3D 提交 | HTTP 200;10.164ms;`credits_used=0` |
|
||||||
|
| 状态观测 | `QUEUED` 约 0.010s → `RUNNING` 约 2.041s → `COMPLETED` 约 10.197s;11 次轮询 |
|
||||||
|
| 结果落地 | 返回非空的模型和预览 URL,主机解析为本地 `192.168.3.102`;生成 1 个资产。该 E2E 脚本未单独执行对象 `HEAD/GET/stat` |
|
||||||
|
| 生成后 | 积分 100;资产 1;积分变化 0 |
|
||||||
|
| 总耗时 | 10.457s;零积分与本地存储校验均为 true |
|
||||||
|
|
||||||
|
Mock 任务状态保存在单个 Python 进程内存中。后端重启时未完成任务会丢失,多 worker 或多副本也不会共享该状态;它只能验证 POC 的接口、拒绝契约和本地落盘,不能用于多实例正式调度。
|
||||||
|
|
||||||
|
## 8. 健康端点微基准
|
||||||
|
|
||||||
|
用户和 Admin 健康端点分别执行并发 `1/5/10/20/40`、每档 200 个计入统计的请求,共 2,000 个请求计入结果,全部成功;另有每档 5 个预热请求,不计入统计。该结果只用于 HTTP、框架、代理和基础数据库连通性参考,不能代表登录、列表、统计或生成业务容量。
|
||||||
|
|
||||||
|
| 场景 | 并发 | 请求 | RPS | P95 ms | P99 ms |
|
||||||
|
| --- | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
| 用户健康 | 1 | 200 | 360.447 | 2.871 | 2.950 |
|
||||||
|
| 用户健康 | 5 | 200 | 567.193 | 8.599 | 113.399 |
|
||||||
|
| 用户健康 | 10 | 200 | 845.545 | 33.954 | 38.924 |
|
||||||
|
| 用户健康 | 20 | 200 | 765.827 | 111.719 | 133.561 |
|
||||||
|
| 用户健康 | 40 | 200 | 1125.933 | 49.905 | 53.925 |
|
||||||
|
| Admin 健康 | 1 | 200 | 101.635 | 38.585 | 47.034 |
|
||||||
|
| Admin 健康 | 5 | 200 | 168.495 | 81.889 | 92.547 |
|
||||||
|
| Admin 健康 | 10 | 200 | 246.407 | 90.420 | 92.923 |
|
||||||
|
| Admin 健康 | 20 | 200 | 183.326 | 191.156 | 202.178 |
|
||||||
|
| Admin 健康 | 40 | 200 | 324.631 | 191.989 | 211.508 |
|
||||||
|
|
||||||
|
部分数值不单调,原因包括运行过短、调度抖动和采样噪声。不能用用户健康接口的最高 RPS 对外承诺业务吞吐。
|
||||||
|
|
||||||
|
## 9. 资源观测
|
||||||
|
|
||||||
|
业务压测资源 CSV 覆盖 `2026-08-13 14:50:08–14:55:26 +08:00`,跨度 318 秒;共 721 个容器数据行、103 个采样时刻,每个时刻 7 个常驻容器。名义采样间隔为 1 秒,但 `docker stats` 本身耗时,实际大约 3 秒。
|
||||||
|
|
||||||
|
90 个业务 phase 中有 86 个被资源采样命中;未命中 `address-list-c10-r1`、`device-list-c10-r3`、`workflow-validate-c5-r1`、`workflow-validate-c40-r1`。这些 phase 的 HTTP 结果完整,只是数秒级负载没有被资源采样器单独捕获。
|
||||||
|
|
||||||
|
| 容器 | 整个采样窗口峰值 CPU | 整个采样窗口峰值内存 |
|
||||||
|
| --- | ---: | ---: |
|
||||||
|
| 用户后端 | 123.22%(约 1.23 核) | 114.30MiB |
|
||||||
|
| PostgreSQL | 70.80% | 96.28MiB |
|
||||||
|
| Redis | 9.04% | 13.84MiB |
|
||||||
|
| MinIO | 8.82% | 141.00MiB |
|
||||||
|
| 用户前端 | 4.08% | 14.75MiB |
|
||||||
|
| Admin 后端 | 0.24% | 291.70MiB |
|
||||||
|
| Admin 前端 | 0.02% | 62.93MiB |
|
||||||
|
|
||||||
|
主机最低可用内存约 `28.91GiB`,发生在 `workflow-validate-c80-r3` 附近;没有观察到内存接近耗尽。Docker 的网络和块 I/O 字段为累计值,本轮没有可靠地换算成瞬时吞吐、IOPS 或磁盘延迟,因此不在本报告中给出伪精确的磁盘/网络速率。
|
||||||
|
|
||||||
|
资源结果说明 32GB 内存不是本轮短时轻量接口的限制因素。后端的 123.22% 也低于 2 核上限;但采样间隔较粗,可能漏掉数秒场景峰值,不能据此排除 CPU 瞬时饱和。下一轮需要同时采集 PostgreSQL 连接池等待、锁、慢 SQL、Redis 延迟、主机 `iostat` 和应用 profiler,才能定位 c20 以后等待增长的根因。
|
||||||
|
|
||||||
|
## 10. 停电恢复与备份
|
||||||
|
|
||||||
|
测试过程中发生过一次非计划停电。重新开机后人工观察到:
|
||||||
|
|
||||||
|
- 中心服务器的用户前后端、Admin 前后端、PostgreSQL、Redis 和 MinIO 自动恢复;
|
||||||
|
- 所有中心验收脚本再次通过;
|
||||||
|
- Client 工作站也曾在重启后观察到数据库、后端、前端恢复,`/healthz` 返回正常,之后又出现 Tailscale 离线;
|
||||||
|
- Compose 使用 `restart: unless-stopped`,PostgreSQL、Redis 和 MinIO 使用命名卷。
|
||||||
|
|
||||||
|
这不是受控灾备演练。没有记录精确断电时间、开机时间、服务恢复时间、断电前后业务校验和、WAL/文件系统日志或在途任务结果,因此不能给出正式 RTO/RPO,也不能证明突然断电下的数据完整性。Mock 未完成任务是内存态,后端重启后预期丢失。
|
||||||
|
|
||||||
|
基础设施备份曾在 `20260808-161430` 和 `20260813-123227` 批次完成校验:PostgreSQL dump 恢复到临时数据库,MinIO 对象镜像到临时 bucket 后校验,Redis 使用 `redis-check-rdb` 做结构检查。它们是在同一运行环境中的临时目标验证,尚未完成整套隔离环境或异机恢复演练。生产或客户交付前还必须把备份复制到另一物理设备,并完成异机恢复演练。
|
||||||
|
|
||||||
|
## 11. 尚未覆盖的能力
|
||||||
|
|
||||||
|
### 11.1 Admin
|
||||||
|
|
||||||
|
本轮证明 Admin 页面、前端代理和后端健康可用,并有此前人工登录成功的现场记录。没有执行已认证 Admin 业务接口压测。Admin 的单登录会话机制会使反复登录踢掉现有账号,下一轮应创建专用只读压测管理员,只登录一次后复用 token,分别测试用户列表和统计接口;健康端点 RPS 不能代表这些业务。
|
||||||
|
|
||||||
|
### 11.2 Client 农场端
|
||||||
|
|
||||||
|
本轮 45,000 请求完全不经过 Client。尚未验证:
|
||||||
|
|
||||||
|
- Client 独立 PostgreSQL 的容量和增长;
|
||||||
|
- 中心到 Client 的批量任务同步、领取、状态回传与幂等;
|
||||||
|
- 长时间运行、工作站休眠、Docker Desktop 自启动和离线恢复;
|
||||||
|
- 经 Tailscale/Wi-Fi 的端到端延迟;
|
||||||
|
- 工作站在 8GB 内存条件下的稳定容器余量。
|
||||||
|
|
||||||
|
### 11.3 快造 U1
|
||||||
|
|
||||||
|
尚未连接真实打印机,不能给出“支持多少台打印机”的结论。打印机专项需要单独验证:
|
||||||
|
|
||||||
|
- 首次 Wi-Fi PIN 配对和授权信息的保存方式;
|
||||||
|
- DHCP 动态 IP 变化后的设备发现,必要时配置 DHCP 地址保留;
|
||||||
|
- 单机和多机心跳、断线重连、任务幂等、取消和状态回传;
|
||||||
|
- 单打印机队列、多打印机调度及完成/失败恢复;
|
||||||
|
- 模型文件传输速度、Wi-Fi 抖动与有线网络对照。
|
||||||
|
|
||||||
|
### 11.4 真实 Tripo
|
||||||
|
|
||||||
|
本轮没有测量真实 Tripo 的并发、排队、生成耗时或质量。官方没有为本报告提供当前账户固定队列长度或最长等待 SLA;并发占满时可能直接 429,而不是接受无限队列。正式联调前应从账户或官方支持确认实际套餐与类别额度,只做极少量、预算受控的真实冒烟请求,绝不能把本报告的饱和压测切换到真实 Key。
|
||||||
|
|
||||||
|
## 12. 下一阶段测试计划
|
||||||
|
|
||||||
|
建议按以下顺序继续:
|
||||||
|
|
||||||
|
1. 将 Client 工作站设置为接通电源时不休眠,确认 Docker Desktop、Tailscale 和 Client 三容器开机后自动可用,并增加健康巡检。
|
||||||
|
2. 做一次受控重启演练:记录 boot ID、容器 StartedAt/RestartCount、服务恢复秒数和数据库/对象校验值;随后在隔离目录实际恢复备份,形成 RTO/RPO 证据。
|
||||||
|
3. 构造至少 100 个独立测试账号/token 和接近真实量级的项目、地址、设备数据,测试并发 `10/15/20/30/40`,每档持续 15–30 分钟并重复 3 次。
|
||||||
|
4. 在 c20 做 2–4 小时稳态,在 c40 做 5–10 分钟突发并观察恢复;暂定门槛为错误率 ≤0.1%、P95 ≤250ms、P99 ≤500ms、长期 CPU <70%、无持续内存增长和容器重启。
|
||||||
|
5. 把本机直连、用户前端 Nginx、主电脑经 Tailscale 三种链路分开测量,不能混在一个 RPS 数字中。
|
||||||
|
6. 为 Admin 创建专用只读测试账号,补充登录一次后的用户列表和统计聚合低并发压测。
|
||||||
|
7. 工作站恢复稳定在线后,补充 Client 心跳、订单同步、断线重连、本地数据库与 8GB 内存长稳测试。
|
||||||
|
8. 最后接入 1 台快造 U1,先完成 PIN、IP 发现和断线恢复,再逐步增加打印机与真实订单队列。
|
||||||
|
9. 只有用户明确提供专用 Tripo Key 并接受费用预算时,才做一次受控真实冒烟;真实 Tripo 不参与饱和压测。
|
||||||
|
|
||||||
|
## 13. 证据索引与完整性
|
||||||
|
|
||||||
|
大型原始数据保存在中心服务器 `/srv/ai-soulmate-local-deployment/results/raw/`,并已把本轮 122 个文件完整复制到本机同名目录,包括 90 个业务逐轮 JSON、10 个健康逐档 JSON、资源 CSV、汇总和所有前后快照。原始文件仍由 `.gitignore` 排除,不直接进入 Git;可入库的完整 SHA-256 清单为 `results/reports/POC-PERFORMANCE-EVIDENCE-SHA256-2026-08-13.txt`。该清单可用于发现本机副本后续是否变化并支持独立重算汇总,但不是来源认证、数字签名或可信时间戳。报告不包含账号密码、JWT、API Key 或完整签名 URL。
|
||||||
|
|
||||||
|
| 证据文件 | SHA-256 |
|
||||||
|
| --- | --- |
|
||||||
|
| `business-baseline-20260813/resources-during-load.csv` | `db005025e74902570a9d1b49a0bafb9ef5d71690c63c8e22f96c78e18b16363b` |
|
||||||
|
| `business-baseline-20260813/session-metadata.json` | `58f09baa45eac9a7edea97239a399eeacaf094a87557b143fd892f92ab48f321` |
|
||||||
|
| `business-baseline-20260813/summary.json` | `6a97352e59ff2cd92f9c33f1625867f650a3b2887bd27c49e88e80e0673ee367` |
|
||||||
|
| `business-baseline-20260813/summary.md` | `be56624975d28533cc2d5bb1253ad8757b552a9725f8e34cd13c37cac46ff046` |
|
||||||
|
| `e2e-conservative-20260813/user-e2e-smoke.json` | `03588948f6fd8d2563687a8fbf7229ea07edeb6900e558cd94992890bdd9769a` |
|
||||||
|
| `health-baseline-20260813/resources-during-load.csv` | `70384eb082dc2f9a2a4f1a49f414144b2847f7dd01983be7fe3fedd9766d431f` |
|
||||||
|
| `health-baseline-20260813/summary.md` | `aaa8a7c942891b19e71bcb6ddbe373724ccee32c2dd270548d92412658286bbd` |
|
||||||
|
| `tripo-conservative-20260813/tripo-mock-model-pages-conservative.json` | `806ebb6206fd202d1efb53c2800c1f3065d9cdff80b4dc12f4fb2f632bb74825` |
|
||||||
|
| `tripo-rate-limits-20260813/tripo-mock-rate-limits-page.json` | `c204a102b8afd59c4d9400034a77c81d95a505db1e5a2859ea2a95df1917b102` |
|
||||||
|
|
||||||
|
上表列出核心证据;122 个文件的完整清单与哈希见 `POC-PERFORMANCE-EVIDENCE-SHA256-2026-08-13.txt`。
|
||||||
|
|
||||||
|
核心复现命令:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/verify-backend.sh compose/.env
|
||||||
|
./scripts/verify-frontend.sh compose/.env
|
||||||
|
./scripts/verify-infra.sh compose/.env
|
||||||
|
./scripts/verify-admin.sh compose/.env
|
||||||
|
./scripts/verify-tripo-mock.sh compose/.env
|
||||||
|
|
||||||
|
BUSINESS_BENCHMARK_REQUESTS_PER_LEVEL=500 \
|
||||||
|
BUSINESS_BENCHMARK_REPEATS=3 \
|
||||||
|
./scripts/run-business-benchmark-suite.sh \
|
||||||
|
compose/.env \
|
||||||
|
business-baseline-20260813
|
||||||
|
```
|
||||||
|
|
||||||
|
## 14. 最终判定
|
||||||
|
|
||||||
|
当前中心服务器已经具备 AI SoulMate 本地化 POC、功能联调和进一步稳态容量测试的条件。就本轮轻量已认证短时基线而言,c10 处于低延迟区,下一轮应重点测试 c10/c15/c20 且把 c20 作为已测候选上沿,c40 起出现明显退化迹象,c80 不适合作为常态建议。
|
||||||
|
|
||||||
|
本轮结果还不足以形成面向客户的最终硬件档位:必须补齐多账号和真实数据、长稳、Admin 已认证业务、Client、真实网络、快造 U1、受控恢复和真实账户额度校准。现阶段对外最准确的表述是“POC 条件通过,短时基线通过,生产容量与高可用尚待验证”。
|
||||||
+31
-2
@@ -28,6 +28,10 @@ env_value() {
|
|||||||
printf '%s' "$value"
|
printf '%s' "$value"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
env_optional_value() {
|
||||||
|
awk -F= -v key="$1" '$1 == key {sub(/^[^=]*=/, ""); print; exit}' "$env_file"
|
||||||
|
}
|
||||||
|
|
||||||
compose_command=(docker compose --env-file "$env_file" -f "$compose_file")
|
compose_command=(docker compose --env-file "$env_file" -f "$compose_file")
|
||||||
"${compose_command[@]}" config --quiet
|
"${compose_command[@]}" config --quiet
|
||||||
|
|
||||||
@@ -56,6 +60,26 @@ mkdir -p "$staging_directory/minio"
|
|||||||
'exec pg_dump --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" --format=custom --compress=6 --no-owner --no-acl' \
|
'exec pg_dump --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" --format=custom --compress=6 --no-owner --no-acl' \
|
||||||
> "$staging_directory/postgres.dump"
|
> "$staging_directory/postgres.dump"
|
||||||
|
|
||||||
|
postgres_user="$(env_value POSTGRES_USER)"
|
||||||
|
admin_database="$(env_optional_value ADMIN_POSTGRES_DB)"
|
||||||
|
admin_artifact="null"
|
||||||
|
if [[ -n "$admin_database" ]]; then
|
||||||
|
if [[ ! "$admin_database" =~ ^[A-Za-z][A-Za-z0-9_]{0,62}$ ]]; then
|
||||||
|
printf 'ADMIN_POSTGRES_DB is not a safe PostgreSQL identifier.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
admin_database_exists="$("${compose_command[@]}" exec -T postgres psql \
|
||||||
|
--username "$postgres_user" --dbname postgres --tuples-only --no-align \
|
||||||
|
--command "SELECT 1 FROM pg_database WHERE datname = '$admin_database'")"
|
||||||
|
if [[ "$admin_database_exists" == "1" ]]; then
|
||||||
|
"${compose_command[@]}" exec -T postgres pg_dump \
|
||||||
|
--username "$postgres_user" --dbname "$admin_database" \
|
||||||
|
--format=custom --compress=6 --no-owner --no-acl \
|
||||||
|
> "$staging_directory/admin-postgres.dump"
|
||||||
|
admin_artifact='"admin-postgres.dump"'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
"${compose_command[@]}" exec -T redis sh -ec \
|
"${compose_command[@]}" exec -T redis sh -ec \
|
||||||
'redis-cli --no-auth-warning -a "$REDIS_PASSWORD" SAVE >/dev/null'
|
'redis-cli --no-auth-warning -a "$REDIS_PASSWORD" SAVE >/dev/null'
|
||||||
redis_container_id="$("${compose_command[@]}" ps -q redis)"
|
redis_container_id="$("${compose_command[@]}" ps -q redis)"
|
||||||
@@ -84,12 +108,13 @@ fi
|
|||||||
minio_object_count="$(find "$staging_directory/minio" -type f | wc -l | tr -d '[:space:]')"
|
minio_object_count="$(find "$staging_directory/minio" -type f | wc -l | tr -d '[:space:]')"
|
||||||
|
|
||||||
cat > "$staging_directory/manifest.yml" <<EOF
|
cat > "$staging_directory/manifest.yml" <<EOF
|
||||||
schema_version: 1
|
schema_version: 2
|
||||||
created_at: "$(date --iso-8601=seconds)"
|
created_at: "$(date --iso-8601=seconds)"
|
||||||
deployment_repository_commit: "$deployment_repository_commit"
|
deployment_repository_commit: "$deployment_repository_commit"
|
||||||
compose_file: "$compose_file"
|
compose_file: "$compose_file"
|
||||||
artifacts:
|
artifacts:
|
||||||
postgres: "postgres.dump"
|
postgres: "postgres.dump"
|
||||||
|
admin_postgres: $admin_artifact
|
||||||
redis: "redis.rdb"
|
redis: "redis.rdb"
|
||||||
minio: "minio/"
|
minio: "minio/"
|
||||||
minio:
|
minio:
|
||||||
@@ -102,7 +127,11 @@ EOF
|
|||||||
|
|
||||||
(
|
(
|
||||||
cd "$staging_directory"
|
cd "$staging_directory"
|
||||||
find manifest.yml postgres.dump redis.rdb minio -type f -print0 \
|
checksum_paths=(manifest.yml postgres.dump redis.rdb minio)
|
||||||
|
if [[ -f admin-postgres.dump ]]; then
|
||||||
|
checksum_paths+=(admin-postgres.dump)
|
||||||
|
fi
|
||||||
|
find "${checksum_paths[@]}" -type f -print0 \
|
||||||
| LC_ALL=C sort -z \
|
| LC_ALL=C sort -z \
|
||||||
| xargs -0 sha256sum
|
| xargs -0 sha256sum
|
||||||
) > "$staging_directory/checksums.sha256"
|
) > "$staging_directory/checksums.sha256"
|
||||||
|
|||||||
Executable
+59
@@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
env_file="${1:-compose/.env}"
|
||||||
|
source_directory="${2:-/srv/ai-soulmate/sources/mlkj-admin}"
|
||||||
|
|
||||||
|
for required_command in awk docker git; do
|
||||||
|
if ! command -v "$required_command" >/dev/null 2>&1; then
|
||||||
|
printf 'Required command is unavailable: %s\n' "$required_command" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ ! -r "$env_file" || ! -r "$source_directory/backend-java/Dockerfile" || ! -r "$source_directory/frontend/Dockerfile" ]]; then
|
||||||
|
printf 'Admin environment or source Dockerfiles are unavailable.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
env_value() {
|
||||||
|
awk -F= -v key="$1" '$1 == key {sub(/^[^=]*=/, ""); print; exit}' "$env_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
source_branch="$(git -C "$source_directory" branch --show-current)"
|
||||||
|
source_commit="$(git -C "$source_directory" rev-parse HEAD)"
|
||||||
|
source_short_commit="${source_commit:0:12}"
|
||||||
|
backend_image="$(env_value ADMIN_BACKEND_IMAGE)"
|
||||||
|
frontend_image="$(env_value ADMIN_FRONTEND_IMAGE)"
|
||||||
|
if [[ "$source_branch" != "local-deployment" ]]; then
|
||||||
|
printf 'Expected mlkj-admin branch local-deployment, found: %s\n' "$source_branch" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ -n "$(git -C "$source_directory" status --short --untracked-files=no)" ]]; then
|
||||||
|
printf 'Tracked mlkj-admin source changes are present; refusing an uncommitted build.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ "$backend_image" != "ai-soulmate-admin-backend:${source_short_commit}" || "$frontend_image" != "ai-soulmate-admin-frontend:${source_short_commit}" ]]; then
|
||||||
|
printf 'Admin image tags do not match source commit; rerun configure-admin-env.sh.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker build \
|
||||||
|
--build-context "maven-local-repository=$source_directory/.empty-maven-repository" \
|
||||||
|
--build-arg "MAVEN_IMAGE=$(env_value ADMIN_MAVEN_IMAGE)" \
|
||||||
|
--build-arg "JRE_IMAGE=$(env_value ADMIN_JRE_IMAGE)" \
|
||||||
|
--target runtime \
|
||||||
|
--label "org.opencontainers.image.revision=${source_commit}" \
|
||||||
|
--file "$source_directory/backend-java/Dockerfile" \
|
||||||
|
--tag "$backend_image" \
|
||||||
|
"$source_directory"
|
||||||
|
|
||||||
|
docker build \
|
||||||
|
--build-arg "NODE_IMAGE=$(env_value ADMIN_NODE_IMAGE)" \
|
||||||
|
--build-arg ADMIN_MODULE_CONFIG=module-config.local.json \
|
||||||
|
--target runtime \
|
||||||
|
--label "org.opencontainers.image.revision=${source_commit}" \
|
||||||
|
--tag "$frontend_image" \
|
||||||
|
"$source_directory/frontend"
|
||||||
|
|
||||||
|
docker image inspect "$backend_image" "$frontend_image" \
|
||||||
|
--format 'Admin image built: {{index .RepoTags 0}} id={{.Id}} size={{.Size}} revision={{index .Config.Labels "org.opencontainers.image.revision"}}'
|
||||||
Executable
+45
@@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
env_file="${1:-compose/.env}"
|
||||||
|
source_directory="${2:-/srv/ai-soulmate/sources/ai-soulmate-server}"
|
||||||
|
|
||||||
|
for required_command in docker git sed; do
|
||||||
|
if ! command -v "$required_command" >/dev/null 2>&1; then
|
||||||
|
printf 'Required command is unavailable: %s\n' "$required_command" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ ! -r "$env_file" ]]; then
|
||||||
|
printf 'Environment file not found: %s\n' "$env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! -r "$source_directory/frontend-vue/Dockerfile" ]]; then
|
||||||
|
printf 'Frontend Dockerfile not found under: %s\n' "$source_directory" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
source_branch="$(git -C "$source_directory" branch --show-current)"
|
||||||
|
source_commit="$(git -C "$source_directory" rev-parse HEAD)"
|
||||||
|
source_short_commit="${source_commit:0:12}"
|
||||||
|
image="$(sed -n 's/^FRONTEND_IMAGE=//p' "$env_file" | head -n 1)"
|
||||||
|
if [[ "$source_branch" != "local-deployment" ]]; then
|
||||||
|
printf 'Expected source branch local-deployment, found: %s\n' "$source_branch" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ -n "$(git -C "$source_directory" status --short --untracked-files=no)" ]]; then
|
||||||
|
printf 'Tracked source changes are present; refusing to build an uncommitted image.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ "$image" != "ai-soulmate-frontend:${source_short_commit}" ]]; then
|
||||||
|
printf 'FRONTEND_IMAGE does not match source commit; rerun configure-backend-env.sh.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker build \
|
||||||
|
--label "org.opencontainers.image.revision=${source_commit}" \
|
||||||
|
--tag "$image" \
|
||||||
|
"$source_directory/frontend-vue"
|
||||||
|
|
||||||
|
docker image inspect "$image" \
|
||||||
|
--format 'Frontend image built: {{index .RepoTags 0}} id={{.Id}} size={{.Size}}'
|
||||||
Executable
+79
@@ -0,0 +1,79 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
env_file="${1:-${repo_root}/compose/.env}"
|
||||||
|
infra_compose="${repo_root}/compose/docker-compose.infra.yml"
|
||||||
|
backend_compose="${repo_root}/compose/docker-compose.backend.yml"
|
||||||
|
admin_compose="${repo_root}/compose/docker-compose.admin.yml"
|
||||||
|
|
||||||
|
if [[ ! -f "$env_file" ]]; then
|
||||||
|
echo "Environment file not found: $env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
section() {
|
||||||
|
printf '\n## %s\n' "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
read_value() {
|
||||||
|
local key="$1"
|
||||||
|
sed -n "s/^${key}=//p" "$env_file" | head -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
infra_project="$(read_value COMPOSE_PROJECT_NAME)"
|
||||||
|
backend_project="$(read_value BACKEND_COMPOSE_PROJECT_NAME)"
|
||||||
|
admin_project="$(read_value ADMIN_COMPOSE_PROJECT_NAME)"
|
||||||
|
|
||||||
|
if [[ -z "$infra_project" || -z "$backend_project" || -z "$admin_project" ]]; then
|
||||||
|
echo "Compose project names are missing from the environment file." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
section "Runtime snapshot"
|
||||||
|
bash "${repo_root}/scripts/capture-runtime-snapshot.sh"
|
||||||
|
|
||||||
|
section "Application containers"
|
||||||
|
docker compose --project-name "$infra_project" --env-file "$env_file" -f "$infra_compose" ps --all
|
||||||
|
docker compose --project-name "$backend_project" --env-file "$env_file" -f "$backend_compose" ps --all
|
||||||
|
docker compose --project-name "$admin_project" --env-file "$env_file" -f "$admin_compose" ps --all
|
||||||
|
|
||||||
|
section "Container resource totals"
|
||||||
|
docker stats --no-stream --format 'table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}\t{{.PIDs}}'
|
||||||
|
|
||||||
|
section "PostgreSQL database statistics"
|
||||||
|
docker compose --project-name "$infra_project" --env-file "$env_file" -f "$infra_compose" exec -T postgres sh -ec '
|
||||||
|
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB" -P pager=off -c "
|
||||||
|
SELECT datname,
|
||||||
|
numbackends,
|
||||||
|
xact_commit,
|
||||||
|
xact_rollback,
|
||||||
|
blks_read,
|
||||||
|
blks_hit,
|
||||||
|
temp_files,
|
||||||
|
temp_bytes,
|
||||||
|
deadlocks,
|
||||||
|
pg_database_size(datname) AS size_bytes
|
||||||
|
FROM pg_stat_database
|
||||||
|
WHERE datname IN (current_database(), '\''mlkj_admin'\'')
|
||||||
|
ORDER BY datname;"
|
||||||
|
'
|
||||||
|
|
||||||
|
section "PostgreSQL connection states"
|
||||||
|
docker compose --project-name "$infra_project" --env-file "$env_file" -f "$infra_compose" exec -T postgres sh -ec '
|
||||||
|
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB" -P pager=off -c "
|
||||||
|
SELECT datname, state, wait_event_type, count(*)
|
||||||
|
FROM pg_stat_activity
|
||||||
|
WHERE datname IS NOT NULL
|
||||||
|
GROUP BY datname, state, wait_event_type
|
||||||
|
ORDER BY datname, state, wait_event_type;"
|
||||||
|
'
|
||||||
|
|
||||||
|
section "Redis statistics"
|
||||||
|
docker compose --project-name "$infra_project" --env-file "$env_file" -f "$infra_compose" exec -T redis sh -ec '
|
||||||
|
redis-cli --no-auth-warning -a "$REDIS_PASSWORD" INFO clients memory stats persistence |
|
||||||
|
grep -E "^(connected_clients|blocked_clients|used_memory:|used_memory_peak:|mem_fragmentation_ratio:|total_connections_received:|total_commands_processed:|instantaneous_ops_per_sec:|keyspace_hits:|keyspace_misses:|evicted_keys:|expired_keys:|rdb_last_bgsave_status:|aof_enabled:)"
|
||||||
|
'
|
||||||
|
|
||||||
|
section "Docker disk usage"
|
||||||
|
docker system df
|
||||||
Executable
+44
@@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
env_file="${1:-compose/.env}"
|
||||||
|
admin_compose_file="${ADMIN_COMPOSE_FILE:-compose/docker-compose.admin.yml}"
|
||||||
|
infra_compose_file="${COMPOSE_FILE:-compose/docker-compose.infra.yml}"
|
||||||
|
|
||||||
|
if [[ ! -r "$env_file" ]]; then
|
||||||
|
printf 'Environment file not found: %s\n' "$env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env_value() {
|
||||||
|
awk -F= -v key="$1" '$1 == key {sub(/^[^=]*=/, ""); print; exit}' "$env_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
infra_compose=(docker compose --env-file "$env_file" -f "$infra_compose_file")
|
||||||
|
super_admin_count="$("${infra_compose[@]}" exec -T postgres psql \
|
||||||
|
--username "$(env_value POSTGRES_USER)" --dbname "$(env_value ADMIN_POSTGRES_DB)" \
|
||||||
|
--tuples-only --no-align \
|
||||||
|
--command "SELECT count(*) FROM poly_admin_users WHERE role_type = 'SUPER_ADMIN'")"
|
||||||
|
if [[ "$super_admin_count" != "1" ]]; then
|
||||||
|
printf 'Refusing to clear bootstrap password; expected one SUPER_ADMIN, found: %s\n' "$super_admin_count" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
temporary_file="$(mktemp "${env_file}.tmp.XXXXXX")"
|
||||||
|
awk '
|
||||||
|
BEGIN { found = 0 }
|
||||||
|
index($0, "ADMIN_INITIAL_PASSWORD=") == 1 {
|
||||||
|
if (!found) print "ADMIN_INITIAL_PASSWORD="
|
||||||
|
found = 1
|
||||||
|
next
|
||||||
|
}
|
||||||
|
{ print }
|
||||||
|
END { if (!found) print "ADMIN_INITIAL_PASSWORD=" }
|
||||||
|
' "$env_file" > "$temporary_file"
|
||||||
|
chmod 600 "$temporary_file"
|
||||||
|
mv -f "$temporary_file" "$env_file"
|
||||||
|
|
||||||
|
project_name="$(env_value ADMIN_COMPOSE_PROJECT_NAME)"
|
||||||
|
admin_compose=(docker compose --project-name "$project_name" --env-file "$env_file" -f "$admin_compose_file")
|
||||||
|
"${admin_compose[@]}" config --quiet
|
||||||
|
"${admin_compose[@]}" up -d --force-recreate admin-backend
|
||||||
|
printf 'Admin bootstrap password cleared from compose/.env and backend container environment.\n'
|
||||||
Executable
+98
@@ -0,0 +1,98 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
env_file="${1:-compose/.env}"
|
||||||
|
source_directory="${2:-/srv/ai-soulmate/sources/mlkj-admin}"
|
||||||
|
public_host="${3:-}"
|
||||||
|
|
||||||
|
for required_command in awk git mktemp openssl; do
|
||||||
|
if ! command -v "$required_command" >/dev/null 2>&1; then
|
||||||
|
printf 'Required command is unavailable: %s\n' "$required_command" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ ! -r "$env_file" ]]; then
|
||||||
|
printf 'Environment file not found: %s\n' "$env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! -d "$source_directory/.git" ]]; then
|
||||||
|
printf 'mlkj-admin source checkout not found: %s\n' "$source_directory" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ -z "$public_host" || ! "$public_host" =~ ^[A-Za-z0-9.-]+$ ]]; then
|
||||||
|
printf 'Provide the approved LAN IPv4 address or DNS name as argument 3.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
source_branch="$(git -C "$source_directory" branch --show-current)"
|
||||||
|
source_commit="$(git -C "$source_directory" rev-parse HEAD)"
|
||||||
|
source_short_commit="${source_commit:0:12}"
|
||||||
|
if [[ "$source_branch" != "local-deployment" ]]; then
|
||||||
|
printf 'Expected mlkj-admin branch local-deployment, found: %s\n' "$source_branch" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ -n "$(git -C "$source_directory" status --short --untracked-files=no)" ]]; then
|
||||||
|
printf 'Tracked mlkj-admin source changes are present.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
env_value() {
|
||||||
|
awk -F= -v key="$1" '$1 == key {sub(/^[^=]*=/, ""); print; exit}' "$env_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
set_value() {
|
||||||
|
local key="$1"
|
||||||
|
local value="$2"
|
||||||
|
local temporary_file
|
||||||
|
temporary_file="$(mktemp "${env_file}.tmp.XXXXXX")"
|
||||||
|
awk -v key="$key" -v value="$value" '
|
||||||
|
BEGIN { prefix = key "="; found = 0 }
|
||||||
|
index($0, prefix) == 1 {
|
||||||
|
if (!found) print prefix value
|
||||||
|
found = 1
|
||||||
|
next
|
||||||
|
}
|
||||||
|
{ print }
|
||||||
|
END { if (!found) print prefix value }
|
||||||
|
' "$env_file" > "$temporary_file"
|
||||||
|
chmod 600 "$temporary_file"
|
||||||
|
mv -f "$temporary_file" "$env_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_secret() {
|
||||||
|
if [[ -z "$(env_value "$1")" ]]; then
|
||||||
|
set_value "$1" "$(openssl rand -hex 32)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
set_value ADMIN_COMPOSE_PROJECT_NAME ai-soulmate-admin
|
||||||
|
set_value ADMIN_BACKEND_IMAGE "ai-soulmate-admin-backend:${source_short_commit}"
|
||||||
|
set_value ADMIN_FRONTEND_IMAGE "ai-soulmate-admin-frontend:${source_short_commit}"
|
||||||
|
set_value ADMIN_POSTGRES_DB mlkj_admin
|
||||||
|
set_value ADMIN_BACKEND_BIND_ADDRESS 127.0.0.1
|
||||||
|
set_value ADMIN_BACKEND_HOST_PORT 8088
|
||||||
|
set_value ADMIN_FRONTEND_BIND_ADDRESS "$public_host"
|
||||||
|
set_value ADMIN_FRONTEND_HOST_PORT 8081
|
||||||
|
set_value ADMIN_BACKEND_MEMORY_LIMIT 2g
|
||||||
|
set_value ADMIN_BACKEND_CPU_LIMIT 1.5
|
||||||
|
set_value AI_SOULMATE_ADMIN_AUTO_DISPATCH_ON_PAID true
|
||||||
|
set_value ADMIN_FRONTEND_MEMORY_LIMIT 512m
|
||||||
|
set_value ADMIN_FRONTEND_CPU_LIMIT 0.5
|
||||||
|
if [[ -z "$(env_value ADMIN_INITIAL_USERNAME)" ]]; then
|
||||||
|
set_value ADMIN_INITIAL_USERNAME localadmin
|
||||||
|
fi
|
||||||
|
if ! grep -q '^ADMIN_INITIAL_PASSWORD=' "$env_file"; then
|
||||||
|
set_value ADMIN_INITIAL_PASSWORD ""
|
||||||
|
fi
|
||||||
|
ensure_secret ADMIN_JWT_SECRET
|
||||||
|
set_value ADMIN_MAVEN_IMAGE maven:3.9-eclipse-temurin-21
|
||||||
|
set_value ADMIN_JRE_IMAGE eclipse-temurin:21-jre
|
||||||
|
set_value ADMIN_NODE_IMAGE node:22-bookworm-slim
|
||||||
|
|
||||||
|
chmod 600 "$env_file"
|
||||||
|
printf 'Admin environment configured without displaying secrets.\n'
|
||||||
|
printf 'Source commit: %s\n' "$source_commit"
|
||||||
|
printf 'Admin backend image: ai-soulmate-admin-backend:%s\n' "$source_short_commit"
|
||||||
|
printf 'Admin frontend image: ai-soulmate-admin-frontend:%s\n' "$source_short_commit"
|
||||||
|
printf 'Admin frontend bind: %s:8081\n' "$public_host"
|
||||||
|
printf 'Admin backend remains bound to 127.0.0.1:8088.\n'
|
||||||
@@ -4,6 +4,7 @@ set -Eeuo pipefail
|
|||||||
env_file="${1:-compose/.env}"
|
env_file="${1:-compose/.env}"
|
||||||
source_directory="${2:-/srv/ai-soulmate/sources/ai-soulmate-server}"
|
source_directory="${2:-/srv/ai-soulmate/sources/ai-soulmate-server}"
|
||||||
public_host="${3:-}"
|
public_host="${3:-}"
|
||||||
|
client_id="${4:-farm-workstation-001}"
|
||||||
|
|
||||||
for required_command in git grep mktemp openssl; do
|
for required_command in git grep mktemp openssl; do
|
||||||
if ! command -v "$required_command" >/dev/null 2>&1; then
|
if ! command -v "$required_command" >/dev/null 2>&1; then
|
||||||
@@ -24,6 +25,10 @@ if [[ -z "$public_host" || ! "$public_host" =~ ^[A-Za-z0-9.-]+$ ]]; then
|
|||||||
printf 'Provide the approved LAN IPv4 address or DNS name as argument 3.\n' >&2
|
printf 'Provide the approved LAN IPv4 address or DNS name as argument 3.\n' >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
if [[ -z "$client_id" || ! "$client_id" =~ ^[A-Za-z0-9._-]+$ ]]; then
|
||||||
|
printf 'Provide a client ID using letters, numbers, dot, underscore, or hyphen as argument 4.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
source_branch="$(git -C "$source_directory" branch --show-current)"
|
source_branch="$(git -C "$source_directory" branch --show-current)"
|
||||||
source_commit="$(git -C "$source_directory" rev-parse HEAD)"
|
source_commit="$(git -C "$source_directory" rev-parse HEAD)"
|
||||||
@@ -79,6 +84,13 @@ set_value BACKEND_BIND_ADDRESS 127.0.0.1
|
|||||||
set_value BACKEND_HOST_PORT 3001
|
set_value BACKEND_HOST_PORT 3001
|
||||||
set_value BACKEND_MEMORY_LIMIT 4g
|
set_value BACKEND_MEMORY_LIMIT 4g
|
||||||
set_value BACKEND_CPU_LIMIT 2.0
|
set_value BACKEND_CPU_LIMIT 2.0
|
||||||
|
set_value BACKEND_UPLOADS_VOLUME_NAME ai-soulmate-backend-uploads
|
||||||
|
set_value BACKEND_LOGS_VOLUME_NAME ai-soulmate-backend-logs
|
||||||
|
set_value FRONTEND_IMAGE "ai-soulmate-frontend:${source_short_commit}"
|
||||||
|
set_value FRONTEND_BIND_ADDRESS "$public_host"
|
||||||
|
set_value FRONTEND_HOST_PORT 8080
|
||||||
|
set_value FRONTEND_MEMORY_LIMIT 1g
|
||||||
|
set_value FRONTEND_CPU_LIMIT 1.0
|
||||||
|
|
||||||
set_value APP_ENV production
|
set_value APP_ENV production
|
||||||
ensure_secret SECRET_KEY
|
ensure_secret SECRET_KEY
|
||||||
@@ -88,16 +100,69 @@ ensure_secret CDK_CODE_PEPPER
|
|||||||
ensure_secret MLKJ_INTEGRATION_KEY
|
ensure_secret MLKJ_INTEGRATION_KEY
|
||||||
ensure_secret MLKJ_INTEGRATION_SECRET
|
ensure_secret MLKJ_INTEGRATION_SECRET
|
||||||
ensure_secret PRINT_CLIENT_SHARED_TOKEN
|
ensure_secret PRINT_CLIENT_SHARED_TOKEN
|
||||||
|
set_value PRINT_DEFAULT_TARGET_CLIENT_ID "$client_id"
|
||||||
|
set_value PRINT_ALLOWED_CLIENT_ID "$client_id"
|
||||||
|
set_value PRINT_EXTERNAL_TOOLS_HOST_PATH /srv/ai-soulmate/runtime/external-tools-production-20260416
|
||||||
|
set_value PRINT_LOCAL_PROFILES_HOST_PATH /srv/ai-soulmate/runtime/u1-profiles
|
||||||
|
set_value PRINT_SLICER_TIMEOUT_SECONDS 900
|
||||||
|
set_value PRINT_SLICER_CMD_TEMPLATE 'python /app/scripts/slice_with_orca.py {input_path} {output_dir} {material} {height}'
|
||||||
|
set_value PRINT_ORCA_SLICER_BINARY /app/external-tools/bin/Snapmaker_Orca_Linux_AppImage_Ubuntu2404_V2.3.0_Beta.AppImage
|
||||||
|
set_value PRINT_ORCA_APPIMAGE_EXTRACT_AND_RUN true
|
||||||
|
set_value PRINT_ORCA_PRINTER_PROFILE '/app/external-tools/bin/squashfs-root/resources/profiles/Snapmaker/machine/Snapmaker U1 (0.4 nozzle).json'
|
||||||
|
set_value PRINT_ORCA_MATERIAL_PROFILE_MAP '{"default":"/app/external-tools/bin/squashfs-root/resources/profiles/Snapmaker/filament/Snapmaker PLA @U1.json","PLA":"/app/external-tools/bin/squashfs-root/resources/profiles/Snapmaker/filament/Snapmaker PLA @U1.json","PLA_WHITE":"/app/external-tools/bin/squashfs-root/resources/profiles/Snapmaker/filament/Snapmaker PLA @U1.json"}'
|
||||||
|
set_value PRINT_ORCA_HEIGHT_PROFILE_MAP '{"default":"/app/local-profiles/u1-compatible-generic-process.json"}'
|
||||||
|
set_value PRINT_ORCA_DEFAULT_TOOL_COMMAND T0
|
||||||
|
set_value PRINT_ORCA_TOOL_COMMAND_MAP '{"PLA":"T0","PLA_WHITE":"T0"}'
|
||||||
|
set_value PRINT_ORCA_FIRST_LAYER_BED_TEMPERATURE_MAP '{"PLA":"65","PLA_WHITE":"65"}'
|
||||||
|
set_value PRINT_ORCA_BED_TEMPERATURE_MAP '{"PLA":"60","PLA_WHITE":"60"}'
|
||||||
|
|
||||||
set_value OSS_PUBLIC_ENDPOINT "http://${public_host}:9000"
|
set_value OSS_PUBLIC_ENDPOINT "http://${public_host}:9000"
|
||||||
set_value CORS_ALLOWED_ORIGINS "http://${public_host},http://${public_host}:8080,http://${public_host}:8081,http://localhost:8080,http://127.0.0.1:8080"
|
set_value CORS_ALLOWED_ORIGINS "http://${public_host},http://${public_host}:8080,http://${public_host}:8081,http://localhost:8080,http://127.0.0.1:8080"
|
||||||
set_value AI_SOULMATE_PUBLIC_URL "http://${public_host}:8080"
|
set_value AI_SOULMATE_PUBLIC_URL "http://${public_host}:8080"
|
||||||
set_value FRONTEND_URL "http://${public_host}:8080"
|
set_value FRONTEND_URL "http://${public_host}:8080"
|
||||||
if ! grep -q '^TRIPO3D_API_KEY=' "$env_file"; then
|
if ! grep -q '^TRIPO3D_MODE=' "$env_file"; then
|
||||||
|
set_value TRIPO3D_MODE disabled
|
||||||
|
fi
|
||||||
|
tripo_mode="$(env_value TRIPO3D_MODE)"
|
||||||
|
if [[ "$tripo_mode" == "mock" ]]; then
|
||||||
set_value TRIPO3D_API_KEY ""
|
set_value TRIPO3D_API_KEY ""
|
||||||
|
set_value TRIPO3D_BASE_URL http://127.0.0.1:9/tripo-mock-blocked
|
||||||
|
else
|
||||||
|
if ! grep -q '^TRIPO3D_API_KEY=' "$env_file"; then
|
||||||
|
set_value TRIPO3D_API_KEY ""
|
||||||
|
fi
|
||||||
|
if ! grep -q '^TRIPO3D_BASE_URL=' "$env_file"; then
|
||||||
|
set_value TRIPO3D_BASE_URL https://api.tripo3d.com/v2/openapi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
set_value TRIPO3D_BASE_URL https://api.tripo3d.com/v2/openapi
|
|
||||||
set_value TRIPO3D_DEFAULT_MODEL_VERSION v3.1-20260211
|
set_value TRIPO3D_DEFAULT_MODEL_VERSION v3.1-20260211
|
||||||
|
if ! grep -q '^TRIPO3D_MOCK_QUEUE_DELAY_SECONDS=' "$env_file"; then
|
||||||
|
set_value TRIPO3D_MOCK_QUEUE_DELAY_SECONDS 2
|
||||||
|
fi
|
||||||
|
if ! grep -q '^TRIPO3D_MOCK_RUN_DELAY_SECONDS=' "$env_file"; then
|
||||||
|
set_value TRIPO3D_MOCK_RUN_DELAY_SECONDS 8
|
||||||
|
fi
|
||||||
|
if ! grep -q '^TRIPO3D_MOCK_H_CONCURRENCY=' "$env_file"; then
|
||||||
|
set_value TRIPO3D_MOCK_H_CONCURRENCY 10
|
||||||
|
fi
|
||||||
|
if ! grep -q '^TRIPO3D_MOCK_P_CONCURRENCY=' "$env_file"; then
|
||||||
|
set_value TRIPO3D_MOCK_P_CONCURRENCY 5
|
||||||
|
fi
|
||||||
|
if ! grep -q '^TRIPO3D_MOCK_IMAGE_CONCURRENCY=' "$env_file"; then
|
||||||
|
set_value TRIPO3D_MOCK_IMAGE_CONCURRENCY 1
|
||||||
|
fi
|
||||||
|
if ! grep -q '^TRIPO3D_MOCK_ANIMATION_CONCURRENCY=' "$env_file"; then
|
||||||
|
set_value TRIPO3D_MOCK_ANIMATION_CONCURRENCY 10
|
||||||
|
fi
|
||||||
|
if ! grep -q '^TRIPO3D_MOCK_POSTPROCESS_CONCURRENCY=' "$env_file"; then
|
||||||
|
set_value TRIPO3D_MOCK_POSTPROCESS_CONCURRENCY 5
|
||||||
|
fi
|
||||||
|
if ! grep -q '^TRIPO3D_MOCK_MESH_CONCURRENCY=' "$env_file"; then
|
||||||
|
set_value TRIPO3D_MOCK_MESH_CONCURRENCY 10
|
||||||
|
fi
|
||||||
|
if ! grep -q '^TRIPO3D_MOCK_TASK_RETENTION_SECONDS=' "$env_file"; then
|
||||||
|
set_value TRIPO3D_MOCK_TASK_RETENTION_SECONDS 3600
|
||||||
|
fi
|
||||||
|
|
||||||
chmod 600 "$env_file"
|
chmod 600 "$env_file"
|
||||||
printf 'Backend environment configured without displaying secrets.\n'
|
printf 'Backend environment configured without displaying secrets.\n'
|
||||||
|
|||||||
@@ -58,6 +58,32 @@ BACKEND_BIND_ADDRESS=127.0.0.1
|
|||||||
BACKEND_HOST_PORT=3001
|
BACKEND_HOST_PORT=3001
|
||||||
BACKEND_MEMORY_LIMIT=4g
|
BACKEND_MEMORY_LIMIT=4g
|
||||||
BACKEND_CPU_LIMIT=2.0
|
BACKEND_CPU_LIMIT=2.0
|
||||||
|
BACKEND_UPLOADS_VOLUME_NAME=ai-soulmate-backend-uploads
|
||||||
|
BACKEND_LOGS_VOLUME_NAME=ai-soulmate-backend-logs
|
||||||
|
FRONTEND_IMAGE=ai-soulmate-frontend:local-deployment
|
||||||
|
FRONTEND_BIND_ADDRESS=127.0.0.1
|
||||||
|
FRONTEND_HOST_PORT=8080
|
||||||
|
FRONTEND_MEMORY_LIMIT=1g
|
||||||
|
FRONTEND_CPU_LIMIT=1.0
|
||||||
|
|
||||||
|
ADMIN_COMPOSE_PROJECT_NAME=ai-soulmate-admin
|
||||||
|
ADMIN_BACKEND_IMAGE=ai-soulmate-admin-backend:local-deployment
|
||||||
|
ADMIN_FRONTEND_IMAGE=ai-soulmate-admin-frontend:local-deployment
|
||||||
|
ADMIN_POSTGRES_DB=mlkj_admin
|
||||||
|
ADMIN_BACKEND_BIND_ADDRESS=127.0.0.1
|
||||||
|
ADMIN_BACKEND_HOST_PORT=8088
|
||||||
|
ADMIN_FRONTEND_BIND_ADDRESS=127.0.0.1
|
||||||
|
ADMIN_FRONTEND_HOST_PORT=8081
|
||||||
|
ADMIN_BACKEND_MEMORY_LIMIT=2g
|
||||||
|
ADMIN_BACKEND_CPU_LIMIT=1.5
|
||||||
|
ADMIN_FRONTEND_MEMORY_LIMIT=512m
|
||||||
|
ADMIN_FRONTEND_CPU_LIMIT=0.5
|
||||||
|
ADMIN_INITIAL_USERNAME=localadmin
|
||||||
|
ADMIN_INITIAL_PASSWORD=
|
||||||
|
ADMIN_JWT_SECRET=$(random_secret)
|
||||||
|
ADMIN_MAVEN_IMAGE=maven:3.9-eclipse-temurin-21
|
||||||
|
ADMIN_JRE_IMAGE=eclipse-temurin:21-jre
|
||||||
|
ADMIN_NODE_IMAGE=node:22-bookworm-slim
|
||||||
|
|
||||||
APP_ENV=production
|
APP_ENV=production
|
||||||
SECRET_KEY=$(random_secret)
|
SECRET_KEY=$(random_secret)
|
||||||
@@ -67,6 +93,8 @@ CDK_CODE_PEPPER=$(random_secret)
|
|||||||
MLKJ_INTEGRATION_KEY=$(random_secret)
|
MLKJ_INTEGRATION_KEY=$(random_secret)
|
||||||
MLKJ_INTEGRATION_SECRET=$(random_secret)
|
MLKJ_INTEGRATION_SECRET=$(random_secret)
|
||||||
PRINT_CLIENT_SHARED_TOKEN=$(random_secret)
|
PRINT_CLIENT_SHARED_TOKEN=$(random_secret)
|
||||||
|
PRINT_DEFAULT_TARGET_CLIENT_ID=farm-workstation-001
|
||||||
|
PRINT_ALLOWED_CLIENT_ID=farm-workstation-001
|
||||||
|
|
||||||
OSS_PUBLIC_ENDPOINT=http://127.0.0.1:9000
|
OSS_PUBLIC_ENDPOINT=http://127.0.0.1:9000
|
||||||
CORS_ALLOWED_ORIGINS=http://localhost:8080,http://127.0.0.1:8080
|
CORS_ALLOWED_ORIGINS=http://localhost:8080,http://127.0.0.1:8080
|
||||||
@@ -75,6 +103,17 @@ FRONTEND_URL=http://127.0.0.1:8080
|
|||||||
TRIPO3D_API_KEY=
|
TRIPO3D_API_KEY=
|
||||||
TRIPO3D_BASE_URL=https://api.tripo3d.com/v2/openapi
|
TRIPO3D_BASE_URL=https://api.tripo3d.com/v2/openapi
|
||||||
TRIPO3D_DEFAULT_MODEL_VERSION=v3.1-20260211
|
TRIPO3D_DEFAULT_MODEL_VERSION=v3.1-20260211
|
||||||
|
TRIPO3D_MODE=disabled
|
||||||
|
TRIPO3D_MOCK_PROFILE=not-selected
|
||||||
|
TRIPO3D_MOCK_QUEUE_DELAY_SECONDS=2
|
||||||
|
TRIPO3D_MOCK_RUN_DELAY_SECONDS=8
|
||||||
|
TRIPO3D_MOCK_H_CONCURRENCY=10
|
||||||
|
TRIPO3D_MOCK_P_CONCURRENCY=5
|
||||||
|
TRIPO3D_MOCK_IMAGE_CONCURRENCY=1
|
||||||
|
TRIPO3D_MOCK_ANIMATION_CONCURRENCY=10
|
||||||
|
TRIPO3D_MOCK_POSTPROCESS_CONCURRENCY=5
|
||||||
|
TRIPO3D_MOCK_MESH_CONCURRENCY=10
|
||||||
|
TRIPO3D_MOCK_TASK_RETENTION_SECONDS=3600
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod 600 "$target_path"
|
chmod 600 "$target_path"
|
||||||
|
|||||||
Executable
+81
@@ -0,0 +1,81 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
env_file="${1:-${repo_root}/compose/.env}"
|
||||||
|
profile="${2:-}"
|
||||||
|
|
||||||
|
if [[ ! -f "$env_file" ]]; then
|
||||||
|
echo "Environment file not found: $env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$profile" ]]; then
|
||||||
|
echo "Choose a mock profile explicitly: rate-limits-page or model-pages-conservative" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$profile" in
|
||||||
|
rate-limits-page)
|
||||||
|
h_concurrency=10
|
||||||
|
p_concurrency=5
|
||||||
|
image_concurrency=1
|
||||||
|
animation_concurrency=10
|
||||||
|
postprocess_concurrency=5
|
||||||
|
mesh_concurrency=10
|
||||||
|
;;
|
||||||
|
model-pages-conservative)
|
||||||
|
h_concurrency=3
|
||||||
|
p_concurrency=3
|
||||||
|
image_concurrency=1
|
||||||
|
animation_concurrency=3
|
||||||
|
postprocess_concurrency=5
|
||||||
|
mesh_concurrency=10
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown mock profile: $profile" >&2
|
||||||
|
echo "Supported profiles: rate-limits-page, model-pages-conservative" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
set_value() {
|
||||||
|
local key="$1"
|
||||||
|
local value="$2"
|
||||||
|
local temporary_file
|
||||||
|
|
||||||
|
temporary_file="$(mktemp "${env_file}.tmp.XXXXXX")"
|
||||||
|
awk -v key="$key" -v value="$value" '
|
||||||
|
BEGIN { prefix = key "="; found = 0 }
|
||||||
|
index($0, prefix) == 1 {
|
||||||
|
if (!found) print prefix value
|
||||||
|
found = 1
|
||||||
|
next
|
||||||
|
}
|
||||||
|
{ print }
|
||||||
|
END { if (!found) print prefix value }
|
||||||
|
' "$env_file" > "$temporary_file"
|
||||||
|
chmod 600 "$temporary_file"
|
||||||
|
mv -f "$temporary_file" "$env_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
set_value TRIPO3D_MODE mock
|
||||||
|
set_value TRIPO3D_MOCK_PROFILE "$profile"
|
||||||
|
set_value TRIPO3D_API_KEY ""
|
||||||
|
set_value TRIPO3D_BASE_URL http://127.0.0.1:9/tripo-mock-blocked
|
||||||
|
set_value TRIPO3D_MOCK_H_CONCURRENCY "$h_concurrency"
|
||||||
|
set_value TRIPO3D_MOCK_P_CONCURRENCY "$p_concurrency"
|
||||||
|
set_value TRIPO3D_MOCK_IMAGE_CONCURRENCY "$image_concurrency"
|
||||||
|
set_value TRIPO3D_MOCK_ANIMATION_CONCURRENCY "$animation_concurrency"
|
||||||
|
set_value TRIPO3D_MOCK_POSTPROCESS_CONCURRENCY "$postprocess_concurrency"
|
||||||
|
set_value TRIPO3D_MOCK_MESH_CONCURRENCY "$mesh_concurrency"
|
||||||
|
set_value TRIPO3D_MOCK_QUEUE_DELAY_SECONDS 2
|
||||||
|
set_value TRIPO3D_MOCK_RUN_DELAY_SECONDS 8
|
||||||
|
set_value TRIPO3D_MOCK_TASK_RETENTION_SECONDS 3600
|
||||||
|
|
||||||
|
chmod 600 "$env_file"
|
||||||
|
|
||||||
|
echo "Tripo zero-cost mock profile enabled."
|
||||||
|
echo "Profile: $profile"
|
||||||
|
echo "H/P/Image/Animation/Postprocess/Mesh concurrency: ${h_concurrency}/${p_concurrency}/${image_concurrency}/${animation_concurrency}/${postprocess_concurrency}/${mesh_concurrency}"
|
||||||
|
echo "Real Tripo API key cleared and outbound base URL blocked."
|
||||||
Executable
+86
@@ -0,0 +1,86 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
env_file="${1:-compose/.env}"
|
||||||
|
source_directory="${2:-/srv/ai-soulmate/sources/mlkj-admin}"
|
||||||
|
compose_file="${COMPOSE_FILE:-compose/docker-compose.infra.yml}"
|
||||||
|
|
||||||
|
for required_command in awk docker git; do
|
||||||
|
if ! command -v "$required_command" >/dev/null 2>&1; then
|
||||||
|
printf 'Required command is unavailable: %s\n' "$required_command" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ ! -r "$env_file" ]]; then
|
||||||
|
printf 'Environment file not found: %s\n' "$env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! -d "$source_directory/.git" ]]; then
|
||||||
|
printf 'mlkj-admin source checkout not found: %s\n' "$source_directory" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
env_value() {
|
||||||
|
awk -F= -v key="$1" '$1 == key {sub(/^[^=]*=/, ""); print; exit}' "$env_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
postgres_user="$(env_value POSTGRES_USER)"
|
||||||
|
admin_database="$(env_value ADMIN_POSTGRES_DB)"
|
||||||
|
source_commit="$(git -C "$source_directory" rev-parse HEAD)"
|
||||||
|
if [[ ! "$admin_database" =~ ^[A-Za-z][A-Za-z0-9_]{0,62}$ ]]; then
|
||||||
|
printf 'ADMIN_POSTGRES_DB is not a safe PostgreSQL identifier.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ "$(git -C "$source_directory" branch --show-current)" != "local-deployment" ]]; then
|
||||||
|
printf 'Expected mlkj-admin branch local-deployment.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
schema_files=(
|
||||||
|
"$source_directory/db/cloud/02_create_poly_admin_schema.sql"
|
||||||
|
"$source_directory/db/cloud/04_add_single_login_session.sql"
|
||||||
|
"$source_directory/db/cloud/05_create_poly_traffic_analytics.sql"
|
||||||
|
"$source_directory/db/cloud/06_backfill_poly_traffic_request_uri.sql"
|
||||||
|
)
|
||||||
|
for schema_file in "${schema_files[@]}"; do
|
||||||
|
if [[ ! -r "$schema_file" ]]; then
|
||||||
|
printf 'Admin schema file is missing: %s\n' "$schema_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
compose_command=(docker compose --env-file "$env_file" -f "$compose_file")
|
||||||
|
"${compose_command[@]}" config --quiet
|
||||||
|
if [[ -z "$("${compose_command[@]}" ps -q postgres)" ]]; then
|
||||||
|
printf 'PostgreSQL is not running.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
database_exists="$("${compose_command[@]}" exec -T postgres psql \
|
||||||
|
--username "$postgres_user" --dbname postgres --tuples-only --no-align \
|
||||||
|
--command "SELECT 1 FROM pg_database WHERE datname = '$admin_database'")"
|
||||||
|
if [[ "$database_exists" != "1" ]]; then
|
||||||
|
"${compose_command[@]}" exec -T postgres createdb \
|
||||||
|
--username "$postgres_user" --owner "$postgres_user" --encoding UTF8 "$admin_database"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for schema_file in "${schema_files[@]}"; do
|
||||||
|
printf 'Applying admin schema: %s\n' "$(basename "$schema_file")"
|
||||||
|
"${compose_command[@]}" exec -T postgres psql \
|
||||||
|
--username "$postgres_user" --dbname "$admin_database" \
|
||||||
|
--set ON_ERROR_STOP=1 < "$schema_file"
|
||||||
|
done
|
||||||
|
|
||||||
|
"${compose_command[@]}" exec -T postgres psql \
|
||||||
|
--username "$postgres_user" --dbname "$admin_database" \
|
||||||
|
--set ON_ERROR_STOP=1 --set source_commit="$source_commit" <<'SQL'
|
||||||
|
CREATE TABLE IF NOT EXISTS local_deployment_schema_history (
|
||||||
|
source_commit text PRIMARY KEY,
|
||||||
|
applied_at timestamptz NOT NULL DEFAULT now()
|
||||||
|
);
|
||||||
|
INSERT INTO local_deployment_schema_history(source_commit)
|
||||||
|
VALUES (:'source_commit')
|
||||||
|
ON CONFLICT (source_commit) DO NOTHING;
|
||||||
|
SQL
|
||||||
|
|
||||||
|
printf 'Local admin database initialized: %s at source %s\n' "$admin_database" "$source_commit"
|
||||||
Executable
+49
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
runtime_directory="${1:-/srv/ai-soulmate/runtime/external-tools-production-20260416}"
|
||||||
|
profile_directory="${2:-/srv/ai-soulmate/runtime/u1-profiles}"
|
||||||
|
source_profile="$runtime_directory/bin/squashfs-root/resources/profiles/Snapmaker/process/0.20 Standard @Snapmaker (0.4 nozzle).json"
|
||||||
|
target_profile="$profile_directory/u1-compatible-generic-process.json"
|
||||||
|
|
||||||
|
if ! command -v python3 >/dev/null 2>&1; then
|
||||||
|
printf 'Required command is unavailable: python3\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! -f "$source_profile" ]]; then
|
||||||
|
printf 'Generic Snapmaker process profile not found: %s\n' "$source_profile" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
install -d -m 0750 "$profile_directory"
|
||||||
|
temporary_profile="$(mktemp "$profile_directory/.u1-compatible-generic-process.XXXXXX")"
|
||||||
|
trap 'rm -f "$temporary_profile"' EXIT
|
||||||
|
|
||||||
|
python3 - "$source_profile" "$temporary_profile" <<'PY'
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
|
source_path, target_path = sys.argv[1:]
|
||||||
|
with open(source_path, encoding="utf-8") as source_file:
|
||||||
|
profile = json.load(source_file)
|
||||||
|
|
||||||
|
if profile.get("type") != "process":
|
||||||
|
raise SystemExit("source profile is not a process profile")
|
||||||
|
|
||||||
|
profile.pop("inherits", None)
|
||||||
|
profile["name"] = "0.20 Standard @Snapmaker U1 (local compatibility)"
|
||||||
|
profile["setting_id"] = "LOCAL_U1_COMPAT_GENERIC"
|
||||||
|
profile["compatible_printers"] = ["Snapmaker U1 (0.4 nozzle)"]
|
||||||
|
profile.pop("compatible_printers_condition", None)
|
||||||
|
|
||||||
|
with open(target_path, "w", encoding="utf-8") as target_file:
|
||||||
|
json.dump(profile, target_file, ensure_ascii=False, indent=2)
|
||||||
|
target_file.write("\n")
|
||||||
|
PY
|
||||||
|
|
||||||
|
chmod 0640 "$temporary_profile"
|
||||||
|
mv -f "$temporary_profile" "$target_profile"
|
||||||
|
trap - EXIT
|
||||||
|
|
||||||
|
printf 'U1 local process profile prepared: %s\n' "$target_profile"
|
||||||
|
sha256sum "$target_profile"
|
||||||
Executable
+168
@@ -0,0 +1,168 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
env_file="${1:-${repo_root}/compose/.env}"
|
||||||
|
run_id="${2:-business-baseline-$(date +%Y%m%d-%H%M%S)}"
|
||||||
|
request_count="${BUSINESS_BENCHMARK_REQUESTS_PER_LEVEL:-500}"
|
||||||
|
repeat_count="${BUSINESS_BENCHMARK_REPEATS:-3}"
|
||||||
|
output_root="${repo_root}/results/raw/${run_id}"
|
||||||
|
temporary_root=""
|
||||||
|
|
||||||
|
if [[ ! -f "$env_file" ]]; then
|
||||||
|
echo "Environment file not found: $env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! "$run_id" =~ ^[A-Za-z0-9][A-Za-z0-9_.-]{0,119}$ || "$run_id" == *..* ]]; then
|
||||||
|
echo "Run ID must be 1-120 safe filename characters and must not contain '..'." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! [[ "$request_count" =~ ^[1-9][0-9]*$ ]] || (( request_count > 100000 )); then
|
||||||
|
echo "BUSINESS_BENCHMARK_REQUESTS_PER_LEVEL must be between 1 and 100000." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! [[ "$repeat_count" =~ ^[1-9][0-9]*$ ]] || (( repeat_count > 10 )); then
|
||||||
|
echo "BUSINESS_BENCHMARK_REPEATS must be between 1 and 10." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$output_root"
|
||||||
|
runtime_root="/dev/shm"
|
||||||
|
if [[ ! -d "$runtime_root" || ! -w "$runtime_root" || "$(stat -f -c %T "$runtime_root")" != "tmpfs" ]]; then
|
||||||
|
echo "Writable tmpfs runtime directory is unavailable: $runtime_root" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
temporary_root="$(mktemp -d "${runtime_root}/ai-soulmate-business-benchmark.XXXXXX")"
|
||||||
|
headers_file="${temporary_root}/headers.json"
|
||||||
|
phase_file="${temporary_root}/phase.txt"
|
||||||
|
sampler_stop="${temporary_root}/sampler-stop"
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
if [[ -n "${sampler_pid:-}" ]]; then
|
||||||
|
touch "$sampler_stop"
|
||||||
|
wait "$sampler_pid" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
if [[ -r "$headers_file" ]]; then
|
||||||
|
python3 "${repo_root}/benchmark/close-local-benchmark-session.py" \
|
||||||
|
--base-url http://127.0.0.1:3001 \
|
||||||
|
--headers-file "$headers_file" >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
rm -f "$headers_file" "$phase_file" "$sampler_stop"
|
||||||
|
rmdir "$temporary_root" 2>/dev/null || true
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
declare -a concurrencies=(1 5 10 20 40 80)
|
||||||
|
deployment_commit="$(git -C "$repo_root" rev-parse HEAD)"
|
||||||
|
if [[ -n "$(git -C "$repo_root" status --short --untracked-files=no)" ]]; then
|
||||||
|
deployment_dirty=true
|
||||||
|
else
|
||||||
|
deployment_dirty=false
|
||||||
|
fi
|
||||||
|
project_name="$(sed -n 's/^BACKEND_COMPOSE_PROJECT_NAME=//p' "$env_file" | head -n 1)"
|
||||||
|
project_name="${project_name:-ai-soulmate-backend}"
|
||||||
|
backend_container_id="$(docker compose --project-name "$project_name" --env-file "$env_file" -f "${repo_root}/compose/docker-compose.backend.yml" ps -q backend)"
|
||||||
|
if [[ -z "$backend_container_id" ]]; then
|
||||||
|
echo "Running backend container was not found." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
source_commit="$(docker inspect --format '{{ index .Config.Labels "org.opencontainers.image.revision" }}' "$backend_container_id")"
|
||||||
|
backend_image="$(sed -n 's/^BACKEND_IMAGE=//p' "$env_file" | head -n 1)"
|
||||||
|
backend_image_id="$(docker inspect --format '{{.Image}}' "$backend_container_id")"
|
||||||
|
backend_container_started_at="$(docker inspect --format '{{.State.StartedAt}}' "$backend_container_id")"
|
||||||
|
|
||||||
|
bash "${repo_root}/scripts/verify-tripo-mock.sh" "$env_file"
|
||||||
|
bash "${repo_root}/scripts/verify-infra.sh" "$env_file" >/dev/null
|
||||||
|
python3 "${repo_root}/benchmark/prepare-local-benchmark-session.py" \
|
||||||
|
--base-url http://127.0.0.1:3001 \
|
||||||
|
--headers-output "$headers_file" \
|
||||||
|
--metadata-output "${output_root}/session-metadata.json" \
|
||||||
|
--deployment-commit "$deployment_commit" \
|
||||||
|
--deployment-dirty "$deployment_dirty" \
|
||||||
|
--source-commit "$source_commit" \
|
||||||
|
--backend-image "$backend_image" \
|
||||||
|
--backend-image-id "$backend_image_id" \
|
||||||
|
--backend-container-started-at "$backend_container_started_at" \
|
||||||
|
--requests-per-level "$request_count" \
|
||||||
|
--repeat-count "$repeat_count" \
|
||||||
|
--concurrencies "$(IFS=,; echo "${concurrencies[*]}")"
|
||||||
|
chmod 600 "$headers_file"
|
||||||
|
|
||||||
|
printf '%s\n' setup > "$phase_file"
|
||||||
|
bash "${repo_root}/scripts/sample-benchmark-resources.sh" \
|
||||||
|
"$sampler_stop" 1 "$phase_file" \
|
||||||
|
> "${output_root}/resources-during-load.csv" &
|
||||||
|
sampler_pid=$!
|
||||||
|
|
||||||
|
bash "${repo_root}/scripts/capture-benchmark-snapshot.sh" "$env_file" \
|
||||||
|
> "${output_root}/snapshot-before.txt"
|
||||||
|
|
||||||
|
declare -a names=(workflow-validate user-profile projects-list address-list device-list)
|
||||||
|
declare -a methods=(POST GET GET GET GET)
|
||||||
|
declare -a paths=(
|
||||||
|
/api/workflow/validate
|
||||||
|
/api/user/profile
|
||||||
|
/api/projects
|
||||||
|
/api/address
|
||||||
|
/api/device
|
||||||
|
)
|
||||||
|
for repeat in $(seq 1 "$repeat_count"); do
|
||||||
|
for index in "${!names[@]}"; do
|
||||||
|
name="${names[$index]}"
|
||||||
|
method="${methods[$index]}"
|
||||||
|
url="http://127.0.0.1:3001${paths[$index]}"
|
||||||
|
for concurrency in "${concurrencies[@]}"; do
|
||||||
|
phase="${name}-c${concurrency}-r${repeat}"
|
||||||
|
printf '%s\n' "$phase" > "$phase_file"
|
||||||
|
command=(
|
||||||
|
python3 "${repo_root}/benchmark/run-http-benchmark.py"
|
||||||
|
--url "$url"
|
||||||
|
--method "$method"
|
||||||
|
--requests "$request_count"
|
||||||
|
--concurrency "$concurrency"
|
||||||
|
--warmup 5
|
||||||
|
--timeout 10
|
||||||
|
--expected-status 200
|
||||||
|
--headers-file "$headers_file"
|
||||||
|
--allow-failures
|
||||||
|
--output "${output_root}/${phase}.json"
|
||||||
|
)
|
||||||
|
if [[ "$method" == POST ]]; then
|
||||||
|
command+=(--body-file "${repo_root}/benchmark/workflow-validate-body.json")
|
||||||
|
fi
|
||||||
|
"${command[@]}" > /dev/null
|
||||||
|
echo "Completed ${phase}."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
printf '%s\n' snapshot-after > "$phase_file"
|
||||||
|
bash "${repo_root}/scripts/capture-benchmark-snapshot.sh" "$env_file" \
|
||||||
|
> "${output_root}/snapshot-after.txt"
|
||||||
|
|
||||||
|
touch "$sampler_stop"
|
||||||
|
if ! wait "$sampler_pid"; then
|
||||||
|
echo "Resource sampler failed during the benchmark." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
unset sampler_pid
|
||||||
|
|
||||||
|
expected_results="$(( ${#names[@]} * ${#concurrencies[@]} * repeat_count ))"
|
||||||
|
actual_results="$(find "$output_root" -maxdepth 1 -type f -name '*-c*-r*.json' | wc -l)"
|
||||||
|
if [[ "$actual_results" -ne "$expected_results" ]]; then
|
||||||
|
echo "Expected ${expected_results} benchmark result files, found ${actual_results}." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! awk -F, 'NR > 1 && $2 != "" { found = 1 } END { exit(found ? 0 : 1) }' \
|
||||||
|
"${output_root}/resources-during-load.csv"; then
|
||||||
|
echo "Resource sampler did not capture any phase-tagged rows." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
python3 "${repo_root}/benchmark/summarize-business-results.py" "$output_root" \
|
||||||
|
--markdown-output "${output_root}/summary.md" \
|
||||||
|
--json-output "${output_root}/summary.json" \
|
||||||
|
--require-concurrency-one-success
|
||||||
|
|
||||||
|
echo "Authenticated business benchmark completed: $output_root"
|
||||||
Executable
+77
@@ -0,0 +1,77 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
env_file="${1:-${repo_root}/compose/.env}"
|
||||||
|
run_id="${2:-$(date +%Y%m%d-%H%M%S)}"
|
||||||
|
request_count="${BENCHMARK_REQUESTS_PER_LEVEL:-200}"
|
||||||
|
output_root="${repo_root}/results/raw/${run_id}"
|
||||||
|
|
||||||
|
if [[ ! -f "$env_file" ]]; then
|
||||||
|
echo "Environment file not found: $env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
read_value() {
|
||||||
|
local key="$1"
|
||||||
|
sed -n "s/^${key}=//p" "$env_file" | head -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
backend_bind_address="$(read_value BACKEND_BIND_ADDRESS)"
|
||||||
|
backend_host_port="$(read_value BACKEND_HOST_PORT)"
|
||||||
|
admin_backend_bind_address="$(read_value ADMIN_BACKEND_BIND_ADDRESS)"
|
||||||
|
admin_backend_host_port="$(read_value ADMIN_BACKEND_HOST_PORT)"
|
||||||
|
|
||||||
|
if [[ -z "$backend_bind_address" || -z "$backend_host_port" || -z "$admin_backend_bind_address" || -z "$admin_backend_host_port" ]]; then
|
||||||
|
echo "Backend benchmark endpoints are missing from the environment file." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$output_root"
|
||||||
|
sampler_stop="${output_root}/.resource-sampler-stop"
|
||||||
|
rm -f "$sampler_stop"
|
||||||
|
bash "${repo_root}/scripts/sample-benchmark-resources.sh" "$sampler_stop" \
|
||||||
|
> "${output_root}/resources-during-load.csv" &
|
||||||
|
sampler_pid=$!
|
||||||
|
|
||||||
|
stop_sampler() {
|
||||||
|
touch "$sampler_stop"
|
||||||
|
wait "$sampler_pid" 2>/dev/null || true
|
||||||
|
rm -f "$sampler_stop"
|
||||||
|
}
|
||||||
|
trap stop_sampler EXIT
|
||||||
|
|
||||||
|
declare -a names=(user-health admin-health)
|
||||||
|
declare -a urls=(
|
||||||
|
"http://${backend_bind_address}:${backend_host_port}/api/health"
|
||||||
|
"http://${admin_backend_bind_address}:${admin_backend_host_port}/actuator/health"
|
||||||
|
)
|
||||||
|
declare -a concurrencies=(1 5 10 20 40)
|
||||||
|
|
||||||
|
bash "${repo_root}/scripts/capture-benchmark-snapshot.sh" "$env_file" \
|
||||||
|
> "${output_root}/snapshot-before.txt"
|
||||||
|
|
||||||
|
for index in "${!names[@]}"; do
|
||||||
|
name="${names[$index]}"
|
||||||
|
url="${urls[$index]}"
|
||||||
|
for concurrency in "${concurrencies[@]}"; do
|
||||||
|
python3 "${repo_root}/benchmark/run-http-benchmark.py" \
|
||||||
|
--url "$url" \
|
||||||
|
--requests "$request_count" \
|
||||||
|
--concurrency "$concurrency" \
|
||||||
|
--warmup 5 \
|
||||||
|
--timeout 10 \
|
||||||
|
--expected-status 200 \
|
||||||
|
--output "${output_root}/${name}-c${concurrency}.json" \
|
||||||
|
> /dev/null
|
||||||
|
echo "Completed ${name} at concurrency ${concurrency}."
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
bash "${repo_root}/scripts/capture-benchmark-snapshot.sh" "$env_file" \
|
||||||
|
> "${output_root}/snapshot-after.txt"
|
||||||
|
|
||||||
|
stop_sampler
|
||||||
|
trap - EXIT
|
||||||
|
|
||||||
|
echo "HTTP benchmark suite completed: $output_root"
|
||||||
Executable
+71
@@ -0,0 +1,71 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
env_file="${1:-${repo_root}/compose/.env}"
|
||||||
|
run_id="${2:-$(date +%Y%m%d-%H%M%S)}"
|
||||||
|
output_root="${repo_root}/results/raw/${run_id}"
|
||||||
|
compose_file="${repo_root}/compose/docker-compose.backend.yml"
|
||||||
|
|
||||||
|
if [[ ! -f "$env_file" ]]; then
|
||||||
|
echo "Environment file not found: $env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
read_value() {
|
||||||
|
local key="$1"
|
||||||
|
sed -n "s/^${key}=//p" "$env_file" | head -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
project_name="$(read_value BACKEND_COMPOSE_PROJECT_NAME)"
|
||||||
|
profile="$(read_value TRIPO3D_MOCK_PROFILE)"
|
||||||
|
if [[ -z "$project_name" ]]; then
|
||||||
|
echo "BACKEND_COMPOSE_PROJECT_NAME is missing." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
compose_command=(
|
||||||
|
docker compose
|
||||||
|
--project-name "$project_name"
|
||||||
|
--env-file "$env_file"
|
||||||
|
-f "$compose_file"
|
||||||
|
)
|
||||||
|
|
||||||
|
bash "${repo_root}/scripts/verify-tripo-mock.sh" "$env_file"
|
||||||
|
mkdir -p "$output_root"
|
||||||
|
sampler_stop="${output_root}/.resource-sampler-stop"
|
||||||
|
rm -f "$sampler_stop"
|
||||||
|
bash "${repo_root}/scripts/sample-benchmark-resources.sh" "$sampler_stop" \
|
||||||
|
> "${output_root}/resources-during-tripo-mock.csv" &
|
||||||
|
sampler_pid=$!
|
||||||
|
|
||||||
|
stop_sampler() {
|
||||||
|
touch "$sampler_stop"
|
||||||
|
wait "$sampler_pid" 2>/dev/null || true
|
||||||
|
rm -f "$sampler_stop"
|
||||||
|
}
|
||||||
|
trap stop_sampler EXIT
|
||||||
|
|
||||||
|
bash "${repo_root}/scripts/capture-benchmark-snapshot.sh" "$env_file" \
|
||||||
|
> "${output_root}/tripo-mock-snapshot-before.txt"
|
||||||
|
|
||||||
|
container_id="$("${compose_command[@]}" ps -q backend)"
|
||||||
|
if [[ -z "$container_id" ]]; then
|
||||||
|
echo "Backend container is not running." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
container_result="/tmp/tripo-mock-${run_id}.json"
|
||||||
|
"${compose_command[@]}" exec -T backend python \
|
||||||
|
/app/tools/tripo_mock_benchmark.py \
|
||||||
|
--output "$container_result"
|
||||||
|
docker cp "${container_id}:${container_result}" \
|
||||||
|
"${output_root}/tripo-mock-${profile}.json"
|
||||||
|
|
||||||
|
bash "${repo_root}/scripts/capture-benchmark-snapshot.sh" "$env_file" \
|
||||||
|
> "${output_root}/tripo-mock-snapshot-after.txt"
|
||||||
|
|
||||||
|
stop_sampler
|
||||||
|
trap - EXIT
|
||||||
|
|
||||||
|
echo "Tripo mock benchmark completed: ${output_root}/tripo-mock-${profile}.json"
|
||||||
Executable
+50
@@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
env_file="${1:-${repo_root}/compose/.env}"
|
||||||
|
run_id="${2:-$(date +%Y%m%d-%H%M%S)}"
|
||||||
|
output_root="${repo_root}/results/raw/${run_id}"
|
||||||
|
|
||||||
|
if [[ ! -f "$env_file" ]]; then
|
||||||
|
echo "Environment file not found: $env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$output_root"
|
||||||
|
bash "${repo_root}/scripts/verify-tripo-mock.sh" "$env_file"
|
||||||
|
sampler_stop="${output_root}/.resource-sampler-stop"
|
||||||
|
rm -f "$sampler_stop"
|
||||||
|
bash "${repo_root}/scripts/sample-benchmark-resources.sh" "$sampler_stop" \
|
||||||
|
> "${output_root}/resources-during-user-e2e.csv" &
|
||||||
|
sampler_pid=$!
|
||||||
|
|
||||||
|
stop_sampler() {
|
||||||
|
touch "$sampler_stop"
|
||||||
|
wait "$sampler_pid" 2>/dev/null || true
|
||||||
|
rm -f "$sampler_stop"
|
||||||
|
}
|
||||||
|
trap stop_sampler EXIT
|
||||||
|
|
||||||
|
bash "${repo_root}/scripts/capture-benchmark-snapshot.sh" "$env_file" \
|
||||||
|
> "${output_root}/user-e2e-snapshot-before.txt"
|
||||||
|
|
||||||
|
set +e
|
||||||
|
python3 "${repo_root}/benchmark/run-user-e2e-smoke.py" \
|
||||||
|
--base-url http://127.0.0.1:3001 \
|
||||||
|
--output "${output_root}/user-e2e-smoke.json"
|
||||||
|
smoke_status=$?
|
||||||
|
set -e
|
||||||
|
|
||||||
|
bash "${repo_root}/scripts/capture-benchmark-snapshot.sh" "$env_file" \
|
||||||
|
> "${output_root}/user-e2e-snapshot-after.txt"
|
||||||
|
|
||||||
|
stop_sampler
|
||||||
|
trap - EXIT
|
||||||
|
|
||||||
|
if [[ "$smoke_status" -ne 0 ]]; then
|
||||||
|
echo "User E2E smoke failed; inspect: ${output_root}/user-e2e-smoke.json" >&2
|
||||||
|
exit "$smoke_status"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "User E2E smoke completed: ${output_root}/user-e2e-smoke.json"
|
||||||
Executable
+26
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
stop_file="${1:?stop file is required}"
|
||||||
|
interval_seconds="${2:-1}"
|
||||||
|
phase_file="${3:-}"
|
||||||
|
|
||||||
|
if ! [[ "$interval_seconds" =~ ^[1-9][0-9]*$ ]]; then
|
||||||
|
echo "Sampling interval must be a positive integer." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '%s\n' 'captured_at,phase,load_1m,mem_available_kib,container,cpu_percent,memory_usage,network_io,block_io,pids'
|
||||||
|
while [[ ! -e "$stop_file" ]]; do
|
||||||
|
captured_at="$(date --iso-8601=seconds)"
|
||||||
|
phase=""
|
||||||
|
if [[ -n "$phase_file" && -r "$phase_file" ]]; then
|
||||||
|
phase="$(tr -cd 'A-Za-z0-9_.-' < "$phase_file")"
|
||||||
|
phase="${phase:0:120}"
|
||||||
|
fi
|
||||||
|
load_1m="$(awk '{print $1}' /proc/loadavg)"
|
||||||
|
mem_available_kib="$(awk '/^MemAvailable:/ {print $2}' /proc/meminfo)"
|
||||||
|
docker stats --no-stream \
|
||||||
|
--format "${captured_at},${phase},${load_1m},${mem_available_kib},{{.Name}},{{.CPUPerc}},{{.MemUsage}},{{.NetIO}},{{.BlockIO}},{{.PIDs}}"
|
||||||
|
sleep "$interval_seconds"
|
||||||
|
done
|
||||||
Executable
+58
@@ -0,0 +1,58 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
env_file="${1:-compose/.env}"
|
||||||
|
if [[ ! -r "$env_file" ]]; then
|
||||||
|
printf 'Environment file not found: %s\n' "$env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! -t 0 ]]; then
|
||||||
|
printf 'Run this script from an interactive terminal.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
current_username="$(awk -F= '$1 == "ADMIN_INITIAL_USERNAME" {sub(/^[^=]*=/, ""); print; exit}' "$env_file")"
|
||||||
|
read -r -p "Initial admin username [${current_username:-localadmin}]: " username
|
||||||
|
username="${username:-${current_username:-localadmin}}"
|
||||||
|
if [[ ! "$username" =~ ^[A-Za-z0-9_.-]{3,80}$ ]]; then
|
||||||
|
printf 'Username must be 3-80 characters using letters, numbers, dot, underscore, or hyphen.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -r -s -p 'Initial admin password (at least 16 letters/numbers/_/-): ' password
|
||||||
|
printf '\n'
|
||||||
|
read -r -s -p 'Confirm initial admin password: ' password_confirmation
|
||||||
|
printf '\n'
|
||||||
|
if [[ "$password" != "$password_confirmation" ]]; then
|
||||||
|
printf 'Passwords do not match.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ${#password} -lt 16 || ! "$password" =~ ^[A-Za-z0-9_-]+$ ]]; then
|
||||||
|
printf 'Password must be at least 16 characters using only letters, numbers, underscore, or hyphen.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set_value() {
|
||||||
|
local key="$1"
|
||||||
|
local value="$2"
|
||||||
|
local temporary_file
|
||||||
|
temporary_file="$(mktemp "${env_file}.tmp.XXXXXX")"
|
||||||
|
awk -v key="$key" -v value="$value" '
|
||||||
|
BEGIN { prefix = key "="; found = 0 }
|
||||||
|
index($0, prefix) == 1 {
|
||||||
|
if (!found) print prefix value
|
||||||
|
found = 1
|
||||||
|
next
|
||||||
|
}
|
||||||
|
{ print }
|
||||||
|
END { if (!found) print prefix value }
|
||||||
|
' "$env_file" > "$temporary_file"
|
||||||
|
chmod 600 "$temporary_file"
|
||||||
|
mv -f "$temporary_file" "$env_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
set_value ADMIN_INITIAL_USERNAME "$username"
|
||||||
|
set_value ADMIN_INITIAL_PASSWORD "$password"
|
||||||
|
unset password password_confirmation
|
||||||
|
chmod 600 "$env_file"
|
||||||
|
printf 'Initial admin credentials stored without displaying the password.\n'
|
||||||
Executable
+40
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
env_file="${1:-compose/.env}"
|
||||||
|
compose_file="${ADMIN_COMPOSE_FILE:-compose/docker-compose.admin.yml}"
|
||||||
|
infra_compose_file="${COMPOSE_FILE:-compose/docker-compose.infra.yml}"
|
||||||
|
|
||||||
|
if [[ ! -r "$env_file" ]]; then
|
||||||
|
printf 'Environment file not found: %s\n' "$env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env_value() {
|
||||||
|
awk -F= -v key="$1" '$1 == key {sub(/^[^=]*=/, ""); print; exit}' "$env_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
project_name="$(env_value ADMIN_COMPOSE_PROJECT_NAME)"
|
||||||
|
backend_image="$(env_value ADMIN_BACKEND_IMAGE)"
|
||||||
|
frontend_image="$(env_value ADMIN_FRONTEND_IMAGE)"
|
||||||
|
if [[ -z "$(env_value ADMIN_INITIAL_PASSWORD)" ]]; then
|
||||||
|
infra_compose=(docker compose --env-file "$env_file" -f "$infra_compose_file")
|
||||||
|
super_admin_count="$("${infra_compose[@]}" exec -T postgres psql \
|
||||||
|
--username "$(env_value POSTGRES_USER)" --dbname "$(env_value ADMIN_POSTGRES_DB)" \
|
||||||
|
--tuples-only --no-align \
|
||||||
|
--command "SELECT count(*) FROM poly_admin_users WHERE role_type = 'SUPER_ADMIN'" 2>/dev/null || true)"
|
||||||
|
if [[ "$super_admin_count" != "1" ]]; then
|
||||||
|
printf 'Initial admin password is unset and no SUPER_ADMIN exists; run scripts/set-admin-credentials.sh first.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
for image in "$backend_image" "$frontend_image"; do
|
||||||
|
if [[ -z "$image" ]] || ! docker image inspect "$image" >/dev/null 2>&1; then
|
||||||
|
printf 'Configured admin image is unavailable: %s\n' "$image" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
compose_command=(docker compose --project-name "$project_name" --env-file "$env_file" -f "$compose_file")
|
||||||
|
"${compose_command[@]}" config --quiet
|
||||||
|
"${compose_command[@]}" up -d
|
||||||
|
"${compose_command[@]}" ps --all
|
||||||
Executable
+37
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
env_file="${1:-compose/.env}"
|
||||||
|
compose_file="${BACKEND_COMPOSE_FILE:-compose/docker-compose.backend.yml}"
|
||||||
|
|
||||||
|
if [[ ! -r "$env_file" ]]; then
|
||||||
|
printf 'Environment file not found: %s\n' "$env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
env_value() {
|
||||||
|
sed -n "s/^${1}=//p" "$env_file" | head -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
project_name="$(env_value BACKEND_COMPOSE_PROJECT_NAME)"
|
||||||
|
if [[ -z "$project_name" || "$project_name" == "$(env_value COMPOSE_PROJECT_NAME)" ]]; then
|
||||||
|
printf 'BACKEND_COMPOSE_PROJECT_NAME must be set and differ from the infrastructure project.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
uploads_volume="$(env_value BACKEND_UPLOADS_VOLUME_NAME)"
|
||||||
|
logs_volume="$(env_value BACKEND_LOGS_VOLUME_NAME)"
|
||||||
|
uploads_volume="${uploads_volume:-ai-soulmate-backend-uploads}"
|
||||||
|
logs_volume="${logs_volume:-ai-soulmate-backend-logs}"
|
||||||
|
docker volume create "$uploads_volume" >/dev/null
|
||||||
|
docker volume create "$logs_volume" >/dev/null
|
||||||
|
|
||||||
|
compose_command=(
|
||||||
|
docker compose
|
||||||
|
--project-name "$project_name"
|
||||||
|
--env-file "$env_file"
|
||||||
|
-f "$compose_file"
|
||||||
|
)
|
||||||
|
"${compose_command[@]}" config --quiet
|
||||||
|
"${compose_command[@]}" up -d backend
|
||||||
|
"${compose_command[@]}" ps --all
|
||||||
Executable
+35
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
env_file="${1:-compose/.env}"
|
||||||
|
compose_file="${BACKEND_COMPOSE_FILE:-compose/docker-compose.backend.yml}"
|
||||||
|
|
||||||
|
if [[ ! -r "$env_file" ]]; then
|
||||||
|
printf 'Environment file not found: %s\n' "$env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
env_value() {
|
||||||
|
sed -n "s/^${1}=//p" "$env_file" | head -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
project_name="$(env_value BACKEND_COMPOSE_PROJECT_NAME)"
|
||||||
|
frontend_image="$(env_value FRONTEND_IMAGE)"
|
||||||
|
if [[ -z "$project_name" || "$project_name" == "$(env_value COMPOSE_PROJECT_NAME)" ]]; then
|
||||||
|
printf 'BACKEND_COMPOSE_PROJECT_NAME must be set and differ from the infrastructure project.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ -z "$frontend_image" ]] || ! docker image inspect "$frontend_image" >/dev/null 2>&1; then
|
||||||
|
printf 'Configured frontend image is not available locally: %s\n' "$frontend_image" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
compose_command=(
|
||||||
|
docker compose
|
||||||
|
--project-name "$project_name"
|
||||||
|
--env-file "$env_file"
|
||||||
|
-f "$compose_file"
|
||||||
|
)
|
||||||
|
"${compose_command[@]}" config --quiet
|
||||||
|
"${compose_command[@]}" up -d frontend
|
||||||
|
"${compose_command[@]}" ps --all
|
||||||
Executable
+70
@@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
env_file="${1:-compose/.env}"
|
||||||
|
admin_compose_file="${ADMIN_COMPOSE_FILE:-compose/docker-compose.admin.yml}"
|
||||||
|
infra_compose_file="${COMPOSE_FILE:-compose/docker-compose.infra.yml}"
|
||||||
|
|
||||||
|
for required_command in awk curl docker jq; do
|
||||||
|
if ! command -v "$required_command" >/dev/null 2>&1; then
|
||||||
|
printf 'Required command is unavailable: %s\n' "$required_command" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
env_value() {
|
||||||
|
awk -F= -v key="$1" '$1 == key {sub(/^[^=]*=/, ""); print; exit}' "$env_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
project_name="$(env_value ADMIN_COMPOSE_PROJECT_NAME)"
|
||||||
|
backend_url="http://$(env_value ADMIN_BACKEND_BIND_ADDRESS):$(env_value ADMIN_BACKEND_HOST_PORT)"
|
||||||
|
frontend_url="http://$(env_value ADMIN_FRONTEND_BIND_ADDRESS):$(env_value ADMIN_FRONTEND_HOST_PORT)"
|
||||||
|
admin_database="$(env_value ADMIN_POSTGRES_DB)"
|
||||||
|
postgres_user="$(env_value POSTGRES_USER)"
|
||||||
|
admin_compose=(docker compose --project-name "$project_name" --env-file "$env_file" -f "$admin_compose_file")
|
||||||
|
infra_compose=(docker compose --env-file "$env_file" -f "$infra_compose_file")
|
||||||
|
"${admin_compose[@]}" config --quiet
|
||||||
|
|
||||||
|
backend_health=""
|
||||||
|
frontend_health=""
|
||||||
|
for _attempt in $(seq 1 24); do
|
||||||
|
backend_health="$(curl --fail --silent --show-error --max-time 5 "$backend_url/actuator/health" 2>/dev/null || true)"
|
||||||
|
frontend_health="$(curl --fail --silent --show-error --max-time 5 "$frontend_url/actuator/health" 2>/dev/null || true)"
|
||||||
|
if printf '%s' "$backend_health" | jq -e '.status == "UP"' >/dev/null 2>&1 \
|
||||||
|
&& printf '%s' "$frontend_health" | jq -e '.status == "UP"' >/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
backend_health=""
|
||||||
|
frontend_health=""
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
if [[ -z "$backend_health" || -z "$frontend_health" ]]; then
|
||||||
|
printf 'Admin health checks did not become ready.\n' >&2
|
||||||
|
"${admin_compose[@]}" ps >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
index_html="$(curl --fail --silent --show-error --max-time 5 "$frontend_url/")"
|
||||||
|
module_config="$(curl --fail --silent --show-error --max-time 5 "$frontend_url/assets/module-config.json")"
|
||||||
|
if ! printf '%s' "$index_html" | grep -q 'id="app"'; then
|
||||||
|
printf 'Admin frontend index is invalid.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ "$(printf '%s' "$module_config" | jq -r '[.modules[].code] | join(",")')" != "AI_SOULMATE,CONSOLE" ]]; then
|
||||||
|
printf 'Admin frontend is not using the AI SoulMate local module configuration.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
super_admin_count="$("${infra_compose[@]}" exec -T postgres psql \
|
||||||
|
--username "$postgres_user" --dbname "$admin_database" --tuples-only --no-align \
|
||||||
|
--command "SELECT count(*) FROM poly_admin_users WHERE role_type = 'SUPER_ADMIN'")"
|
||||||
|
if [[ "$super_admin_count" != "1" ]]; then
|
||||||
|
printf 'Expected exactly one local SUPER_ADMIN, found: %s\n' "$super_admin_count" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
"${infra_compose[@]}" exec -T postgres psql \
|
||||||
|
--username "$postgres_user" --dbname "$(env_value POSTGRES_DB)" --tuples-only --no-align \
|
||||||
|
--command "SELECT count(*) FROM pg_tables WHERE schemaname = 'public'" | grep -Eq '^[1-9][0-9]*$'
|
||||||
|
|
||||||
|
printf '%s\n' "$frontend_health" | jq .
|
||||||
|
"${admin_compose[@]}" ps
|
||||||
|
printf 'AI SoulMate local admin, local PostgreSQL, and MinIO configuration checks passed.\n'
|
||||||
@@ -22,7 +22,17 @@ env_value() {
|
|||||||
backend_bind_address="$(env_value BACKEND_BIND_ADDRESS)"
|
backend_bind_address="$(env_value BACKEND_BIND_ADDRESS)"
|
||||||
backend_host_port="$(env_value BACKEND_HOST_PORT)"
|
backend_host_port="$(env_value BACKEND_HOST_PORT)"
|
||||||
oss_public_endpoint="$(env_value OSS_PUBLIC_ENDPOINT)"
|
oss_public_endpoint="$(env_value OSS_PUBLIC_ENDPOINT)"
|
||||||
compose_command=(docker compose --env-file "$env_file" -f "$compose_file")
|
project_name="$(env_value BACKEND_COMPOSE_PROJECT_NAME)"
|
||||||
|
if [[ -z "$project_name" || "$project_name" == "$(env_value COMPOSE_PROJECT_NAME)" ]]; then
|
||||||
|
printf 'BACKEND_COMPOSE_PROJECT_NAME must be set and differ from the infrastructure project.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
compose_command=(
|
||||||
|
docker compose
|
||||||
|
--project-name "$project_name"
|
||||||
|
--env-file "$env_file"
|
||||||
|
-f "$compose_file"
|
||||||
|
)
|
||||||
|
|
||||||
"${compose_command[@]}" config --quiet
|
"${compose_command[@]}" config --quiet
|
||||||
|
|
||||||
|
|||||||
Executable
+64
@@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
env_file="${1:-compose/.env}"
|
||||||
|
compose_file="${BACKEND_COMPOSE_FILE:-compose/docker-compose.backend.yml}"
|
||||||
|
|
||||||
|
for required_command in curl docker jq sed; do
|
||||||
|
if ! command -v "$required_command" >/dev/null 2>&1; then
|
||||||
|
printf 'Required command is unavailable: %s\n' "$required_command" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [[ ! -r "$env_file" ]]; then
|
||||||
|
printf 'Environment file not found: %s\n' "$env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
env_value() {
|
||||||
|
sed -n "s/^${1}=//p" "$env_file" | head -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
project_name="$(env_value BACKEND_COMPOSE_PROJECT_NAME)"
|
||||||
|
frontend_bind_address="$(env_value FRONTEND_BIND_ADDRESS)"
|
||||||
|
frontend_host_port="$(env_value FRONTEND_HOST_PORT)"
|
||||||
|
if [[ -z "$project_name" || "$project_name" == "$(env_value COMPOSE_PROJECT_NAME)" ]]; then
|
||||||
|
printf 'BACKEND_COMPOSE_PROJECT_NAME must be set and differ from the infrastructure project.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
compose_command=(
|
||||||
|
docker compose
|
||||||
|
--project-name "$project_name"
|
||||||
|
--env-file "$env_file"
|
||||||
|
-f "$compose_file"
|
||||||
|
)
|
||||||
|
"${compose_command[@]}" config --quiet
|
||||||
|
|
||||||
|
base_url="http://${frontend_bind_address}:${frontend_host_port}"
|
||||||
|
api_json=""
|
||||||
|
for _attempt in $(seq 1 18); do
|
||||||
|
if curl --fail --silent --show-error --max-time 5 "${base_url}/health" | grep -q '^ok'; then
|
||||||
|
if api_json="$(curl --fail --silent --show-error --max-time 5 "${base_url}/api/health" 2>/dev/null)"; then
|
||||||
|
if printf '%s' "$api_json" | jq -e '.status == "healthy" and .database == "connected"' >/dev/null; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
api_json=""
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
if [[ -z "$api_json" ]]; then
|
||||||
|
printf 'Frontend or proxied API health check did not become healthy: %s\n' "$base_url" >&2
|
||||||
|
"${compose_command[@]}" ps >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
index_html="$(curl --fail --silent --show-error --max-time 5 "${base_url}/")"
|
||||||
|
if ! printf '%s' "$index_html" | grep -q 'id="app"'; then
|
||||||
|
printf 'Frontend index does not contain the Vue application mount point.\n' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '%s\n' "$api_json" | jq .
|
||||||
|
"${compose_command[@]}" ps
|
||||||
|
printf 'Frontend static site and proxied backend health checks passed.\n'
|
||||||
@@ -48,29 +48,43 @@ postgres_user="$(env_value POSTGRES_USER)"
|
|||||||
sha256sum --check checksums.sha256
|
sha256sum --check checksums.sha256
|
||||||
)
|
)
|
||||||
|
|
||||||
restore_database="restore_check_$(date +%s)_$$"
|
restore_databases=()
|
||||||
cleanup_postgres() {
|
cleanup_postgres() {
|
||||||
"${compose_command[@]}" exec -T postgres dropdb \
|
local restore_database
|
||||||
--if-exists --username "$postgres_user" "$restore_database" >/dev/null 2>&1 || true
|
for restore_database in "${restore_databases[@]}"; do
|
||||||
|
"${compose_command[@]}" exec -T postgres dropdb \
|
||||||
|
--if-exists --username "$postgres_user" "$restore_database" >/dev/null 2>&1 || true
|
||||||
|
done
|
||||||
}
|
}
|
||||||
trap cleanup_postgres EXIT
|
trap cleanup_postgres EXIT
|
||||||
|
|
||||||
"${compose_command[@]}" exec -T postgres createdb \
|
verify_postgres_dump() {
|
||||||
--username "$postgres_user" "$restore_database"
|
local dump_path="$1"
|
||||||
"${compose_command[@]}" exec -T postgres pg_restore \
|
local suffix="$2"
|
||||||
--username "$postgres_user" \
|
local restore_database="restore_check_${suffix}_$(date +%s)_$$"
|
||||||
--dbname "$restore_database" \
|
restore_databases+=("$restore_database")
|
||||||
--no-owner \
|
"${compose_command[@]}" exec -T postgres createdb \
|
||||||
--no-acl \
|
--username "$postgres_user" "$restore_database"
|
||||||
--exit-on-error \
|
"${compose_command[@]}" exec -T postgres pg_restore \
|
||||||
< "$backup_directory/postgres.dump"
|
--username "$postgres_user" \
|
||||||
"${compose_command[@]}" exec -T postgres psql \
|
--dbname "$restore_database" \
|
||||||
--username "$postgres_user" \
|
--no-owner \
|
||||||
--dbname "$restore_database" \
|
--no-acl \
|
||||||
--tuples-only \
|
--exit-on-error \
|
||||||
--no-align \
|
< "$dump_path"
|
||||||
--command 'SELECT 1' \
|
"${compose_command[@]}" exec -T postgres psql \
|
||||||
| grep -qx '1'
|
--username "$postgres_user" \
|
||||||
|
--dbname "$restore_database" \
|
||||||
|
--tuples-only \
|
||||||
|
--no-align \
|
||||||
|
--command 'SELECT 1' \
|
||||||
|
| grep -qx '1'
|
||||||
|
}
|
||||||
|
|
||||||
|
verify_postgres_dump "$backup_directory/postgres.dump" primary
|
||||||
|
if [[ -f "$backup_directory/admin-postgres.dump" ]]; then
|
||||||
|
verify_postgres_dump "$backup_directory/admin-postgres.dump" admin
|
||||||
|
fi
|
||||||
cleanup_postgres
|
cleanup_postgres
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
|
|
||||||
|
|||||||
Executable
+127
@@ -0,0 +1,127 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
env_file="${1:-${repo_root}/compose/.env}"
|
||||||
|
compose_file="${repo_root}/compose/docker-compose.backend.yml"
|
||||||
|
|
||||||
|
if [[ ! -f "$env_file" ]]; then
|
||||||
|
echo "Environment file not found: $env_file" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
read_value() {
|
||||||
|
local key="$1"
|
||||||
|
sed -n "s/^${key}=//p" "$env_file" | tail -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
mode="$(read_value TRIPO3D_MODE)"
|
||||||
|
api_key="$(read_value TRIPO3D_API_KEY)"
|
||||||
|
base_url="$(read_value TRIPO3D_BASE_URL)"
|
||||||
|
project_name="$(read_value BACKEND_COMPOSE_PROJECT_NAME)"
|
||||||
|
profile="$(read_value TRIPO3D_MOCK_PROFILE)"
|
||||||
|
|
||||||
|
if [[ "$mode" != "mock" ]]; then
|
||||||
|
echo "TRIPO3D_MODE must be mock; found: ${mode:-unset}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$api_key" ]]; then
|
||||||
|
echo "TRIPO3D_API_KEY must be empty in a zero-cost benchmark." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$base_url" != "http://127.0.0.1:9/tripo-mock-blocked" ]]; then
|
||||||
|
echo "TRIPO3D_BASE_URL is not the blocked loopback sentinel." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$profile" in
|
||||||
|
rate-limits-page)
|
||||||
|
expected_limits=(10 5 1 10 5 10)
|
||||||
|
;;
|
||||||
|
model-pages-conservative)
|
||||||
|
expected_limits=(3 3 1 3 5 10)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "TRIPO3D_MOCK_PROFILE was not explicitly selected." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
limit_keys=(
|
||||||
|
TRIPO3D_MOCK_H_CONCURRENCY
|
||||||
|
TRIPO3D_MOCK_P_CONCURRENCY
|
||||||
|
TRIPO3D_MOCK_IMAGE_CONCURRENCY
|
||||||
|
TRIPO3D_MOCK_ANIMATION_CONCURRENCY
|
||||||
|
TRIPO3D_MOCK_POSTPROCESS_CONCURRENCY
|
||||||
|
TRIPO3D_MOCK_MESH_CONCURRENCY
|
||||||
|
)
|
||||||
|
for index in "${!limit_keys[@]}"; do
|
||||||
|
actual_limit="$(read_value "${limit_keys[$index]}")"
|
||||||
|
if [[ "$actual_limit" != "${expected_limits[$index]}" ]]; then
|
||||||
|
echo "${limit_keys[$index]}=${actual_limit:-unset} does not match profile ${profile}." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$(read_value TRIPO3D_MOCK_QUEUE_DELAY_SECONDS)" != "2" ]] \
|
||||||
|
|| [[ "$(read_value TRIPO3D_MOCK_RUN_DELAY_SECONDS)" != "8" ]]; then
|
||||||
|
echo "Mock queue/run delays do not match the benchmark baseline." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$project_name" ]]; then
|
||||||
|
echo "BACKEND_COMPOSE_PROJECT_NAME is missing." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
compose_command=(
|
||||||
|
docker compose
|
||||||
|
--project-name "$project_name"
|
||||||
|
--env-file "$env_file"
|
||||||
|
-f "$compose_file"
|
||||||
|
)
|
||||||
|
|
||||||
|
"${compose_command[@]}" exec -T backend python -c '
|
||||||
|
import os
|
||||||
|
|
||||||
|
assert os.environ.get("TRIPO3D_MODE") == "mock"
|
||||||
|
assert not os.environ.get("TRIPO3D_API_KEY")
|
||||||
|
assert os.environ.get("TRIPO3D_BASE_URL") == "http://127.0.0.1:9/tripo-mock-blocked"
|
||||||
|
assert os.environ.get("TRIPO3D_MOCK_PROFILE") in {"rate-limits-page", "model-pages-conservative"}
|
||||||
|
|
||||||
|
expected_profiles = {
|
||||||
|
"rate-limits-page": (10, 5, 1, 10, 5, 10),
|
||||||
|
"model-pages-conservative": (3, 3, 1, 3, 5, 10),
|
||||||
|
}
|
||||||
|
actual_limits = tuple(int(os.environ[name]) for name in (
|
||||||
|
"TRIPO3D_MOCK_H_CONCURRENCY",
|
||||||
|
"TRIPO3D_MOCK_P_CONCURRENCY",
|
||||||
|
"TRIPO3D_MOCK_IMAGE_CONCURRENCY",
|
||||||
|
"TRIPO3D_MOCK_ANIMATION_CONCURRENCY",
|
||||||
|
"TRIPO3D_MOCK_POSTPROCESS_CONCURRENCY",
|
||||||
|
"TRIPO3D_MOCK_MESH_CONCURRENCY",
|
||||||
|
))
|
||||||
|
assert actual_limits == expected_profiles[os.environ["TRIPO3D_MOCK_PROFILE"]]
|
||||||
|
assert float(os.environ["TRIPO3D_MOCK_QUEUE_DELAY_SECONDS"]) == 2
|
||||||
|
assert float(os.environ["TRIPO3D_MOCK_RUN_DELAY_SECONDS"]) == 8
|
||||||
|
|
||||||
|
from services.tripo3d import Tripo3DService
|
||||||
|
|
||||||
|
service = Tripo3DService()
|
||||||
|
assert service._api_url("task") == "mock://tripo-local/task"
|
||||||
|
assert service.billable_credits(40) == 0
|
||||||
|
print("Container mock invariants passed.")
|
||||||
|
'
|
||||||
|
|
||||||
|
backend_bind_address="$(read_value BACKEND_BIND_ADDRESS)"
|
||||||
|
backend_host_port="$(read_value BACKEND_HOST_PORT)"
|
||||||
|
health_json="$(curl --fail --silent --show-error --max-time 5 "http://${backend_bind_address}:${backend_host_port}/api/health")"
|
||||||
|
if ! printf '%s' "$health_json" | jq -e --arg profile "$profile" \
|
||||||
|
'.status == "healthy" and .database == "connected" and .tripo_mode == "mock" and .tripo_mock_profile == $profile' >/dev/null; then
|
||||||
|
echo "Backend health response does not report tripo_mode=mock." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Tripo zero-cost runtime verification passed."
|
||||||
Reference in new issue
Block a user