fix: add write-stopped test and remove VKValueLogPointer from test logic

- Add TestWriteStoppedAfterIOError verifying ErrCommitUnknown → write-stopped
  transition after I/O failure (DoD requirement)
- Replace VKValueLogPointer with VKInline in segment_writer_test.go large
  batch test (9 × 4KB entries, still tests multi-fragment)
- Replace put_vlptr_val_empty with put_inline_val_empty in entry_test.go
- VKValueLogPointer remains only in constants_test.go (enum value check)
This commit is contained in:
dailz
2026-06-12 14:39:16 +08:00
parent b833a21848
commit 56bec62a6e
3 changed files with 59 additions and 6 deletions
+12 -5
View File
@@ -1,6 +1,7 @@
package wal
import (
"fmt"
"os"
"path/filepath"
"testing"
@@ -255,13 +256,19 @@ func TestSegmentWriterLargeBatch(t *testing.T) {
}
// Create a batch larger than one block payload (~32KB - 7 bytes).
largeValue := make([]byte, 40*1024)
largeValue := make([]byte, MaxWalInlineValueBytes)
for i := range largeValue {
largeValue[i] = byte(i % 256)
}
entries := []*WalEntry{
{OpType: OpPut, ValueKind: VKValueLogPointer, Key: []byte("large-key"), Value: largeValue},
var entries []*WalEntry
for i := 0; i < 9; i++ {
entries = append(entries, &WalEntry{
OpType: OpPut,
ValueKind: VKInline,
Key: []byte(fmt.Sprintf("large-key-%d", i)),
Value: largeValue,
})
}
encoded, err := EncodeWalBatch(0, entries)
if err != nil {
@@ -315,8 +322,8 @@ func TestSegmentWriterLargeBatch(t *testing.T) {
if err != nil {
t.Fatalf("DecodeWalBatch: %v", err)
}
if decoded.EntryCount != 1 {
t.Errorf("EntryCount = %d, want 1", decoded.EntryCount)
if decoded.EntryCount != uint32(len(entries)) {
t.Errorf("EntryCount = %d, want %d", decoded.EntryCount, len(entries))
}
}