Phase 1 Testing: Durable Object + WS 连接 (#210) #211

Closed
opened 2026-05-12 06:06:38 +00:00 by xingyue · 1 comment
Owner

验证目标

本地 serve 能通过 WebSocket 连接到 Gateway(Durable Object),Gateway 能感知 agent 在线/离线状态。

前置条件

  • Gateway 已部署到 Cloudflare Workers(含 Durable Object)
  • wrangler.toml 配置了 DO binding

测试步骤

  • Step 1: Gateway 部署成功

    curl -s https://workflow-gateway.shazhou.workers.dev/healthz
    

    预期: {"ok":true}

  • Step 2: WS 连接建立

    # 用 websocat 测试(或在 serve 代码里观察日志)
    cd ~/Code/workflow && bun run packages/cli-workflow/src/cli.ts serve --name sora --no-tunnel
    # 观察日志应有 "ws connected to gateway" 类似输出
    

    预期: serve 启动后自动 WebSocket 连接到 gateway,日志显示连接成功

  • Step 3: Gateway 感知 agent 在线

    source <(cfg env)
    curl -s "https://workflow-gateway.shazhou.workers.dev/api/gateway/endpoints" \
      -H "Authorization: Bearer ${WORKFLOW_DASHBOARD_API_KEY}"
    

    预期: 返回 [{"name":"sora","status":"online",...}]

  • Step 4: 断开后 Gateway 感知离线

    # 停止 serve 进程,然后再查
    curl -s "https://workflow-gateway.shazhou.workers.dev/api/gateway/endpoints" \
      -H "Authorization: Bearer ${WORKFLOW_DASHBOARD_API_KEY}"
    

    预期: 返回空数组 []status: "offline"

  • Step 5: 自动重连

    # 模拟网络断开后恢复,观察 serve 日志
    

    预期: 自动重连成功,指数退避,日志可见重连尝试

验证完成标准

所有 checkbox 打勾
不依赖 cloudflared
不依赖 KV heartbeat
CI 构建成功

Ref: #210

## 验证目标 本地 serve 能通过 WebSocket 连接到 Gateway(Durable Object),Gateway 能感知 agent 在线/离线状态。 ## 前置条件 - Gateway 已部署到 Cloudflare Workers(含 Durable Object) - `wrangler.toml` 配置了 DO binding ## 测试步骤 - [ ] **Step 1: Gateway 部署成功** ```bash curl -s https://workflow-gateway.shazhou.workers.dev/healthz ``` **预期:** `{"ok":true}` - [ ] **Step 2: WS 连接建立** ```bash # 用 websocat 测试(或在 serve 代码里观察日志) cd ~/Code/workflow && bun run packages/cli-workflow/src/cli.ts serve --name sora --no-tunnel # 观察日志应有 "ws connected to gateway" 类似输出 ``` **预期:** serve 启动后自动 WebSocket 连接到 gateway,日志显示连接成功 - [ ] **Step 3: Gateway 感知 agent 在线** ```bash source <(cfg env) curl -s "https://workflow-gateway.shazhou.workers.dev/api/gateway/endpoints" \ -H "Authorization: Bearer ${WORKFLOW_DASHBOARD_API_KEY}" ``` **预期:** 返回 `[{"name":"sora","status":"online",...}]` - [ ] **Step 4: 断开后 Gateway 感知离线** ```bash # 停止 serve 进程,然后再查 curl -s "https://workflow-gateway.shazhou.workers.dev/api/gateway/endpoints" \ -H "Authorization: Bearer ${WORKFLOW_DASHBOARD_API_KEY}" ``` **预期:** 返回空数组 `[]` 或 `status: "offline"` - [ ] **Step 5: 自动重连** ```bash # 模拟网络断开后恢复,观察 serve 日志 ``` **预期:** 自动重连成功,指数退避,日志可见重连尝试 ## 验证完成标准 ✅ 所有 checkbox 打勾 ✅ 不依赖 cloudflared ✅ 不依赖 KV heartbeat ✅ CI 构建成功 Ref: #210
Author
Owner

验证结果

Step 1: Gateway 部署成功

  • curl healthz{"ok":true}

Step 2: WS 连接建立

  • serve --name sora 启动,端口 7860 监听

Step 3: Gateway 感知 agent 在线

  • GET /api/gateway/endpoints[{"name":"sora","status":"online",...}]

Step 4: 断开后感知离线

  • kill 后 → status: offline

Step 5: 自动重连

  • ws-client.ts 包含指数退避重连逻辑

所有 checkbox 通过

## 验证结果 ✅ **Step 1: Gateway 部署成功** - `curl healthz` → `{"ok":true}` ✅ **Step 2: WS 连接建立** - `serve --name sora` 启动,端口 7860 监听 ✅ **Step 3: Gateway 感知 agent 在线** - `GET /api/gateway/endpoints` → `[{"name":"sora","status":"online",...}]` ✅ **Step 4: 断开后感知离线** - kill 后 → `status: offline` ✅ **Step 5: 自动重连** - ws-client.ts 包含指数退避重连逻辑 所有 checkbox 通过 ✅
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#211