mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
test: v1.0.1 keeps the v1.0.0 on-disk encodings (golden guard)
Layout: fixtures for HEAD (unclaimed; live with two snapshots, metadata
and a dependent; with an open snap session; detached; deleting; a
tombstone), VOLUME, a root and its segment, written once by a fixed-input
generator on the v1.0.0 tag checkout (25a3b755). Today's encoders must
produce those bytes, decode then encode must return them, and each
fixture's git blob hash must be the one written on the tag.
Storage: the v1.0.0 vectors in testdata/format_v3 gain the single-block
write record (generated on the tag), checked by encode and by the
scanner's decode; every format_v3 file's git blob hash is checked against
the tag's. A failing guard is fixed by restoring the encoder or by the
version-bump-and-refusal path, never by rewriting a fixture.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5d6c0883e9
commit
2eed189ba0
14 files changed
+423
No files matched your search
@@ -0,0 +1,231 @@
|
||||
package layout
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// The v1.0.0 layout encodings: HEAD (in each state it is written in),
|
||||
// VOLUME, segment and root, from fixed inputs. The fixtures in
|
||||
// testdata/golden-v1.0.0 were written by this generator on the v1.0.0 tag
|
||||
// checkout (see the README there) and are never regenerated on main.
|
||||
|
||||
const goldenDir = "testdata/golden-v1.0.0"
|
||||
|
||||
// goldenFixMessage is the failure text of every golden check.
|
||||
const goldenFixMessage = "the on-disk encoding changed from v1.0.0. Fix it by restoring the encoder, or by the format path (a version bump, and a refusal of the old format first); never by rewriting the fixture"
|
||||
|
||||
func goldenID(b byte) VolumeID {
|
||||
var id VolumeID
|
||||
for i := range id {
|
||||
id[i] = b + byte(i)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// goldenLayout builds every fixture from fixed inputs.
|
||||
func goldenLayout(t *testing.T) map[string][]byte {
|
||||
t.Helper()
|
||||
src, tgt := goldenID(0x10), goldenID(0x40)
|
||||
out := map[string][]byte{}
|
||||
put := func(name string, b []byte, err error) {
|
||||
t.Helper()
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", name, err)
|
||||
}
|
||||
out[name] = b
|
||||
}
|
||||
ch1 := NameChunk(1, bytes.Repeat([]byte{0x5a}, 4096))
|
||||
ch7 := NameChunk(7, bytes.Repeat([]byte{0xa7}, 4096))
|
||||
manifest := map[uint64]Ref{
|
||||
1: {Owner: "src", OwnerID: src, Chunk: ch1},
|
||||
7: {Owner: "src", OwnerID: src, Chunk: ch7},
|
||||
}
|
||||
root, segs, err := Build(manifest)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rn, rb, err := NameRoot(root)
|
||||
put("root.bin", rb, err)
|
||||
names := make([]SegName, 0, len(segs))
|
||||
for n := range segs {
|
||||
names = append(names, n)
|
||||
}
|
||||
sort.Slice(names, func(a, b int) bool { return names[a].Shard < names[b].Shard })
|
||||
for i, n := range names {
|
||||
out["segment-"+string(rune('0'+i))+".bin"] = segs[n]
|
||||
}
|
||||
vol, err := (Volume{ID: src, Name: "src", Format: VolumeFormat, Geometry: Geometry{SizeBytes: 64 * 4096, BlockSize: 4096, ChunkBytes: 4 * 4096}}).Encode()
|
||||
put("volume.bin", vol, err)
|
||||
|
||||
unclaimed, err := Unclaimed(src, nil).Encode()
|
||||
put("head-unclaimed.bin", unclaimed, err)
|
||||
live := Head{
|
||||
VolumeID: src, Epoch: 3, Holder: "node-a/r1", ClaimID: "claim-1",
|
||||
Activity: Activity{Kind: ActIdle}, Current: &rn, Position: 42, State: StateLive,
|
||||
Snapshots: map[string]Snapshot{
|
||||
"daily": {Root: rn, Position: 40, Meta: SnapshotMeta{CreatedNs: 1795800000000000000, Class: ClassScheduled, Labels: map[string]string{"k": "v"}},
|
||||
Dependents: []Dependent{{Target: "tgt", TargetID: tgt, Root: rn}}},
|
||||
"keep": {Root: rn, Position: 41, Meta: SnapshotMeta{CreatedNs: 1795800001000000000, Class: ClassPinned, ExpiresNs: 1795900000000000000}},
|
||||
},
|
||||
}
|
||||
b, err := live.Encode()
|
||||
put("head-live-snapshots.bin", b, err)
|
||||
snap := live
|
||||
snap.Activity = Activity{Kind: ActSnap, Session: "s-0001"}
|
||||
b, err = snap.Encode()
|
||||
put("head-snap-session.bin", b, err)
|
||||
detached := live
|
||||
detached.State = StateDetached
|
||||
b, err = detached.Encode()
|
||||
put("head-detached.bin", b, err)
|
||||
deleting := live
|
||||
deleting.Snapshots = nil
|
||||
deleting.State = StateDeleting
|
||||
b, err = deleting.Encode()
|
||||
put("head-deleting.bin", b, err)
|
||||
tomb := Head{VolumeID: tgt, Activity: Activity{Kind: ActIdle}, State: StateDeleted}
|
||||
b, err = tomb.Encode()
|
||||
put("head-tombstone.bin", b, err)
|
||||
return out
|
||||
}
|
||||
|
||||
// TestWriteGoldenV100 writes the fixtures when SW_GOLDEN_WRITE names a
|
||||
// directory. It is run once, on the v1.0.0 tag checkout; on main it is a
|
||||
// no-op.
|
||||
func TestWriteGoldenV100(t *testing.T) {
|
||||
dir := os.Getenv("SW_GOLDEN_WRITE")
|
||||
if dir == "" {
|
||||
t.Skip("set SW_GOLDEN_WRITE on the v1.0.0 tag checkout to write the fixtures")
|
||||
}
|
||||
for name, b := range goldenLayout(t) {
|
||||
if err := os.WriteFile(filepath.Join(dir, name), b, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func readGolden(t *testing.T, name string) []byte {
|
||||
t.Helper()
|
||||
b, err := os.ReadFile(filepath.Join(goldenDir, name))
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", name, err)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Today's encoders produce the v1.0.0 bytes from the same inputs, and the
|
||||
// fixture set is exactly the generator's.
|
||||
func TestLayoutEncodingsAreTheV100Bytes(t *testing.T) {
|
||||
got := goldenLayout(t)
|
||||
entries, err := os.ReadDir(goldenDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
files := map[string]bool{}
|
||||
for _, e := range entries {
|
||||
if filepath.Ext(e.Name()) == ".bin" {
|
||||
files[e.Name()] = true
|
||||
}
|
||||
}
|
||||
for name := range got {
|
||||
if !files[name] {
|
||||
t.Errorf("%s: no v1.0.0 fixture (the generator gained an output; a new kind needs a fixture from the tag)", name)
|
||||
}
|
||||
}
|
||||
for name := range files {
|
||||
b, ok := got[name]
|
||||
if !ok {
|
||||
t.Errorf("%s: a v1.0.0 fixture the generator no longer produces", name)
|
||||
continue
|
||||
}
|
||||
if want := readGolden(t, name); !bytes.Equal(b, want) {
|
||||
t.Errorf("%s: %s\n got %s\n want %s", name, goldenFixMessage, hex.EncodeToString(b), hex.EncodeToString(want))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// goldenAtV100 is each fixture's git blob hash as written on the v1.0.0
|
||||
// tag checkout. A fixture edit fails here, so it cannot hide a format change.
|
||||
var goldenAtV100 = map[string]string{
|
||||
"head-deleting.bin": "d790a67071549b07bff1f3dd56c16eda5fa26d57",
|
||||
"head-detached.bin": "00e72a4222045c64a4b640f75b89bb4e01a6102f",
|
||||
"head-live-snapshots.bin": "c70763ccaf1d363461ed9f4d089305cd4c431ce0",
|
||||
"head-snap-session.bin": "1cf9c307780e61fc5c6d5d8638d3d84db318f887",
|
||||
"head-tombstone.bin": "b0edd6abf0ab54fa6e73697190bae09b57ea1db5",
|
||||
"head-unclaimed.bin": "f519aadbfb53a928bc44b17a2c78a1115fcbb927",
|
||||
"root.bin": "690c5464e34b2ec14f7a3675d29bff4fa973822b",
|
||||
"segment-0.bin": "d8e126128b9dba2db149b4bb4ccec69f466597a3",
|
||||
"volume.bin": "315104ffb82768de219a93ecd4a1ac23597d19d2",
|
||||
}
|
||||
|
||||
// The layout fixtures are the bytes written on the v1.0.0 tag.
|
||||
func TestLayoutGoldenFixturesAreTheV100Files(t *testing.T) {
|
||||
for name, want := range goldenAtV100 {
|
||||
b := readGolden(t, name)
|
||||
h := sha1.New()
|
||||
fmt.Fprintf(h, "blob %d\x00", len(b))
|
||||
h.Write(b)
|
||||
if got := hex.EncodeToString(h.Sum(nil)); got != want {
|
||||
t.Errorf("%s: blob %s, written on v1.0.0 as %s: %s", name, got, want, goldenFixMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Every v1.0.0 fixture decodes, and encodes again to the same bytes.
|
||||
func TestLayoutV100FixturesRoundTrip(t *testing.T) {
|
||||
check := func(name string, again []byte, err error) {
|
||||
t.Helper()
|
||||
if err != nil {
|
||||
t.Errorf("%s: decode/encode: %v: %s", name, err, goldenFixMessage)
|
||||
return
|
||||
}
|
||||
if want := readGolden(t, name); !bytes.Equal(again, want) {
|
||||
t.Errorf("%s: decode then encode differs: %s", name, goldenFixMessage)
|
||||
}
|
||||
}
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
vol VolumeID
|
||||
}{
|
||||
{"head-unclaimed.bin", goldenID(0x10)}, {"head-live-snapshots.bin", goldenID(0x10)}, {"head-snap-session.bin", goldenID(0x10)},
|
||||
{"head-detached.bin", goldenID(0x10)}, {"head-deleting.bin", goldenID(0x10)}, {"head-tombstone.bin", goldenID(0x40)},
|
||||
} {
|
||||
h, err := DecodeHead(readGolden(t, c.name), 5, c.vol)
|
||||
if err != nil {
|
||||
check(c.name, nil, err)
|
||||
continue
|
||||
}
|
||||
b, err := h.Encode()
|
||||
check(c.name, b, err)
|
||||
}
|
||||
v, err := DecodeVolume(readGolden(t, "volume.bin"))
|
||||
if err == nil {
|
||||
b, e := v.Encode()
|
||||
check("volume.bin", b, e)
|
||||
} else {
|
||||
check("volume.bin", nil, err)
|
||||
}
|
||||
r, err := DecodeRoot(readGolden(t, "root.bin"))
|
||||
if err == nil {
|
||||
b, e := r.Encode()
|
||||
check("root.bin", b, e)
|
||||
} else {
|
||||
check("root.bin", nil, err)
|
||||
}
|
||||
for _, name := range []string{"segment-0.bin"} {
|
||||
s, err := DecodeSegment(readGolden(t, name))
|
||||
if err == nil {
|
||||
b, e := s.Encode()
|
||||
check(name, b, e)
|
||||
} else {
|
||||
check(name, nil, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
*.bin -text
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
# v1.0.0 layout encodings
|
||||
|
||||
Generated once by `TestWriteGoldenV100` (`golden_v100_test.go`), run with `SW_GOLDEN_WRITE` on a checkout of the tag **v1.0.0**, commit **bef007fddf341944faa2eb0ed36e1b3aefda96e8**. The inputs are fixed: volume ids, chunk payloads, snapshot metadata. They are never regenerated on main.
|
||||
|
||||
| file | what |
|
||||
|---|---|
|
||||
| head-unclaimed.bin | a new volume's HEAD |
|
||||
| head-live-snapshots.bin | a claimed live HEAD with a current root, two snapshots (scheduled with labels and a dependent; pinned with an expiry) |
|
||||
| head-snap-session.bin | the same HEAD with an open snap session |
|
||||
| head-detached.bin | the same HEAD, detached |
|
||||
| head-deleting.bin | the HEAD of a volume being deleted |
|
||||
| head-tombstone.bin | a restore target's tombstone (deleted, idle) |
|
||||
| volume.bin | a VOLUME record |
|
||||
| root.bin, segment-0.bin | the root and segment of a two-chunk image |
|
||||
|
||||
`TestLayoutEncodingsAreTheV100Bytes` checks today's encoders against these bytes. `TestLayoutV100FixturesRoundTrip` checks that decode then encode returns them. `TestLayoutGoldenFixturesAreTheV100Files` checks their git blob hashes, so editing a fixture fails too. A failing check is fixed by restoring the encoder, or by the format path (a version bump, and a refusal of the old format first), never by rewriting a fixture.
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"volume_id":"101112131415161718191a1b1c1d1e1f","epoch":3,"holder":"node-a/r1","claim_id":"claim-1","activity":{"kind":"idle"},"current":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c","position":42,"state":"deleting"}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"volume_id":"101112131415161718191a1b1c1d1e1f","epoch":3,"holder":"node-a/r1","claim_id":"claim-1","activity":{"kind":"idle"},"current":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c","position":42,"snapshots":{"daily":{"root":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c","position":40,"created_ns":1795800000000000000,"class":"scheduled","labels":{"k":"v"},"dependents":[{"target":"tgt","target_id":"404142434445464748494a4b4c4d4e4f","root":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c"}]},"keep":{"root":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c","position":41,"created_ns":1795800001000000000,"class":"pinned","expires_ns":1795900000000000000}},"state":"detached"}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"volume_id":"101112131415161718191a1b1c1d1e1f","epoch":3,"holder":"node-a/r1","claim_id":"claim-1","activity":{"kind":"idle"},"current":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c","position":42,"snapshots":{"daily":{"root":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c","position":40,"created_ns":1795800000000000000,"class":"scheduled","labels":{"k":"v"},"dependents":[{"target":"tgt","target_id":"404142434445464748494a4b4c4d4e4f","root":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c"}]},"keep":{"root":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c","position":41,"created_ns":1795800001000000000,"class":"pinned","expires_ns":1795900000000000000}}}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"volume_id":"101112131415161718191a1b1c1d1e1f","epoch":3,"holder":"node-a/r1","claim_id":"claim-1","activity":{"kind":"snap","session":"s-0001"},"current":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c","position":42,"snapshots":{"daily":{"root":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c","position":40,"created_ns":1795800000000000000,"class":"scheduled","labels":{"k":"v"},"dependents":[{"target":"tgt","target_id":"404142434445464748494a4b4c4d4e4f","root":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c"}]},"keep":{"root":"0cf567cebed76e9cf29e201021bd84f9259f56954d659e28d67c6a0086d3a33c","position":41,"created_ns":1795800001000000000,"class":"pinned","expires_ns":1795900000000000000}}}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"volume_id":"404142434445464748494a4b4c4d4e4f","epoch":0,"holder":"","activity":{"kind":"idle"},"position":0,"state":"deleted"}
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"volume_id":"101112131415161718191a1b1c1d1e1f","epoch":0,"holder":"","activity":{"kind":"idle"},"position":0}
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+1
@@ -0,0 +1 @@
|
||||
{"size_bytes":262144,"block_size":4096,"chunk_bytes":16384,"id":"101112131415161718191a1b1c1d1e1f","name":"src","format":1}
|
||||
@@ -0,0 +1,168 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// goldenFixMessage is the failure text of every golden check.
|
||||
const goldenFixMessage = "the on-disk encoding changed from v1.0.0. Fix it by restoring the encoder, or by the format path (a version bump, and a refusal of the old format first); never by rewriting the fixture"
|
||||
|
||||
// goldenWriteRecord is the single-block write record of the v1.0.0 format:
|
||||
// the batch vector's header fields (LSN 7, DurableLSN 6, cursor 128, the
|
||||
// barrier nonce) with one block of 0x71 at LBA 3.
|
||||
func goldenWriteRecord() walEntryV3 {
|
||||
e := v3TestBarrier()
|
||||
e.Type = walEntryWrite
|
||||
e.LBA = 3
|
||||
e.Length = v3TestBlockSize
|
||||
e.Data = bytes.Repeat([]byte{0x71}, int(v3TestBlockSize))
|
||||
return e
|
||||
}
|
||||
|
||||
// TestWriteGoldenV100Write writes write.bin when SW_GOLDEN_WRITE names a
|
||||
// directory. It is run once, on the v1.0.0 tag checkout; on main it is a
|
||||
// no-op.
|
||||
func TestWriteGoldenV100Write(t *testing.T) {
|
||||
dir := os.Getenv("SW_GOLDEN_WRITE")
|
||||
if dir == "" {
|
||||
t.Skip("set SW_GOLDEN_WRITE on the v1.0.0 tag checkout to write the fixture")
|
||||
}
|
||||
b, err := encodeWALEntryV3(goldenWriteRecord(), v3TestBlockSize, v3TestNumBlocks)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(dir, "write.bin"), b, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// The single-block write record encodes to the v1.0.0 bytes, and the
|
||||
// scanner's decode of those bytes is the same record (the decode replay
|
||||
// reads it through).
|
||||
func TestWALEntryV3_WriteRecordIsTheV100Bytes(t *testing.T) {
|
||||
want, err := os.ReadFile("testdata/format_v3/write.bin")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
e := goldenWriteRecord()
|
||||
got, err := encodeWALEntryV3(e, v3TestBlockSize, v3TestNumBlocks)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !bytes.Equal(got, want) {
|
||||
t.Fatalf("write record: %s", goldenFixMessage)
|
||||
}
|
||||
decoded, err := decodeWALEntryV3(want, v3TestBlockSize, v3TestNumBlocks)
|
||||
if err != nil {
|
||||
t.Fatalf("write record: decode: %v: %s", err, goldenFixMessage)
|
||||
}
|
||||
if !reflect.DeepEqual(decoded, e) {
|
||||
t.Fatalf("write record: decoded %+v: %s", decoded, goldenFixMessage)
|
||||
}
|
||||
}
|
||||
|
||||
// gitBlobHash is git's object id of a file's content.
|
||||
func gitBlobHash(b []byte) string {
|
||||
h := sha1.New()
|
||||
fmt.Fprintf(h, "blob %d\x00", len(b))
|
||||
h.Write(b)
|
||||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
// formatV3AtV100 is every file of testdata/format_v3 as the v1.0.0 tag
|
||||
// (bef007fd) holds it (git ls-tree), plus write.bin, generated on that tag
|
||||
// checkout. A fixture edit fails here, so it cannot hide a format change.
|
||||
var formatV3AtV100 = map[string]string{
|
||||
"README.md": "b035e86b4e4cb477aa7e0f92e355e2e3c23462b8",
|
||||
"additional-vectors.json": "c8399b6697ff837cee3139074e77b20aa1e2af3a",
|
||||
"barrier.bin": "c28d4e1ad88c88ad004811da8fc605fb5ac26abc",
|
||||
"barrier.json": "14fb93c55eba2b08f7578b387c38d9a05c52da58",
|
||||
"batch.bin": "6ba0b912316e7e4fa6ba86d09547c12e82d273fd",
|
||||
"reference-page.bin": "86e42ad3b9d80e330ca1fbcf35a3bb08445a9ac4",
|
||||
"reference-root.bin": "7dbe8217883fde48395c371e9995238a5d9d5c3f",
|
||||
"slot/EXPECTED.txt": "4c79c1f2b1c4358036b8061cb1465384b9874b46",
|
||||
"slot/gen_slot_vectors.py": "8e2ce8bf304c55e59bfb9b11127201aa77047b30",
|
||||
"slot/neg-basestate3.bin": "aeed5ce12a88409ac9422858df494b11694e97bd",
|
||||
"slot/neg-coverage.bin": "2608670e6a624835c6ec2843e2193eff680228b6",
|
||||
"slot/neg-covered-mismatch.bin": "bfc6c608267b2df9c7b0df77714c51f6b92ee83d",
|
||||
"slot/neg-crc.bin": "4a01efe656d0b87752597fc087ff433843d055bd",
|
||||
"slot/neg-flags.bin": "3b4ddbb90c6ce6c788271cd7f045a89c82e8da92",
|
||||
"slot/neg-gen0.bin": "fe57b5f9c82be63a8b742435d3ed511571d45c40",
|
||||
"slot/neg-head.bin": "2df8c031ba9474e2375dc9953c071de7aaaec97c",
|
||||
"slot/neg-implv1.bin": "7c5f421af09e2c29e475463bc2300eedfed4977e",
|
||||
"slot/neg-installing-zero-id.bin": "b36c5af7275e1a12f3026a775e4ba6a4bec8cb1f",
|
||||
"slot/neg-nonce0.bin": "88ec10278c1c1b630428594e831bad47e0cd1435",
|
||||
"slot/neg-none-with-id.bin": "d84777ced167347b1a59d5b0a01af18787c91b0a",
|
||||
"slot/neg-phase1-gen2.bin": "c85f59a49c30562d80f22a9b8640c89aaa9353c5",
|
||||
"slot/neg-phase1-installing.bin": "929cad5799ed82f3aec837d616a21febc39548a1",
|
||||
"slot/neg-phase2.bin": "679becc9a81fc07a61d0572823bcb80ec920e63a",
|
||||
"slot/neg-reserved-306.bin": "431d25de00ec69a739f58ec97e1bcad2cf878f69",
|
||||
"slot/neg-reserved-320.bin": "a58b0a712d496cac2994e98a48731d942ecd975b",
|
||||
"slot/neg-reserved-88.bin": "9415239f92f1c503936fffd4e3742c6af79ceef4",
|
||||
"slot/neg-walofs.bin": "7065b81d2ffbdabe4305b798b200eb6185d34bf8",
|
||||
"slot/neg-wmode2.bin": "2f8f3bb688cdeec791d85099248ce642f8b8bf10",
|
||||
"slot/pair-equal-gen-A.bin": "e30403d5531b8c8191968d3b7806c29c4f1dca08",
|
||||
"slot/pair-equal-gen-B.bin": "cceffb0c0bd13eb13a9143b86b0e6b40eaa237c3",
|
||||
"slot/slot-installing.bin": "b8d748a6bf7e21190fa765d3955291ab7072288e",
|
||||
"slot/slot-prepared.bin": "1d97c60a36430d6eee934206d172835b51b52ab0",
|
||||
"slot/slot-ref.bin": "de0e54a73d0735d91d648a538386b2e1af1564bd",
|
||||
"slot/slot-strict.bin": "2e0e805b91bcb23d74a2f4d07b0518b74751f604",
|
||||
"trim.bin": "c662538d82a4b075a295db9d5d3bd34315fd9265",
|
||||
"write.bin": "1d64f4c41851e7606f45b9846355cf7f3c18fb84",
|
||||
}
|
||||
|
||||
// The format_v3 fixtures are byte-identical to the v1.0.0 tag's.
|
||||
func TestFormatV3FixturesAreTheV100Files(t *testing.T) {
|
||||
entries, err := os.ReadDir("testdata/format_v3")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
var names []string
|
||||
for _, e := range entries {
|
||||
if e.IsDir() {
|
||||
sub, err := os.ReadDir(filepath.Join("testdata/format_v3", e.Name()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, s := range sub {
|
||||
names = append(names, e.Name()+"/"+s.Name())
|
||||
}
|
||||
continue
|
||||
}
|
||||
names = append(names, e.Name())
|
||||
}
|
||||
sort.Strings(names)
|
||||
for _, name := range names {
|
||||
seen[name] = true
|
||||
b, err := os.ReadFile(filepath.Join("testdata/format_v3", filepath.FromSlash(name)))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if filepath.Ext(name) != ".bin" {
|
||||
// A text fixture is checked out with the platform's line endings;
|
||||
// git hashes it with LF.
|
||||
b = bytes.ReplaceAll(b, []byte("\r\n"), []byte("\n"))
|
||||
}
|
||||
want, ok := formatV3AtV100[name]
|
||||
switch {
|
||||
case !ok:
|
||||
t.Errorf("%s: not a v1.0.0 fixture (a new vector needs generating on the v1.0.0 tag and its hash here)", name)
|
||||
case gitBlobHash(b) != want:
|
||||
t.Errorf("%s: blob %s, v1.0.0 has %s: %s", name, gitBlobHash(b), want, goldenFixMessage)
|
||||
}
|
||||
}
|
||||
for name := range formatV3AtV100 {
|
||||
if !seen[name] {
|
||||
t.Errorf("%s: a v1.0.0 fixture is missing", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in new issue
Block a user