mirror of
https://github.com/hanzoai/s3.git
synced 2026-11-02 13:11:24 +00:00
hanzoai/s3 was an AGPL-3.0 MinIO fork whose network-copyleft blocks embedding
and reselling as a managed service. Replace it wholesale with a fork of
SeaweedFS (github.com/seaweedfs/seaweedfs, Apache-2.0, Go) which ships a
built-in S3 gateway + Filer.
- License: AGPL-3.0 -> Apache-2.0 (upstream LICENSE kept verbatim, incl.
"Copyright 2025 Chris Lu"); NOTICE added crediting SeaweedFS. No AGPL/BUSL/
SSPL/GPL or enterprise ("ee") files remain.
- Module: go.mod path set to github.com/hanzoai/s3 with a self-replace
(replace github.com/seaweedfs/seaweedfs => ./) so the ~1800 internal Go files
keep their upstream import paths with zero churn. Internal identifiers and
import paths are intentionally NOT renamed.
- CLI rebrand: the binary is built as `s3` (was `weed`); root usage, per-command
help/usage/flag strings, shell autocomplete program name, and the product name
in CLI output now read "Hanzo S3" / `s3`. Users never see `weed`.
(e.g. `s3 server`, `s3 filer`, `s3 master`, `s3 volume`, `s3 s3`, `s3 mount`.)
- Build: `make` (or `go build -o s3 ./weed`) builds the `s3` binary green;
`cmd/weed-db` and `cmd/weed-sql` also build; `go vet ./weed/command/` clean.
- README/LLM.md rewritten for Hanzo S3; AGENTS.md/CLAUDE.md symlinks preserved.
- Dropped a 33MB prebuilt Mach-O `stress` binary upstream had committed; `.gitignore`
updated to ignore the `s3` build output.
83 lines
2.9 KiB
Go
83 lines
2.9 KiB
Go
package posixlock
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// A mount's tracked locks round-trip through Snapshot back to a fresh owner via
|
|
// Reassert — the owner-restart / ring-change recovery path.
|
|
func TestReassertRebuildsOnFreshOwner(t *testing.T) {
|
|
const sid = uint64(7)
|
|
|
|
// Client mirror: two granted locks on one key, one on another.
|
|
client := NewManager()
|
|
client.Track("a", Range{Start: 0, End: 99, Type: Write, Sid: sid, Owner: 1})
|
|
client.Track("a", Range{Start: 200, End: 299, Type: Read, Sid: sid, Owner: 2})
|
|
client.Track("b", Range{Start: 0, End: maxEnd, Type: Write, Sid: sid, Owner: 1, IsFlock: true})
|
|
|
|
// Fresh owner (post-restart / new ring owner) knows nothing.
|
|
owner := NewManager()
|
|
for key, locks := range client.Snapshot() {
|
|
if c := owner.Reassert(key, sid, locks); c != nil {
|
|
t.Fatalf("unexpected conflict reasserting %s: %+v", key, c)
|
|
}
|
|
}
|
|
|
|
// The owner now reports the same conflicts a foreign session would hit.
|
|
if _, granted := owner.TryLock("a", Range{Start: 50, End: 60, Type: Write, Sid: 99, Owner: 1}); granted {
|
|
t.Fatal("owner should block a foreign write after rebuild")
|
|
}
|
|
if _, granted := owner.TryLock("b", Range{Start: 0, End: 0, Type: Read, Sid: 99, Owner: 1, IsFlock: true}); granted {
|
|
t.Fatal("owner should block a foreign flock read after rebuild")
|
|
}
|
|
}
|
|
|
|
// Re-asserting every tick is idempotent: the owner's view is unchanged.
|
|
func TestReassertIdempotent(t *testing.T) {
|
|
const sid = uint64(1)
|
|
m := NewManager()
|
|
m.TryLock("k", Range{Start: 0, End: 99, Type: Write, Sid: sid, Owner: 1})
|
|
before := append([]Range(nil), m.byKey["k"].locks...)
|
|
|
|
m.Reassert("k", sid, before)
|
|
m.Reassert("k", sid, before)
|
|
|
|
if !reflect.DeepEqual(m.byKey["k"].locks, before) {
|
|
t.Fatalf("reassert not idempotent:\n got %+v\nwant %+v", m.byKey["k"].locks, before)
|
|
}
|
|
}
|
|
|
|
// A lock another session grabbed in the migration window is reported as a
|
|
// conflict and not double-granted.
|
|
func TestReassertReportsConflict(t *testing.T) {
|
|
const mine, other = uint64(1), uint64(2)
|
|
m := NewManager()
|
|
// Another mount took the lock on this (new) owner during the gap.
|
|
m.TryLock("k", Range{Start: 0, End: 99, Type: Write, Sid: other, Owner: 1})
|
|
|
|
conflicts := m.Reassert("k", mine, []Range{{Start: 0, End: 99, Type: Write, Sid: mine, Owner: 1}})
|
|
if len(conflicts) != 1 {
|
|
t.Fatalf("expected 1 conflict, got %d: %+v", len(conflicts), conflicts)
|
|
}
|
|
// The other session keeps the lock; mine was not installed.
|
|
if got := len(m.byKey["k"].locks); got != 1 {
|
|
t.Fatalf("expected only the incumbent lock, got %d", got)
|
|
}
|
|
}
|
|
|
|
// Reassert renews the lease, so a re-asserting mount is not reaped.
|
|
func TestReassertRenewsLease(t *testing.T) {
|
|
const sid = uint64(1)
|
|
m := NewManager()
|
|
m.Renew(sid)
|
|
m.Reassert("k", sid, []Range{{Start: 0, End: 9, Type: Write, Sid: sid, Owner: 1}})
|
|
|
|
if reaped := m.ReapExpired(time.Hour); len(reaped) != 0 {
|
|
t.Fatalf("freshly re-asserted session should not be reaped: %v", reaped)
|
|
}
|
|
}
|
|
|
|
const maxEnd = ^uint64(0)
|