This commit is contained in:
parent
7e744fe85b
commit
9a98349115
@ -125,7 +125,8 @@ func (m *MockStatsCollector) StartRecovery() time.Time {
|
||||
return time.Now()
|
||||
}
|
||||
|
||||
func (m *MockStatsCollector) FinishRecovery(startTime time.Time, filesRecovered, entriesRecovered, corruptedEntries uint64) {}
|
||||
func (m *MockStatsCollector) FinishRecovery(startTime time.Time, filesRecovered, entriesRecovered, corruptedEntries uint64) {
|
||||
}
|
||||
|
||||
func TestForwardingLayer(t *testing.T) {
|
||||
// Create mocks
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
|
||||
const (
|
||||
ReplicationModeStandalone = "standalone"
|
||||
ReplicationModePrimary = "primary"
|
||||
ReplicationModeReplica = "replica"
|
||||
ReplicationModePrimary = "primary"
|
||||
ReplicationModeReplica = "replica"
|
||||
)
|
||||
|
||||
// ReplicationNodeInfo contains information about a node in the replication topology
|
||||
|
@ -48,11 +48,11 @@ func (m *Manager) BeginTransaction(readOnly bool) (Transaction, error) {
|
||||
|
||||
// Create a new transaction
|
||||
tx := &TransactionImpl{
|
||||
storage: m.storage,
|
||||
mode: mode,
|
||||
buffer: NewBuffer(),
|
||||
rwLock: &m.txLock,
|
||||
stats: m,
|
||||
storage: m.storage,
|
||||
mode: mode,
|
||||
buffer: NewBuffer(),
|
||||
rwLock: &m.txLock,
|
||||
stats: m,
|
||||
}
|
||||
|
||||
// Set transaction as active
|
||||
|
@ -17,11 +17,11 @@ func TestTransactionBasicOperations(t *testing.T) {
|
||||
|
||||
// Create a transaction
|
||||
tx := &TransactionImpl{
|
||||
storage: storage,
|
||||
mode: ReadWrite,
|
||||
buffer: NewBuffer(),
|
||||
rwLock: rwLock,
|
||||
stats: statsCollector,
|
||||
storage: storage,
|
||||
mode: ReadWrite,
|
||||
buffer: NewBuffer(),
|
||||
rwLock: rwLock,
|
||||
stats: statsCollector,
|
||||
}
|
||||
tx.active.Store(true)
|
||||
|
||||
@ -148,11 +148,11 @@ func TestReadOnlyTransactionOperations(t *testing.T) {
|
||||
|
||||
// Create a read-only transaction
|
||||
tx := &TransactionImpl{
|
||||
storage: storage,
|
||||
mode: ReadOnly,
|
||||
buffer: NewBuffer(),
|
||||
rwLock: rwLock,
|
||||
stats: statsCollector,
|
||||
storage: storage,
|
||||
mode: ReadOnly,
|
||||
buffer: NewBuffer(),
|
||||
rwLock: rwLock,
|
||||
stats: statsCollector,
|
||||
}
|
||||
tx.active.Store(true)
|
||||
|
||||
@ -209,11 +209,11 @@ func TestTransactionRollback(t *testing.T) {
|
||||
|
||||
// Create a transaction
|
||||
tx := &TransactionImpl{
|
||||
storage: storage,
|
||||
mode: ReadWrite,
|
||||
buffer: NewBuffer(),
|
||||
rwLock: rwLock,
|
||||
stats: statsCollector,
|
||||
storage: storage,
|
||||
mode: ReadWrite,
|
||||
buffer: NewBuffer(),
|
||||
rwLock: rwLock,
|
||||
stats: statsCollector,
|
||||
}
|
||||
tx.active.Store(true)
|
||||
|
||||
@ -271,11 +271,11 @@ func TestTransactionIterators(t *testing.T) {
|
||||
|
||||
// Create a transaction
|
||||
tx := &TransactionImpl{
|
||||
storage: storage,
|
||||
mode: ReadWrite,
|
||||
buffer: NewBuffer(),
|
||||
rwLock: rwLock,
|
||||
stats: statsCollector,
|
||||
storage: storage,
|
||||
mode: ReadWrite,
|
||||
buffer: NewBuffer(),
|
||||
rwLock: rwLock,
|
||||
stats: statsCollector,
|
||||
}
|
||||
tx.active.Store(true)
|
||||
|
||||
|
@ -453,7 +453,7 @@ func (w *WAL) AppendExactBytes(rawBytes []byte, seqNum uint64) (uint64, error) {
|
||||
|
||||
// Extract payload size to validate record integrity
|
||||
payloadSize := int(binary.LittleEndian.Uint16(rawBytes[4:6]))
|
||||
if len(rawBytes) != HeaderSize + payloadSize {
|
||||
if len(rawBytes) != HeaderSize+payloadSize {
|
||||
return 0, fmt.Errorf("raw WAL record size mismatch: header says %d payload bytes, but got %d total bytes",
|
||||
payloadSize, len(rawBytes))
|
||||
}
|
||||
|
@ -596,9 +596,9 @@ func TestAppendWithSequence(t *testing.T) {
|
||||
|
||||
// Write entries with specific sequence numbers
|
||||
testCases := []struct {
|
||||
key string
|
||||
value string
|
||||
seqNum uint64
|
||||
key string
|
||||
value string
|
||||
seqNum uint64
|
||||
entryType uint8
|
||||
}{
|
||||
{"key1", "value1", 100, OpTypePut},
|
||||
@ -793,21 +793,21 @@ func TestAppendBatchWithSequence(t *testing.T) {
|
||||
t.Errorf("Expected %d operations, got %d", len(entries), len(batch.Operations))
|
||||
}
|
||||
|
||||
// Verify batch operations
|
||||
for i, op := range batch.Operations {
|
||||
if i < len(entries) {
|
||||
expected := entries[i]
|
||||
if op.Type != expected.Type {
|
||||
t.Errorf("Operation %d: expected type %d, got %d", i, expected.Type, op.Type)
|
||||
}
|
||||
if string(op.Key) != string(expected.Key) {
|
||||
t.Errorf("Operation %d: expected key %q, got %q", i, string(expected.Key), string(op.Key))
|
||||
}
|
||||
if expected.Type != OpTypeDelete && string(op.Value) != string(expected.Value) {
|
||||
t.Errorf("Operation %d: expected value %q, got %q", i, string(expected.Value), string(op.Value))
|
||||
}
|
||||
}
|
||||
}
|
||||
// Verify batch operations
|
||||
for i, op := range batch.Operations {
|
||||
if i < len(entries) {
|
||||
expected := entries[i]
|
||||
if op.Type != expected.Type {
|
||||
t.Errorf("Operation %d: expected type %d, got %d", i, expected.Type, op.Type)
|
||||
}
|
||||
if string(op.Key) != string(expected.Key) {
|
||||
t.Errorf("Operation %d: expected key %q, got %q", i, string(expected.Key), string(op.Key))
|
||||
}
|
||||
if expected.Type != OpTypeDelete && string(op.Value) != string(expected.Value) {
|
||||
t.Errorf("Operation %d: expected value %q, got %q", i, string(expected.Value), string(op.Value))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
t.Errorf("Failed to decode batch: %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user