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.
104 lines
3.3 KiB
Go
104 lines
3.3 KiB
Go
package iceberg
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/apache/iceberg-go/table"
|
|
"github.com/seaweedfs/seaweedfs/weed/s3api/s3tables"
|
|
)
|
|
|
|
func TestParseCommitUpdatesSeparatesStatistics(t *testing.T) {
|
|
raw := []json.RawMessage{
|
|
json.RawMessage(`{"action":"set-statistics","snapshot-id":10,"statistics-path":"s3://bucket/table/metadata/stats.puffin","file-size-in-bytes":100,"file-footer-size-in-bytes":20,"blob-metadata":[]}`),
|
|
json.RawMessage(`{"action":"set-properties","updates":{"k":"v"}}`),
|
|
}
|
|
|
|
updates, stats, err := parseCommitUpdates(raw)
|
|
if err != nil {
|
|
t.Fatalf("parseCommitUpdates() error = %v", err)
|
|
}
|
|
if len(stats) != 1 {
|
|
t.Fatalf("statistics updates = %d, want 1", len(stats))
|
|
}
|
|
if stats[0].set == nil || stats[0].set.SnapshotID != 10 {
|
|
t.Fatalf("unexpected statistics update: %#v", stats[0])
|
|
}
|
|
if len(updates) != 1 {
|
|
t.Fatalf("decoded updates = %d, want 1", len(updates))
|
|
}
|
|
}
|
|
|
|
func TestParseCommitUpdatesRejectsIncompleteSetStatistics(t *testing.T) {
|
|
raw := []json.RawMessage{
|
|
json.RawMessage(`{"action":"set-statistics","snapshot-id":10}`),
|
|
}
|
|
|
|
_, _, err := parseCommitUpdates(raw)
|
|
if err == nil {
|
|
t.Fatalf("parseCommitUpdates() expected error")
|
|
}
|
|
if !errors.Is(err, ErrIncompleteSetStatistics) {
|
|
t.Fatalf("parseCommitUpdates() error = %v, want ErrIncompleteSetStatistics", err)
|
|
}
|
|
}
|
|
|
|
func TestApplyStatisticsUpdatesUpsertAndRemove(t *testing.T) {
|
|
metadata := []byte(`{"format-version":2,"statistics":[{"snapshot-id":1,"statistics-path":"s3://bucket/stats-1.puffin","file-size-in-bytes":10,"file-footer-size-in-bytes":1,"blob-metadata":[]},{"snapshot-id":2,"statistics-path":"s3://bucket/stats-2.puffin","file-size-in-bytes":20,"file-footer-size-in-bytes":2,"blob-metadata":[]}]} `)
|
|
|
|
snapshotID := int64(2)
|
|
setUpdates := []statisticsUpdate{
|
|
{
|
|
set: &statisticsFileForTest,
|
|
},
|
|
{
|
|
remove: &snapshotID,
|
|
},
|
|
}
|
|
|
|
updated, err := applyStatisticsUpdates(metadata, setUpdates)
|
|
if err != nil {
|
|
t.Fatalf("applyStatisticsUpdates() error = %v", err)
|
|
}
|
|
|
|
var decoded map[string]json.RawMessage
|
|
if err := json.Unmarshal(updated, &decoded); err != nil {
|
|
t.Fatalf("json.Unmarshal(updated) error = %v", err)
|
|
}
|
|
|
|
var stats []map[string]any
|
|
if err := json.Unmarshal(decoded["statistics"], &stats); err != nil {
|
|
t.Fatalf("json.Unmarshal(statistics) error = %v", err)
|
|
}
|
|
if len(stats) != 1 {
|
|
t.Fatalf("statistics length = %d, want 1", len(stats))
|
|
}
|
|
if got := int64(stats[0]["snapshot-id"].(float64)); got != 1 {
|
|
t.Fatalf("remaining snapshot-id = %d, want 1", got)
|
|
}
|
|
if got := int64(stats[0]["file-size-in-bytes"].(float64)); got != 11 {
|
|
t.Fatalf("remaining file-size-in-bytes = %d, want 11", got)
|
|
}
|
|
}
|
|
|
|
var statisticsFileForTest = table.StatisticsFile{
|
|
SnapshotID: 1,
|
|
StatisticsPath: "s3://bucket/stats-1.puffin",
|
|
FileSizeInBytes: 11,
|
|
FileFooterSizeInBytes: 2,
|
|
BlobMetadata: []table.BlobMetadata{},
|
|
}
|
|
|
|
func TestIsS3TablesConflict(t *testing.T) {
|
|
if !isS3TablesConflict(s3tables.ErrVersionTokenMismatch) {
|
|
t.Fatalf("expected ErrVersionTokenMismatch to be conflict")
|
|
}
|
|
if !isS3TablesConflict(&s3tables.S3TablesError{Type: s3tables.ErrCodeConflict, Message: "Version token mismatch"}) {
|
|
t.Fatalf("expected S3Tables conflict error to be conflict")
|
|
}
|
|
if isS3TablesConflict(errors.New("other")) {
|
|
t.Fatalf("unexpected conflict for non-conflict error")
|
|
}
|
|
}
|