test(serve): point the shared-server --global case at the test server (#7167)

TestSharedServerModeServeGlobalReportsTheServedDatabase was parked outside
the proxied discovery pattern because `bd serve --global` exited 1 on the
#5920 shared-store migration guard (v65 -> v69). The guard was right; the
test setup was wrong.

The workspace was a plain `bd init --server --server-port <test server>`
that only flipped BEADS_DOLT_SHARED_SERVER=1 afterwards. Shared-server
mode deliberately ignores the workspace's own dolt_server_port and
resolves the machine-wide shared server (BEADS_DOLT_SERVER_PORT, the
shared port file, ..., then the 3308 default), so every --global command
dialled 127.0.0.1:3308 rather than the hermetic test server. On CI nothing
listens there; on a developer machine running a real shared server, the
test read that server's own beads_global (created by an older bd at v65)
and serve asked to migrate it. beads_global was also never provisioned on
the test server, because only `bd init --shared-server` does that.

Set the workspace up the way an operator joins an externally-managed
shared server: `bd init --shared-server --external` (provisions
beads_global on the test server at the current schema) plus
BEADS_DOLT_SERVER_PORT naming that server. No product change: the guard
correctly refuses an un-consented migration of a shared database, and a
freshly created one (version 0) passes it.

Rename the test into the TestServerMode* discovery pattern and add it to
the Bazel 30-shard block via the generator's incremental --write. The
frozen legacy 15-shard block is untouched; the name hash-distributes there
(shard 12/15).

Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Julian Knutsen 2026-10-03 23:19:28 -07:00 • committed by GitHub
commit 60598ec146
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 20 deletions

View file

@ -277,6 +277,7 @@
30 8 TestProxiedServerShow2
30 8 TestProxiedServerTypes
30 8 TestProxiedServerUpdateClosePolicy
30 8 TestServerModeSharedServeGlobalReportsTheServedDatabase
30 9 TestProxiedServerCloseConcurrent
30 9 TestProxiedServerDep2

View file

@ -34,7 +34,8 @@ type serverModeProject struct {
env []string
}
func newServerModeProject(t *testing.T, bd, prefix string) serverModeProject {
// extraInitArgs are appended to the `bd init --server` command line.
func newServerModeProject(t *testing.T, bd, prefix string, extraInitArgs ...string) serverModeProject {
t.Helper()
// The shared container IS an externally-managed dolt sql-server: nothing
// about it is proxied. The gate env var is named for the suite that
@ -62,6 +63,7 @@ func newServerModeProject(t *testing.T, bd, prefix string) serverModeProject {
"--database", database,
"--prefix", prefix,
"--non-interactive", "--skip-agents", "--skip-hooks")
cmd.Args = append(cmd.Args, extraInitArgs...)
cmd.Dir = dir
cmd.Env = env
stdout, stderr, err := runCommandBuffers(t, cmd)
@ -285,27 +287,29 @@ func TestServerModeServeSkipsPostRunMaintenance(t *testing.T) {
// from the global one is a lie with a straight face. Without the fix the
// handshake and the startup line both report p.database here.
//
// Deliberately not named TestServerMode...: this would make it discovered by
// the shard scripts' ^Test(ProxiedServer|ServerMode) regex, but it still
// fails: `bd serve --global` refuses to auto-apply 4 pending schema
// migrations (v65 to v69) to a shared/proxied server database and exits 1
// with a consent-required usage message instead of starting (bead filed:
// shared-server global DB created at schema v65, serve --global refuses the
// #5920 migration guard). Renaming it into a required lane before that's
// resolved would turn Bazel + the legacy 15-shard hash-fallback + main.yml's
// push job red. Rename it once the guard interaction is resolved.
func TestSharedServerModeServeGlobalReportsTheServedDatabase(t *testing.T) {
requireSharedProxiedServer(t)
// The workspace is set up the way an operator joins an externally-managed
// shared server: `bd init --shared-server --external`, which provisions
// beads_global on that server at the current schema, plus
// BEADS_DOLT_SERVER_PORT naming it. Both halves are load-bearing. Shared-server
// mode deliberately ignores the workspace's own dolt_server_port and resolves
// the machine-wide shared server (env, the shared port file, then 3308), and
// `--external` means bd never writes that port file. Without the env var every
// --global command here dials 127.0.0.1:3308 instead of the test server:
// unreachable on CI, and on a developer machine running a real shared server,
// that server's own beads_global. Without the init, beads_global does not exist
// on the test server at all.
func TestServerModeSharedServeGlobalReportsTheServedDatabase(t *testing.T) {
port := requireSharedProxiedServer(t)
t.Parallel()
bd := buildEmbeddedBD(t)
p := newServerModeProject(t, bd, "srvgl")
p := newServerModeProject(t, bd, "srvgl", "--shared-server", "--external")
// Shared-server mode is server mode plus this switch; the workspace is
// otherwise the same one every other case in this file uses. It also moves
// the proxy root under the shared dolt directory, so the project-local
// cleanup newServerModeProject registered does not cover the child this test
// leaves behind.
p.env = append(p.env, "BEADS_DOLT_SHARED_SERVER=1")
// Shared-server mode is server mode plus this switch (init also persisted
// it in config.yaml); the workspace is otherwise the same one every other
// case in this file uses. It also moves the proxy root under the shared
// dolt directory, so the project-local cleanup newServerModeProject
// registered does not cover the child this test leaves behind.
p.env = append(p.env, "BEADS_DOLT_SHARED_SERVER=1", "BEADS_DOLT_SERVER_PORT="+strconv.Itoa(port))
sharedProxyRoot := filepath.Join(p.dir, ".beads", "shared-server", "dolt")
t.Cleanup(func() {
if err := proxy.Shutdown(sharedProxyRoot); err != nil {