Skip to content

test(bot): realign stale unit tests with main and run the suite in CI - #4746

Open
now-ing wants to merge 4 commits into
volcengine:mainfrom
now-ing:m3-test/bot-suite-revival
Open

now-ing wants to merge 4 commits into
volcengine:mainfrom
now-ing:m3-test/bot-suite-revival

Conversation

@now-ing

@now-ing now-ing commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Summary

The VikingBot unit test suites (bot/tests/ + bot/vikingbot/, 531 tests) are not executed by any workflow in the repo — no job sets working-directory: bot or invokes pytest on bot paths. As a result the suite drifted red silently: 12 of 531 tests were failing on current main (verified on f97ce530), in some cases for weeks:

Family Count Root cause Since
compact-hook (test_openviking_api_key_type.py) 4 commit_session now sends turn-budget retention kwargs (retention_mode="turn_budget", keep_recent_turn_count, …) from #3380; test fakes had strict signatures → TypeError → success=False ~6 weeks
agent-loop outcome (test_agent_loop_outcome.py) 3 token_usage now includes cache_read_input_tokens (#4059); the pre-model hook kwarg was renamed keep_recent_count → keep_recent_turn_count #4059
compile prompt (test_compile.py) 1 checkout rule text changed from "commits only validated changes" to "scans and validates the complete tree" (#4059) #4059
legacy workspace (test_session_portable_paths.py) 1 hardcoded 2026-08-20 timestamps crossed the 2-day STALE_SESSION_THRESHOLD — a time-bomb test, failing since ~08-22 #4162

All 12 are test-side drift against intentional main behavior — no production code is changed by this PR. Each was triaged against the introducing commit before updating the expectation.

What the tests now pin (notable)

  • The compact-hook tests previously recorded only the deprecated physical-message keep_recent_count. They now record the full retention contract: (session_id, retention_mode, keep_recent_turn_count, user_id), with configs migrated to the active commit_keep_recent_turn_count field (commit_keep_recent_count remains in AgentsConfig as the documented deprecated field).
  • The heartbeat test derives its timestamps relative to now so it can never cross the staleness window again, instead of rotting on a fixed date.

CI lane

Adds a path-gated bot-tests job to 01. Pull Request Checks:

  • Gate: runs when bot/**, pyproject.toml, uv.lock, or the workflow itself change (same check-deps outputs pattern as cuvs-tests / langchain-tests).
  • Install: uv sync --frozen --extra bot — the documented bot dependency set (README installs openviking[bot]); vikingbot is a packaged module of the main distribution ([tool.setuptools.packages.find] where = [".", "bot"]), so no PYTHONPATH tricks are needed.
  • Run: uv run python -m pytest -q -o addopts='' bot/tests bot/vikingbot (coverage addopts disabled for this lane — the --cov=openviking default measures the wrong package for a bot run).

Verification

  • Clean checkout of main @ f97ce530: 519 passed, 12 failed.
  • With this branch: 531 passed (bot/tests + bot/vikingbot, Python 3.12).
  • uv.lock provides-extras includes bot; bot-only deps (croniter, lark-oapi, gradio, …) are present in the lockfile, so uv sync --frozen --extra bot resolves offline-pinned.
  • Workflow YAML structure validated (job graph: check-deps → bot-tests, outputs wired).

This closes the fifth known CI blind-spot family for this suite (after openclaw vitest, dsh plugin tests, web-studio vitest, and the plugin-tests manifest).

mac added 2 commits September 7, 2026 01:58
The bot suites have not run in CI, so they drifted silently against main:

- compact-hook tests: commit_session now sends turn-budget retention
  kwargs (retention_mode/keep_recent_turn_count/...); fakes recorded only
  the dead physical-message keep_recent_count. Record the full retention
  contract and migrate configs to commit_keep_recent_turn_count
  (commit_keep_recent_count is the deprecated field).
- agent-loop tests: token_usage now includes cache_read_input_tokens and
  the pre-model hook receives keep_recent_turn_count instead of
  keep_recent_count; align expectations and configs.
- compile prompt test: the checkout rule now states Compile 'scans and
  validates the complete tree' instead of 'commits only validated
  changes'.
- legacy workspace test: hardcoded 2026-08-20 timestamps crossed the
  2-day STALE_SESSION_THRESHOLD window, so the session was skipped;
  derive timestamps relative to now.

No production code changed. Full suite: 531 passed.
None of the repo workflows exercise bot/tests or bot/vikingbot, so the
531-test suite had no CI signal and drifted red unnoticed (12 stale
failures at the time of this change). Add a path-gated bot-tests job to
the PR workflow: it runs when bot/, the shared dependency manifests, or
this workflow change, installs via 'uv sync --frozen --extra bot', and
runs pytest over both bot test trees.
The first bot-tests run failed 239 async tests with "async def
functions are not natively supported": 'uv sync --frozen --extra bot'
only provides the dev group's bare pytest, while pyproject sets
asyncio_mode=auto, which requires pytest-asyncio from the test extra.

Add --extra test, matching the existing pattern in _test_lite.yml.
@now-ing

now-ing commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

The first bot-tests run failed: 239 async tests errored with async def functions are not natively supported (run 34050328674).

Root cause: uv sync --frozen --extra bot only installs the dev group's bare pytest (9.0.2), but pyproject.toml sets asyncio_mode = "auto", which needs pytest-asyncio — that lives in the test extra. My local environment had it installed, which is why the 531/531 green run didn't catch this.

Fix in c267be4: add --extra test to the sync step, matching the existing pattern in _test_lite.yml:73. Verified locally that the same test file that failed in CI (bot/tests/test_agent_loop_outcome.py) passes 26/26 once pytest-asyncio is present.

@now-ing

now-ing commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Confirmed green: with --extra test the bot-tests job now passes 531/531 in run 34051460140 — matching the local baseline exactly. "01. Pull Request Checks" is green; integration lane still running.

@now-ing

now-ing commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

The failed integration run (34051459778) hit a single unrelated flake: filesystem/test_fs_cp.py::TestFsCp::test_cp_directory_requires_recursive_and_copies_tree failed with 409 CONFLICT path_busy (lock acquire timed out after 0ms, retryable: true) — the same async directory-abstract lock window that test_fs_rm hit before, which #4374 addresses. Everything else passed (1 failed, 11 passed). This PR only touches bot/ and .github/workflows/pr.yml, so there is no overlap with that code path.

I've pushed an empty commit to retrigger, and I'm extending #4374 to cover test_fs_cp as well so the whole path-busy flake family is fixed at the root.

This branch has not been deployed

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant