mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
command: read the compacted volume's version from its super block in tests
Compaction can write a different needle version than the source volume, so parse the .cpd with the version it records instead of the current one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c3b7c27f70
commit
59a7633115
1 file changed
+7
-3
@@ -34,17 +34,21 @@ func compactedKeys(t *testing.T, base string) (indexed, intact []uint64) {
|
||||
}
|
||||
dat := backend.NewDiskFile(datFile)
|
||||
defer dat.Close()
|
||||
sb, err := super_block.ReadSuperBlock(dat)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
idxFile, err := os.Open(base + ".cpx")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer idxFile.Close()
|
||||
listed := int64(super_block.SuperBlockSize)
|
||||
listed := int64(sb.BlockSize())
|
||||
if err := idx.WalkIndexFile(idxFile, 0, func(key types.NeedleId, offset types.Offset, size types.Size) error {
|
||||
indexed = append(indexed, uint64(key))
|
||||
listed += needle.GetActualSize(size, needle.GetCurrentVersion())
|
||||
listed += needle.GetActualSize(size, sb.Version)
|
||||
n := new(needle.Needle)
|
||||
if n.ReadData(dat, offset.ToActualOffset(), size, needle.GetCurrentVersion()) == nil && bytes.Equal(n.Data, bytes.Repeat([]byte{byte(key)}, 1000*int(key))) {
|
||||
if n.ReadData(dat, offset.ToActualOffset(), size, sb.Version) == nil && bytes.Equal(n.Data, bytes.Repeat([]byte{byte(key)}, 1000*int(key))) {
|
||||
intact = append(intact, uint64(key))
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in new issue
Block a user