🧪 Harden object storage acceptance

This commit is contained in:
eust-w 2026-06-16 17:56:50 +08:00
parent 5d20029c57
commit 452e38f47a
15 changed files with 445 additions and 275 deletions

View File

@ -26,6 +26,27 @@ on:
required: true
default: false
type: boolean
run_object_storage_acceptance:
description: "Run browser object-storage create/upload/delete acceptance"
required: true
default: false
type: boolean
object_storage_connection_id:
description: "Storage connection id for object-storage acceptance"
required: false
type: string
object_storage_connection_name:
description: "Storage connection name for object-storage acceptance"
required: false
type: string
object_storage_bucket:
description: "Bucket override for object-storage acceptance"
required: false
type: string
object_storage_video_key:
description: "Optional existing video object key to verify browser playback"
required: false
type: string
jobs:
acceptance:
@ -36,6 +57,10 @@ jobs:
DROBOTICFLOW_API_TOKEN: ${{ secrets.DROBOTICFLOW_API_TOKEN }}
DROBOTICFLOW_SMOKE_EMAIL: ${{ secrets.DROBOTICFLOW_SMOKE_EMAIL }}
DROBOTICFLOW_SMOKE_PASSWORD: ${{ secrets.DROBOTICFLOW_SMOKE_PASSWORD }}
OBJECT_STORAGE_CONNECTION_ID: ${{ inputs.object_storage_connection_id || secrets.OBJECT_STORAGE_CONNECTION_ID }}
OBJECT_STORAGE_CONNECTION_NAME: ${{ inputs.object_storage_connection_name || secrets.OBJECT_STORAGE_CONNECTION_NAME }}
OBJECT_STORAGE_BUCKET: ${{ inputs.object_storage_bucket || secrets.OBJECT_STORAGE_BUCKET }}
OBJECT_STORAGE_VIDEO_KEY: ${{ inputs.object_storage_video_key || secrets.OBJECT_STORAGE_VIDEO_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v4
@ -45,6 +70,19 @@ jobs:
with:
version: v1.34.2
- name: Set up Node.js
if: inputs.run_object_storage_acceptance
uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
- name: Install object-storage acceptance dependencies
if: inputs.run_object_storage_acceptance
run: |
npm ci
npx playwright install --with-deps chromium
- name: Configure kubeconfig
run: |
if [[ -z "${KUBE_CONFIG_B64}" ]]; then
@ -75,3 +113,18 @@ jobs:
exit 1
fi
./scripts/gpu-smoke-test.sh
- name: Object-storage acceptance
if: inputs.run_object_storage_acceptance
env:
BASE_URL: ${{ inputs.api_base_url }}
run: |
if [[ -z "$BASE_URL" ]]; then
echo "api_base_url is required when run_object_storage_acceptance=true" >&2
exit 1
fi
if [[ -z "$OBJECT_STORAGE_CONNECTION_ID" && -z "$OBJECT_STORAGE_CONNECTION_NAME" && -z "$OBJECT_STORAGE_BUCKET" ]]; then
echo "Set OBJECT_STORAGE_CONNECTION_ID, OBJECT_STORAGE_CONNECTION_NAME, or OBJECT_STORAGE_BUCKET for object-storage acceptance." >&2
exit 1
fi
npm run acceptance:object-storage

View File

@ -64,11 +64,12 @@ Drobodata is a workflow orchestration platform for embodied AI and vision pipeli
- `npm run format:check`: check frontend formatting without writing files
- `npm test`: Go unit and integration tests
- `npm run build`: build frontend assets and Go binaries
- `npm run verify`: lint, Go tests, Python operator-runner tests, frontend node tests, build, dependency audit, and Kubernetes manifest dry-run validation
- `npm run verify`: web/Go/script lint, Go tests, Python operator-runner tests, frontend node tests, build, dependency audit, and Kubernetes manifest dry-run validation
- `npm run smoke`: local smoke test against the running API and worker
- `npm run gpu:smoke`: real Kubernetes GPU scheduling and `nvidia-smi` smoke test
- `npm run k8s:cleanup-jobs`: delete old finished operator-runner Jobs that predate TTL cleanup
- `npm run reconcile:data -- <api-base-url>`: remove legacy demo data, reset settings, and bootstrap built-in operators through the real API; honors `DROBOTICFLOW_API_TOKEN` and optional session login env vars for protected deployments
- `npm run acceptance:object-storage`: browser-driven object-storage acceptance against a configured live storage connection; requires `OBJECT_STORAGE_CONNECTION_ID`, `OBJECT_STORAGE_CONNECTION_NAME`, or `OBJECT_STORAGE_BUCKET`
- `python3 scripts/wjzh_operator_regression.py --preflight-only`: preflight the production-style WJZH real-data operator regression against a live API
## Runtime Configuration
@ -230,7 +231,18 @@ Run a smoke test against a deployed cluster:
./scripts/smoke-test.sh http://<node-ip>:30080
```
Run real-environment acceptance from GitHub Actions with the manual `Acceptance` workflow. It accepts the deployed API URL, optional direct worker URL, and can run GPU smoke when the repository secret `KUBE_CONFIG_B64` is configured.
Run browser object-storage acceptance against a deployed cluster:
```bash
BASE_URL=http://<node-ip>:30080 \
OBJECT_STORAGE_CONNECTION_ID=<storage-connection-id> \
OBJECT_STORAGE_BUCKET=<bucket> \
npm run acceptance:object-storage
```
Set `OBJECT_STORAGE_VIDEO_KEY=<existing-video-key>` to additionally verify browser video playback from object storage. Public session-auth deployments should also set `DROBOTICFLOW_SMOKE_EMAIL` and `DROBOTICFLOW_SMOKE_PASSWORD`; token-protected non-session deployments can set `DROBOTICFLOW_API_TOKEN`.
Run real-environment acceptance from GitHub Actions with the manual `Acceptance` workflow. It accepts the deployed API URL, optional direct worker URL, API smoke, GPU smoke, and object-storage acceptance inputs. GPU smoke needs `KUBE_CONFIG_B64`; object-storage acceptance needs an existing storage connection selector and optionally an existing video key.
See the detailed guides:

View File

@ -285,9 +285,9 @@ Each artifact item can now include:
{
"name": "X-platform-test 自采数据扫描",
"description": "扫描并索引真实采集目录",
"sourcePath": "bos://datastorage/algo/X-platform-test",
"bucket": "datastorage",
"prefix": "algo/X-platform-test",
"sourcePath": "bos://<bucket>/<prefix>",
"bucket": "<bucket>",
"prefix": "<prefix>",
"pattern": "",
"interval": 86400,
"enabled": true,

View File

@ -39,7 +39,7 @@
生成命令示例:
```bash
python3 scripts/generate_operator_docs.py --api-base-url http://114.111.24.223:30080
python3 scripts/generate_operator_docs.py --api-base-url http://<api-host>:30080
```
如果你手上只有一个 AI 生成的单算子 JSON,也可以直接生成文档,不必先手工包装成 `{ "items": [...] }`:

View File

@ -212,7 +212,8 @@ http://<node-ip>:30080
- `IMAGE_TAG` defaults to the current git short SHA in build, deploy, and render scripts. Set it explicitly for release names or rollback-friendly tags.
- `scripts/smoke-test.sh` can exercise session-authenticated deployments when `DROBOTICFLOW_SMOKE_EMAIL` and `DROBOTICFLOW_SMOKE_PASSWORD` are set; it logs in, persists cookies, and sends the CSRF header on write requests.
- `scripts/reconcile-system-data.sh` uses the same protected-client behavior. Set `DROBOTICFLOW_API_TOKEN` for token-protected APIs when session auth is not enforced. For public session-auth deployments, set `DROBOTICFLOW_SMOKE_EMAIL` and `DROBOTICFLOW_SMOKE_PASSWORD` to an organization admin account because the reconcile flow updates settings, users, templates, and operators.
- `scripts/object-storage-acceptance.mjs` runs browser create, preview, rename, upload, delete, and optional video playback checks against a live storage connection. It never rewrites storage connection metadata; provide `OBJECT_STORAGE_CONNECTION_ID`, `OBJECT_STORAGE_CONNECTION_NAME`, or `OBJECT_STORAGE_BUCKET` explicitly, and set `OBJECT_STORAGE_VIDEO_KEY` only when an existing playable object should be validated. The script supports `DROBOTICFLOW_API_TOKEN` for token-protected non-session APIs and `DROBOTICFLOW_SMOKE_EMAIL` / `DROBOTICFLOW_SMOKE_PASSWORD` for session-authenticated browser access.
- `npm run gpu:smoke` creates a temporary GPU Job in the target namespace and runs `nvidia-smi`. Override `GPU_SMOKE_IMAGE`, `GPU_RESOURCE_NAME`, `GPU_RESOURCE_COUNT`, and the `OPERATOR_GPU_*` scheduling variables when the cluster uses custom GPU images or labels.
- GitHub Actions includes a manual `Acceptance` workflow for deployed-environment checks. Configure `KUBE_CONFIG_B64` for Kubernetes access and optionally `DROBOTICFLOW_API_TOKEN`, `DROBOTICFLOW_SMOKE_EMAIL`, and `DROBOTICFLOW_SMOKE_PASSWORD` for authenticated smoke tests.
- GitHub Actions includes a manual `Acceptance` workflow for deployed-environment checks. Configure `KUBE_CONFIG_B64` for Kubernetes access and optionally `DROBOTICFLOW_API_TOKEN`, `DROBOTICFLOW_SMOKE_EMAIL`, `DROBOTICFLOW_SMOKE_PASSWORD`, `OBJECT_STORAGE_CONNECTION_ID`, `OBJECT_STORAGE_CONNECTION_NAME`, `OBJECT_STORAGE_BUCKET`, and `OBJECT_STORAGE_VIDEO_KEY` for authenticated smoke and object-storage acceptance tests.
- If you use DashScope-compatible models, prefer a backend-allowed API key. Do not deploy tool-only Coding Plan keys into the cluster.
- Production hardening still depends on the target cluster policy: TLS ingress, network policies, backup strategy, and secret rotation.

View File

@ -4,9 +4,9 @@ This document is the handoff guide for internal teams and third-party integrator
## 1. Integration Target
- Base URL: `http://114.111.24.223:30080`
- Base URL: `<drobodata-base-url>`
- Auth header: `X-API-Key`
- Allowed connectionId: `mongo-6fc71b9f604165b38279f068c4294423`
- Allowed connectionId: `<authorized-mongo-connection-id>`
- Allowed collection whitelist:
- `businessWriteValidation`
@ -47,11 +47,11 @@ X-API-Key: dbw_...
Request:
```bash
curl -X POST 'http://114.111.24.223:30080/api/external/business-db/documents' \
curl -X POST '<drobodata-base-url>/api/external/business-db/documents' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: dbw_<your-live-api-key>' \
--data '{
"connectionId": "mongo-6fc71b9f604165b38279f068c4294423",
"connectionId": "<authorized-mongo-connection-id>",
"collection": "businessWriteValidation",
"document": {
"runLabel": "partner-demo-001",
@ -66,7 +66,7 @@ Typical success response:
```json
{
"connectionId": "mongo-6fc71b9f604165b38279f068c4294423",
"connectionId": "<authorized-mongo-connection-id>",
"collection": "businessWriteValidation",
"operation": "created",
"document": {
@ -86,11 +86,11 @@ Typical success response:
Request:
```bash
curl -X PATCH 'http://114.111.24.223:30080/api/external/business-db/documents/<documentId>' \
curl -X PATCH '<drobodata-base-url>/api/external/business-db/documents/<documentId>' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: dbw_<your-live-api-key>' \
--data '{
"connectionId": "mongo-6fc71b9f604165b38279f068c4294423",
"connectionId": "<authorized-mongo-connection-id>",
"collection": "businessWriteValidation",
"patch": {
"value": 789,
@ -103,7 +103,7 @@ Typical success response:
```json
{
"connectionId": "mongo-6fc71b9f604165b38279f068c4294423",
"connectionId": "<authorized-mongo-connection-id>",
"collection": "businessWriteValidation",
"operation": "updated",
"document": {
@ -125,11 +125,11 @@ Use this when the third party wants "insert if not exists, otherwise update".
Request:
```bash
curl -X POST 'http://114.111.24.223:30080/api/external/business-db/upserts' \
curl -X POST '<drobodata-base-url>/api/external/business-db/upserts' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: dbw_<your-live-api-key>' \
--data '{
"connectionId": "mongo-6fc71b9f604165b38279f068c4294423",
"connectionId": "<authorized-mongo-connection-id>",
"collection": "businessWriteValidation",
"match": {
"runLabel": "partner-demo-001"

View File

@ -337,7 +337,7 @@
<h1>Drobodata 功能介绍与线上验收报告</h1>
<p>
本页基于 2026-04-15 对 Kubernetes 部署环境
<code>http://114.111.24.223:30080</code>
<code><deployed-api-base-url></code>
的真实验收结果生成。内容同时包含功能说明、Playwright 回归范围、页面截图和一份可回放的录屏。
</p>
<div class="hero-actions">
@ -567,7 +567,7 @@
</table>
<p class="small">
执行命令:
<code>BASE_URL=http://114.111.24.223:30080 node scripts/playwright-functional-check.mjs</code>
<code>BASE_URL=<deployed-api-base-url> node scripts/playwright-functional-check.mjs</code>
</p>
</section>

View File

@ -1,7 +1,7 @@
# Drobodata 功能介绍与线上验收报告
测试时间:2026-04-15
测试环境:`http://114.111.24.223:30080`
测试环境:`<deployed-api-base-url>`
测试方式:真实线上环境 API 采样 + Playwright 端到端自动化
测试结论:核心功能链路已完成两轮完整回归,主流程全部通过
@ -332,7 +332,7 @@ Playwright 实测覆盖了:
执行命令如下:
```bash
BASE_URL=http://114.111.24.223:30080 node scripts/playwright-functional-check.mjs
BASE_URL=<deployed-api-base-url> node scripts/playwright-functional-check.mjs
```
脚本文件位置:

View File

@ -119,6 +119,17 @@ python3 scripts/wjzh_operator_regression.py --preflight-only
See the full runbook in [`docs/wjzh-operator-regression.md`](wjzh-operator-regression.md).
Run browser object-storage acceptance against a live storage connection:
```bash
BASE_URL=http://<node-ip>:30080 \
OBJECT_STORAGE_CONNECTION_ID=<storage-connection-id> \
OBJECT_STORAGE_BUCKET=<bucket> \
npm run acceptance:object-storage
```
Set `OBJECT_STORAGE_VIDEO_KEY=<existing-video-key>` when video playback should be included. The script creates temporary objects under an `object-storage-acceptance-*` prefix and removes them at the end. For session-authenticated public APIs, provide `DROBOTICFLOW_SMOKE_EMAIL` and `DROBOTICFLOW_SMOKE_PASSWORD`; for token-protected non-session APIs, provide `DROBOTICFLOW_API_TOKEN`.
Reconcile persistent system data and remove legacy demo records:
```bash

View File

@ -47,6 +47,17 @@ Run deployed smoke after rollout:
./scripts/smoke-test.sh http://<node-ip>:30080
```
Run browser object-storage acceptance after rollout:
```bash
BASE_URL=http://<node-ip>:30080 \
OBJECT_STORAGE_CONNECTION_ID=<storage-connection-id> \
OBJECT_STORAGE_BUCKET=<bucket> \
npm run acceptance:object-storage
```
Set `OBJECT_STORAGE_VIDEO_KEY` to validate browser playback for a known existing video object. The script requires an explicit storage connection selector and will not modify connection metadata to make the check pass.
Reconcile persistent system data after rollout:
```bash
@ -59,7 +70,7 @@ Run GPU smoke on a real GPU cluster:
npm run gpu:smoke
```
The manual GitHub Actions `Acceptance` workflow can run API smoke and GPU smoke against a deployed environment. Configure `KUBE_CONFIG_B64` when GPU smoke needs Kubernetes access.
The manual GitHub Actions `Acceptance` workflow can run API smoke, GPU smoke, and object-storage acceptance against a deployed environment. Configure `KUBE_CONFIG_B64` when GPU smoke needs Kubernetes access and provide an object-storage connection selector when object-storage acceptance is enabled.
## Remaining Cluster Responsibilities

View File

@ -18,9 +18,10 @@
"start:operator-runner": "python3 backend/operator-runner/main.py",
"preview": "vite preview",
"clean": "rm -rf dist build",
"lint": "npm run lint:web && npm run lint:go",
"lint": "npm run lint:web && npm run lint:go && npm run lint:scripts",
"lint:web": "tsc --noEmit",
"lint:go": "bash -lc 'test -z \"$(gofmt -l cmd internal)\"'",
"lint:scripts": "node --check scripts/*.mjs && python3 -m py_compile scripts/*.py",
"format": "prettier --write \"src/**/*.{ts,tsx,css}\" \"tests/frontend/**/*.mjs\"",
"format:check": "prettier --check \"src/**/*.{ts,tsx,css}\" \"tests/frontend/**/*.mjs\"",
"test": "go test ./...",
@ -37,7 +38,8 @@
"k8s:cleanup-jobs": "./scripts/cleanup-operator-jobs.sh",
"gpu:smoke": "./scripts/gpu-smoke-test.sh",
"smoke": "./scripts/smoke-test.sh",
"reconcile:data": "./scripts/reconcile-system-data.sh"
"reconcile:data": "./scripts/reconcile-system-data.sh",
"acceptance:object-storage": "node scripts/object-storage-acceptance.mjs"
},
"dependencies": {
"@tailwindcss/vite": "^4.1.14",

View File

@ -5,73 +5,190 @@ import path from "node:path";
import { chromium } from "playwright";
const BASE_URL = (process.env.BASE_URL || "http://114.111.24.223:30080").replace(/\/+$/, "");
const BASE_URL = (process.env.BASE_URL || process.env.API_BASE_URL || "http://127.0.0.1:3001").replace(/\/+$/, "");
const API_TOKEN = (process.env.DROBOTICFLOW_API_TOKEN || "").trim();
const SMOKE_EMAIL = (process.env.DROBOTICFLOW_SMOKE_EMAIL || "").trim();
const SMOKE_PASSWORD = process.env.DROBOTICFLOW_SMOKE_PASSWORD || "";
const CONNECTION_ID = (process.env.OBJECT_STORAGE_CONNECTION_ID || "").trim();
const CONNECTION_NAME = (process.env.OBJECT_STORAGE_CONNECTION_NAME || "").trim();
const CONFIGURED_BUCKET = (process.env.OBJECT_STORAGE_BUCKET || "").trim();
const VIDEO_KEY = (process.env.OBJECT_STORAGE_VIDEO_KEY || "").trim();
const IGNORE_HTTPS_ERRORS = /^(1|true|yes)$/i.test(process.env.PLAYWRIGHT_IGNORE_HTTPS_ERRORS || "");
const bucketName = "datastorage";
const testPrefix = `object-storage-acceptance-${Date.now()}`;
const createdKey = `${testPrefix}/object-storage-test.json`;
const renamedKey = `${testPrefix}/object-storage-renamed.json`;
const uploadKey = `${testPrefix}/nested/object-upload.txt`;
const uploadPayload = "upload payload from object storage acceptance";
const uploadFilePath = path.join(os.tmpdir(), "object-storage-upload.txt");
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "droboticflow-object-storage-"));
const uploadFilePath = path.join(tmpDir, "object-storage-upload.txt");
fs.writeFileSync(uploadFilePath, uploadPayload, "utf8");
async function requestJSON(input, init) {
const response = await fetch(input, init);
if (Boolean(SMOKE_EMAIL) !== Boolean(SMOKE_PASSWORD)) {
throw new Error("DROBOTICFLOW_SMOKE_EMAIL and DROBOTICFLOW_SMOKE_PASSWORD must be set together");
}
function csrfProtectedMethod(method) {
return !["GET", "HEAD", "OPTIONS"].includes(method.toUpperCase());
}
async function csrfToken(context) {
const cookies = await context.cookies(BASE_URL);
const cookie = cookies.find((item) => item.name === "droboticflow_csrf");
return cookie?.value ? decodeURIComponent(cookie.value) : "";
}
async function apiRequest(
context,
pathName,
{ method = "GET", body, headers = {}, expected = [200, 201, 202, 204] } = {},
) {
const requestHeaders = { ...headers };
if (API_TOKEN) {
requestHeaders.Authorization = `Bearer ${API_TOKEN}`;
}
if (body !== undefined && !requestHeaders["Content-Type"]) {
requestHeaders["Content-Type"] = "application/json";
}
if (csrfProtectedMethod(method)) {
const token = await csrfToken(context);
if (token) {
requestHeaders["X-Droboticflow-CSRF-Token"] = token;
}
}
const response = await context.request.fetch(`${BASE_URL}${pathName}`, {
method,
headers: requestHeaders,
data: body === undefined ? undefined : JSON.stringify(body),
});
const text = await response.text();
if (!response.ok) {
throw new Error(text || `Request failed: ${response.status}`);
if (!expected.includes(response.status())) {
throw new Error(`${method} ${pathName} failed with ${response.status()}: ${text}`);
}
return text ? JSON.parse(text) : null;
}
async function ensureConnection() {
const connectionsPayload = await requestJSON(`${BASE_URL}/api/storage/connections`);
const items = connectionsPayload?.items || [];
const matched = items.find((item) => item.bucket === bucketName);
if (matched?.id) {
return matched;
async function loginIfConfigured(context) {
if (!SMOKE_EMAIL) {
return;
}
const fallback = items[0];
assert.ok(fallback?.id, "expected at least one storage connection");
return requestJSON(`${BASE_URL}/api/storage/connections/${fallback.id}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
name: fallback.name,
description: fallback.description || "",
provider: "BOS",
endpoint: fallback.endpoint || "",
bucket: bucketName,
}),
const response = await apiRequest(context, "/api/auth/login", {
method: "POST",
body: {
email: SMOKE_EMAIL,
password: SMOKE_PASSWORD,
},
expected: [200],
});
console.log(`logged in object-storage acceptance user: ${response?.email || response?.name || SMOKE_EMAIL}`);
}
async function cleanupArtifacts(connectionId) {
try {
await fetch(
`${BASE_URL}/api/object-storage/objects?connectionId=${encodeURIComponent(connectionId)}&key=${encodeURIComponent(testPrefix)}&recursive=true`,
{ method: "DELETE" },
async function resolveConnection(context) {
const payload = await apiRequest(context, "/api/storage/connections");
const items = payload?.items || [];
let matched = null;
if (CONNECTION_ID) {
matched = items.find((item) => item.id === CONNECTION_ID);
} else if (CONNECTION_NAME) {
matched = items.find((item) => item.name === CONNECTION_NAME);
} else if (CONFIGURED_BUCKET) {
matched = items.find((item) => item.bucket === CONFIGURED_BUCKET);
} else {
throw new Error(
"Set OBJECT_STORAGE_CONNECTION_ID, OBJECT_STORAGE_CONNECTION_NAME, or OBJECT_STORAGE_BUCKET before running object-storage acceptance",
);
} catch {}
}
if (!matched?.id) {
const selectors = [
CONNECTION_ID && `id=${CONNECTION_ID}`,
CONNECTION_NAME && `name=${CONNECTION_NAME}`,
CONFIGURED_BUCKET && `bucket=${CONFIGURED_BUCKET}`,
]
.filter(Boolean)
.join(", ");
throw new Error(`No storage connection matched ${selectors || "the configured selector"}`);
}
return matched;
}
function objectStoragePath(pathName, connectionId, bucket, params = {}) {
const search = new URLSearchParams({ connectionId });
if (bucket) {
search.set("bucket", bucket);
}
for (const [key, value] of Object.entries(params)) {
if (value !== undefined && value !== "") {
search.set(key, String(value));
}
}
return `${pathName}?${search.toString()}`;
}
async function cleanupArtifacts(context, connectionId, bucket) {
try {
await apiRequest(
context,
objectStoragePath("/api/object-storage/objects", connectionId, bucket, {
key: testPrefix,
recursive: "true",
}),
{
method: "DELETE",
expected: [200, 204, 404],
},
);
} catch (error) {
console.warn(`cleanup skipped: ${error instanceof Error ? error.message : String(error)}`);
}
}
async function waitForObjectRow(page, key) {
const locator = page.locator(`[data-object-key="${key}"]`);
const locator = page.locator(`[data-object-key=${JSON.stringify(key)}]`);
await locator.waitFor({ state: "visible" });
return locator;
}
async function run() {
const connection = await ensureConnection();
assert.ok(connection?.id, "expected an object storage connection");
async function openObjectKey(page, key) {
const segments = key.split("/").filter(Boolean);
assert.ok(segments.length > 0, "OBJECT_STORAGE_VIDEO_KEY must not be empty");
await page.click('button:has-text("根目录")');
let prefix = "";
for (const segment of segments.slice(0, -1)) {
prefix = prefix ? `${prefix}/${segment}` : segment;
await waitForObjectRow(page, prefix);
await page.dblclick(`[data-object-key=${JSON.stringify(prefix)}]`);
}
await waitForObjectRow(page, key);
await page.click(`[data-object-key=${JSON.stringify(key)}]`);
}
async function run() {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
page.on("dialog", (dialog) => dialog.accept());
const context = await browser.newContext({
extraHTTPHeaders: API_TOKEN ? { Authorization: `Bearer ${API_TOKEN}` } : undefined,
ignoreHTTPSErrors: IGNORE_HTTPS_ERRORS,
});
let connection = null;
let bucketName = "";
try {
await loginIfConfigured(context);
connection = await resolveConnection(context);
bucketName = CONFIGURED_BUCKET || connection.bucket || "";
assert.ok(
bucketName,
"Selected storage connection has no bound bucket; set OBJECT_STORAGE_BUCKET for object-storage acceptance",
);
const page = await context.newPage();
page.on("dialog", (dialog) => dialog.accept());
await page.goto(`${BASE_URL}/object-storage`, { waitUntil: "networkidle" });
await page.waitForSelector('[data-testid="object-storage-connection-select"]');
await page.waitForFunction(
@ -97,9 +214,9 @@ async function run() {
);
await page.click('[data-testid="object-save-button"]');
await waitForObjectRow(page, testPrefix);
await page.dblclick(`[data-object-key="${testPrefix}"]`);
await page.dblclick(`[data-object-key=${JSON.stringify(testPrefix)}]`);
await waitForObjectRow(page, createdKey);
await page.click(`[data-object-key="${createdKey}"]`);
await page.click(`[data-object-key=${JSON.stringify(createdKey)}]`);
await page.waitForFunction(() => {
const preview = document.querySelector("pre");
return preview && preview.textContent?.includes("hello object storage");
@ -113,65 +230,50 @@ async function run() {
await page.setInputFiles('[data-testid="upload-file-input"]', uploadFilePath);
await page.click('[data-testid="object-upload-button"]');
await waitForObjectRow(page, `${testPrefix}/nested`);
await page.dblclick(`[data-object-key="${testPrefix}/nested"]`);
await page.dblclick(`[data-object-key=${JSON.stringify(`${testPrefix}/nested`)}]`);
await waitForObjectRow(page, uploadKey);
await page.click(`[data-object-key="${uploadKey}"]`);
await page.waitForFunction(
(text) => {
const preview = document.querySelector("pre");
return preview && preview.textContent?.includes(text);
},
uploadPayload,
);
await page.click(`[data-object-key=${JSON.stringify(uploadKey)}]`);
await page.waitForFunction((text) => {
const preview = document.querySelector("pre");
return preview && preview.textContent?.includes(text);
}, uploadPayload);
await page.click('button:has-text("返回上级")');
await waitForObjectRow(page, renamedKey);
await page.click(`[data-object-key="${renamedKey}"]`);
await page.click(`[data-object-key=${JSON.stringify(renamedKey)}]`);
await page.click('[data-testid="object-delete-button"]');
await page.waitForFunction(
(key) => !document.querySelector(`[data-object-key="${key}"]`),
(key) => !document.querySelector(`[data-object-key=${JSON.stringify(key)}]`),
renamedKey,
);
await page.click(`[data-object-key="${testPrefix}/nested"]`);
await page.click(`[data-object-key=${JSON.stringify(`${testPrefix}/nested`)}]`);
await page.click('[data-testid="object-delete-button"]');
await page.waitForFunction(
(key) => !document.querySelector(`[data-object-key="${key}"]`),
(key) => !document.querySelector(`[data-object-key=${JSON.stringify(key)}]`),
`${testPrefix}/nested`,
);
await page.click('button:has-text("根目录")');
await waitForObjectRow(page, "algo");
await page.dblclick('[data-object-key="algo"]');
await page.dblclick('[data-object-key="algo/X-platform-test"]');
await page.dblclick('[data-object-key="algo/X-platform-test/raw"]');
await page.dblclick(
'[data-object-key="algo/X-platform-test/raw/BJ_001_0001_OsmoNano_2026-03-19_14-51-43"]',
);
await page.dblclick(
'[data-object-key="algo/X-platform-test/raw/BJ_001_0001_OsmoNano_2026-03-19_14-51-43/DJI_001"]',
);
const videoKey =
"algo/X-platform-test/raw/BJ_001_0001_OsmoNano_2026-03-19_14-51-43/DJI_001/DJI_20260318112834_0001_D.MP4";
await page.click(`[data-object-key="${videoKey}"]`);
await page.waitForSelector("video");
await page.waitForFunction(() => {
const element = document.querySelector("video");
return element && element.readyState >= 2;
});
if (VIDEO_KEY) {
await openObjectKey(page, VIDEO_KEY);
await page.waitForSelector("video");
await page.waitForFunction(() => {
const element = document.querySelector("video");
return element && element.readyState >= 2;
});
}
const overview = await requestJSON(
`${BASE_URL}/api/object-storage?connectionId=${encodeURIComponent(connection.id)}`,
);
assert.equal(overview?.bucket, bucketName, "expected bound datastorage bucket in overview");
const overview = await apiRequest(context, objectStoragePath("/api/object-storage", connection.id, bucketName));
assert.equal(overview?.bucket, bucketName, "expected bound bucket in overview");
console.log(
JSON.stringify(
{
baseUrl: BASE_URL,
connectionId: connection.id,
bucket: bucketName,
testPrefix,
verifiedVideoKey: videoKey,
verifiedVideoKey: VIDEO_KEY || null,
status: "ok",
},
null,
@ -179,8 +281,11 @@ async function run() {
),
);
} finally {
await cleanupArtifacts(connection.id);
if (connection?.id) {
await cleanupArtifacts(context, connection.id, bucketName);
}
await browser.close();
fs.rmSync(tmpDir, { recursive: true, force: true });
}
}

View File

@ -2,11 +2,13 @@ import { chromium } from "playwright";
import fs from "node:fs";
import path from "node:path";
const baseURL = (process.env.BASE_URL || process.argv[2] || "http://114.111.24.223:30080").replace(/\/+$/, "");
const baseURL = (process.env.BASE_URL || process.argv[2] || "http://127.0.0.1:3001").replace(/\/+$/, "");
const apiBaseURL = `${baseURL}`;
const artifactDir = path.resolve("output/playwright");
const videoDir = path.join(artifactDir, "video");
const suffix = Date.now().toString(36);
const scanBucket = (process.env.PLAYWRIGHT_SCAN_BUCKET || "").trim();
const scanPrefix = (process.env.PLAYWRIGHT_SCAN_PREFIX || "").trim().replace(/^\/+|\/+$/g, "");
const names = {
admin: `PW Admin ${suffix}`,
adminEmail: `pw-admin-${suffix}@playwright.local`,
@ -134,12 +136,7 @@ async function waitForWorkflowEditor(page) {
await page.locator('[data-testid="operator-library-count"]').waitFor();
}
async function ensureButtonState({
page,
activeLocator,
inactiveLocator,
activate,
}) {
async function ensureButtonState({ page, activeLocator, inactiveLocator, activate }) {
const isVisible = async (locator) => {
try {
return await locator.isVisible();
@ -250,7 +247,9 @@ async function createAuditWorkflow(projectName, workflowName) {
position: { x: 200, y: 0 },
},
],
edges: [{ id: "review-upload", source: "review", sourceHandle: "approved", target: "upload", targetHandle: "in-1" }],
edges: [
{ id: "review-upload", source: "review", sourceHandle: "approved", target: "upload", targetHandle: "in-1" },
],
}),
});
@ -363,7 +362,10 @@ async function main() {
await page.getByRole("button", { name: "确认注册" }).click();
await page.getByPlaceholder("搜索算子...").fill(`PW Operator ${suffix}`);
await page.getByText(`PW Operator ${suffix}`).waitFor();
const operatorCard = page.locator("div").filter({ hasText: `PW Operator ${suffix}` }).first();
const operatorCard = page
.locator("div")
.filter({ hasText: `PW Operator ${suffix}` })
.first();
await operatorCard.getByRole("button", { name: /配置详情|查看详情/ }).click();
await page.getByPlaceholder("描述该算子的功能与用途...").fill("Playwright updated operator");
await page.getByRole("button", { name: "保存修改" }).click();
@ -377,11 +379,7 @@ async function main() {
await page.getByRole("link", { name: "业务数据库" }).click();
await page.getByRole("heading", { name: "业务数据库" }).waitFor();
await page.getByText("管理用户自定义的业务 MongoDB 连接").waitFor();
const connectionSelect = page
.locator('label:has-text("当前连接")')
.locator("..")
.locator("select")
.first();
const connectionSelect = page.locator('label:has-text("当前连接")').locator("..").locator("select").first();
const optionCount = await connectionSelect.locator("option").count();
if (optionCount > 1) {
await connectionSelect.selectOption({ index: 1 });
@ -444,15 +442,9 @@ async function main() {
await page.getByRole("button", { name: "确认创建" }).click();
await waitForWorkflowEditor(page);
await page.getByPlaceholder("搜索算子...").fill("BOS 增量扫描");
const scanOperatorCard = page
.locator("div")
.filter({ hasText: "BOS 增量扫描" })
.first();
const scanOperatorCard = page.locator("div").filter({ hasText: "BOS 增量扫描" }).first();
await scanOperatorCard.locator('button[title="点击添加到画布"]').click();
const scanCanvasNode = page
.locator(".react-flow__node")
.filter({ hasText: "BOS 增量扫描" })
.first();
const scanCanvasNode = page.locator(".react-flow__node").filter({ hasText: "BOS 增量扫描" }).first();
await scanCanvasNode.waitFor();
await scanCanvasNode.dblclick();
await page.getByText("扫描源配置").waitFor();
@ -465,7 +457,7 @@ async function main() {
await page.getByRole("button", { name: "工作流配置" }).click();
const storageConnections = (await api("/api/storage/connections")).items || [];
if (storageConnections.length > 0) {
if (storageConnections.length > 0 && scanBucket && scanPrefix) {
log("scan source operator favorite storage paths");
const connectionId = storageConnections[0].id;
await page
@ -474,69 +466,57 @@ async function main() {
.locator("select")
.first()
.selectOption(connectionId);
await page.waitForFunction(() => {
await page.waitForFunction((bucket) => {
const labels = Array.from(document.querySelectorAll("label"));
const bucketLabel = labels.find((item) => item.textContent?.includes("Bucket"));
const select = bucketLabel?.parentElement?.querySelector("select");
return (
!!select &&
Array.from(select.options).some((option) => option.value === "datastorage")
);
});
const bucketSelect = page
.locator('label:has-text("Bucket")')
.locator("..")
.locator("select")
.first();
return !!select && Array.from(select.options).some((option) => option.value === bucket);
}, scanBucket);
const bucketSelect = page.locator('label:has-text("Bucket")').locator("..").locator("select").first();
const prefixGroup = page.locator('label:has-text("Prefix")').locator("..");
const prefixInput = prefixGroup.locator("input").first();
await bucketSelect.selectOption("datastorage");
await prefixInput.fill("algo/X-platform-test");
await bucketSelect.selectOption(scanBucket);
await prefixInput.fill(scanPrefix);
await prefixInput.blur();
await ensureButtonState({
page,
activeLocator: page.getByRole("button", { name: "取消收藏当前路径" }).first(),
inactiveLocator: page.getByRole("button", { name: "收藏当前路径" }).first(),
activate: () =>
clickWithRetry(
page,
page.getByRole("button", { name: "收藏当前路径" }).first(),
),
activate: () => clickWithRetry(page, page.getByRole("button", { name: "收藏当前路径" }).first()),
});
await page.getByText("常用路径").first().waitFor();
await bucketSelect.selectOption("");
await prefixInput.fill("");
await prefixInput.blur();
const browseButton = prefixGroup.locator('button[title="浏览前缀"]').first();
const browseDisabled = await browseButton.evaluate((node) =>
node.hasAttribute("disabled"),
);
const browseDisabled = await browseButton.evaluate((node) => node.hasAttribute("disabled"));
assert(!browseDisabled, "favorite storage path should keep OSS browse enabled");
await browseButton.click();
await page.getByRole("heading", { name: "OSS 资源浏览器" }).waitFor();
await page.evaluate(() => {
const candidates = Array.from(
document.querySelectorAll('button[title="datastorage/algo/X-platform-test"]'),
);
const target = candidates
.map((node) => ({ node, x: node.getBoundingClientRect().x }))
.sort((a, b) => a.x - b.x)[0]?.node;
if (!target) {
throw new Error("favorite storage path chip not found");
}
target.click();
});
await page.waitForFunction(() => {
const labels = Array.from(document.querySelectorAll("label"));
const bucketLabel = labels.find((item) => item.textContent?.includes("Bucket"));
const prefixLabel = labels.find((item) => item.textContent?.includes("Prefix"));
const bucketSelect = bucketLabel?.parentElement?.querySelector("select");
const prefixInput = prefixLabel?.parentElement?.querySelector("input");
return (
bucketSelect?.value === "datastorage" &&
prefixInput?.value === "algo/X-platform-test"
);
});
await page.evaluate(
({ bucket, prefix }) => {
const candidates = Array.from(document.querySelectorAll(`button[title="${bucket}/${prefix}"]`));
const target = candidates
.map((node) => ({ node, x: node.getBoundingClientRect().x }))
.sort((a, b) => a.x - b.x)[0]?.node;
if (!target) {
throw new Error("favorite storage path chip not found");
}
target.click();
},
{ bucket: scanBucket, prefix: scanPrefix },
);
await page.waitForFunction(
({ bucket, prefix }) => {
const labels = Array.from(document.querySelectorAll("label"));
const bucketLabel = labels.find((item) => item.textContent?.includes("Bucket"));
const prefixLabel = labels.find((item) => item.textContent?.includes("Prefix"));
const bucketSelect = bucketLabel?.parentElement?.querySelector("select");
const prefixInput = prefixLabel?.parentElement?.querySelector("input");
return bucketSelect?.value === bucket && prefixInput?.value === prefix;
},
{ bucket: scanBucket, prefix: scanPrefix },
);
await page.evaluate(() => {
const heading = Array.from(document.querySelectorAll("h3")).find((item) =>
item.textContent?.includes("OSS 资源浏览器"),
@ -547,22 +527,17 @@ async function main() {
closeButton.click();
}
});
await page
.getByRole("heading", { name: "OSS 资源浏览器" })
.waitFor({ state: "hidden" });
const saveScanWorkflowRequest = page.waitForResponse((response) =>
response.request().method() === "PUT" &&
/\/api\/workflows\/[^/]+$/.test(response.url()) &&
response.ok(),
await page.getByRole("heading", { name: "OSS 资源浏览器" }).waitFor({ state: "hidden" });
const saveScanWorkflowRequest = page.waitForResponse(
(response) =>
response.request().method() === "PUT" && /\/api\/workflows\/[^/]+$/.test(response.url()) && response.ok(),
);
await page.getByRole("button", { name: "保存" }).click();
await saveScanWorkflowRequest;
const savedScanWorkflowId = page.url().match(/\/workflow\/([^?]+)/)?.[1];
assert(savedScanWorkflowId, `unable to resolve saved scan workflow id from ${page.url()}`);
const savedScanWorkflow = await api(`/api/workflows/${encodeURIComponent(savedScanWorkflowId)}`);
const savedScanSourceNode = (savedScanWorkflow.nodes || []).find(
(item) => item?.data?.label === "BOS 增量扫描",
);
const savedScanSourceNode = (savedScanWorkflow.nodes || []).find((item) => item?.data?.label === "BOS 增量扫描");
assert(savedScanSourceNode?.id, "saved scan workflow did not persist BOS 增量扫描 node id");
log("scan source operator favorite storage paths survive fresh browser context");
@ -572,17 +547,10 @@ async function main() {
const verifyPage = await verifyContext.newPage();
try {
await gotoWithRetry(verifyPage, page.url());
await verifyPage
.locator(".react-flow__node")
.filter({ hasText: "BOS 增量扫描" })
.first()
.dblclick();
await verifyPage.locator(".react-flow__node").filter({ hasText: "BOS 增量扫描" }).first().dblclick();
await verifyPage.locator('label:has-text("Bucket")').waitFor();
await verifyPage.getByText("我的常用路径").first().waitFor();
await verifyPage
.getByRole("button", { name: "取消收藏当前路径" })
.first()
.waitFor();
await verifyPage.getByRole("button", { name: "取消收藏当前路径" }).first().waitFor();
} finally {
await verifyContext.close();
}
@ -612,22 +580,11 @@ async function main() {
3000,
);
await page.reload({ waitUntil: "networkidle" });
await page
.locator(".react-flow__node")
.filter({ hasText: "BOS 增量扫描" })
.first()
.dblclick();
await page.locator(".react-flow__node").filter({ hasText: "BOS 增量扫描" }).first().dblclick();
await page.getByText("增量状态").waitFor();
await page.getByText("最近写入 Run").waitFor();
await page
.locator(".node-config-panel")
.getByText(scanRun.id, { exact: true })
.first()
.waitFor();
await clickWithRetry(
page,
page.getByRole("button", { name: "重置当前状态" }).first(),
);
await page.locator(".node-config-panel").getByText(scanRun.id, { exact: true }).first().waitFor();
await clickWithRetry(page, page.getByRole("button", { name: "重置当前状态" }).first());
await poll(
() =>
api(
@ -639,6 +596,8 @@ async function main() {
2000,
);
await page.getByText("当前配置下还没有已提交的增量状态").waitFor();
} else {
log("skip scan source live storage checks; set PLAYWRIGHT_SCAN_BUCKET and PLAYWRIGHT_SCAN_PREFIX to enable");
}
await gotoWithRetry(page, `${baseURL}/project/${project.id}`);
@ -730,11 +689,7 @@ async function main() {
});
await page.reload({ waitUntil: "networkidle" });
await page
.locator(".react-flow__node")
.filter({ hasText: "真实数据源" })
.first()
.dblclick();
await page.locator(".react-flow__node").filter({ hasText: "真实数据源" }).first().dblclick();
const sourceGroup = page.locator('label:has-text("SOURCE_TEXT")').locator("..").locator("..");
await sourceGroup.locator("input").fill(`playwright-ui-${suffix}`);
await page.getByRole("button", { name: "保存" }).click();
@ -864,14 +819,9 @@ async function main() {
item.status === "running" &&
item.nodeExecutions?.some(
(execution) =>
execution.nodeId === "source-1" &&
execution.status === "completed" &&
execution.artifacts?.length > 0,
execution.nodeId === "source-1" && execution.status === "completed" && execution.artifacts?.length > 0,
) &&
item.nodeExecutions?.some(
(execution) =>
execution.nodeId === "shell-1" && execution.status === "running",
),
item.nodeExecutions?.some((execution) => execution.nodeId === "shell-1" && execution.status === "running"),
`edge running workflow ${edgeRunningRun.id} to enter running state`,
120000,
1500,
@ -880,28 +830,16 @@ async function main() {
edgeRunningRunDetail.nodeExecutions
?.find((execution) => execution.nodeId === "source-1")
?.artifacts?.find((artifact) => artifact.portId === "out-1") ||
edgeRunningRunDetail.artifacts?.find(
(artifact) =>
artifact.nodeId === "source-1" && artifact.portId === "out-1",
);
edgeRunningRunDetail.artifacts?.find((artifact) => artifact.nodeId === "source-1" && artifact.portId === "out-1");
assert(edgeRunningArtifact?.name, "running edge artifact not found");
await gotoWithRetry(page, `${baseURL}/workflow/${edgeRunningWorkflow.id}`);
await page.locator(".react-flow").waitFor();
await page.getByText(`Run ${edgeRunningRun.id}`).waitFor();
await clickWorkflowEdge(page, "真实数据源 到 Shell 命令执行 连线");
await page
.locator(".edge-output-panel")
.getByText("连线输出", { exact: true })
.waitFor();
await page
.locator(".edge-output-panel")
.getByText("正在执行中", { exact: true })
.waitFor();
await page
.locator(".edge-output-panel")
.getByText(edgeRunningArtifact.name, { exact: true })
.waitFor();
await page.locator(".edge-output-panel").getByText("连线输出", { exact: true }).waitFor();
await page.locator(".edge-output-panel").getByText("正在执行中", { exact: true }).waitFor();
await page.locator(".edge-output-panel").getByText(edgeRunningArtifact.name, { exact: true }).waitFor();
await poll(
async () => api(`/api/runs/${edgeRunningRun.id}`),
@ -913,14 +851,8 @@ async function main() {
await gotoWithRetry(page, `${baseURL}/workflow/${edgeRunningWorkflow.id}`);
await page.getByText(`Run ${edgeRunningRun.id}`).waitFor();
await clickWorkflowEdge(page, "真实数据源 到 Shell 命令执行 连线");
await page
.locator(".edge-output-panel")
.getByText("执行完成", { exact: true })
.waitFor();
await page
.locator(".edge-output-panel")
.getByText(edgeRunningArtifact.name, { exact: true })
.waitFor();
await page.locator(".edge-output-panel").getByText("执行完成", { exact: true }).waitFor();
await page.locator(".edge-output-panel").getByText(edgeRunningArtifact.name, { exact: true }).waitFor();
const edgeFailedWorkflow = await createWorkflow(
project.id,
@ -983,9 +915,7 @@ async function main() {
item.status === "failed" &&
item.nodeExecutions?.some(
(execution) =>
execution.nodeId === "source-1" &&
execution.status === "completed" &&
execution.artifacts?.length > 0,
execution.nodeId === "source-1" && execution.status === "completed" && execution.artifacts?.length > 0,
),
`edge failed workflow ${edgeFailedRun.id} failure`,
120000,
@ -995,30 +925,25 @@ async function main() {
edgeFailedRunDetail.nodeExecutions
?.find((execution) => execution.nodeId === "source-1")
?.artifacts?.find((artifact) => artifact.portId === "out-1") ||
edgeFailedRunDetail.artifacts?.find(
(artifact) =>
artifact.nodeId === "source-1" && artifact.portId === "out-1",
);
edgeFailedRunDetail.artifacts?.find((artifact) => artifact.nodeId === "source-1" && artifact.portId === "out-1");
assert(edgeFailedArtifact?.name, "failed edge artifact not found");
await gotoWithRetry(page, `${baseURL}/workflow/${edgeFailedWorkflow.id}`);
await page.locator(".react-flow").waitFor();
await page.getByText(`Run ${edgeFailedRun.id}`).waitFor();
await clickWorkflowEdge(page, "真实数据源 到 Shell 命令执行 连线");
await page
.locator(".edge-output-panel")
.getByText("执行失败", { exact: true })
.waitFor();
await page
.locator(".edge-output-panel")
.getByText(edgeFailedArtifact.name, { exact: true })
.waitFor();
await page.locator(".edge-output-panel").getByText("执行失败", { exact: true }).waitFor();
await page.locator(".edge-output-panel").getByText(edgeFailedArtifact.name, { exact: true }).waitFor();
log("export template from workflow editor");
await gotoWithRetry(page, `${baseURL}/workflow/${workflow.id}?runId=${editorRun.id}`);
await page.locator(".react-flow").waitFor();
await page.getByRole("button", { name: "导出模板" }).click();
await page.locator('input').filter({ has: page.locator('.. >> text=模板名称') }).first().fill(names.template);
await page
.locator("input")
.filter({ has: page.locator(".. >> text=模板名称") })
.first()
.fill(names.template);
await page.getByRole("button", { name: "创建模板" }).click();
await page.waitForURL(/type=template/);
@ -1051,12 +976,24 @@ async function main() {
await page.getByRole("link", { name: "用户管理" }).click();
await page.getByRole("heading", { name: "用户管理" }).waitFor();
await capture(page, "14-users");
await clickWithRetry(page, page.locator("button").filter({ hasText: /^创建用户$/ }).first());
await clickWithRetry(
page,
page
.locator("button")
.filter({ hasText: /^创建用户$/ })
.first(),
);
await page.getByRole("heading", { name: "创建用户" }).waitFor();
await fillLabeledInput(page, "用户名", names.extraUser);
await fillLabeledInput(page, "邮箱地址", names.extraUserEmail);
await page.locator('label:has-text("角色权限")').locator("..").locator("select").selectOption("operator");
await clickWithRetry(page, page.locator("button").filter({ hasText: /^创建用户$/ }).last());
await clickWithRetry(
page,
page
.locator("button")
.filter({ hasText: /^创建用户$/ })
.last(),
);
await page.getByText(names.extraUser).waitFor();
const userRow = page.locator("tr").filter({ hasText: names.extraUser }).first();
await userRow.getByRole("button", { name: "编辑" }).click();
@ -1095,7 +1032,10 @@ async function main() {
} finally {
await page.close().catch(() => {});
if (page.video()) {
recordedVideoPath = await page.video().path().catch(() => "");
recordedVideoPath = await page
.video()
.path()
.catch(() => "");
}
await context.close();
await browser.close();

View File

@ -1,6 +1,6 @@
import { chromium } from "playwright";
const baseURL = (process.env.BASE_URL || process.argv[2] || "http://114.111.24.223:30080").replace(/\/+$/, "");
const baseURL = (process.env.BASE_URL || process.argv[2] || "http://127.0.0.1:3001").replace(/\/+$/, "");
const suffix = Date.now().toString(36);
const prefix = `PWX ${suffix}`;
@ -112,7 +112,10 @@ async function cleanupTestData() {
async function ensureUIReady(page) {
await gotoWithRetry(page, baseURL);
const bootstrapVisible = await page.getByText("新增真实平台用户").isVisible({ timeout: 5000 }).catch(() => false);
const bootstrapVisible = await page
.getByText("新增真实平台用户")
.isVisible({ timeout: 5000 })
.catch(() => false);
if (bootstrapVisible) {
await page.getByPlaceholder("输入真实姓名或账号名").fill(names.user);
await page.getByPlaceholder("name@example.com").fill(names.email);
@ -157,7 +160,10 @@ async function runWorkflow(workflowId) {
180000,
3000,
);
assert(finished.status === "completed", `Run ${queued.id} finished with ${finished.status}: ${finished.error || "unknown error"}`);
assert(
finished.status === "completed",
`Run ${queued.id} finished with ${finished.status}: ${finished.error || "unknown error"}`,
);
return finished;
}
@ -204,7 +210,8 @@ async function createWorkflows(projectId) {
hyperparams: [
{
key: "COMMAND",
value: "printf '{\"device\":{\"id\":\"robot-1\",\"status\":\"ok\"},\"items\":[{\"kind\":\"keep\",\"value\":1},{\"kind\":\"drop\",\"value\":2}]}' > payload.json",
value:
'printf \'{"device":{"id":"robot-1","status":"ok"},"items":[{"kind":"keep","value":1},{"kind":"drop","value":2}]}\' > payload.json',
},
],
},
@ -235,7 +242,7 @@ async function createWorkflows(projectId) {
hyperparams: [
{ key: "FIELD_PATH", value: "kind" },
{ key: "OPERATOR", value: "eq" },
{ key: "EXPECTED_JSON", value: "\"keep\"" },
{ key: "EXPECTED_JSON", value: '"keep"' },
],
},
position: { x: 220, y: -20 },
@ -249,7 +256,7 @@ async function createWorkflows(projectId) {
description: "Rename fields",
inputs: [{ id: "in-1", name: "input", type: "json" }],
outputs: [{ id: "out-1", name: "mapped", type: "json" }],
hyperparams: [{ key: "FIELD_MAP_JSON", value: "{\"kind\":\"label\",\"value\":\"score\"}" }],
hyperparams: [{ key: "FIELD_MAP_JSON", value: '{"kind":"label","value":"score"}' }],
},
position: { x: 220, y: 120 },
},
@ -280,7 +287,7 @@ async function createWorkflows(projectId) {
hyperparams: [
{ key: "FIELD_PATH", value: "kind" },
{ key: "OPERATOR", value: "eq" },
{ key: "EXPECTED_JSON", value: "\"keep\"" },
{ key: "EXPECTED_JSON", value: '"keep"' },
],
},
position: { x: 220, y: 260 },
@ -375,7 +382,8 @@ async function createWorkflows(projectId) {
hyperparams: [
{
key: "COMMAND",
value: "mkdir -p scan-root && printf 'alpha' > scan-root/a.txt && printf '{\"beta\":1}' > scan-root/b.json && printf '{\"sourcePath\":\"'\"$OUTPUT_DIR\"'/scan-root\"}' > manifest.json",
value:
"mkdir -p scan-root && printf 'alpha' > scan-root/a.txt && printf '{\"beta\":1}' > scan-root/b.json && printf '{\"sourcePath\":\"'\"$OUTPUT_DIR\"'/scan-root\"}' > manifest.json",
},
],
},
@ -413,7 +421,8 @@ async function createWorkflows(projectId) {
hyperparams: [
{
key: "COMMAND",
value: "python3 - <<'PY'\nimport sqlite3\nconn = sqlite3.connect('bag_0.db3')\ncur = conn.cursor()\ncur.execute('create table topics (id integer primary key, name text, type text, serialization_format text)')\ncur.execute('create table messages (id integer primary key, topic_id integer, timestamp integer, data blob)')\ncur.execute(\"insert into topics (id, name, type, serialization_format) values (1, '/camera', 'sensor_msgs/msg/Image', 'cdr')\")\ncur.execute(\"insert into messages (topic_id, timestamp, data) values (1, 100, X'01')\")\ncur.execute(\"insert into messages (topic_id, timestamp, data) values (1, 200, X'02')\")\nconn.commit()\nconn.close()\nPY",
value:
"python3 - <<'PY'\nimport sqlite3\nconn = sqlite3.connect('bag_0.db3')\ncur = conn.cursor()\ncur.execute('create table topics (id integer primary key, name text, type text, serialization_format text)')\ncur.execute('create table messages (id integer primary key, topic_id integer, timestamp integer, data blob)')\ncur.execute(\"insert into topics (id, name, type, serialization_format) values (1, '/camera', 'sensor_msgs/msg/Image', 'cdr')\")\ncur.execute(\"insert into messages (topic_id, timestamp, data) values (1, 100, X'01')\")\ncur.execute(\"insert into messages (topic_id, timestamp, data) values (1, 200, X'02')\")\nconn.commit()\nconn.close()\nPY",
},
],
},
@ -451,7 +460,8 @@ async function createWorkflows(projectId) {
hyperparams: [
{
key: "COMMAND",
value: "mkdir -p dataset/meta dataset/data dataset/videos && printf '{\"robot_type\":\"aloha\",\"fps\":30}' > dataset/meta/info.json && printf '{\"episodes\":2}' > dataset/meta/stats.json && printf '{\"task\":\"pick\"}\\n{\"task\":\"place\"}\\n' > dataset/meta/tasks.jsonl && printf 'PAR1' > dataset/data/episode_000.parquet && printf 'video' > dataset/videos/episode_000.mp4",
value:
'mkdir -p dataset/meta dataset/data dataset/videos && printf \'{"robot_type":"aloha","fps":30}\' > dataset/meta/info.json && printf \'{"episodes":2}\' > dataset/meta/stats.json && printf \'{"task":"pick"}\\n{"task":"place"}\\n\' > dataset/meta/tasks.jsonl && printf \'PAR1\' > dataset/data/episode_000.parquet && printf \'video\' > dataset/videos/episode_000.mp4',
},
],
},
@ -511,7 +521,10 @@ async function main() {
log("verify operator catalog");
const operators = (await api("/api/operators")).items;
for (const name of requiredOperators) {
assert(operators.some((item) => item.name === name), `Missing built-in operator ${name}`);
assert(
operators.some((item) => item.name === name),
`Missing built-in operator ${name}`,
);
}
log("create workflows");
@ -521,19 +534,34 @@ async function main() {
log("run preview workflow");
const previewRun = await runWorkflow(workflows.previewWorkflow.id);
const previewArtifacts = (await api(`/api/runs/${previewRun.id}/artifacts`)).items;
assert(artifactByName(previewArtifacts, "report.csv").data.preview.kind === "table", "report.csv preview should be table");
assert(artifactByName(previewArtifacts, "notes.txt").data.preview.kind === "text", "notes.txt preview should be text");
assert(
artifactByName(previewArtifacts, "report.csv").data.preview.kind === "table",
"report.csv preview should be table",
);
assert(
artifactByName(previewArtifacts, "notes.txt").data.preview.kind === "text",
"notes.txt preview should be text",
);
log("run data ops workflow");
const dataOpsRun = await runWorkflow(workflows.dataOpsWorkflow.id);
const dataOpsArtifacts = (await api(`/api/runs/${dataOpsRun.id}/artifacts`)).items;
assert(artifactByName(dataOpsArtifacts, "extracted.json").data.value === "robot-1", "JSON extract should return robot-1");
assert(
artifactByName(dataOpsArtifacts, "extracted.json").data.value === "robot-1",
"JSON extract should return robot-1",
);
assert(artifactByName(dataOpsArtifacts, "filtered.json").data.count === 1, "JSON filter should keep one row");
const mapped = artifactByName(dataOpsArtifacts, "mapped.json").data.items;
assert(Array.isArray(mapped) && mapped[0].label === "keep" && mapped[0].score === 1, "JSON map should rename fields");
assert(artifactByName(dataOpsArtifacts, "rows.csv").data.preview.kind === "table", "JSON to CSV should produce previewable csv");
assert(
artifactByName(dataOpsArtifacts, "rows.csv").data.preview.kind === "table",
"JSON to CSV should produce previewable csv",
);
assert(artifactByName(dataOpsArtifacts, "matched.json").portId === "matched", "matched artifact should carry portId");
assert(artifactByName(dataOpsArtifacts, "unmatched.json").portId === "unmatched", "unmatched artifact should carry portId");
assert(
artifactByName(dataOpsArtifacts, "unmatched.json").portId === "unmatched",
"unmatched artifact should carry portId",
);
log("run csv conversion workflow");
const csvRun = await runWorkflow(workflows.csvWorkflow.id);
@ -543,14 +571,20 @@ async function main() {
log("run directory scan workflow");
const scanRun = await runWorkflow(workflows.scanWorkflow.id);
const scanArtifacts = (await api(`/api/runs/${scanRun.id}/artifacts`)).items;
assert(artifactByName(scanArtifacts, "directory-scan.json").data.summary.fileCount >= 2, "Directory scan should report files");
assert(
artifactByName(scanArtifacts, "directory-scan.json").data.summary.fileCount >= 2,
"Directory scan should report files",
);
log("run rosbag workflow");
const rosbagRun = await runWorkflow(workflows.rosbagWorkflow.id);
const rosbagArtifacts = (await api(`/api/runs/${rosbagRun.id}/artifacts`)).items;
const rosbagPreview = artifactByName(rosbagArtifacts, "rosbag-summary.json").data.preview;
assert(rosbagPreview.format === "rosbag2", "ROSBag summary should detect rosbag2 sqlite");
assert(Array.isArray(rosbagPreview.topics) && rosbagPreview.topics[0].name === "/camera", "ROSBag summary should include topics");
assert(
Array.isArray(rosbagPreview.topics) && rosbagPreview.topics[0].name === "/camera",
"ROSBag summary should include topics",
);
log("run lerobot workflow");
const lerobotRun = await runWorkflow(workflows.lerobotWorkflow.id);

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3
import json
import os
import sys
import textwrap
import time
@ -7,7 +8,7 @@ import urllib.error
import urllib.request
BASE = "http://114.111.24.223:30080"
BASE = os.getenv("BASE_URL", os.getenv("API_BASE_URL", "http://127.0.0.1:3001")).rstrip("/")
def request(method, path, payload=None, expected=(200, 201, 202, 204)):