mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
test: v1.0.0 fixtures for a cleaning HEAD and the store's filer entries
Both generated on the v1.0.0 tag checkout (25a3b755); the nine earlier
layout fixtures regenerate byte-identical there. A HEAD with an open
cleaning session decodes, round-trips, and today's Start over it ends the
cleaning (the same root) or claims it idle (a new claim). entries.json
records one volume's filer entries with their attributes; today's store
writes the same entries and reads them, an unmarked object (v1.0.0 writes
the mark attribute empty) and one with no mark attribute at all as
unmarked.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d094c1bbba
commit
09d6f71254
6 files changed
+95
-5
No files matched your search
@@ -30,7 +30,7 @@ const goldenFixMessage = "the filer entries or their attributes changed from v1.
|
||||
|
||||
// goldenEntriesAtV100 is entries.json's git blob hash as written on the
|
||||
// v1.0.0 tag checkout.
|
||||
const goldenEntriesAtV100 = "ENTRIES_JSON_HASH"
|
||||
const goldenEntriesAtV100 = "84cf8a9781c7526919164ad8fd595fb53094e5d2"
|
||||
|
||||
// goldenEntry is one filer entry, without its times.
|
||||
type goldenEntry struct {
|
||||
@@ -192,8 +192,10 @@ func TestLayoutStoreWritesTheV100Entries(t *testing.T) {
|
||||
}
|
||||
|
||||
// Today's store reads the v1.0.0 entries: the VOLUME, the committed HEAD
|
||||
// with its snapshot, and every object's attributes, the unmarked segment and
|
||||
// root (no mark attribute at all) as unmarked and the chunk with its mark.
|
||||
// with its snapshot, and every object's attributes. v1.0.0 writes the mark
|
||||
// attribute on every object, empty while unmarked: the segment and root read
|
||||
// as unmarked, the chunk with its mark. An object with no mark attribute at
|
||||
// all reads as unmarked too.
|
||||
func TestLayoutStoreReadsTheV100Entries(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
_, es := readGoldenEntries(t)
|
||||
@@ -251,7 +253,7 @@ func TestLayoutStoreReadsTheV100Entries(t *testing.T) {
|
||||
if err != nil || !found || meta.Volume != id || meta.Session != "s-1" {
|
||||
t.Fatalf("object %s: %+v found=%t %v: %s", rel, meta, found, err, goldenFixMessage)
|
||||
}
|
||||
_, hasMark := e.Extended[layoutMark]
|
||||
hasMark := e.Extended[layoutMark] != ""
|
||||
switch {
|
||||
case hasMark && meta.Mark == "m-1":
|
||||
marked++
|
||||
@@ -264,6 +266,17 @@ func TestLayoutStoreReadsTheV100Entries(t *testing.T) {
|
||||
if marked != 1 || unmarked < 2 {
|
||||
t.Fatalf("read %d marked and %d unmarked objects; the fixture has 1 marked and the segment and root unmarked", marked, unmarked)
|
||||
}
|
||||
// The same entries with the mark attribute removed from every unmarked
|
||||
// object read unmarked, not as an error.
|
||||
for p, e := range f.entries {
|
||||
if rel, ok := relOfObject(p); ok && string(e.Extended[layoutMark]) == "" {
|
||||
delete(e.Extended, layoutMark)
|
||||
meta, found, err := s.Stat(ctx, rel)
|
||||
if err != nil || !found || meta.Mark != "" || meta.Session != "s-1" {
|
||||
t.Fatalf("object %s with no mark attribute: %+v found=%t %v", rel, meta, found, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// relOfObject is an object entry's path relative to the volume's directory
|
||||
|
||||
@@ -159,6 +159,7 @@ func TestLayoutEncodingsAreTheV100Bytes(t *testing.T) {
|
||||
// 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-clean-session.bin": "7016a05571254c23794b469e213056c682bb5373",
|
||||
"head-deleting.bin": "d790a67071549b07bff1f3dd56c16eda5fa26d57",
|
||||
"head-detached.bin": "00e72a4222045c64a4b640f75b89bb4e01a6102f",
|
||||
"head-live-snapshots.bin": "c70763ccaf1d363461ed9f4d089305cd4c431ce0",
|
||||
@@ -245,7 +246,7 @@ func TestStartOverAV100CleaningHead(t *testing.T) {
|
||||
line HolderID
|
||||
local LocalRoot
|
||||
}{
|
||||
{"same root restarts", HolderID{Epoch: 3, Holder: "node-a/r1"}, LocalRoot{Geometry: g, ClaimID: "claim-1"}},
|
||||
{"same root restarts", HolderID{Epoch: 3, Holder: "node-a/r1"}, LocalRoot{Geometry: g, ClaimID: "claim-1", Position: 42}},
|
||||
{"a new claim", HolderID{Epoch: 4, Holder: "node-b/r1"}, LocalRoot{Geometry: g, ClaimID: "claim-2", Fresh: true, CanStartFrom: anyStart}},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
||||
+1
@@ -7,6 +7,7 @@ Generated once by `TestWriteGoldenV100` (`golden_v100_test.go`), run with `SW_GO
|
||||
| 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-clean-session.bin | the same HEAD with an open cleaning session (a holder stopped mid-pass); `TestStartOverAV100CleaningHead` attaches over it |
|
||||
| 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) |
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"volume_id":"101112131415161718191a1b1c1d1e1f","epoch":3,"holder":"node-a/r1","claim_id":"claim-1","activity":{"kind":"clean","session":"c-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}}}
|
||||
@@ -0,0 +1,19 @@
|
||||
# v1.0.0 filer entries of the layout store
|
||||
|
||||
`entries.json` was generated once by `TestWriteGoldenV100Entries` (`golden_v100_test.go`), run with `SW_GOLDEN_WRITE` on a checkout of the tag **v1.0.0**, commit **bef007fddf341944faa2eb0ed36e1b3aefda96e8**. It is never regenerated on main.
|
||||
|
||||
The life it records, from fixed inputs:
|
||||
1. create a volume: its VOLUME and its unclaimed HEAD;
|
||||
2. claim it;
|
||||
3. open a snap session and write one chunk, its segment and its root;
|
||||
4. commit, naming the snapshot `daily`;
|
||||
5. mark the chunk for cleaning. The segment and root stay unmarked, with no mark attribute at all.
|
||||
|
||||
Each entry is recorded as its path, its inline content (base64), its chunk file ids and its extended attributes (`swb.layout.kind`, `volume`, `gen`, `session`, `mark`). Times are not recorded.
|
||||
|
||||
The checks:
|
||||
- `TestLayoutStoreWritesTheV100Entries`: today's store writes the same entries and attributes.
|
||||
- `TestLayoutStoreReadsTheV100Entries`: today's store reads the VOLUME, the HEAD and every object's attributes. The unmarked objects read as unmarked, and the chunk carries its mark.
|
||||
- `TestGoldenEntriesAreTheV100File`: the fixture's git blob hash.
|
||||
|
||||
A failing check is fixed by restoring the writer, or by the format path (a version bump, and a refusal of the old format first), never by rewriting the fixture.
|
||||
@@ -0,0 +1,55 @@
|
||||
[
|
||||
{
|
||||
"path": "/blocks/gv-20212223/HEAD",
|
||||
"content": "eyJ2b2x1bWVfaWQiOiIyMDIxMjIyMzI0MjUyNjI3MjgyOTJhMmIyYzJkMmUyZiIsImVwb2NoIjoxLCJob2xkZXIiOiJub2RlLWEvcjEiLCJjbGFpbV9pZCI6ImNsYWltLTEiLCJhY3Rpdml0eSI6eyJraW5kIjoiaWRsZSJ9LCJjdXJyZW50IjoiZDZjYmI4OTc4MTAwYzYwMTE3MWNiM2YyMzMzMTFlMjgwMGQ1Yzg0NWEwZTIyNzYzZTExNGM4YzA0N2Y5MzUxYyIsInBvc2l0aW9uIjoxLCJzbmFwc2hvdHMiOnsiZGFpbHkiOnsicm9vdCI6ImQ2Y2JiODk3ODEwMGM2MDExNzFjYjNmMjMzMzExZTI4MDBkNWM4NDVhMGUyMjc2M2UxMTRjOGMwNDdmOTM1MWMiLCJwb3NpdGlvbiI6MX19fQ==",
|
||||
"extended": {
|
||||
"swb.layout.gen": "4",
|
||||
"swb.layout.kind": "head",
|
||||
"swb.layout.volume": "202122232425262728292a2b2c2d2e2f"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/blocks/gv-20212223/VOLUME",
|
||||
"content": "eyJzaXplX2J5dGVzIjoyNjIxNDQsImJsb2NrX3NpemUiOjQwOTYsImNodW5rX2J5dGVzIjoxNjM4NCwiaWQiOiIyMDIxMjIyMzI0MjUyNjI3MjgyOTJhMmIyYzJkMmUyZiIsIm5hbWUiOiJndiIsImZvcm1hdCI6MX0=",
|
||||
"extended": {
|
||||
"swb.layout.kind": "volume",
|
||||
"swb.layout.volume": "202122232425262728292a2b2c2d2e2f"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/blocks/gv-20212223/pool/0/1-7f7d7f621694cdc133548e9a3eb50d7f1dfdf6abd00bef37d46d18bc7967a433",
|
||||
"chunks": [
|
||||
"3,00000001"
|
||||
],
|
||||
"extended": {
|
||||
"swb.layout.kind": "object",
|
||||
"swb.layout.mark": "m-1",
|
||||
"swb.layout.session": "s-1",
|
||||
"swb.layout.volume": "202122232425262728292a2b2c2d2e2f"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/blocks/gv-20212223/root/d6cbb8978100c601171cb3f233311e2800d5c845a0e22763e114c8c047f9351c",
|
||||
"chunks": [
|
||||
"3,00000003"
|
||||
],
|
||||
"extended": {
|
||||
"swb.layout.kind": "object",
|
||||
"swb.layout.mark": "",
|
||||
"swb.layout.session": "s-1",
|
||||
"swb.layout.volume": "202122232425262728292a2b2c2d2e2f"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "/blocks/gv-20212223/seg/0-467948fd269cc5866b1c6b287a27f9ee76a3c10c5bae0deec3fab60048cdb189",
|
||||
"chunks": [
|
||||
"3,00000002"
|
||||
],
|
||||
"extended": {
|
||||
"swb.layout.kind": "object",
|
||||
"swb.layout.mark": "",
|
||||
"swb.layout.session": "s-1",
|
||||
"swb.layout.volume": "202122232425262728292a2b2c2d2e2f"
|
||||
}
|
||||
}
|
||||
]
|
||||
Reference in new issue
Block a user