fix(dedup): use deterministic seed in TestChunker_ShiftedData
The test was flaky because it used crypto/rand for random data, causing non-deterministic chunk boundaries. With small sample sizes (100KB / 8KB avg = ~12 chunks), variance was high - sometimes only 42.9% overlap instead of expected >50%. Fixed by using math/rand with seed 42 for reproducible test results. Now consistently achieves 91.7% overlap (11/12 chunks).
This commit is contained in:
@@ -3,9 +3,9 @@
|
|||||||
This directory contains pre-compiled binaries for the DB Backup Tool across multiple platforms and architectures.
|
This directory contains pre-compiled binaries for the DB Backup Tool across multiple platforms and architectures.
|
||||||
|
|
||||||
## Build Information
|
## Build Information
|
||||||
- **Version**: 3.42.49
|
- **Version**: 3.42.50
|
||||||
- **Build Time**: 2026-01-16_14:37:18_UTC
|
- **Build Time**: 2026-01-16_14:53:54_UTC
|
||||||
- **Git Commit**: bfe99e9
|
- **Git Commit**: 5728b46
|
||||||
|
|
||||||
## Recent Updates (v1.1.0)
|
## Recent Updates (v1.1.0)
|
||||||
- ✅ Fixed TUI progress display with line-by-line output
|
- ✅ Fixed TUI progress display with line-by-line output
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"io"
|
"io"
|
||||||
|
mathrand "math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -100,12 +101,15 @@ func TestChunker_Deterministic(t *testing.T) {
|
|||||||
|
|
||||||
func TestChunker_ShiftedData(t *testing.T) {
|
func TestChunker_ShiftedData(t *testing.T) {
|
||||||
// Test that shifted data still shares chunks (the key CDC benefit)
|
// Test that shifted data still shares chunks (the key CDC benefit)
|
||||||
|
// Use deterministic random data for reproducible test results
|
||||||
|
rng := mathrand.New(mathrand.NewSource(42))
|
||||||
|
|
||||||
original := make([]byte, 100*1024)
|
original := make([]byte, 100*1024)
|
||||||
rand.Read(original)
|
rng.Read(original)
|
||||||
|
|
||||||
// Create shifted version (prepend some bytes)
|
// Create shifted version (prepend some bytes)
|
||||||
prefix := make([]byte, 1000)
|
prefix := make([]byte, 1000)
|
||||||
rand.Read(prefix)
|
rng.Read(prefix)
|
||||||
shifted := append(prefix, original...)
|
shifted := append(prefix, original...)
|
||||||
|
|
||||||
// Chunk both
|
// Chunk both
|
||||||
|
|||||||
Reference in New Issue
Block a user