Intermediate rounds skipped a directory when its inode version and its ceph.dir.rctime matched the previous round. In the 10,000-file lab test a round snapshot taken seconds after changes skipped tree/ with about 250 changed files in its subdirectories: the inode version of tree/ changes only with its own entries, and Ceph had not yet propagated the rctime of the grandchildren. The target snapshot of that round was incomplete, and its verification skipped the same subtrees; only finalize closed the gap. Every round now scans all metadata again. Base index entries that the old version marked carried are never trusted, so such files are copied in full in the next round. The smallfiles verification now checks only snapshots that sync did not remove. BREAKING CHANGE: the configuration field "full_scan" and the transfer statistic "skipped_subtrees" are removed; a configuration with "full_scan" is rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package migration
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.zb-server.de/Sebi/CephfsMig/internal/storage"
|
|
)
|
|
|
|
func TestEntryEncodingCarriedAndLegacy(t *testing.T) {
|
|
e := baseEntry{Inode: 1, Version: 2, Size: 3, TargetInode: 4, Carried: true}
|
|
got, ok := decodeEntry(encodeEntry(e))
|
|
if !ok || got != e {
|
|
t.Fatalf("round trip: %+v %v", got, ok)
|
|
}
|
|
|
|
legacy := encodeEntry(baseEntry{Inode: 1, Version: 2, Size: 3, TargetInode: 4})[:32]
|
|
if got, ok := decodeEntry(legacy); !ok || got.Carried || got.TargetInode != 4 {
|
|
t.Fatalf("legacy record: %+v %v", got, ok)
|
|
}
|
|
|
|
for _, bad := range [][]byte{make([]byte, 31), append(make([]byte, 32), 2)} {
|
|
if _, ok := decodeEntry(bad); ok {
|
|
t.Fatalf("accepted %d-byte record", len(bad))
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestBaseTrustRejectsCarriedEntries(t *testing.T) {
|
|
n := storage.Node{Inode: 1, Size: 3}
|
|
target := storage.Node{Inode: 4, Size: 3}
|
|
e := baseEntry{Inode: 1, Version: 2, Size: 3, TargetInode: 4}
|
|
if !baseTrusted(e, n, target) {
|
|
t.Fatal("matching entry not trusted")
|
|
}
|
|
|
|
e.Carried = true
|
|
if baseTrusted(e, n, target) {
|
|
t.Fatal("carried entry trusted")
|
|
}
|
|
|
|
e.Carried = false
|
|
target.Inode = 5
|
|
if baseTrusted(e, n, target) {
|
|
t.Fatal("entry of a replaced target trusted")
|
|
}
|
|
}
|