* test(testutil): local dolt sql-server backend behind the Dolt test server API Add a second backend to internal/testutil behind the unchanged container API (EnsureDoltContainerForTestMain, RequireDoltContainer, StartIsolatedDoltContainer[Handle], NewContainerProvider, RestartSharedDoltContainer, DoltContainerCrashed, IsolatedDoltContainer Stop/Start/CurrentPort/Exec): the test process spawns `dolt sql-server` from the pinned dolt CLI instead of a dolthub/dolt-sql-server container. - BEADS_TEST_DOLT_SERVER=local|container selects it; unset keeps plain `go test` on the container (no behavior change) and makes `bazel test` use the local backend. Other values fail instead of guessing. - The CLI (BEADS_TEST_DOLT_BINARY, else PATH) must be the image's version. - Provisioned like testcontainers' dolt module: root@% (DOLT_ROOT_HOST=%), database beads_test, user test/test. Clean env, TZ=UTC, GOMAXPROCS=4, own dolt global config with metrics and the version check disabled. - Loopback port picked here (dolt rejects -P 0), never 3307, retried when another process wins the port; readiness requires the server's own "Server ready" line plus a bounded ping, so a foreign listener on a contested port cannot pass for it. - State lives under the TMPDIR captured at package init, outside every PinSuiteTempRoot root, so suite leak sweeps never see it. The server stays in the test's process group (bazel's group kill reaps it) with Pdeathsig on Linux. - BEADS_TEST_REQUIRE_DOLT_CONTAINER=1 now also makes every TestMain that only warned about an unavailable server exit 1 (DoltUnavailableForTestMain), plus the shared proxied harness. - dolt_benchmark_purge_test finds .dolt_dropped_databases relative to Exec's working directory (the data dir in both backends). - TestDoltServerFingerprint checks each available backend against one checked-in fingerprint (users, grants, databases, server variables); local-backend tests cover the bind-race retry, 3307, crash detection, Stop/Start, Exec cwd, state outside the suite root, and teardown. - Bazel: the requires-docker variants pin BEADS_TEST_DOLT_SERVER=container so the docker lane stays the container A/B control; the test wrapper's dolt global config disables metrics and the version check. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(testutil): select the local Dolt test server only when asked for Under Bazel an unset BEADS_TEST_DOLT_SERVER used to mean the local backend, so every non-ci `bazel test` started servers for Dolt suites no lane runs with one (//internal/storage/dolt:dolt_test went from a 16 s skip to a timeout). Unset now means container everywhere: in a Bazel action without docker that is the pre-existing warn+skip, and only a target's env or --test_env=BEADS_TEST_DOLT_SERVER=local starts local servers. Plain `go test` is unchanged. The docker variants keep their container pin: a rule env beats --test_env, so a local-backend invocation cannot flip the docker lane. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(testutil): harden the local Dolt test server's host footprint - DOLT_DISABLE_EVENT_FLUSH=1 for every dolt the backend runs (and in the Bazel test wrapper): the metrics/versioncheck keys stop network calls but not the detached `dolt send-metrics` child each command forks on exit, which re-created the version probe's removed HOME (one leaked bdt-doltver-* per test process) and raced terminate's RemoveAll. - Every bdt-dolt-*/bdt-doltver-* root records its owner PID, and the first use of the backend in a process removes this user's roots whose owner is dead (the SweepDeadSuiteRoots rule; a copy, since doltserver's tests import testutil). A panicking, timed-out or killed test binary, or a package whose TestMain never terminates the singleton, no longer leaks a 40-100 MB state dir per run. - secure_file_priv is the state root's sfp/ directory, set through a per-launch --config file (dolt ignores other flags with --config): a local server runs as the test user on the host with a passwordless root@%, so LOAD_FILE / INTO OUTFILE must not reach the user's files. The fingerprint treats that path as the container's "". - Fingerprint: character_set_server, collation_server, max_allowed_packet, transaction_isolation, lower_case_table_names, lower_case_file_system (compared on Linux only: APFS reports ON), wait_timeout, innodb_lock_wait_timeout. - The local backend's own tests skip off Linux (no Pdeathsig, so a killed test binary would orphan servers on the macOS runners) unless BEADS_TEST_DOLT_SERVER=local asks for them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * ci: compare the container and local Dolt test servers in the domain+uow job TestDoltServerFingerprint's container half never ran in CI: only the test-domain-uow job has both the pulled image and the pinned dolt CLI, and it never ran ./internal/testutil. Run the fingerprint there (with BEADS_TEST_REQUIRE_DOLT_CONTAINER=1 so the container half cannot skip) so an image bump that drifts the container side fails in the PR. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
108 lines
3.8 KiB
Python
108 lines
3.8 KiB
Python
load("@rules_go//go:def.bzl", "go_library", "go_test")
|
|
load("@rules_shell//shell:sh_test.bzl", "sh_test")
|
|
load("//tools/bazel:race.bzl", "go_test_race_off")
|
|
|
|
go_library(
|
|
name = "protocol",
|
|
srcs = ["corpus.go"],
|
|
importpath = "github.com/steveyegge/beads/cmd/bd/protocol",
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
go_test(
|
|
name = "protocol_test",
|
|
srcs = [
|
|
"assignee_test.go",
|
|
"blocked_status_test.go",
|
|
"blocked_test.go",
|
|
"blocking_semantics_test.go",
|
|
"canonicalize_test.go",
|
|
"child_id_test.go",
|
|
"children_test.go",
|
|
"close_guard_test.go",
|
|
"comments_test.go",
|
|
"corpus_test.go",
|
|
"defer_test.go",
|
|
"dep_identity_test.go",
|
|
"errors_contract_test.go",
|
|
"exit_codes_init_test.go",
|
|
"exit_codes_test.go",
|
|
"helpers_test.go",
|
|
"input_validation_test.go",
|
|
"interchange_test.go",
|
|
"json_contract_test.go",
|
|
"lease_claim_test.go",
|
|
"lifecycle_test.go",
|
|
"memory_contract_test.go",
|
|
"preservation_test.go",
|
|
"ready_front_test.go",
|
|
"roundtrip_test.go",
|
|
"stale_test.go",
|
|
"status_validation_test.go",
|
|
"versioning_contract_test.go",
|
|
"wp4_helpers_test.go",
|
|
],
|
|
data = glob(["testdata/**"]) + ["//cmd/bd:bd_for_tests"],
|
|
embed = [":protocol"],
|
|
env = {"BEADS_TEST_BD_BINARY": "$(rlocationpath //cmd/bd:bd_for_tests)"},
|
|
deps = [
|
|
"//internal/storage/schema",
|
|
"//internal/testutil",
|
|
"//internal/testutil/bazeltest",
|
|
],
|
|
)
|
|
|
|
# protocol_test without the race detector, which --config=docker otherwise
|
|
# turns on for every target: pr.yml's "Contract corpus" job runs
|
|
# `go test ./cmd/bd/protocol` without -race (PR Core covers the race build).
|
|
# Matching it is cheap: tools/bazel/race.bzl lands protocol_test's deps in
|
|
# the configuration the non-race //cmd/bd:bd_for_tests already builds them in,
|
|
# so the extra work is protocol_test's test-only libraries and one link.
|
|
# Racing it instead would also be acceptable (a race-only failure is a real
|
|
# bug); then drop this target and point protocol_docker_test back at
|
|
# :protocol_test.
|
|
#
|
|
# Tags:
|
|
# manual: only protocol_docker_test's input, never a build target of its
|
|
# own. `bazel test //...` in every lane still builds it through
|
|
# protocol_docker_test (a test tag filter does not stop the build).
|
|
go_test_race_off(
|
|
name = "protocol_race_off",
|
|
tags = ["manual"],
|
|
test = ":protocol_test",
|
|
)
|
|
|
|
# protocol_test as pr.yml's "Contract corpus" job runs it: non-race, TestMain
|
|
# starts a dolt sql-server container and BEADS_PROTOCOL_REQUIRE_DOLT=1 turns a
|
|
# missing container into a failure instead of a skip. It repeats
|
|
# protocol_test's `env` (go_test_variant.sh cannot inherit it). protocol_test
|
|
# itself stays untagged: under --config=prcore (BEADS_TEST_SKIP=dolt) its
|
|
# Dolt-backed tests skip.
|
|
#
|
|
# Tags:
|
|
# requires-docker: needs a docker daemon; excluded from --config=prcore/ci,
|
|
# selected by --config=docker.
|
|
# no-remote-exec: the daemon is on the host, not on remote workers.
|
|
sh_test(
|
|
name = "protocol_docker_test",
|
|
size = "large",
|
|
srcs = ["//tools/bazel:go_test_variant.sh"],
|
|
args = ["$(rootpath :protocol_race_off)"],
|
|
data = [
|
|
":protocol_race_off",
|
|
"//cmd/bd:bd_for_tests",
|
|
],
|
|
# Pinned to the container backend (the docker lane is the A/B control);
|
|
# rule env beats --test_env, so =local on the command line cannot flip it.
|
|
env = {
|
|
"BEADS_PROTOCOL_REQUIRE_DOLT": "1",
|
|
"BEADS_TEST_BD_BINARY": "$(rlocationpath //cmd/bd:bd_for_tests)",
|
|
"BEADS_TEST_DOLT_SERVER": "container",
|
|
},
|
|
# ~10 min unsharded without -race in pr.yml.
|
|
shard_count = 8,
|
|
tags = [
|
|
"no-remote-exec",
|
|
"requires-docker",
|
|
],
|
|
)
|