beads/tests/regression
Jim Wordelman 50003b803b
feat(storage): refuse test DBs on production dolt servers (AD-01) (#3632)
* feat(storage): be-c5p AD-01 isProductionPort + DB-name firewall

Generalize the BEADS_TEST_MODE production-port guard so deployments
on non-3307 ports (BEADS_PRODUCTION_PORT env, BeadsDir/dolt-server.port
file) are also caught, and add a defense-in-depth database-name
firewall that refuses test-named DBs on any server unless the operator
opts into the dedicated test-server lane via BEADS_TEST_SERVER=1.

Both defenses honor BEADS_TEST_SERVER=1 as the single opt-in for
test-server connections, so each test harness flips one env var rather
than each layer reasoning about test/prod independently. Adds benchdb_
to testDatabasePrefixes (per-bench scratch DBs from cmd/bd/dolt.go)
and updates the doc-block to call out the two sibling prefix lists
that need to converge under be-avn.

Test harnesses across cmd/bd, internal/storage/dolt, internal/molecules,
internal/tracker, internal/utils, doctor, doctor/fix, protocol,
regression, and the root suite now set BEADS_TEST_SERVER=1 alongside
BEADS_TEST_MODE=1 in TestMain. The cross-rig integration test that
filters BEADS_* env on subprocess Cmd.Env adds it back explicitly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore: release gate PASS for be-c5p-firewall (be-m1u/47dcc380)

* fix(test): adapt store_unit_test.go for BEADS_DOLT_SERVER_PORT (rebase compat)

Tests that exercise applyConfigDefaults now clear BEADS_DOLT_SERVER_PORT (added
to main after this branch was cut) so the legacy BEADS_DOLT_PORT path runs as
intended. Without this, a GC-city environment with BEADS_DOLT_SERVER_PORT set
causes the tests to resolve an unexpected port.

* fix(dolt): stop BEADS_TEST_SERVER=1 from suppressing DefaultSQLPort detection

Restructure productionPortReasons so Rule 1 (cfg.ServerPort ==
DefaultSQLPort) is evaluated unconditionally; BEADS_TEST_SERVER=1 now only
suppresses the BEADS_PRODUCTION_PORT and dolt-server.port heuristics (Rules
2 and 3). isProductionPort loses its independent whole-function bypass and
becomes a thin wrapper. Update doc comments on both functions and the
buildTestModeProductionPortPanic fix list (which no longer lists
BEADS_TEST_SERVER=1 as a fix when port 3307 is the matched reason) to match.
Add TestApplyConfigDefaults_TestModeBlocksProdPort_EvenWithTestServerOptIn
asserting port 3307 is still refused with the opt-in set.

Also: drop a redundant explicit db.Close() in openServerConnection's
firewall-refusal path (already covered by the connReady defer), and fix two
comments that referenced a non-existent uniqueBenchDBName, pointing them at
the real generator (cmd/bd/template_test.go newTemplateBenchmarkStore) with
the correct benchdb_ name format.

Agent-Signature: claude-sonnet-medium on behalf of matt wilkie

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-24 01:28:51 -07:00
..
BASELINE_VERSION test(regression): Dolt migration regression discovery (long-lived branch) (#1906) 2026-02-22 15:18:56 -08:00
DISCOVERY.md fix(filters): Dolt label-filter regression fix — LabelPattern + LabelRegex + JSON truncation hint suppression (#3971) 2026-07-24 00:17:02 -07:00
discovery_test.go fix(filters): Dolt label-filter regression fix — LabelPattern + LabelRegex + JSON truncation hint suppression (#3971) 2026-07-24 00:17:02 -07:00
regression_test.go feat(storage): refuse test DBs on production dolt servers (AD-01) (#3632) 2026-07-24 01:28:51 -07:00
scenarios_test.go fix: repair PR4107 blocked-state corruption (#4139) 2026-05-24 05:37:52 -07:00