mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
Implements the frontend contract per T1 sketch §5-9: Identity,
Backend, Provider, ProjectionView types; ErrStalePrimary /
ErrNotReady / ErrBackendClosed sentinels; memback contract-smoke
backend that re-validates full lineage on every Read/Write.
Tests per QA test-spec:
L0 x7 (provider open healthy + not-ready, backend read/write,
stale read, stale write table-driven, close, boundary guard)
L1 x1 (Publisher + VolumeBridge publication route, Epoch-bump
move, old backend rejects, new backend serves post-move)
Two sw review notes for QA Owner:
- Spec samples use engine.ReplicaProjection{VolumeID, ReplicaID,
Healthy}. Actual engine type lacks those fields; per sketch §5
the frontend defines its own Projection struct. Documented in
file headers.
- Spec's T1.L1.1 asserts ReplicaID change across the move.
Cross-replica authorship requires TopologyController, not
StaticDirective. This L1 proves Epoch-drift fence (the fence's
actual invariant). ReplicaID-change coverage routed to L2
over the real product route.
L2 test (T1.L2.1) not written: BLOCKED-BY-T0 per test-spec §6 —
the T0 noop executor cannot produce a frontend-serving projection
until the T1-owned readiness bridge lands in cmd/blockvolume.
35 lines
850 B
Go
35 lines
850 B
Go
// Ownership: sw test-support (per test-spec §9: non-test helper
|
|
// files *_test_support.go are sw-owned). Holds shared fakes
|
|
// used by QA-owned test files in this package.
|
|
package frontend_test
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/seaweedfs/seaweed-block/core/frontend"
|
|
)
|
|
|
|
// fakeProjectionView is a concurrency-safe, settable
|
|
// ProjectionView used by all L0 tests. set() swaps the current
|
|
// projection; Projection() returns the latest.
|
|
type fakeProjectionView struct {
|
|
mu sync.Mutex
|
|
proj frontend.Projection
|
|
}
|
|
|
|
func newFakeProjectionView(p frontend.Projection) *fakeProjectionView {
|
|
return &fakeProjectionView{proj: p}
|
|
}
|
|
|
|
func (f *fakeProjectionView) Projection() frontend.Projection {
|
|
f.mu.Lock()
|
|
defer f.mu.Unlock()
|
|
return f.proj
|
|
}
|
|
|
|
func (f *fakeProjectionView) set(p frontend.Projection) {
|
|
f.mu.Lock()
|
|
defer f.mu.Unlock()
|
|
f.proj = p
|
|
}
|