Skip to content

test: cover backup and system contracts - #33

Merged
githubsaturn merged 20 commits into
mainfrom
test/backup-system-contracts
Sep 22, 2026
Merged

githubsaturn merged 20 commits into
mainfrom
test/backup-system-contracts

Conversation

@githubsaturn

@githubsaturn githubsaturn commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add core coverage for system, version, load-balancer, node, and Pro read contracts
  • verify fresh-server defaults before later destructive tests
  • create and inspect a one-time binary backup without logging archive contents or secrets
  • compare API node data against Docker inspection over SSH

This is the PR 14 in https://github.com/caprover/caprover-e2e/blob/main/E2E_TEST_PLAN.md

Backend dependency

Final Fresh Server validation must run only after caprover/caprover#2496 is merged and the updated caprover/caprover-edge image is published. PR #2496 fixes the backup archive layout and the second-download missing-file response that PR14 intentionally verifies.

Validation

  • npm ci
  • npm run typecheck
  • npm run test:unit (64 passing)
  • npm run format
  • confirmed destructive selection is guarded without CAPROVER_E2E_ENVIRONMENT=ephemeral

A Fresh Server run remains required before merge. Its requested image, resolved digest, test count, and run link will be recorded after validation.

Summary by CodeRabbit

  • New Features

    • Added access to CapRover system information, including version, load balancer, node, and Pro feature details.
    • Added support for creating downloadable CapRover backups.
    • Added binary download handling to preserve archive and file contents.
    • Added Docker Swarm node discovery and inspection support.
  • Reliability

    • Improved validation and handling of node data and backup downloads.
    • Added coverage for system defaults, system information, backups, node discovery, and binary responses.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 190e6e3b-6bf4-48d1-9300-69a464250a85

📥 Commits

Reviewing files that changed from the base of the PR and between c0f3b0d and b0e1319.

📒 Files selected for processing (13)
  • src/clients/caprover.ts
  • src/clients/http.ts
  • src/inspectors/docker.ts
  • src/test-selection.ts
  • src/test-sequencer.ts
  • tests/backup.test.ts
  • tests/system-defaults.test.ts
  • tests/system-info.test.ts
  • tests/unit/caprover-client.test.ts
  • tests/unit/docker.test.ts
  • tests/unit/http.test.ts
  • tests/unit/test-selection.test.ts
  • vitest.config.mts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The PR adds CapRover system and backup accessors, binary HTTP responses, Docker node inspection, deterministic system-default test ordering, and unit and end-to-end coverage for system information and backup archives.

Changes

System inspection and backup coverage

Layer / File(s) Summary
System SDK and binary transport
src/clients/caprover.ts, src/clients/http.ts, tests/unit/caprover-client.test.ts, tests/unit/http.test.ts
CapRoverClient exposes system and backup operations. HttpClient returns binary response bodies as Buffer values. Unit tests cover both additions.
Docker node inspection and test ordering
src/inspectors/docker.ts, src/test-sequencer.ts, src/test-selection.ts, vitest.config.mts, tests/unit/docker.test.ts, tests/unit/test-selection.test.ts
DockerInspector lists, validates, and inspects Swarm nodes. Vitest runs tests/system-defaults.test.ts first. Unit tests cover node validation and file ordering.
Provisioning and system information checks
tests/system-defaults.test.ts, tests/system-info.test.ts
End-to-end tests validate provisioning defaults and consistency across CapRover system data, Docker nodes, load-balancer counters, SSL settings, and Pro configuration.
Backup archive validation
tests/backup.test.ts
The backup test validates invalid and valid download tokens, archive metadata, retained configuration, and one-time download behavior.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Sequence Diagram(s)

sequenceDiagram
  participant SystemInfoTest
  participant CapRoverClient
  participant CapRoverAPI
  participant DockerInspector
  SystemInfoTest->>CapRoverClient: request system information
  CapRoverClient->>CapRoverAPI: fetch system and node data
  SystemInfoTest->>DockerInspector: retrieve Docker nodes
  DockerInspector-->>SystemInfoTest: return inspected nodes
  CapRoverAPI-->>SystemInfoTest: return CapRover data
Loading

Merge Risk: ⚪ Minimal · up to b0e13

This PR adds system and backup contract coverage with deterministic test ordering; no concrete production or data-integrity failure is identified. It is mergeable pending the stated Fresh Server validation.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 13 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding backup and system contract test coverage, including sequencing support for those tests.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

Addressed the PR14 sequencing review.

  • Added an explicit Vitest 5 BaseSequencer that preserves Vitest's normal ordering, then moves tests/system-defaults.test.ts ahead of every other selected file.
  • Wired the sequencer into vitest.config.mts.
  • Replaced the array-position unit test with a test of the actual sequencing rule.
  • Handles both absolute and relative Vitest moduleId paths.

The Fresh Server validation run is still required before merge.

Copy link
Copy Markdown
Contributor Author

Fresh Server run 35686746468 was useful and exposed one PR14 test bug plus a CI budget issue.

  • Sequencing is confirmed working: system-defaults.test.ts ran first and passed.
  • system-info.test.ts passed.
  • 81/82 tests passed.
  • backup.test.ts used /api/v2/download, but CapRover mounts the download router at /api/v2/downloads/. The request therefore hit the generic 404 handler before token validation.
  • Fixed the backup URL to /api/v2/downloads/.
  • The suite took 661.41s and hit the 11-minute E2E step timeout, so the Fresh Server E2E step now allows 15 minutes.

A new Fresh Server run is required because re-running the old job would test the old commit.

@githubsaturn
githubsaturn merged commit dc67650 into main Sep 22, 2026
2 checks passed
@githubsaturn
githubsaturn deleted the test/backup-system-contracts branch September 23, 2026 00:59
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.

1 participant