Skip to content

test: add a cross-mover conformance test for shared mover invariants #2187

Open

Description

@JohnStrunk

Summary

VolSync has five movers (rsync, rsync-tls, rclone, restic, syncthing) that each implement the same scaffolding independently (source/destination PVC selection, Service/Secret handling, Job or Deployment spec, MoverConfig application, cleanup, immutable-Job replacement). Nothing asserts that they agree on the shared contract, so drift is only caught by e2e (where it costs a full cluster run) or by users.

Concretely:

  • mover/rsync/mover.go and mover/rsynctls/mover.go are near line-for-line equivalents (~500 lines each), as are their rsync_common.go files.
  • Each mover's test suite (2.1k-3.2k lines) re-discovers the same invariants locally, so a rule that changes in one mover's tests is not enforced in the others.
  • The common mover package only tests Result.ReconcileResult() (internal/controller/mover/mover_test.go).

Proposal

Add a table-driven conformance test over the builder catalog (internal/controller/mover/builder.go) that builds each mover from a minimal ReplicationSource/ReplicationDestination and asserts the shared contract:

  1. Catalog semantics: zero movers configured returns ErrNoMoverFound; two configured returns ErrMultipleMoversFound; each builder returns (nil, nil) when its mover type is not referenced.
  2. Identity: Name() is non-empty and unique across the catalog.
  3. Generated resources: common VolSync labels, owner references, generated ServiceAccount name, and required RBAC objects.
  4. MoverConfig propagation: securityContext, resources, affinity/tolerations, labels, and extra volumes reach the Job/Deployment pod template. (All five call utils.UpdatePodTemplateSpecFromMoverConfig today; assert it stays that way.)
  5. Cleanup: temporary PVCs/snapshots/Secrets/Services created during Synchronize are removed by Cleanup, and protected images survive.
  6. Job lifecycle: immutable-field changes on an active Job are deferred, and an inactive immutable Job is replaced rather than failing.

Prefer sigs.k8s.io/controller-runtime/pkg/client/fake for the cases that do not need real API-server semantics; where one does, reuse the existing envtest bootstrap. The intent is a single small test that runs in a couple of seconds, not a new suite.

Acceptance criteria

  • One test (or one small file per concern) iterates the whole catalog rather than being copied per mover.
  • Adding a new mover without these behaviors fails the test.
  • Runs in the existing Go test invocation in a few seconds; no new e2e playbooks or matrix jobs.

(AI generated)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions