mirror of
https://github.com/hanzoai/s3.git
synced 2026-10-30 14:59:09 +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.
130 lines
4.2 KiB
Go
130 lines
4.2 KiB
Go
package dash
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
|
)
|
|
|
|
func TestBuildExportVolumeDerivedFields(t *testing.T) {
|
|
v := buildExportVolume(&master_pb.VolumeInformationMessage{
|
|
Id: 7,
|
|
Collection: "photos",
|
|
Size: 100,
|
|
DeletedByteCount: 25,
|
|
ReplicaPlacement: 0,
|
|
ModifiedAtSecond: 1700000000,
|
|
}, 1000)
|
|
|
|
if v.GarbageRatio != 0.25 {
|
|
t.Errorf("garbage ratio = %v, want 0.25", v.GarbageRatio)
|
|
}
|
|
if v.FullnessRatio != 0.1 {
|
|
t.Errorf("fullness ratio = %v, want 0.1", v.FullnessRatio)
|
|
}
|
|
if v.ReplicaPlacement != "000" {
|
|
t.Errorf("replica placement = %q, want 000", v.ReplicaPlacement)
|
|
}
|
|
if v.ModifiedAt == "" {
|
|
t.Error("modified_at should be set when modified_at_second > 0")
|
|
}
|
|
}
|
|
|
|
func TestBuildExportDiskFilterAndTotals(t *testing.T) {
|
|
disk := &master_pb.DiskInfo{
|
|
Type: "hdd",
|
|
VolumeCount: 2,
|
|
VolumeInfos: []*master_pb.VolumeInformationMessage{
|
|
{Id: 1, Collection: "keep", Size: 10, FileCount: 3, DeleteCount: 1, DeletedByteCount: 2},
|
|
{Id: 2, Collection: "drop", Size: 99, FileCount: 9},
|
|
},
|
|
EcShardInfos: []*master_pb.VolumeEcShardInformationMessage{
|
|
{Id: 3, Collection: "keep", EcIndexBits: 0b111, ShardSizes: []int64{4, 4, 4}, FileCount: 5},
|
|
{Id: 4, Collection: "drop", EcIndexBits: 0b1, ShardSizes: []int64{7}},
|
|
},
|
|
}
|
|
|
|
var totals VolumeExportTotals
|
|
got := buildExportDisk(disk, "keep", 1000, &totals)
|
|
if got == nil {
|
|
t.Fatal("expected disk with matching records, got nil")
|
|
}
|
|
if len(got.Volumes) != 1 || got.Volumes[0].Id != 1 {
|
|
t.Errorf("expected only volume 1 after filter, got %+v", got.Volumes)
|
|
}
|
|
if len(got.EcShards) != 1 || got.EcShards[0].Id != 3 {
|
|
t.Errorf("expected only ec shard 3 after filter, got %+v", got.EcShards)
|
|
}
|
|
if got.VolumeCount != 2 {
|
|
t.Errorf("disk VolumeCount should stay physical (2), got %d", got.VolumeCount)
|
|
}
|
|
if got.EcShards[0].TotalSize != 12 {
|
|
t.Errorf("ec shard total size = %d, want 12", got.EcShards[0].TotalSize)
|
|
}
|
|
|
|
if totals.VolumeCount != 1 || totals.EcShardCount != 1 {
|
|
t.Errorf("totals counts = vol %d ec %d, want 1/1", totals.VolumeCount, totals.EcShardCount)
|
|
}
|
|
// 10 (volume size) + 12 (kept ec shard sizes).
|
|
if totals.TotalSize != 22 {
|
|
t.Errorf("totals TotalSize = %d, want 22", totals.TotalSize)
|
|
}
|
|
if totals.FileCount != 3 || totals.DeletedFileCount != 1 || totals.DeletedBytes != 2 {
|
|
t.Errorf("totals files = %d del %d delBytes %d, want 3/1/2", totals.FileCount, totals.DeletedFileCount, totals.DeletedBytes)
|
|
}
|
|
}
|
|
|
|
func TestBuildExportDiskPrunesWhenNoMatch(t *testing.T) {
|
|
disk := &master_pb.DiskInfo{
|
|
Type: "hdd",
|
|
VolumeInfos: []*master_pb.VolumeInformationMessage{{Id: 1, Collection: "other"}},
|
|
}
|
|
var totals VolumeExportTotals
|
|
if got := buildExportDisk(disk, "keep", 0, &totals); got != nil {
|
|
t.Errorf("expected nil for disk with no matching records, got %+v", got)
|
|
}
|
|
}
|
|
|
|
func TestFindDuplicateVolumeIdsForExport(t *testing.T) {
|
|
topo := &master_pb.TopologyInfo{
|
|
DataCenterInfos: []*master_pb.DataCenterInfo{{
|
|
RackInfos: []*master_pb.RackInfo{{
|
|
DataNodeInfos: []*master_pb.DataNodeInfo{
|
|
{DiskInfos: map[string]*master_pb.DiskInfo{"hdd": {
|
|
VolumeInfos: []*master_pb.VolumeInformationMessage{
|
|
{Id: 5, Collection: "a"},
|
|
{Id: 7, Collection: "shared"}, // replica below, same collection
|
|
},
|
|
}}},
|
|
{DiskInfos: map[string]*master_pb.DiskInfo{"hdd": {
|
|
VolumeInfos: []*master_pb.VolumeInformationMessage{
|
|
{Id: 5, Collection: "b"}, // 5 now spans a + b -> duplicate
|
|
{Id: 7, Collection: "shared"}, // replica, not a duplicate
|
|
},
|
|
EcShardInfos: []*master_pb.VolumeEcShardInformationMessage{
|
|
{Id: 5, Collection: "c"}, // 5 also as EC in c
|
|
},
|
|
}}},
|
|
},
|
|
}},
|
|
}},
|
|
}
|
|
|
|
dups := findDuplicateVolumeIdsForExport(topo)
|
|
if len(dups) != 1 {
|
|
t.Fatalf("expected exactly 1 duplicate, got %+v", dups)
|
|
}
|
|
if dups[0].VolumeId != 5 {
|
|
t.Errorf("duplicate volume id = %d, want 5", dups[0].VolumeId)
|
|
}
|
|
want := []string{"a", "b", "c"}
|
|
if len(dups[0].Collections) != len(want) {
|
|
t.Fatalf("collections = %v, want %v", dups[0].Collections, want)
|
|
}
|
|
for i := range want {
|
|
if dups[0].Collections[i] != want[i] {
|
|
t.Errorf("collections[%d] = %q, want %q", i, dups[0].Collections[i], want[i])
|
|
}
|
|
}
|
|
}
|