* ci(bazel): scope the proxied lane's shared-server projects to their own database (44 -> 28 shards)
//cmd/bd:bd_proxied_test spends nearly all its time in `bd init
--proxied-server` against the shard's shared dolt sql-server. Measured
where that goes (dolt query log): of ~2,031 statements per init, the ~220
INFORMATION_SCHEMA queries (migration guards and pre-repair probes) are
~80% of server time at a handful of databases, the 81 DOLT_COMMITs only
~0.5s. Dolt evaluates INFORMATION_SCHEMA by walking every database the
session can see, so as root each init cost the server ~1.2 CPU-seconds
more per database already on it (locally 6.7 CPU-s with 1 database, 21
with 11): a shard's k-th init paid for the k-1 projects before it.
- proxied_shared_harness_test.go: newSharedProxiedProject now provisions
the database server-side (root creates it plus a passwordless user of
the same name with ALL on it and nothing else) and inits with
--proxied-server-external-user, so each project's sessions see one
database. newSharedProxiedRootProject keeps the old root/bd-creates-it
shape for the four tests that need a server-wide privilege (DOLT_REMOTE
remove, CREATE DATABASE, one compact statement); a run with the server
log in test outputs showed no other denied statement.
- Dropping finished databases instead was tried and rejected: a DROP
DATABASE fails other sessions' in-flight INFORMATION_SCHEMA queries
("no root value found in session"), ~35 init failures per run.
- No assertion changed. The bd-creates-the-database path stays covered
by the root variant, the managed-local and non-shared init tests.
- proxied_test_durations.json re-measured (two rbe-west runs): 19,618 ->
6,345 cost-seconds. 44 -> 28 shards, LPT-packed to ~227 per shard.
rbe-west, --nocache_test_results (BEP attempt durations): before 44
shards, sum 6,063s, max 186s; scoped users at 44 shards, sum 2,337s, max
68s; at 20 shards, sum 1,950s, max 136s.
Bead: ga-vnycm2.16
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* ci(bazel): proxied lane 28 -> 34 shards for a <=100s slowest shard
PR CI at 28 shards (~227 packed cost each): 2,285 shard-seconds, median
78s, but max 113s; equally packed shards spread up to 1.45x the median.
34 shards (~187 each) targets a slowest shard under 100s.
Bead: ga-vnycm2.16
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
95 lines
2.7 KiB
Go
95 lines
2.7 KiB
Go
//go:build cgo
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestProxiedServerDoltRemoteRemove(t *testing.T) {
|
|
requireSharedProxiedServer(t)
|
|
t.Parallel()
|
|
bd := buildEmbeddedBD(t)
|
|
|
|
seedRemote := func(t *testing.T, p proxiedProject, name, url string) {
|
|
t.Helper()
|
|
db := openProxiedDB(t, p)
|
|
if _, err := db.ExecContext(context.Background(),
|
|
"CALL DOLT_REMOTE('add', ?, ?)", name, url); err != nil {
|
|
t.Fatalf("seed remote %s: %v", name, err)
|
|
}
|
|
}
|
|
|
|
remoteCount := func(t *testing.T, p proxiedProject, name string) int {
|
|
t.Helper()
|
|
db := openProxiedDB(t, p)
|
|
var count int
|
|
if err := db.QueryRowContext(context.Background(),
|
|
"SELECT COUNT(*) FROM dolt_remotes WHERE name = ?", name).Scan(&count); err != nil {
|
|
t.Fatalf("query dolt_remotes: %v", err)
|
|
}
|
|
return count
|
|
}
|
|
|
|
t.Run("removes_existing_remote", func(t *testing.T) {
|
|
t.Parallel()
|
|
p := newSharedProxiedRootProject(t, bd, "prr1")
|
|
seedRemote(t, p, "backup", "https://doltremoteapi.dolthub.com/org/backup")
|
|
|
|
out, err := bdProxiedRun(t, bd, p.dir, "dolt", "remote", "remove", "backup")
|
|
if err != nil {
|
|
t.Fatalf("remote remove failed: %v\n%s", err, out)
|
|
}
|
|
if !strings.Contains(string(out), `Removed remote "backup"`) {
|
|
t.Errorf("unexpected output: %s", out)
|
|
}
|
|
if c := remoteCount(t, p, "backup"); c != 0 {
|
|
t.Errorf("remote 'backup' still present after remove (count=%d)", c)
|
|
}
|
|
})
|
|
|
|
t.Run("json_output", func(t *testing.T) {
|
|
t.Parallel()
|
|
p := newSharedProxiedRootProject(t, bd, "prr2")
|
|
seedRemote(t, p, "backup", "https://doltremoteapi.dolthub.com/org/backup")
|
|
|
|
out, err := bdProxiedRun(t, bd, p.dir, "dolt", "remote", "remove", "--json", "backup")
|
|
if err != nil {
|
|
t.Fatalf("remote remove --json failed: %v\n%s", err, out)
|
|
}
|
|
s := string(out)
|
|
start := strings.Index(s, "{")
|
|
if start < 0 {
|
|
t.Fatalf("no JSON object in output: %s", s)
|
|
}
|
|
var res struct {
|
|
Name string `json:"name"`
|
|
Removed bool `json:"removed"`
|
|
}
|
|
if err := json.Unmarshal([]byte(s[start:]), &res); err != nil {
|
|
t.Fatalf("parse JSON: %v\n%s", err, s)
|
|
}
|
|
if res.Name != "backup" || !res.Removed {
|
|
t.Errorf("unexpected JSON result: %+v", res)
|
|
}
|
|
if c := remoteCount(t, p, "backup"); c != 0 {
|
|
t.Errorf("remote 'backup' still present after remove (count=%d)", c)
|
|
}
|
|
})
|
|
|
|
t.Run("nonexistent_remote_errors", func(t *testing.T) {
|
|
t.Parallel()
|
|
p := newSharedProxiedRootProject(t, bd, "prr3")
|
|
out, err := bdProxiedRun(t, bd, p.dir, "dolt", "remote", "remove", "ghost")
|
|
if err == nil {
|
|
t.Fatalf("expected error removing nonexistent remote, got:\n%s", out)
|
|
}
|
|
s := string(out)
|
|
if !strings.Contains(s, "removing remote") || !strings.Contains(s, "ghost") {
|
|
t.Errorf("expected a remove-failure error naming %q, got:\n%s", "ghost", s)
|
|
}
|
|
})
|
|
}
|