Skip to content

test: cover workflow asset import fan-out, user edits and fetch bounds - #83

Merged
EricWvi merged 3 commits into
ora-space:mainfrom
wanglongan587:test/217-import-direct-tests
Oct 20, 2026
Merged

EricWvi merged 3 commits into
ora-space:mainfrom
wanglongan587:test/217-import-direct-tests

Conversation

@wanglongan587

@wanglongan587 wanglongan587 commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

补齐 #195 命名的三条 workflow 资产导入直接证据,全部真实 HTTPS + 真实 PostgreSQL;不重做导入实现。

Refs ora-space/circus#217

三条证据

  1. 多 Workspace 不 fan-out(TestWorkflowAssetImportDoesNotFanOutToWorkspaces):项目 main Workspace 加两个 isolated,共 ≥2 个 live Workspace;Node 侧安装确实 fan-out(每个 live workspace 一行 workspace_plugin_instances),导入不跟随——来源记录一行、每份文档一个 workflow 和一个已发布快照,第二轮也不新增。
  2. 编辑后升级(TestWorkflowAssetImportKeepsUserEditsAcrossUpgrade):用户编辑导入副本的活稿并发布自己的 v2 快照后升级包;活稿与两份快照的 graph::text 逐字节不变,升级内容不出现在任何位置,仅新增 hotfix.json 按只增不改导入。
  3. 慢响应与体积上界(TestWorkflowAssetImportCancelsSlowOrOversizePackages):四个子用例全部经生产 NewUpstreamClient 传输链触发真实边界——10 秒连接(接受 TCP 后不完成 TLS 握手;TCP 拨号与 TLS 握手同一 10 秒取值)、30 秒响应头、60 秒整包、16 MiB 流式(无 Content-Length 的 chunked 流,读计数在读完前中断,服务端写失败为证)。每个失败都是包级(无文档行、无 workflow、无快照),同一 URL 修复后重装同版本重试成功。四个子用例并行(各自独立 schema 与服务器),整个测试耗时约等于最长边界 60 秒,而非总和。

生产代码改动

仅一处测试接缝:feat(modelgateway) commit 新增 NewUpstreamClientWithRoots(config, roots),按 gitrefs.NewWithHTTP 的既有做法给测试一个显式信任根入口;生产调用方(cmd/server、cmd/model-gateway)仍只调用 NewUpstreamClient,上游身份照旧由部署的 system root pool 验证。边界测试用它在受控 HTTPS 服务器上跑完整生产链路:受检拨号、10/30 秒截止与 TLS 主机名验证全部照常执行。

根池走构造参数而不是 UpstreamConfig 字段:rebase 到最新 main 后该结构体随 egress 重构变为 72 字节,再加字段会越过 gocritic hugeParam 阈值(80 字节),只能改生产路径的指针签名;构造参数让部署配置结构保持原样。

integration/cloud_test.go 的 gin.SetMode 移到 sync.Once 之后,使并行子测试各自建 fixture 不在 race 检测下竞争全局。

验证

  • 已 rebase 到 cloud main 0f4e60b(含外部 Git 线、WorkflowRun、cloud#84 等),冲突只在 internal/modelgateway/transport.go:按 main 的 egress.Policy / egress.DNSConfig 重接,integration/cloud_test.go 的 sync.Once 自动合入。
  • 新增三个测试全绿;TestWorkflowAssetImport* 全部 8 个用例回归通过;internal/modelgateway 公共路径单测通过。
  • Linux(WSL Ubuntu,gcc 15)go test -race ./integration/ -run TestWorkflowAssetImport 通过(71s),无竞争报告。
  • task lint 0 issues、task format:check 通过、git diff --check 干净。
  • Windows 本机 internal/modelgateway 的 enterprise 用例失败(staticAddresses forbidden by address policy):本机非回环网卡只有 198.18/15、100.64/10 等保留段,与本次改动无关;pristine main 同样失败,已单独核对。

ADR 状态

不涉及新 ADR 实现:20261016-workflow-plugin-assets.md 与 20261016-asset-import-and-published-snapshots.md 均已是 implemented,本 PR 只补测试证据。specs 用例的证据状态在 specs#122 更新,链到 cloud main 上的固定提交,按 owner 结论在 cloud#83 合并后再改并请复核。

@creegon2 creegon2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查 commit d1c23c9。

新增的多 Workspace、用户编辑后升级、TLS 握手/响应头/整包超时及流式中断测试具有直接断言。TLSRoots 仅注入该客户端的根池,两个生产调用方继续使用系统根,未发现阻塞代码问题。并行子测试各自隔离 schema、监听端口和服务端,gin 初始化经 sync.Once 保护。

核对了 CI run 39035300194:PR head 与 CI 实测 merge commit f0c3c75 的 tree 相同,真实 PostgreSQL 的全量 race 门禁通过,日志明确包含三个新测试及四个取包边界子用例。本次未重复运行全量测试。

批准范围限定于这些测试及测试接缝:10 秒用例在 TCP 已连接后阻塞 TLS,实际证明的是 TLS 握手截止,不能替代 TCP 拨号截止的直接证据。specs#122 需单独修正证据状态与漏掉的多 Workspace 义务行;本次 Approve 不表示 circus#195 的全部验收已完成。

Refs ora-space/circus#217

The two import gaps circus#195 names that need no production change:
with several live Workspaces the import stays scoped to the space (one
source row, one workflow and one published snapshot per document), and a
package upgrade after the user edited the imported copy and published
their own snapshot changes nothing the user owns.
…rt tests

NewUpstreamClientWithRoots builds the production upstream client with an
explicit TLS root pool instead of the platform pool, following the
existing gitrefs.NewWithHTTP seam. Production wiring keeps calling
NewUpstreamClient, so deployed upstream identity still comes from the
deployment's system roots; tests that must run the checked dialer, the
10/30-second deadlines and TLS hostname verification against a controlled
HTTPS server inject the root that signed it.

The roots travel as a constructor argument rather than an UpstreamConfig
field so the deployment configuration struct keeps its existing shape and
size; modelgateway always receives the full UpstreamConfig by value, and
growing it past the gocritic hugeParam threshold would force a pointer
signature change on the production path.
The four approved fetch bounds had no slow-response evidence: the 10s
connection deadline, the 30s response-header deadline, the 60s
whole-package deadline and the 16 MiB streaming cap are now each
triggered for real through the production upstream transport against a
controlled HTTPS server (public deployment egress, fixture-host exemption
for 127.0.0.1 only, TLS verified against a generated CA). Every case
asserts the package-level failure leaves no document, workflow or
snapshot rows and that the next administrator trigger retries the same
URL successfully. gin.SetMode moves behind a sync.Once so parallel
subtests can each build their own fixture; the whole test costs its
longest boundary (60s), not the sum.
@wanglongan587
wanglongan587 force-pushed the test/217-import-direct-tests branch from d1c23c9 to 23e4078 Compare October 20, 2026 02:44
@wanglongan587

Copy link
Copy Markdown
Collaborator Author

已 rebase 到 cloud main 0f4e60b,CI(check:buf、golangci-lint 全仓、go test -race -count=1 ./... 真实 PG、四类 build)在 23e4078 通过。

相对上次审的 d1c23c9,测试断言未变,变化只在适配 main 的 egress 重构:

  1. UpstreamConfig 现在是 DNS egress.DNSConfig + Policy *egress.Policy;测试按 cmd/server 同形构造(egress.DefaultDNSConfig() + public policy)。
  2. TLS 信任根接缝从 UpstreamConfig.TLSRoots 字段改为 NewUpstreamClientWithRoots(config, roots):加字段会把 UpstreamConfig 从 72 字节推到 80 字节并触发 gocritic hugeParam;构造入口沿用 gitrefs.NewWithHTTP 的既有做法,cmd/server、cmd/model-gateway 的调用不变。
  3. integration/cloud_test.go 的 gin.SetMode → sync.Once 自动合入。

internal/modelgateway/transport.go 相对 main 净增 20 行。对比:d1c23c9...23e4078

@creegon2 请按新 head 23e4078 复核。

@creegon2 creegon2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve

审的 commit:23e4078d(基线 cloud main 0f4e60b)。相对我上次批准的 d1c23c9,逐文件对比了四个文件:

  • integration/workflow_asset_import_scope_test.go:内容完全相同。
  • integration/workflow_asset_fetch_boundaries_test.go:只有 realAssetFetcher 的构造改了——egress.DefaultDNSConfig() + egress.Parse 解析出的 public 策略,信任根改由 NewUpstreamClientWithRoots 传入。用例和断言没有变化。
  • internal/modelgateway/transport.go:相对 main 只增加 NewUpstreamClientWithRoots 和私有的 newUpstreamClient;NewUpstreamClient 仍传 nil,生产路径不设置 TLSClientConfig,行为不变;传入 nil 根池时报错,不会静默退回系统根。UpstreamConfig 形状与 main 一致。
  • integration/cloud_test.go:gin.SetMode 改为 sync.Once,与上次一致。

另外:

  • 本 PR 与当前 cloud main 5953506(含 #91 / #100 / #104 / #105)试合并无冲突;main 在这几个目录的新增改动只有 internal/egress 和 internal/modelgateway 的 README。
  • CI check 在 23e4078 上通过。

非阻塞建议:internal/modelgateway/README(.en).md 的 transport.go 一行可以补一句“NewUpstreamClientWithRoots 只供测试注入信任根”,方便以后查生产接线的人确认它不在生产路径上。

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants