Skip to content

fix: stabilize API & CLI integration tests in CI#2105

Merged
qin-ctx merged 1 commit into
volcengine:mainfrom
kaisongli:fix/api-test-find-response-401
May 18, 2026
Merged

fix: stabilize API & CLI integration tests in CI#2105
qin-ctx merged 1 commit into
volcengine:mainfrom
kaisongli:fix/api-test-find-response-401

Conversation

@kaisongli
Copy link
Copy Markdown
Collaborator

摘要

修复 CI 中 API 和 CLI 集成测试的稳定性问题,涵盖 PR 模式(fork 仓库无 API KEY)和主仓库 effect 测试(并发过载)两类场景。

修改内容

1. Embedding 服务不可用时跳过相关测试

涉及文件

  • tests/api_test/common/test_response_types.py
  • tests/api_test/resources/slow/test_skill_api.py
  • tests/api_test/scenarios/resources_retrieval_slow/build_test_helpers.py

问题:PR CI 中 fork 仓库无法访问 VLM_API_KEYEMBEDDING_API_KEY 密钥,CI 使用 dummy API key 配置 embedding 服务。依赖 embedding 的接口(findadd_skill)会返回 401 或 500,导致测试误报失败。

根因链

  1. PR CI → 无法访问密钥 → 配置 dummy embedding API key
  2. find 调用 embedding 服务 → 上游返回 401 → 服务端映射为 UNAUTHENTICATED → HTTP 401
  3. add_skill 调用 embedding 做向量化 → 服务端内部错误 → HTTP 500

修复:仅在 401/500 时 pytest.skip(),其他错误仍正常断言失败,保证测试有效性。

2. CLI 测试改为串行执行

涉及文件.github/workflows/api_test.yml

问题:CLI 集成测试使用 -n 4(4 个并行 worker)运行,但共享同一服务器和 session 级别 fixture(test_dir_uritest_pack_uri)。并发 worker 导致:

  • 多个 worker 同时 add-resourceCONFLICT Resource is busy
  • ov write --wait / ov wait 等待被其他 worker 锁定的资源 → 超时 120s

影响的失败用例

  • test_pack_uri fixture → CONFLICT(级联影响 TestContentReadTestContentAbstractTestContentOverviewTestContentDownload
  • TestContentWrite.test_write_append → 超时
  • TestSystemWait.test_wait_with_timeout → 超时
  • TestContentReindex.test_reindex → CONFLICT

修复:移除 CLI 兼容性测试和集成测试的 -n 4 参数,改为串行执行。

3. Effect 测试降低并行度

涉及文件.github/workflows/api_test_effect.yml

问题:effect 测试虽有 API KEY,但资源操作密集的测试并发运行时服务端过载,导致 500 错误和索引构建超时。

修复

  • 轻量测试(common/tasks/skills/retrieval):-n 4-n 2
  • 重量测试(content/resources/sessions/scenarios):-n 2 → 串行

测试验证

  • test_find_response_types 在 embedding 不可用(401)时 SKIP,其他错误仍 FAIL
  • test_add_skill_basic 在 embedding 不可用(500)时 SKIP,其他错误仍 FAIL
  • assert_resource_findable 在 find 返回 401 时 SKIP
  • CLI 测试串行执行,不再因并发冲突产生 CONFLICT 或超时
  • Effect 重量测试串行执行,避免服务端过载

1. Skip find/add_skill tests on 401/500 when embedding unavailable
   - PR CI (fork repos) cannot access VLM/Embedding API keys, causing
     embedding service to return 401/500 with dummy keys
   - test_response_types.py: skip test_find_response_types on 401
   - test_skill_api.py: skip add_skill tests on 500, find tests on 401
   - build_test_helpers.py: skip assert_resource_findable on 401

2. Run CLI tests serially to avoid CONFLICT and timeout
   - CLI tests share session-scoped fixtures (test_dir_uri, test_pack_uri)
   - Concurrent workers cause CONFLICT Resource is busy and timeout errors
   - Remove -n 4 from CLI compatibility and integration test steps

3. Reduce parallelism in effect tests to avoid server overload
   - Lightweight tests: -n 4 -> -n 2
   - Heavy tests: -n 2 -> serial (resource-intensive operations)
@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🏅 Score: 92
🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 Multiple PR themes

Sub-PR theme: Skip tests when embedding service is unavailable

Relevant files:

  • tests/api_test/common/test_response_types.py
  • tests/api_test/resources/slow/test_skill_api.py
  • tests/api_test/scenarios/resources_retrieval_slow/build_test_helpers.py

Sub-PR theme: Adjust CI test parallelism to avoid concurrency issues

Relevant files:

  • .github/workflows/api_test.yml
  • .github/workflows/api_test_effect.yml

⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@qin-ctx qin-ctx merged commit 7673516 into volcengine:main May 18, 2026
4 of 5 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants