Skip to content

Add e2e coverage and lifecycle docs for upgrades#5412

Merged
JAORMX merged 4 commits into
mainfrom
upgrade-6-e2e-docs
Jun 2, 2026
Merged

Add e2e coverage and lifecycle docs for upgrades#5412
JAORMX merged 4 commits into
mainfrom
upgrade-6-e2e-docs

Conversation

@JAORMX
Copy link
Copy Markdown
Collaborator

@JAORMX JAORMX commented Jun 1, 2026

Summary

The upgrade flow spans registry lookup, image verification, and a destructive workload recreate, so it needs end-to-end coverage to catch regressions the unit tests cannot. Final slice of RFC THV-0068, local scope.

  • Add an e2e test exercising the full flow against real osv-mcp image tags via custom registry fixtures: a workload run from the 0.1.1 entry reports up-to-date; repointing the registry to 0.1.3 makes the check report an available upgrade; apply recreates the workload on the new image while preserving a user-set env var. A negative spec confirms a raw-image workload reports not-registry-sourced.
  • All thv invocations run under an isolated config/home/data dir, so the suite never touches the developer's real registry configuration.
  • Document the upgrade state transition in the workloads lifecycle architecture doc.

Type of change

  • New feature

Test plan

  • E2E tests (task test-e2e) — full check→apply flow against real osv-mcp tags + the not-registry-sourced negative path.
  • Linting (task lint-fix)
  • Manual testing (describe below)

Manual: fixtures verified against the real upgrade.Checker (low → up-to-date, high → upgrade-available candidate :0.1.3). The e2e itself requires a container runtime and runs in CI, not in the dev sandbox.

Changes

File Change
test/e2e/upgrade_e2e_test.go Full-flow + negative e2e specs (isolated config)
test/e2e/testdata/upgrade/registry-{low,high}.json Registry fixtures (osv at 0.1.1 / 0.1.3)
docs/arch/08-workloads-lifecycle.md Upgrade state-transition section

Does this introduce a user-facing change?

No — tests and documentation only.

Special notes for reviewers

PR 6 of 6 (final) in the RFC THV-0068 stack; based on #5411. The fixtures use the upstream MCP-registry format (a local file in the legacy ToolHive-native format is rejected by the provider) and mirror the real osv entry's transport/port exactly, differing only by image tag.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the size/M Medium PR: 300-599 lines changed label Jun 1, 2026
@JAORMX JAORMX force-pushed the upgrade-5-apply branch from f901540 to a9af988 Compare June 1, 2026 09:32
@JAORMX JAORMX force-pushed the upgrade-6-e2e-docs branch from 66c9cbf to e794c49 Compare June 1, 2026 09:32
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jun 1, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.85%. Comparing base (fc64061) to head (2720044).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5412      +/-   ##
==========================================
+ Coverage   68.82%   68.85%   +0.03%     
==========================================
  Files         634      634              
  Lines       64422    64422              
==========================================
+ Hits        44338    44358      +20     
+ Misses      16801    16784      -17     
+ Partials     3283     3280       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JAORMX JAORMX force-pushed the upgrade-5-apply branch from a9af988 to 74e4064 Compare June 1, 2026 10:12
@JAORMX JAORMX force-pushed the upgrade-6-e2e-docs branch from e794c49 to 1636922 Compare June 1, 2026 10:12
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jun 1, 2026
@JAORMX JAORMX marked this pull request as ready for review June 1, 2026 10:21
@JAORMX JAORMX force-pushed the upgrade-5-apply branch from 74e4064 to 664b47b Compare June 1, 2026 13:16
@JAORMX JAORMX force-pushed the upgrade-6-e2e-docs branch from 1636922 to 0220e77 Compare June 1, 2026 13:16
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jun 1, 2026
@JAORMX JAORMX force-pushed the upgrade-5-apply branch from 664b47b to 9a11b14 Compare June 1, 2026 13:27
@JAORMX JAORMX force-pushed the upgrade-6-e2e-docs branch from 0220e77 to 7438634 Compare June 1, 2026 13:27
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jun 1, 2026
JAORMX and others added 3 commits June 2, 2026 15:19
Detecting an available upgrade is only useful if users can apply it
while keeping their configuration. Add the apply path that the CLI and
API will drive.

Add upgrade.Applier: it reloads the workload's saved config, re-runs the
check on fresh state (so a stale result can never drive an apply),
resolves the candidate from the registry, and rebuilds the run config
preserving the full user configuration — auth, authz, audit, telemetry,
tools filters, volumes, secrets, ports, permission profile, and more —
changing only the image, merged env/secrets, and re-resolved registry
URLs. New required env vars surface through the injected validator.

Crucially, the candidate image is verified and pulled (and the policy
gate runs) before the destructive stop/delete/start, so a missing or
unverifiable image leaves the running workload untouched — there is no
rollback once UpdateWorkload begins. Verification uses the same path as
thv run.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
With the Applier in place, expose it to users. This lets CLI users and
API clients apply an upgrade while preserving their configuration,
instead of manually re-running a workload with a new image.

Add a thv upgrade apply <name> command. It runs the check, shows the
candidate image, new env vars, and any permission/transport/network
posture drift, then prompts for confirmation. --dry-run reports the plan
without applying; --env/--secret supply values for newly required
variables; --yes (or a non-interactive shell) skips the prompt and fails
loudly on missing required values; --image-verification mirrors thv run.

Add POST /api/v1beta/workloads/{name}/upgrade, delegating to the same
Applier so all clients share one apply path. The API path is always
non-interactive (detached validator) and sources image verification from
server config; the request body can only supply env/secret values, never
redirect the image or weaken verification. Apply failures return a
sanitized 422 with the detailed cause logged server-side, so secret
references in an error chain are never echoed to the caller.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The upgrade flow spans registry lookup, image verification, and a
destructive workload recreate, so it needs end-to-end coverage to catch
regressions the unit tests cannot.

Add an e2e test that exercises the full flow against real osv-mcp image
tags via custom registry fixtures: a workload run from the 0.1.1 entry
reports up-to-date, repointing the registry to 0.1.3 makes the check
report an available upgrade, and apply recreates the workload on the new
image while preserving a user-set env var. A negative spec confirms a
raw-image workload reports not-registry-sourced. All thv invocations run
under an isolated config/home/data dir so the suite never touches the
developer's real registry configuration.

Document the upgrade state transition in the workloads lifecycle
architecture doc.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JAORMX JAORMX force-pushed the upgrade-5-apply branch from 9a11b14 to a153c19 Compare June 2, 2026 12:20
@JAORMX JAORMX force-pushed the upgrade-6-e2e-docs branch from 7438634 to a4bfec3 Compare June 2, 2026 12:20
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jun 2, 2026
Base automatically changed from upgrade-5-apply to main June 2, 2026 14:53
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jun 2, 2026
@JAORMX JAORMX merged commit 12fcd15 into main Jun 2, 2026
72 of 73 checks passed
@JAORMX JAORMX deleted the upgrade-6-e2e-docs branch June 2, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants