 pingqiuandClaude Opus 4.7
|
6a3b84cd29
|
component test framework: cluster harness + 7 demo scenarios
QA-requested (round-39): build a component test framework so QA can
author T4c-follow-up + T4d scenarios in ~20-30 lines without
re-deriving cluster setup boilerplate.
Lands `core/replication/component/` package with:
- Cluster builder: NewCluster(t, factory).WithReplicas(n).Start()
→ fully wired primary + N replicas over real localhost TCP using
production code paths (BlockStore + ReplicaListener + BlockExecutor)
- RunMatrix(t, scenario): runs the scenario across smartwal + walstore;
both substrates gate per round-22 sign-bearing discipline
- RunSubstrate(t, name, factory, scenario): single-substrate runner
for substrate-specific pins
- Write/sync primitives: PrimaryWrite, PrimaryWriteN, PrimarySync,
ReplicaApply (for setting up pre-existing replica state)
- Recovery primitives: CatchUpReplica, ProbeReplica
- Fault injection: KillReplicaListener, SeverConnection
- Convergence assertions: WaitForConverge, AssertReplicaConverged
- Mode-label assertions: AssertSawRecoveryMode with ExpectAnyMode /
ExpectWALReplay / ExpectStateConvergence constants
- Log capture: tees log.Default writer into per-test buffer so mode-
label assertions don't need stderr parsing
- Mode-constant init-time pin: panics if ExpectWALReplay /
ExpectStateConvergence drift from storage.RecoveryMode* values
7 demo scenarios in cluster_test.go double as smoke for the framework
+ copy-paste templates for QA:
- TestComponent_HappyCatchUp — simplest scenario shape
- TestComponent_GapExceedsRetention_Recycled — substrate fault wrap
pattern (recycledScanStub demonstrates ScanLBAs override for
ErrWALRecycled injection)
- TestComponent_ProbeHappy — probe wire smoke across substrates
- TestComponent_TwoReplicas_BothConverge — multi-replica fan-out
- TestComponent_PartialReplicaThenCatchUp — ReplicaApply for
pre-existing partial state setup
- TestComponent_RecoveryModeLabel_Walstore — per-substrate label pin
(wal_replay)
- TestComponent_RecoveryModeLabel_Smartwal — per-substrate label pin
(state_convergence)
- TestComponent_ModeConstantsStable — drift fence
Authoring guide: sw-block/design/v3-phase-15-component-test-guide.md
documents the API + common patterns + extension discipline. Aim:
~20-30 lines per new scenario.
Forward-carry items (sw will add when needed):
- WithPrimaryStorageWrap(wrap) option — substrate fault injection at
the executor layer (today the wrap pattern only works at the
storage layer; substrate-level executor-test integration needs
the option)
- WithEngineDrivenRecovery() option — when T4d lands the
ReplicationVolume↔adapter wiring, the framework gains the engine-
driven recovery flow as an opt-in mode
go test ./... -count=1 → all 22 packages green (component is the
new package).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
2026-04-25 10:35:27 -07:00 |
|