* test(bazel): shard http_served_test and corpus_served_test (embedded lane critical path) Both served targets ran as one shard each (235-597s) and were the embedded lane's longest action in most executing runs; every other embedded shard ends by ~90-155s. - http_served_test runs through go_test_pinned_shard.sh like httpclient_served_test: the 19 TestE2E_* cases >= 3s are pinned onto 6 shards (pin_shards.py from three lane runs' test.xml plus one local run, <= ~88 measured seconds each), the ~28 fast tests round-robin in a 7th. - corpus_served_test: TestServedCorpus becomes TestServedCorpusPart1..4. Shapes are dealt round robin in corpus order; each part starts its own server and seeds its own pair of workspaces. The shapes are independent: every check is served-vs-embedded parity after the same commands, each write owns its target ids, and order preservation keeps each part's reads ahead of its writes. TestCorpusPartsDealEveryShapeOnce checks the deal (every shape once, in order, no empty part); the manifest pins part k to shard k, with a 5th round-robin shard for the engine-free tests, and scripts TestCorpusPartsArePinnedOnePerShard ties corpusParts, the manifest and shard_count together. BEADS_CORPUS_REPORT now accumulates every part the process ran. - pinnedShardTargets and the retired-lane args pins list both targets; go_test_sources_test gets the two packages' manifests as data. Embedded goes from 172 to 182 test actions; the dolt-race/dolt-int union budgets do not include the embedded tag and are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(corpus): guard part wiring; seed metadata on e2e-t-ifa (review of #7537) - testServedCorpus fails (before the engine gate, so in every lane) unless the test's name is TestServedCorpusPart<part>: a TestServedCorpusPart3 calling testServedCorpus(t, 2) would run part 2 twice and silently drop part 3's shapes. TestCorpusPartNameMustMatchItsPart covers the check and that servedCorpusParts lists Part1..N in order. Mutation (Part3 -> 2) fails //backend/http/corpus:corpus_test with "TestServedCorpusPart3 runs corpus part 2; only TestServedCorpusPart2 may". - e2e-t-ifa is seeded with metadata seeded=keep. The parts seed separately, so the two refused (exit 13) conditional updates no longer always follow gc-update-if-assignment's k=v; their verify show again holds that a refusal keeps existing metadata. Mutation (served verify output's seeded=keep rewritten) fails both stale shapes at $[0].metadata.seeded. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
91 lines
3 KiB
Go
91 lines
3 KiB
Go
package scripts_test
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"reflect"
|
|
"regexp"
|
|
"sort"
|
|
"strconv"
|
|
"testing"
|
|
)
|
|
|
|
var goTopLevelTestRe = regexp.MustCompile(`(?m)^func (Test[A-Za-z0-9_]*)\(t \*testing\.T\) \{`)
|
|
|
|
// Every name a pinned-shard manifest pins is a top-level test of the
|
|
// target's package: a stale name runs nowhere, and a renamed test silently
|
|
// falls back to the round-robin shards (regenerate with
|
|
// tools/bazel/pin_shards.py).
|
|
func TestPinnedShardManifestNamesAreTests(t *testing.T) {
|
|
root := sourceRepoRoot(t)
|
|
for _, tgt := range pinnedShardTargets {
|
|
t.Run(tgt.rule, func(t *testing.T) {
|
|
tests := map[string]bool{}
|
|
srcs, err := filepath.Glob(filepath.Join(root, tgt.pkg, "*_test.go"))
|
|
if err != nil || len(srcs) == 0 {
|
|
t.Fatalf("no *_test.go in %s: %v", tgt.pkg, err)
|
|
}
|
|
for _, src := range srcs {
|
|
b, err := os.ReadFile(src)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, m := range goTopLevelTestRe.FindAllStringSubmatch(string(b), -1) {
|
|
tests[m[1]] = true
|
|
}
|
|
}
|
|
pinned, _ := readPinnedShardManifest(t, root, tgt.manifest)
|
|
var stale []string
|
|
for name := range pinned {
|
|
if !tests[name] {
|
|
stale = append(stale, name)
|
|
}
|
|
}
|
|
sort.Strings(stale)
|
|
for _, name := range stale {
|
|
t.Errorf("%s pins %s, which is not a top-level test in %s/*_test.go; regenerate it (tools/bazel/pin_shards.py)", tgt.manifest, name, tgt.pkg)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
var corpusPartsConst = regexp.MustCompile(`(?m)^const corpusParts = (\d+)$`)
|
|
|
|
// corpus_served_test's manifest is not pin_shards.py's: it pins
|
|
// TestServedCorpusPart1..N, the corpus parts (backend/http/corpus
|
|
// corpusParts), to shards 1..N, one each, and pins nothing else, so every
|
|
// part runs alone in its own Bazel shard on its own seed. One shard is left
|
|
// for the binary's round-robin over the package's other (engine-free) tests.
|
|
func TestCorpusPartsArePinnedOnePerShard(t *testing.T) {
|
|
root := sourceRepoRoot(t)
|
|
const (
|
|
build = "backend/http/corpus/BUILD.bazel"
|
|
manifest = "backend/http/corpus/served_pinned_shards.txt"
|
|
src = "backend/http/corpus/corpus_test.go"
|
|
)
|
|
m := corpusPartsConst.FindStringSubmatch(readPolicyFile(t, root, src))
|
|
if m == nil {
|
|
t.Fatalf("%s has no `const corpusParts = N`", src)
|
|
}
|
|
parts, _ := strconv.Atoi(m[1])
|
|
if parts < 2 {
|
|
t.Fatalf("corpusParts = %d; a single part needs no pinned shards", parts)
|
|
}
|
|
pinned, maxShard := readPinnedShardManifest(t, root, manifest)
|
|
want := map[string]int{}
|
|
for k := 1; k <= parts; k++ {
|
|
want[fmt.Sprintf("TestServedCorpusPart%d", k)] = k
|
|
}
|
|
if !reflect.DeepEqual(pinned, want) {
|
|
t.Errorf("%s pins %v, want each of the %d corpus parts on its own shard: %v", manifest, pinned, parts, want)
|
|
}
|
|
rule := bazelRuleBlock(readPolicyFile(t, root, build), "corpus_served_test")
|
|
sm := shardCountPattern.FindStringSubmatch(rule)
|
|
if sm == nil {
|
|
t.Fatalf("%s:corpus_served_test has no shard_count", build)
|
|
}
|
|
if n, _ := strconv.Atoi(sm[1]); n != maxShard+1 {
|
|
t.Errorf("%s:corpus_served_test shard_count = %d, want %d (%d parts and one round-robin shard)", build, n, maxShard+1, maxShard)
|
|
}
|
|
}
|