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.
110 lines
3.2 KiB
Go
110 lines
3.2 KiB
Go
package dash
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"reflect"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/worker/tasks/balance"
|
|
"github.com/seaweedfs/seaweedfs/weed/worker/tasks/erasure_coding"
|
|
"github.com/seaweedfs/seaweedfs/weed/worker/tasks/vacuum"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func tomlConfig(t *testing.T, content string) *viper.Viper {
|
|
t.Helper()
|
|
v := viper.New()
|
|
v.SetConfigType("toml")
|
|
if err := v.ReadConfig(strings.NewReader(content)); err != nil {
|
|
t.Fatalf("read toml: %v", err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
func TestApplyMaintenanceConfigFromToml(t *testing.T) {
|
|
dir := t.TempDir()
|
|
cp := NewConfigPersistence(dir)
|
|
|
|
// simulate an earlier UI edit
|
|
saved := vacuum.NewDefaultConfig()
|
|
saved.MaxConcurrent = 5
|
|
saved.GarbageThreshold = 0.5
|
|
if err := cp.SaveVacuumTaskPolicy(saved.ToTaskPolicy()); err != nil {
|
|
t.Fatalf("save vacuum policy: %v", err)
|
|
}
|
|
|
|
balanceBefore := balance.LoadConfigFromPersistence(cp)
|
|
|
|
v := tomlConfig(t, `
|
|
[maintenance.vacuum]
|
|
garbage_threshold = 0.03
|
|
min_volume_age_seconds = 1800
|
|
|
|
[maintenance.erasure_coding]
|
|
enabled = false
|
|
fullness_ratio = 0.8
|
|
preferred_tags = "Fast, ssd"
|
|
`)
|
|
if err := cp.ApplyMaintenanceConfigFromToml(v); err != nil {
|
|
t.Fatalf("apply: %v", err)
|
|
}
|
|
|
|
vacuumConf := vacuum.LoadConfigFromPersistence(cp)
|
|
if vacuumConf.GarbageThreshold != 0.03 {
|
|
t.Errorf("garbage threshold = %v, want 0.03", vacuumConf.GarbageThreshold)
|
|
}
|
|
// sub-hour values round up to a whole hour instead of truncating to 0
|
|
if vacuumConf.MinVolumeAgeSeconds != 3600 {
|
|
t.Errorf("min volume age = %v, want 3600", vacuumConf.MinVolumeAgeSeconds)
|
|
}
|
|
if vacuumConf.MaxConcurrent != 5 {
|
|
t.Errorf("max concurrent = %v, want UI-saved 5 preserved", vacuumConf.MaxConcurrent)
|
|
}
|
|
|
|
ecConf := erasure_coding.LoadConfigFromPersistence(cp)
|
|
if ecConf.Enabled {
|
|
t.Errorf("ec enabled = true, want false")
|
|
}
|
|
if ecConf.FullnessRatio != 0.8 {
|
|
t.Errorf("fullness ratio = %v, want 0.8", ecConf.FullnessRatio)
|
|
}
|
|
if !reflect.DeepEqual(ecConf.PreferredTags, []string{"fast", "ssd"}) {
|
|
t.Errorf("preferred tags = %v, want [fast ssd]", ecConf.PreferredTags)
|
|
}
|
|
if ecConf.QuietForSeconds != 3600 {
|
|
t.Errorf("quiet for = %v, want default 3600 preserved", ecConf.QuietForSeconds)
|
|
}
|
|
|
|
// balance section absent: nothing written
|
|
if _, err := os.Stat(filepath.Join(dir, ConfigSubdir, BalanceTaskConfigFile)); !os.IsNotExist(err) {
|
|
t.Errorf("balance config written without [maintenance.balance] section")
|
|
}
|
|
if got := balance.LoadConfigFromPersistence(cp); !reflect.DeepEqual(got, balanceBefore) {
|
|
t.Errorf("balance config changed without [maintenance.balance] section")
|
|
}
|
|
}
|
|
|
|
func TestApplyMaintenanceConfigFromTomlNoKeys(t *testing.T) {
|
|
dir := t.TempDir()
|
|
cp := NewConfigPersistence(dir)
|
|
if err := cp.ApplyMaintenanceConfigFromToml(viper.New()); err != nil {
|
|
t.Fatalf("apply: %v", err)
|
|
}
|
|
if _, err := os.Stat(filepath.Join(dir, ConfigSubdir)); !os.IsNotExist(err) {
|
|
t.Errorf("conf dir created without any maintenance keys set")
|
|
}
|
|
}
|
|
|
|
func TestApplyMaintenanceConfigFromTomlRequiresDataDir(t *testing.T) {
|
|
cp := NewConfigPersistence("")
|
|
v := tomlConfig(t, `
|
|
[maintenance.vacuum]
|
|
garbage_threshold = 0.03
|
|
`)
|
|
if err := cp.ApplyMaintenanceConfigFromToml(v); err == nil {
|
|
t.Errorf("expected error when maintenance keys are set without a data dir")
|
|
}
|
|
}
|