Skip to content

test(integration): take the suite's ports from the environment - #434

Merged
freshtonic merged 2 commits into
mainfrom
chore/test-ports-from-env
Aug 5, 2026
Merged

test(integration): take the suite's ports from the environment#434
freshtonic merged 2 commits into
mainfrom
chore/test-ports-from-env

Conversation

@freshtonic

@freshtonic freshtonic commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Prerequisite for the three plaintext-leak fixes stacked on top of this branch (CIP-3680, CIP-3682, CIP-3688). Small and standalone.

Why

The four ports the integration suite connects to were hardcoded (pub const PROXY: u16 = 6432), so only one copy of the suite could run at a time. Fixing three separate Proxy defects in parallel needs three Proxy instances against three databases, which needs three sets of ports.

What

PROXY, PROXY_METRICS_PORT, PG_PORT and PG_TLS_PORT become LazyLock<u16> reading CS_TEST_PROXY_PORT, CS_TEST_PROXY_METRICS_PORT, CS_TEST_PG_PORT and CS_TEST_PG_TLS_PORT, each falling back to its current value. An unconfigured run behaves exactly as before.

A malformed value panics rather than falling back to the default. Silently retargeting the whole suite at whatever else happens to be listening on 6432 is the one failure mode that looks like a pass.

Note for anyone running the suite on custom ports

mise exec overrides CS_DATABASE__PORT from the parent shell, because mise.toml sets it to 5532:

$ CS_DATABASE__PORT=5599 mise exec -- env | grep CS_DATABASE__PORT
CS_DATABASE__PORT=5532

Re-assert it inside: mise exec -- env CS_DATABASE__PORT=5541 cargo …. The CS_TEST_* variables introduced here are not set in mise.toml, so they pass through fine. Tests that run the migrate CLI in-process also need CS_SERVER__PORT set, since that CLI reads it to find Proxy.

Testing

cargo check -p cipherstash-proxy-integration --tests clean; cargo fmt clean. Behaviour with no environment variables set is unchanged by construction.

Acknowledgment

By submitting this pull request, I confirm that CipherStash can use, modify, copy, and redistribute this contribution, under the terms of CipherStash's choice.

Summary by CodeRabbit

  • New Features
    • Integration-test proxy and database ports can now be configured through environment variables, with defaults available when not specified.
  • Bug Fixes
    • Updated connection handling across integration tests to use the runtime-configured ports.
  • Tests
    • Maintained coverage for encryption, mapping, querying, multitenancy, diagnostics, and connection-resilience scenarios with the updated configuration.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@freshtonic, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 36 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1df72a31-7a17-420f-a50d-ab6286508367

📥 Commits

Reviewing files that changed from the base of the PR and between e2198c7 and 92ccc16.

📒 Files selected for processing (49)
  • packages/cipherstash-proxy-integration/src/common.rs
  • packages/cipherstash-proxy-integration/src/connection_resilience.rs
  • packages/cipherstash-proxy-integration/src/decrypt/insert_returning.rs
  • packages/cipherstash-proxy-integration/src/diagnostics.rs
  • packages/cipherstash-proxy-integration/src/disable_mapping.rs
  • packages/cipherstash-proxy-integration/src/empty_result.rs
  • packages/cipherstash-proxy-integration/src/encryption_sanity.rs
  • packages/cipherstash-proxy-integration/src/eql_regression.rs
  • packages/cipherstash-proxy-integration/src/extended_protocol_error_messages.rs
  • packages/cipherstash-proxy-integration/src/insert/insert_domain_type.rs
  • packages/cipherstash-proxy-integration/src/insert/insert_with_params.rs
  • packages/cipherstash-proxy-integration/src/map_concat.rs
  • packages/cipherstash-proxy-integration/src/map_literals.rs
  • packages/cipherstash-proxy-integration/src/map_match_index.rs
  • packages/cipherstash-proxy-integration/src/map_nulls.rs
  • packages/cipherstash-proxy-integration/src/map_ope_index_order.rs
  • packages/cipherstash-proxy-integration/src/map_ope_index_where.rs
  • packages/cipherstash-proxy-integration/src/map_ore_index_order.rs
  • packages/cipherstash-proxy-integration/src/map_ore_index_where.rs
  • packages/cipherstash-proxy-integration/src/map_params.rs
  • packages/cipherstash-proxy-integration/src/map_unique_index.rs
  • packages/cipherstash-proxy-integration/src/migrate/mod.rs
  • packages/cipherstash-proxy-integration/src/multitenant/contention.rs
  • packages/cipherstash-proxy-integration/src/multitenant/ore_order.rs
  • packages/cipherstash-proxy-integration/src/multitenant/set_keyset_id.rs
  • packages/cipherstash-proxy-integration/src/multitenant/set_keyset_name.rs
  • packages/cipherstash-proxy-integration/src/passthrough.rs
  • packages/cipherstash-proxy-integration/src/pipeline.rs
  • packages/cipherstash-proxy-integration/src/schema_change.rs
  • packages/cipherstash-proxy-integration/src/select/distinct_order_by.rs
  • packages/cipherstash-proxy-integration/src/select/indexing.rs
  • packages/cipherstash-proxy-integration/src/select/jsonb_array_elements.rs
  • packages/cipherstash-proxy-integration/src/select/jsonb_containment_index.rs
  • packages/cipherstash-proxy-integration/src/select/jsonb_fusion_gaps.rs
  • packages/cipherstash-proxy-integration/src/select/jsonb_path_query.rs
  • packages/cipherstash-proxy-integration/src/select/jsonb_selector_param_types.rs
  • packages/cipherstash-proxy-integration/src/select/operator_backed_predicates.rs
  • packages/cipherstash-proxy-integration/src/select/operator_class_shapes.rs
  • packages/cipherstash-proxy-integration/src/select/pg_catalog.rs
  • packages/cipherstash-proxy-integration/src/select/select_where_in.rs
  • packages/cipherstash-proxy-integration/src/select/select_where_jsonb.rs
  • packages/cipherstash-proxy-integration/src/select/unmappable.rs
  • packages/cipherstash-proxy-integration/src/set_keyset_error.rs
  • packages/cipherstash-proxy-integration/src/simple_protocol/error_handling.rs
  • packages/cipherstash-proxy-integration/src/simple_protocol/map_literals.rs
  • packages/cipherstash-proxy-integration/src/simple_protocol/map_nulls.rs
  • packages/cipherstash-proxy-integration/src/simple_protocol/multiple_statements.rs
  • packages/cipherstash-proxy-integration/src/update/update_domain_type.rs
  • packages/cipherstash-proxy-integration/src/update/update_with_reused_param.rs
📝 Walkthrough

Walkthrough

Integration-test ports now resolve from environment variables with defaults, and all affected proxy/Postgres connection helpers and tests dereference the new lazy port values.

Changes

Runtime integration test port configuration

Layer / File(s) Summary
Runtime port declarations and shared helpers
packages/cipherstash-proxy-integration/src/common.rs
Proxy, metrics, Postgres, and TLS ports use environment-backed LazyLock<u16> values, with updated shared connection and database-port fallback logic.
Resilience and diagnostics connections
packages/cipherstash-proxy-integration/src/connection_resilience.rs, packages/cipherstash-proxy-integration/src/diagnostics.rs, packages/cipherstash-proxy-integration/src/disable_mapping.rs
Tests pass dereferenced proxy or metrics ports to connection helpers.
Mapping, encryption, and query tests
packages/cipherstash-proxy-integration/src/{decrypt,insert,map*}/*, packages/cipherstash-proxy-integration/src/eql_regression.rs
TLS setup uses *PROXY across mapping, encryption, EQL, insert, and index tests.
Protocol and multitenant tests
packages/cipherstash-proxy-integration/src/{migrate,multitenant,simple_protocol}/*, packages/cipherstash-proxy-integration/src/{passthrough,pipeline,schema_change,set_keyset_error}.rs, packages/cipherstash-proxy-integration/src/update/*
Migration, multitenant, protocol, passthrough, schema, keyset, and update tests use dereferenced proxy ports.
Select and JSONB tests
packages/cipherstash-proxy-integration/src/select/*
Select, JSONB, predicate, catalog, indexing, and unmappable-query tests use *PROXY for TLS connections.

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

Possibly related PRs

Suggested reviewers: tobyhede

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly captures the main change: integration test ports are now read from environment variables.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/test-ports-from-env

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cipherstash-proxy-integration/src/common.rs`:
- Around line 67-72: Update the environment-variable parsing match around
std::env::var in the port configuration logic to distinguish
VarError::NotPresent from VarError::NotUnicode. Return the default only for
NotPresent, and panic with a clear misconfiguration message for NotUnicode
instead of silently using the default port.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 57d425b3-424d-411d-9b31-8cd230844ffb

📥 Commits

Reviewing files that changed from the base of the PR and between 15b7f99 and bf72e2f.

📒 Files selected for processing (49)
  • packages/cipherstash-proxy-integration/src/common.rs
  • packages/cipherstash-proxy-integration/src/connection_resilience.rs
  • packages/cipherstash-proxy-integration/src/decrypt/insert_returning.rs
  • packages/cipherstash-proxy-integration/src/diagnostics.rs
  • packages/cipherstash-proxy-integration/src/disable_mapping.rs
  • packages/cipherstash-proxy-integration/src/empty_result.rs
  • packages/cipherstash-proxy-integration/src/encryption_sanity.rs
  • packages/cipherstash-proxy-integration/src/eql_regression.rs
  • packages/cipherstash-proxy-integration/src/extended_protocol_error_messages.rs
  • packages/cipherstash-proxy-integration/src/insert/insert_domain_type.rs
  • packages/cipherstash-proxy-integration/src/insert/insert_with_params.rs
  • packages/cipherstash-proxy-integration/src/map_concat.rs
  • packages/cipherstash-proxy-integration/src/map_literals.rs
  • packages/cipherstash-proxy-integration/src/map_match_index.rs
  • packages/cipherstash-proxy-integration/src/map_nulls.rs
  • packages/cipherstash-proxy-integration/src/map_ope_index_order.rs
  • packages/cipherstash-proxy-integration/src/map_ope_index_where.rs
  • packages/cipherstash-proxy-integration/src/map_ore_index_order.rs
  • packages/cipherstash-proxy-integration/src/map_ore_index_where.rs
  • packages/cipherstash-proxy-integration/src/map_params.rs
  • packages/cipherstash-proxy-integration/src/map_unique_index.rs
  • packages/cipherstash-proxy-integration/src/migrate/mod.rs
  • packages/cipherstash-proxy-integration/src/multitenant/contention.rs
  • packages/cipherstash-proxy-integration/src/multitenant/ore_order.rs
  • packages/cipherstash-proxy-integration/src/multitenant/set_keyset_id.rs
  • packages/cipherstash-proxy-integration/src/multitenant/set_keyset_name.rs
  • packages/cipherstash-proxy-integration/src/passthrough.rs
  • packages/cipherstash-proxy-integration/src/pipeline.rs
  • packages/cipherstash-proxy-integration/src/schema_change.rs
  • packages/cipherstash-proxy-integration/src/select/distinct_order_by.rs
  • packages/cipherstash-proxy-integration/src/select/indexing.rs
  • packages/cipherstash-proxy-integration/src/select/jsonb_array_elements.rs
  • packages/cipherstash-proxy-integration/src/select/jsonb_containment_index.rs
  • packages/cipherstash-proxy-integration/src/select/jsonb_fusion_gaps.rs
  • packages/cipherstash-proxy-integration/src/select/jsonb_path_query.rs
  • packages/cipherstash-proxy-integration/src/select/jsonb_selector_param_types.rs
  • packages/cipherstash-proxy-integration/src/select/operator_backed_predicates.rs
  • packages/cipherstash-proxy-integration/src/select/operator_class_shapes.rs
  • packages/cipherstash-proxy-integration/src/select/pg_catalog.rs
  • packages/cipherstash-proxy-integration/src/select/select_where_in.rs
  • packages/cipherstash-proxy-integration/src/select/select_where_jsonb.rs
  • packages/cipherstash-proxy-integration/src/select/unmappable.rs
  • packages/cipherstash-proxy-integration/src/set_keyset_error.rs
  • packages/cipherstash-proxy-integration/src/simple_protocol/error_handling.rs
  • packages/cipherstash-proxy-integration/src/simple_protocol/map_literals.rs
  • packages/cipherstash-proxy-integration/src/simple_protocol/map_nulls.rs
  • packages/cipherstash-proxy-integration/src/simple_protocol/multiple_statements.rs
  • packages/cipherstash-proxy-integration/src/update/update_domain_type.rs
  • packages/cipherstash-proxy-integration/src/update/update_with_reused_param.rs

Comment thread packages/cipherstash-proxy-integration/src/common.rs
@freshtonic
freshtonic requested a review from tobyhede July 30, 2026 01:14
The four ports the integration suite connects to were hardcoded, so only
one copy of the suite could run at a time. Several agents each working on
a different Proxy defect need their own Proxy and PostgreSQL, which means
their own ports.

Each port now reads an environment variable and falls back to the current
value, so an unconfigured run behaves exactly as before. A malformed
value panics rather than falling back: silently retargeting the whole
suite at whatever else is listening on 6432 is the one failure that looks
like a pass.
@freshtonic
freshtonic force-pushed the chore/test-ports-from-env branch from bf72e2f to 94ab953 Compare August 5, 2026 05:08
…efaulting

std::env::var returns NotUnicode when the variable is set but not valid
UTF-8; treating every Err as unset silently fell back to the default
port — the exact silent-misdirection port_from_env exists to prevent.

Addresses review feedback on #434.
@freshtonic
freshtonic merged commit 5fbfee7 into main Aug 5, 2026
6 checks passed
@freshtonic
freshtonic deleted the chore/test-ports-from-env branch August 5, 2026 05:48
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.

2 participants