Skip to content

Expand Upload Operation Race And Backend-Parity Tests #151

Description

@TheSilkky

Expand Upload Operation Race And Backend-Parity Tests

Priority

P1

Type

testing

Labels

Suggested GitHub labels:

  • backlog
  • go
  • testing

Branch scope

  • Current branch: develop
  • Current HEAD: a5a29a9645195e149ed0c5d75cbffa5172dd9a7d
  • Target branch, if known: develop
  • Reviewed branch/ref, if applicable: not applicable
  • Reviewed commit SHA, if applicable: not applicable
  • Target release/version, if applicable: not applicable
  • Scope classification: follow-up-after-merge
  • Scope note: This draft was generated from the branch above. Revalidate against the target branch before creating or closing public GitHub issues if the branch has moved or has not yet merged.

Summary

Add shared upload-operation and metadata-backend tests for the concurrency and parity cases that remain documented as expected before production-cluster use.

Context

The current backend implements complete-upload Idempotency-Key support and optional PostgreSQL metadata, but the docs still call out additional expected tests before recommending production-cluster use. docs/postgresql-metadata-migration.md lists shared repository contract tests, HTTP handler tests, concurrency tests for upload versus close/completion, duplicate chunk races, token revocation, and restore-style validation. docs/cluster-safe-upload-semantics.md also lists backend tests for same chunk identity with different ciphertext, future staging cleanup safety, and upload versus incident close or stream completion.

Existing closed work includes PostgreSQL support, the PostgreSQL CI path, idempotency support, and duplicate reconciliation. This draft should extend coverage without redesigning those features.

Proposed change

Create focused tests that exercise the current metadata repository boundary and HTTP upload path across SQLite by default and PostgreSQL when SAFE_POSTGRES_TEST_DSN is available.

Include race or interleaving coverage for upload versus incident close, upload versus stream completion, duplicate same-identity uploads, idempotency replay, idempotency conflict, token revocation behavior, and completed bundle reconstruction after backend-specific metadata writes.

Acceptance criteria

  • Shared tests cover current SQLite behavior without requiring external services.
  • PostgreSQL variants run when SAFE_POSTGRES_TEST_DSN is configured.
  • Upload versus close/completion and duplicate upload races are covered at the repository or HTTP boundary.
  • Tests verify conflicts do not expose raw idempotency keys, request bodies, uploaded bytes, stored paths, plaintext, raw keys, or private deployment details.
  • Documentation comments or test names clearly identify which documented production-cluster expectation each test covers.

Tests / validation

  • gofmt -w ./cmd ./internal ./migrations, if Go files change
  • go test ./..., if code changes
  • go vet ./..., if code changes or CI/testing changes
  • Optional SAFE_POSTGRES_TEST_DSN='<test dsn>' go test ./internal/postgresdb -count=1, if PostgreSQL tests change
  • docs updated, if relevant
  • revalidate on target branch before public issue creation, if branch-scoped

Out of scope

  • Implementing resumable uploads, upload leases, or operation-level Valkey coordination.
  • Exposing /v1 publicly.
  • Changing chunk identity, bundle format, or key custody.
  • Adding Docker Compose or cloud services just to run the default test suite.

Notes

Relevant docs: docs/postgresql-metadata-migration.md, docs/cluster-safe-upload-semantics.md, docs/security-model.md, docs/threat-model.md.

Related completed issues: #93, #131, #132, and #137.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backloggoPull requests that update go codetesting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions