Repository navigation
test: fold duplicated test/benchmark scaffolding into shared helpers #673
Copy link
Copy link
Closed
Labels
trackingUmbrella or index issue tracking other issuesUmbrella or index issue tracking other issues
Description
Test and benchmark scaffolding has been copied per package, next to shared helpers that already
exist. There are ~151 struct types in _test.go files. Recent PRs (#671, #672) each added another
heapSampler, inProcessS3, golden digest and backend matrix. This issue tracks folding them into
shared helpers. Survey at f30d3d4 (main + #672).
Existing shared helpers — extend these, don't invent new homes
backend/backendtest:Runconformance,AtomicConditionalPut,WithCapacity,WithDeferred.- It is used by internal
package blocktests, so it must never import block, engine or
recordengine.
backend/faultbackend:Wrap,Rule,Gate,Ops,Count. It forwards no optional
capabilities.internal/mergestream/mergestreamtest:- a per-key read-counting
BackendwithFailWriteAt; - a cross-engine
Run(t, open)suite through aStoreadapter. This is the model for sharing
suites across engines without an import cycle.
- a per-key read-counting
internal/obs/obstest,internal/vfs/vfstest,internal/reproduce.
Plan (ranked: most duplication, lowest risk first)
- 1. Same-package merges (no boundary risk) — landed in test: fold duplicated test/benchmark scaffolding into shared helpers (#673, items 1-4) #674
- root:
nodeCPUCorpus/headCorpus→ parametrised;isPartKey/goldenIsPartKey;reportIngestMetrics/goldenReportPoints;flushDefault(tb, s, signal)for ~55 inlinelookup*Engine("default")+ flush sites;- hand-rolled
itoa→strconv.Itoa(also in engine, encoding/chunk and pool tests).
- engine_test:
liveHeap/heapAlloc;- generalise
flushParts(engine/decode_bench_test.go) for the 5 external "series × samples
× parts → flush" corpus copies.
- recordengine: extract the duplicated
BenchmarkMergeCompact*loop body. - backend/s3:
faultStoreembedsfakeStore. SetBytesliterals*16→engine.SampleByteswhere the package can import it.
- root:
- 2.
backendtestleaf helpers: — landed in test: fold duplicated test/benchmark scaffolding into shared helpers (#673, items 1-4) #674WithoutCapabilities(5 copies);StreamingMemory(2);- per-key read
Counting(4, absorbingmergestreamtest.Backendvia a type alias); - a capability-preserving byte counter (2);
Digest(tb, b, prefixes)for golden part hashing (2 identical + similar), keeping the golden
format byte-identical;PartDirs/IsPartObject(4).
- 3.
backend/s3/s3test:Client/Backend/Shared/Casereplace 5 in-process — landed in test: fold duplicated test/benchmark scaffolding into shared helpers (#673, items 1-4) #674
go-faster/fs setups.- It always wraps
backendtest.AtomicConditionalPutand closes idle connections. - That fixes a latent conditional-put race:
storage_s3_test.goand both merge golden tests skip
the wrapper today.
- It always wraps
- 4.
backendtest.Matrix+s3test.Case: one backend × window table for the two identical — landed in test: fold duplicated test/benchmark scaffolding into shared helpers (#673, items 1-4) #674
merge golden matrices and the 3 benchmark backend tables. - 5. Migrate ~25 hand-rolled fault/count wrappers to
faultbackend. — test(faultbackend): replace hand-rolled fault and count backends (#673, item 5) #676- 13 of them are identical engine/recordengine twins:
rejectReads,failReads,rejectWrites,
rejectIndexWrites,countCAS,sizeKeyWrite,gateWrites/gateReads,invariantCAS,
syncedCommits,readCounter, … - Needs first:
Op.Bytes;Rule.Lose(a conditional write that loses without an error);- a gate mode that holds every match (today
GateisTimes:1); - an
Afterhook.
- Medium risk: gate and error-identity semantics.
- 13 of them are identical engine/recordengine twins:
- 6.
internal/heaptest:Live,Allocated,BytesPerOp, andFileSampler. — landed in test(heaptest): share heap and allocation measurement (#673, item 6) #675FileSamplerembeds*file.File, so capabilities still forward and the measurement doesn't
change.- Also
AssertFlat, with the floored growth ratio and an absolute bound. - About 12 sites. Keep every test's tuned floor, ratio and
!racetag.
- 7.
cluster/etcd/etcdtest: 4 embedded-etcd copies, every one getting the root's — etcdtest in test(etcdtest): share the embedded etcd and bind it to port 0 (#673, #509) #678 (also removes cluster/etcd tests are flaky in CI: port reuse race in freeAddr, and a timing-sensitive rejoin assertion #509's port race by binding port 0); fetchtest dropped: routing ~150 call sites through it was net +44 lines, all churn and no dedup
port-collision retry.query/fetch/fetchtest.Collect: 9+ fetch-and-drain copies. - 8.
internal/enginetest: cross-engine suites for the ~52 test files mirrored between — test(enginetest): run the twin engine tests as one cross-engine suite (#673, item 8) #679; the fetcher-type unification it surfaced landed as refactor(bucketindex): declare the repair seam types once #681 (refactor: declare PartFetcher/FetchResult/RepairStats once instead of per engine #680)
engine/ and recordengine/ (repair, hole, wants, replica…), through an adapter the way
mergestreamtestdoes it. It is blocked onPartFetcher/FetchResultbeing distinct types per
engine, unless the adapter bridges them.
Found along the way
recordengine's partsBytes doc says it sums on-disk size. It sums sizeBytes, which in the
record engine is decoded bytes (introspect.go), while in the metrics engine it is disk bytes. So
the two engines' merge benchmark MB/s are not comparable. Fix the doc in item 1, and state the unit
in both benchmarks.
Rules for every PR here
- Behaviour-preserving: no test's assertion, tuned threshold or measured quantity changes, and the
golden files stay byte-identical. - A shared helper that forwards or strips backend capabilities must say which, because several
tests measure exactly that. - Shared packages must not create import cycles: no engine or recordengine imports from anything
those packages' internal tests use.
🤖 Generated with Claude Code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
trackingUmbrella or index issue tracking other issuesUmbrella or index issue tracking other issues
Activity
Merge pull request #675 from oteldb/test/673-heaptest
Merge pull request #676 from oteldb/test/673-faultbackend
Merge pull request #678 from oteldb/test/673-etcdtest
test(enginetest): add a cross-engine suite and move the lost-part tes…
tdakkota commentedon Sep 24, 2026
All eight items are done. Landed: #674 (items 1–4), #675 (item 6, heaptest), #676 (item 5, faultbackend), #678 (item 7 etcdtest, which also fixed #509's port race), and #679 (item 8, the cross-engine suite). The follow-up it surfaced, #680, landed as #681. Item 7's fetchtest half was dropped: it came out net +44 lines of call-site churn for no deduplication.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KcLq1G8KpWBvM53JaQb1tS