* test(integration): let SubprocessRunner reuse a prebuilt test binary
BEADS_TEST_SUBPROCESS_BINARY hands SubprocessRunner an already-built test
binary of the package instead of running `go test -c`, which no Bazel
action can do offline (it needs the module source tree and module cache).
A Bazel target passes the running go_test itself: the helper tests
(TestHelperSchemaInit, TestHelperMultiStore) live in the same package.
Unset, behavior is unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(dolt): keep a lane's REQUIRE switch out of the leak-probe child
TestSuiteFixtureLeakFailsOwningSuite re-runs the suite with
BEADS_TEST_SKIP=dolt on purpose. When the parent runs under
BEADS_TEST_REQUIRE_DOLT_CONTAINER=1 (a fail-closed server lane), the child
inherited it and TestMain exited FATAL before the leak sweep the test
checks. Clear it in the child like the other suite-scoped variables.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(bazel): proxied-server and server-Dolt storage tiers (D6d, D6e)
PR Risk's "Test (Proxied Dolt Cmd N/15)" (also main.yml's) and "Test
(Server Dolt Conformance)" / "Test (Server Dolt Full Suite N/16)" as
Bazel variants against local dolt sql-servers (internal/testutil local
backend, pinned dolt from the test wrapper), fail-closed like the
dolt-server lane:
- //cmd/bd:bd_proxied_test: 15 shards; shard k runs the job's
proxied-test-shard.sh k+1 15 through go_test_manifest_shard.sh over the
race bd_test, non-race bd_for_tests as the subprocess bd,
BEADS_TEST_PROXIED_SERVER=1, GOMAXPROCS=4. Tag dolt-server-proxied,
--config=doltserver-proxied (the doltserver lane's build).
- //internal/storage/dolt:dolt_server_{conformance,full}_test over
dolt_race_off (go_test_race_off of dolt_test: the jobs' binary is not
race); the full suite runs server-storage-test-shard.sh k+1 16 with
BEADS_TEST_ENV_RUN_DOLT=1 and hands SubprocessRunner its own binary.
Tag dolt-server-integration, --config=doltserver-integration, whose
build flags are exactly --config=integration's, so the tier shares that
lane's compile (race-off deps land where bd_for_tests already is)
instead of compiling the tagged graph a third time.
- dolt_test gains //internal/storage/schema:migrations as data (the
PR4107/migration replay tests read ../schema/migrations).
- test_env.sh: BEADS_TEST_GIT_IDENTITY=1 writes the jobs' global git
identity ("Configure Git"); the git-remote tests commit in fresh repos.
- Both tags join the taxonomy and bazelPRCoreExcludedTags, so prcore/ci
and integration exclude them.
Per-shard names and statuses equal a replay of the jobs' commands
(container backend) for all 32 jobs.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* ci(bazel): run the proxied and server storage tiers remotely (advisory)
bazel-doltserver gains a second, remote-only step, `bazel test //...
--config=doltserver-proxied` (15 shards of ~5-10 min with a busy dolt
sql-server each do not fit a GitHub-hosted runner; forks and rbe=off keep
the local lane unchanged). bazel-integration gains `bazel test //...
--config=doltserver-integration`, which shares its build flags, so the
server storage tier compiles nothing the integration step has not. Both
steps write their own BEP, run check_testcases.py on it, run even when the
job's first test step failed, and upload logs on failure.
Policy (TestBazelDoltServerTiersMirrorPRRisk): each variant runs its jobs'
shard script with their shard total and has script + manifest in data;
the conformance variant passes the job's flags; the jobs' race/non-race
binaries and switches (BEADS_TEST_PROXIED_SERVER, BEADS_TEST_ENV_RUN_DOLT)
match; doltserver-integration's tags and race equal --config=integration's;
the steps are pinned to their jobs. checkDoltServerRules now holds all
three dolt-server lane tags to the local-backend, fail-closed,
remote-capable rules.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* ci(bazel): run the proxied and server storage tiers in jobs of their own
Review of D6d/e: as steps of bazel-doltserver and bazel-integration the
tiers inherited those jobs' gating (a caller switching the integration
lane off would drop PR Risk's PR-time server tier; a gate requiring the
dolt-server lane would silently require the proxied tier too) and
lengthened their critical paths.
bazel-proxied (--config=doltserver-proxied, 15 shards) and
bazel-server-storage (--config=doltserver-integration: conformance + 16
shards) are remote-only jobs that need only rbe, each with its own BEP,
check_testcases.py step and log upload, 25-minute test step inside a
30-minute job. bazel-doltserver and bazel-integration are back to their
previous content, including the dolt-server step's 80-minute timeout for
local runs. The server tier shares bazel-integration's compiles through
the remote cache (same build flags).
The proxied tier mirrors PR Risk's race bd-cmd-test; main.yml's twin
job runs build-artifacts' non-race one, so Bazel is the stricter of the
two. Comments now say so, and the policy test pins main.yml's build so a
change there is noticed. Policy: the new jobs are pinned (command,
config, remote-only if, BEP + testcase steps, timeouts, log upload), and
no tier step may run in bazel-integration or bazel-doltserver.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
145 lines
7.3 KiB
Bash
Executable file
145 lines
7.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Hermetic environment for every `bazel test` action (wired in .bazelrc with
|
|
# `test --run_under=//tools/bazel:test_env`). It mirrors what
|
|
# scripts/ci/lib/test-env.sh does for `go test` in pr-core: a private HOME,
|
|
# XDG config, Dolt root and empty global gitconfig, so no test reads or writes
|
|
# the developer's or the worker's real configuration.
|
|
#
|
|
# Everything lives in one fresh mktemp directory under /tmp, unique per test
|
|
# process: HOME, config and TMPDIR must be short (t.TempDir() paths hold unix
|
|
# sockets, whose sun_path limit is 104 bytes, and Bazel's TEST_TMPDIR is deep
|
|
# under the output base) and must not be shared between concurrent runs of the
|
|
# same target. The directory is removed when the test exits. Only the fixed
|
|
# wrapper text enters the action key; no host path or client env does.
|
|
set -euo pipefail
|
|
|
|
root="$(mktemp -d /tmp/bbt.XXXXXX)"
|
|
# Kill every process that still names this action's private root in its
|
|
# command line: a detached bd db-proxy-child (Setsid, its own process group)
|
|
# and the dolt sql-server it started carry $root in --root, --config or
|
|
# --logpath. When Bazel times a test out it signals the process group, which
|
|
# misses them, and a proxy that dies without an idle timeout leaves its server
|
|
# orphaned on a persistent remote worker. $root is a fresh mktemp path, so the
|
|
# match cannot reach an unrelated process; this wrapper's own command line
|
|
# never contains it, and pkill never matches itself. The '.' in bbt.XXXXXX is
|
|
# escaped because pkill -f takes an extended regex. Two passes: a proxy killed
|
|
# in the middle of the first may have forked a new server. Without pkill, fall
|
|
# back to scanning /proc; without either, skip.
|
|
# shellcheck disable=SC2317 # invoked from the EXIT trap
|
|
reap_root_processes() {
|
|
local uid pid cmd argv
|
|
uid="$(id -u 2>/dev/null)" || return 0
|
|
if command -v pkill >/dev/null 2>&1; then
|
|
local pattern="${root//./\\.}/"
|
|
pkill -KILL -U "$uid" -f -- "$pattern" 2>/dev/null || true
|
|
pkill -KILL -U "$uid" -f -- "$pattern" 2>/dev/null || true
|
|
elif [[ -d /proc/self ]]; then
|
|
for _ in 1 2; do
|
|
for cmd in /proc/[0-9]*/cmdline; do
|
|
pid="${cmd#/proc/}"
|
|
pid="${pid%/cmdline}"
|
|
[[ "$pid" == "$$" || "$pid" == "$BASHPID" ]] && continue
|
|
argv="$(tr '\0' ' ' <"$cmd" 2>/dev/null)" || continue
|
|
if [[ "$argv" == *"$root/"* ]]; then
|
|
kill -KILL "$pid" 2>/dev/null || true
|
|
fi
|
|
done
|
|
done
|
|
fi
|
|
return 0
|
|
}
|
|
# Cleanup must never change the test's exit status: a child the test left
|
|
# running (a detached bd or a Dolt server shutting down) can still be writing
|
|
# when rm runs, and Bazel only reaps it after this wrapper exits.
|
|
trap 'reap_root_processes 2>/dev/null || true; chmod -R u+w "$root" 2>/dev/null || true; rm -rf "$root" 2>/dev/null || true' EXIT
|
|
|
|
mkdir -p "$root/home" "$root/xdg-config" "$root/dolt-root" "$root/tmp"
|
|
: >"$root/gitconfig"
|
|
# The global git identity of the CI jobs that run `git config --global
|
|
# user.name/user.email` before their tests (PR Risk's server-Dolt and
|
|
# proxied-server jobs): a target mirroring such a job sets
|
|
# BEADS_TEST_GIT_IDENTITY=1 in its env. Everything else keeps pr-core's empty
|
|
# global gitconfig.
|
|
if [[ "${BEADS_TEST_GIT_IDENTITY:-}" == 1 ]]; then
|
|
printf '[user]\n\tname = CI Bot\n\temail = ci@beads.test\n' >"$root/gitconfig"
|
|
fi
|
|
# Dolt identity, as beads_test_env_enter sets with `dolt config --global`:
|
|
# tests that shell out to dolt commit need an author. Written directly so the
|
|
# wrapper does not depend on a dolt binary. The two *.disabled keys stop every
|
|
# dolt command from checking for a newer release and from sending usage
|
|
# events over the network: calls a hermetic test must not depend on (they
|
|
# change no behavior, only drop a "newer version available" stderr line).
|
|
# They do not stop dolt from forking a detached `dolt send-metrics` child on
|
|
# exit, which outlives the command and re-creates $DOLT_ROOT_PATH/.dolt under
|
|
# a test that already removed it; DOLT_DISABLE_EVENT_FLUSH does.
|
|
mkdir -p "$root/dolt-root/.dolt"
|
|
printf '%s\n' '{"user.email":"test@beads.local","user.name":"beads-test","metrics.disabled":"true","versioncheck.disabled":"true"}' \
|
|
>"$root/dolt-root/.dolt/config_global.json"
|
|
export DOLT_DISABLE_EVENT_FLUSH=1
|
|
|
|
export HOME="$root/home"
|
|
export USERPROFILE="$root/home"
|
|
export XDG_CONFIG_HOME="$root/xdg-config"
|
|
export DOLT_ROOT_PATH="$root/dolt-root"
|
|
export GIT_CONFIG_NOSYSTEM=1
|
|
export GIT_CONFIG_GLOBAL="$root/gitconfig"
|
|
export TMPDIR="$root/tmp"
|
|
export BEADS_TEST_IGNORE_REPO_CONFIG=1
|
|
|
|
# Discovery ceilings. bd walks up from its working directory for .beads and
|
|
# .beads/config.yaml, and git walks up for a repository. A test's working
|
|
# directory is in the runfiles tree under the output base, which is usually
|
|
# below the developer's HOME, so an unbounded walk would read and write their
|
|
# real ~/.beads (and a host config would decide test results). Every walk stops
|
|
# below the runfiles root, TEST_TMPDIR and this wrapper's root; a test's own
|
|
# directories under them stay discoverable. Relying on the ceiling rather than
|
|
# failing on an ancestor .beads is deliberate: a live ~/.beads above the output
|
|
# base is normal on a developer machine.
|
|
ceilings=""
|
|
for d in "${TEST_SRCDIR:-}" "${TEST_TMPDIR:-}" "$root"; do
|
|
if [[ -n "$d" && -d "$d" ]]; then
|
|
ceilings="${ceilings:+$ceilings:}$(cd "$d" && pwd -P)"
|
|
fi
|
|
done
|
|
export BEADS_CEILING_DIRECTORIES="$ceilings"
|
|
export GIT_CEILING_DIRECTORIES="$ceilings"
|
|
# The migration-freeze marker walk is deliberately not bounded by the ceiling;
|
|
# point it at a path that never exists so a MIGRATION-FREEZE file above the
|
|
# output base cannot make write commands refuse inside tests.
|
|
export BD_MIGRATION_FREEZE_FILE="$root/no-freeze-marker"
|
|
|
|
# Same scrub as beads_test_env_enter; `--test_env=NAME` on a command line must
|
|
# not be able to point a test at a live workspace or Dolt server.
|
|
unset BEADS_DIR BEADS_DB BD_DB BD_JSON BD_NO_DB BD_NO_DAEMON BD_ACTOR \
|
|
BEADS_ACTOR GT_ROOT BEADS_DOLT_SHARED_SERVER BEADS_DOLT_SERVER_MODE \
|
|
BEADS_DOLT_AUTO_START BEADS_DOLT_SERVER_HOST BEADS_DOLT_SERVER_PORT \
|
|
BEADS_DOLT_PORT BEADS_DOLT_SERVER_DATABASE BEADS_DOLT_SERVER_SOCKET \
|
|
BEADS_DOLT_PASSWORD BEADS_TEST_REPO_ROOT BEADS_DOLT_BIN
|
|
|
|
# Hermetic host tools: the pinned Dolt CLI (tools/bazel/dolt.bzl) goes first on
|
|
# PATH, so no test runs whatever dolt the executor happens to have, or skips
|
|
# because it has none. The directory comes from this wrapper's own runfiles,
|
|
# which Bazel merges into every test's runfiles, so it is always declared;
|
|
# missing it means broken wiring, and every test fails rather than skipping.
|
|
hermetic_bin=""
|
|
runfiles="${RUNFILES_DIR:-${TEST_SRCDIR:-}}"
|
|
rel="${TEST_WORKSPACE:-_main}/tools/bazel/hermetic_bin"
|
|
if [[ -n "$runfiles" && -x "$runfiles/$rel/dolt" ]]; then
|
|
hermetic_bin="$runfiles/$rel"
|
|
elif [[ -n "${RUNFILES_MANIFEST_FILE:-}" && -f "$RUNFILES_MANIFEST_FILE" ]]; then
|
|
dolt_path="$(awk -v k="$rel/dolt" '$1 == k { print $2; exit }' "$RUNFILES_MANIFEST_FILE")"
|
|
if [[ -n "$dolt_path" && -x "$dolt_path" ]]; then
|
|
hermetic_bin="${dolt_path%/*}"
|
|
fi
|
|
fi
|
|
if [[ -z "$hermetic_bin" ]]; then
|
|
printf 'test_env: hermetic dolt not found at %s in the runfiles of this test (//tools/bazel:hermetic_bin)\n' "$rel/dolt" >&2
|
|
exit 1
|
|
fi
|
|
export PATH="$hermetic_bin:${PATH:-/bin:/usr/bin}"
|
|
export BEADS_TEST_DOLT_BINARY="$hermetic_bin/dolt"
|
|
|
|
# Not exec: the trap must run to remove $root. The exit status is the test's.
|
|
status=0
|
|
"$@" || status=$?
|
|
exit "$status"
|