Skip to content

refactor: deduplicate shared test helpers#1399

Open
ericcurtin wants to merge 1 commit into
NVIDIA:mainfrom
ericcurtin:refactor/dedup-test-helpers
Open

refactor: deduplicate shared test helpers#1399
ericcurtin wants to merge 1 commit into
NVIDIA:mainfrom
ericcurtin:refactor/dedup-test-helpers

Conversation

@ericcurtin
Copy link
Copy Markdown
Contributor

@ericcurtin ericcurtin commented May 15, 2026

Summary

Extract four categories of copy-pasted test code into single canonical locations, removing ~1740 lines of duplication across openshell-server and openshell-driver-podman.

Related Issue

N/A — cleanup identified by scanning the codebase.

Changes

  • POLICY_OBJECT_TYPE / DRAFT_CHUNK_OBJECT_TYPE constants: defined identically in both persistence/sqlite.rs and persistence/postgres.rs; promoted to persistence/mod.rs and imported in both store files.

  • test_server_state() helper: was duplicated across grpc/provider.rs, grpc/policy.rs, and grpc/sandbox.rs. A shared grpc::test_support module in grpc/mod.rs now owns the single implementation; each submodule imports it.

  • TestOpenShell stub + PKI helpers: the full OpenShell trait stub (400 lines), install_rustls_provider(), PkiBundle, generate_pki(), and start_test_server() were copied across five openshell-server integration test files. A new tests/common/mod.rs owns them all; each test file does mod common.

  • Podman stub helpers: StubResponse, unique_socket_path(), and spawn_podman_stub() were duplicated between driver.rs and grpc.rs in openshell-driver-podman. A new src/test_utils.rs (cfg-gated to tests) owns the shared helpers.

Testing

  • mise run pre-commit passes (format + lint) for affected crates
  • All unit and integration tests pass (cargo test -p openshell-server -p openshell-driver-podman)
  • E2E tests added/updated (not applicable — test-only refactor)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 15, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@johntmyers johntmyers self-assigned this May 15, 2026
@johntmyers
Copy link
Copy Markdown
Collaborator

/ok to test 9a8ee87

@johntmyers johntmyers added the test:e2e Requires end-to-end coverage label May 15, 2026
@github-actions
Copy link
Copy Markdown

Label test:e2e applied for 9a8ee87. Open the existing run and click Re-run all jobs to execute with the label set. The E2E Gate check on this PR will flip green automatically once the run finishes.

@ericcurtin
Copy link
Copy Markdown
Contributor Author

@johntmyers I wonder can you give me better privileges so the builds can automatically run.

Your call of course!

@ericcurtin
Copy link
Copy Markdown
Contributor Author

Trying to fix CI now

@ericcurtin ericcurtin force-pushed the refactor/dedup-test-helpers branch from 9a8ee87 to f36fef5 Compare May 15, 2026 17:56
Extract four categories of copy-pasted test code into single
canonical locations:

- POLICY_OBJECT_TYPE / DRAFT_CHUNK_OBJECT_TYPE constants that were
  defined identically in both persistence/sqlite.rs and
  persistence/postgres.rs are now owned by persistence/mod.rs.

- test_server_state() was duplicated across grpc/provider.rs,
  grpc/policy.rs, and grpc/sandbox.rs. A shared grpc::test_support
  module in grpc/mod.rs now owns the single implementation; each
  submodule imports it.

- The TestOpenShell stub (full OpenShell trait impl), install_rustls_provider(),
  PkiBundle, generate_pki(), and start_test_server() were copied across
  up to five openshell-server integration test files. A new
  tests/common/mod.rs module owns them; each test file uses mod common.

- StubResponse, unique_socket_path(), and spawn_podman_stub() were
  duplicated between openshell-driver-podman/src/driver.rs and
  openshell-driver-podman/src/grpc.rs. A new src/test_utils.rs
  (cfg(test)-gated) owns the shared helpers.
@ericcurtin ericcurtin force-pushed the refactor/dedup-test-helpers branch from f36fef5 to 0ff3511 Compare May 15, 2026 18:01
@johntmyers
Copy link
Copy Markdown
Collaborator

/ok to test 0ff3511

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

Labels

test:e2e Requires end-to-end coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants