mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
test: restore native typed cut controls and close activation isolation coverage
This commit is contained in:
1 parent
a81bca4926
commit
fbd33f9712
5 files changed
+59
-61
No files matched your search
+4
-1
@@ -46,7 +46,10 @@ jobs:
|
||||
- name: Vet
|
||||
run: go vet ./...
|
||||
|
||||
- name: Test
|
||||
- name: Test default configuration
|
||||
run: go test -p=1 -short -count=1 -timeout 10m ./...
|
||||
|
||||
- name: Test legacy-fixture configuration
|
||||
# Legacy-input fixtures and native caller controls stay executable after
|
||||
# their constructors move behind the explicit test-only build tag.
|
||||
# Bound package concurrency for existing short wall-clock assertions.
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestChunkCut_BaseInstallRefusalIsTyped(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestChunkCut_UploadFailureIsRemoteUnavailable(t *testing.T) {
|
||||
s, _ := newLegacyChunkTestStore(t)
|
||||
s, _ := newMappedCheckpointStoreV3(t)
|
||||
f := newFakeChunkRemote()
|
||||
layer := mustAttach(t, s, f, ctConfig(1))
|
||||
newWriteLog().write(t, s, 2, 0x22)
|
||||
@@ -34,7 +34,7 @@ func TestChunkCut_UploadFailureIsRemoteUnavailable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestChunkCut_ClosedLayerIsTyped(t *testing.T) {
|
||||
s, _ := newLegacyChunkTestStore(t)
|
||||
s, _ := newMappedCheckpointStoreV3(t)
|
||||
layer := mustAttach(t, s, newFakeChunkRemote(), ctConfig(1))
|
||||
if err := layer.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -47,7 +47,7 @@ func TestChunkCut_ClosedLayerIsTyped(t *testing.T) {
|
||||
// A CAS that returned no definite answer, after which HEAD reads a newer
|
||||
// generation from the same holder, did not apply: a head conflict.
|
||||
func TestChunkCut_CASLostToMovedHeadIsHeadConflict(t *testing.T) {
|
||||
s, _ := newLegacyChunkTestStore(t)
|
||||
s, _ := newMappedCheckpointStoreV3(t)
|
||||
f := newFakeChunkRemote()
|
||||
layer := mustAttach(t, s, f, ctConfig(1))
|
||||
w := newWriteLog()
|
||||
|
||||
@@ -32,17 +32,9 @@ func TestLegacyFixtureIsolation(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ast.Inspect(f, func(n ast.Node) bool {
|
||||
call, ok := n.(*ast.CallExpr)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
id, ok := call.Fun.(*ast.Ident)
|
||||
if ok && forbidden[id.Name] {
|
||||
t.Errorf("production source %s calls legacy fixture %s", e.Name(), id.Name)
|
||||
}
|
||||
return true
|
||||
})
|
||||
for _, name := range legacyConstructorReferences(f, forbidden) {
|
||||
t.Errorf("production source %s references legacy fixture %s", e.Name(), name)
|
||||
}
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
@@ -73,3 +65,49 @@ func TestLegacyFixtureIsolation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func legacyConstructorReferences(f *ast.File, forbidden map[string]bool) []string {
|
||||
var refs []string
|
||||
// A constructor declaration is retained for test linking, but every use
|
||||
// (including function values, aliases and arguments) is forbidden.
|
||||
declarations := map[*ast.Ident]bool{}
|
||||
for _, decl := range f.Decls {
|
||||
if fn, ok := decl.(*ast.FuncDecl); ok {
|
||||
declarations[fn.Name] = true
|
||||
}
|
||||
}
|
||||
ast.Inspect(f, func(n ast.Node) bool {
|
||||
if id, ok := n.(*ast.Ident); ok && forbidden[id.Name] && !declarations[id] {
|
||||
refs = append(refs, id.Name)
|
||||
}
|
||||
return true
|
||||
})
|
||||
return refs
|
||||
}
|
||||
|
||||
func TestLegacyFixtureIsolationRejectsFunctionValues(t *testing.T) {
|
||||
const name = "createLegacyWALStoreWithOptions"
|
||||
for _, body := range []string{
|
||||
"func use() { createLegacyWALStoreWithOptions() }",
|
||||
"var constructor = createLegacyWALStoreWithOptions",
|
||||
"func use() { constructor := createLegacyWALStoreWithOptions; constructor() }",
|
||||
"func use() { accept(createLegacyWALStoreWithOptions) }",
|
||||
} {
|
||||
t.Run(body, func(t *testing.T) {
|
||||
f, err := parser.ParseFile(token.NewFileSet(), "production.go", "package storage\n"+body, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if refs := legacyConstructorReferences(f, map[string]bool{name: true}); len(refs) != 1 {
|
||||
t.Fatalf("legacy constructor reference escaped guard: %v", refs)
|
||||
}
|
||||
})
|
||||
}
|
||||
f, err := parser.ParseFile(token.NewFileSet(), "legacy.go", "package storage\nfunc createLegacyWALStoreWithOptions() {}", 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if refs := legacyConstructorReferences(f, map[string]bool{name: true}); len(refs) != 0 {
|
||||
t.Fatalf("declaration is not a use: %v", refs)
|
||||
}
|
||||
}
|
||||
@@ -213,34 +213,6 @@
|
||||
],
|
||||
"todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b"
|
||||
},
|
||||
{
|
||||
"file": "core/storage/chunk_layer_typed_cause_test.go",
|
||||
"test": "TestChunkCut_CASLostToMovedHeadIsHeadConflict",
|
||||
"legacy_roots": [
|
||||
"createLegacyWALStoreWithOptions"
|
||||
],
|
||||
"reason": "legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery",
|
||||
"v3_controls": [
|
||||
"TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint",
|
||||
"TestChunkLayerV3_IgnoresProvidedLegacyBitmap",
|
||||
"TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation"
|
||||
],
|
||||
"todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b"
|
||||
},
|
||||
{
|
||||
"file": "core/storage/chunk_layer_typed_cause_test.go",
|
||||
"test": "TestChunkCut_ClosedLayerIsTyped",
|
||||
"legacy_roots": [
|
||||
"createLegacyWALStoreWithOptions"
|
||||
],
|
||||
"reason": "legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery",
|
||||
"v3_controls": [
|
||||
"TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint",
|
||||
"TestChunkLayerV3_IgnoresProvidedLegacyBitmap",
|
||||
"TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation"
|
||||
],
|
||||
"todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b"
|
||||
},
|
||||
{
|
||||
"file": "core/storage/chunk_layer_precopy_test.go",
|
||||
"test": "TestChunkCut_RecoverWaitsForTheCaptureBarrier",
|
||||
@@ -269,20 +241,6 @@
|
||||
],
|
||||
"todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b"
|
||||
},
|
||||
{
|
||||
"file": "core/storage/chunk_layer_typed_cause_test.go",
|
||||
"test": "TestChunkCut_UploadFailureIsRemoteUnavailable",
|
||||
"legacy_roots": [
|
||||
"createLegacyWALStoreWithOptions"
|
||||
],
|
||||
"reason": "legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery",
|
||||
"v3_controls": [
|
||||
"TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint",
|
||||
"TestChunkLayerV3_IgnoresProvidedLegacyBitmap",
|
||||
"TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation"
|
||||
],
|
||||
"todo": "row 14a: move or retire explicitly only after replacement/migration review; no deletion in 12b"
|
||||
},
|
||||
{
|
||||
"file": "core/storage/chunk_layer_c11_test.go",
|
||||
"test": "TestChunkLayer_C11_BaseRebuildRecovery",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Temporary legacy test inventory at v3 activation
|
||||
|
||||
Ruling: explicit test-only legacy constructors preserve old engine/bitmap controls until row 14a. Production Create/Open/readonly select v3, and v2 input is explicitly refused. `TestLegacyFixtureIsolation` checks that no default production source calls the private legacy constructor chain and that the storage transitive import closure excludes tool/test support.
|
||||
Ruling: explicit test-only legacy constructors preserve old engine/bitmap controls until row 14a. Production Create/Open/readonly select v3, and v2 input is explicitly refused. `TestLegacyFixtureIsolation` checks that no default production source references the private legacy constructor chain and that the storage transitive import closure excludes tool/test support.
|
||||
|
||||
The JSON companion is the exact test inventory (including helper reachability), with each old control’s existing named v3 controls and its remaining format-specific scope. Constructor wrappers live in `_test.go`; cross-package migration fixture entry points exist only under `swblock_format_v3_test`. The real-v2 decoder/migration fixtures moved into that explicit tagged suite; raw codec table tests stay in the default suite. Full validation runs BOTH default and tagged suites. No frozen engine snapshot or test deletion is used.
|
||||
|
||||
@@ -28,11 +28,8 @@ TODO(row 14a): relocate or retire every listed legacy control explicitly; preser
|
||||
| `core/storage/flusher_test.go::TestAllBlocks_ReturnsBlocksAfterFlush` | v2 engine/layout, forced legacy fields or callback seams; v3 uses coherent descriptors | `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` |
|
||||
| `core/storage/walstore_checkpoint_safety_test.go::TestCheckpointPublicationCrashWindowsRemainRecoverable` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` |
|
||||
| `core/storage/chunk_layer_typed_cause_test.go::TestChunkCut_BaseInstallRefusalIsTyped` | legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery | `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestChunkLayerV3_IgnoresProvidedLegacyBitmap`, `TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation` |
|
||||
| `core/storage/chunk_layer_typed_cause_test.go::TestChunkCut_CASLostToMovedHeadIsHeadConflict` | legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery | `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestChunkLayerV3_IgnoresProvidedLegacyBitmap`, `TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation` |
|
||||
| `core/storage/chunk_layer_typed_cause_test.go::TestChunkCut_ClosedLayerIsTyped` | legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery | `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestChunkLayerV3_IgnoresProvidedLegacyBitmap`, `TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation` |
|
||||
| `core/storage/chunk_layer_precopy_test.go::TestChunkCut_RecoverWaitsForTheCaptureBarrier` | legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery | `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestChunkLayerV3_IgnoresProvidedLegacyBitmap`, `TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation` |
|
||||
| `core/storage/chunk_layer_lsn_order_test.go::TestChunkCut_RemoteLSNNeverDecreases` | legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery | `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestChunkLayerV3_IgnoresProvidedLegacyBitmap`, `TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation` |
|
||||
| `core/storage/chunk_layer_typed_cause_test.go::TestChunkCut_UploadFailureIsRemoteUnavailable` | legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery | `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestChunkLayerV3_IgnoresProvidedLegacyBitmap`, `TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation` |
|
||||
| `core/storage/chunk_layer_c11_test.go::TestChunkLayer_C11_BaseRebuildRecovery` | legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery | `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestChunkLayerV3_IgnoresProvidedLegacyBitmap`, `TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation` |
|
||||
| `core/storage/chunk_layer_c11_test.go::TestChunkLayer_C11_BitmapPersistedBeforeWALRecycle` | legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery | `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestChunkLayerV3_IgnoresProvidedLegacyBitmap`, `TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation` |
|
||||
| `core/storage/chunk_layer_c11_test.go::TestChunkLayer_C11_ExtentCallbackIsPureInMemory` | legacy C11 bitmap persistence/reconciliation or pre-v3 permissive frontier/record surgery | `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestChunkLayerV3_IgnoresProvidedLegacyBitmap`, `TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation` |
|
||||
@@ -138,3 +135,5 @@ TODO(row 14a): relocate or retire every listed legacy control explicitly; preser
|
||||
| `core/storage/walstore_checkpoint_safety_test.go::TestWriteExtentDirectFailureRetainsDirtyWAL` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` |
|
||||
| `core/storage/walstore_checkpoint_safety_test.go::TestWriteExtentDirectSupersededWALDoesNotReappearAfterRestart` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` |
|
||||
| `core/storage/walstore_checkpoint_safety_test.go::TestWriteExtentDirectSupersedesPriorDirtyWAL` | v2 fd/callback/checkpoint injection or direct-extent API; v3 fails through the shared publisher/owned map and uses install handles | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore`, `TestBaseInstallV3CompleteServesTheImageAcrossACrash` |
|
||||
|
||||
Native typed-error controls use the owned-map v3 store directly: `TestChunkCut_UploadFailureIsRemoteUnavailable` checks both upload error causes; `TestChunkCut_ClosedLayerIsTyped` checks the closed-cut cause; `TestChunkCut_CASLostToMovedHeadIsHeadConflict` checks ambiguous CAS with a moved HEAD remains a conflict, not fencing. They are not legacy coverage mappings. `TestLegacyFixtureIsolationRejectsFunctionValues` exercises direct calls, package/local aliases and function arguments against the same reference guard. CI executes both default and explicit tagged configurations.
|
||||
Reference in new issue
Block a user