19edd9aa85
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 35s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m28s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m29s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
- ruff 替换 flake8:增加 bugbear/pyupgrade/simplify/return 等规则集 * 自动修复34个问题(未使用import/格式等) * 手动修复10个F841未使用变量 + 2个E722裸except - mypy 类型检查:告警模式接入Validate,不阻断CI * 检查范围:apps/api/app + packages核心业务代码 * 配置:ignore-missing-imports + explicit-package-bases - vulture 死代码扫描升级: * 置信度阈值从80%降到70%,输出更多参考 * 按size排序,便于人工审查高价值条目 * 告警模式不阻断CI - 新增 pyproject.toml:ruff 集中配置 - 修复F841未使用变量(10处)+ E722裸except(2处)
109 lines
2.9 KiB
Python
109 lines
2.9 KiB
Python
"""Public upload smoke for the SaaS Web-domain API path.
|
|
|
|
This intentionally uses https://saas.xiaoxiajianji.com/api/v1 so the Web nginx
|
|
proxy is tested together with the API upload path.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import io
|
|
import os
|
|
import time
|
|
import uuid
|
|
|
|
import requests
|
|
|
|
BASE_URL = "https://saas.xiaoxiajianji.com/api/v1"
|
|
PASSWORD = os.environ.get("SMOKE_TEST_PASSWORD", "changeme")
|
|
|
|
|
|
def _json_or_raise(name: str, response: requests.Response) -> dict:
|
|
print(f"{name}={response.status_code}")
|
|
if response.status_code >= 400:
|
|
print(response.text[:1000])
|
|
response.raise_for_status()
|
|
if not response.content:
|
|
return {}
|
|
return response.json()
|
|
|
|
|
|
def main() -> None:
|
|
session = requests.Session()
|
|
suffix = uuid.uuid4().hex[:10]
|
|
email = f"smoke-upload-{suffix}@example.com"
|
|
username = f"smoke_upload_{suffix}"
|
|
|
|
_json_or_raise(
|
|
"register",
|
|
session.post(
|
|
f"{BASE_URL}/auth/register",
|
|
json={"email": email, "username": username, "password": PASSWORD, "full_name": "Upload Smoke"},
|
|
timeout=30,
|
|
),
|
|
)
|
|
login = _json_or_raise(
|
|
"login",
|
|
session.post(f"{BASE_URL}/auth/login", json={"email": email, "password": PASSWORD}, timeout=30),
|
|
)
|
|
headers = {"Authorization": f"Bearer {login['access_token']}"}
|
|
|
|
_workspace = _json_or_raise(
|
|
"workspace",
|
|
session.post(f"{BASE_URL}/workspaces", json={"name": "Upload Smoke Workspace"}, headers=headers, timeout=30),
|
|
)
|
|
|
|
project = _json_or_raise(
|
|
"project",
|
|
session.post(
|
|
f"{BASE_URL}/projects",
|
|
headers=headers,
|
|
timeout=30,
|
|
),
|
|
)
|
|
project_id = project["id"]
|
|
|
|
library = _json_or_raise(
|
|
"library",
|
|
session.post(
|
|
f"{BASE_URL}/asset-libraries",
|
|
json={
|
|
"project_id": project_id,
|
|
"name": "Smoke Video Library",
|
|
"kind": "video",
|
|
},
|
|
headers=headers,
|
|
timeout=30,
|
|
),
|
|
)
|
|
_library_id = library["id"]
|
|
|
|
upload = _json_or_raise(
|
|
"upload",
|
|
session.post(
|
|
f"{BASE_URL}/upload",
|
|
files={"file": ("smoke.txt", io.BytesIO(b"xiaoxia upload smoke"), "text/plain")},
|
|
headers=headers,
|
|
timeout=60,
|
|
),
|
|
)
|
|
|
|
job_id = upload["ingest_job_id"]
|
|
latest_job = {}
|
|
for attempt in range(10):
|
|
latest_job = _json_or_raise(
|
|
f"ingest_{attempt}",
|
|
session.get(f"{BASE_URL}/ingest-jobs/{job_id}", headers=headers, timeout=30),
|
|
)
|
|
if latest_job.get("status") in {"completed", "failed"}:
|
|
break
|
|
time.sleep(1)
|
|
|
|
if latest_job.get("status") == "failed":
|
|
raise RuntimeError(f"ingest job failed: {latest_job.get('error_message')}")
|
|
|
|
print("public_upload_flow=ok")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|