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.
129 lines
3.3 KiB
Go
129 lines
3.3 KiB
Go
package offset
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/schema_pb"
|
|
)
|
|
|
|
func TestConsumerGroupPosition_JSON(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
position *ConsumerGroupPosition
|
|
}{
|
|
{
|
|
name: "offset-based position",
|
|
position: &ConsumerGroupPosition{
|
|
Type: "offset",
|
|
Value: 12345,
|
|
OffsetType: schema_pb.OffsetType_EXACT_OFFSET.String(),
|
|
CommittedAt: time.Now().UnixMilli(),
|
|
Metadata: "test metadata",
|
|
},
|
|
},
|
|
{
|
|
name: "timestamp-based position",
|
|
position: &ConsumerGroupPosition{
|
|
Type: "timestamp",
|
|
Value: time.Now().UnixNano(),
|
|
OffsetType: schema_pb.OffsetType_EXACT_TS_NS.String(),
|
|
CommittedAt: time.Now().UnixMilli(),
|
|
Metadata: "checkpoint at 2024-10-05",
|
|
},
|
|
},
|
|
{
|
|
name: "minimal position",
|
|
position: &ConsumerGroupPosition{
|
|
Type: "offset",
|
|
Value: 42,
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
// Marshal to JSON
|
|
jsonBytes, err := json.Marshal(tt.position)
|
|
if err != nil {
|
|
t.Fatalf("Failed to marshal: %v", err)
|
|
}
|
|
|
|
t.Logf("JSON: %s", string(jsonBytes))
|
|
|
|
// Unmarshal from JSON
|
|
var decoded ConsumerGroupPosition
|
|
if err := json.Unmarshal(jsonBytes, &decoded); err != nil {
|
|
t.Fatalf("Failed to unmarshal: %v", err)
|
|
}
|
|
|
|
// Verify fields
|
|
if decoded.Type != tt.position.Type {
|
|
t.Errorf("Type mismatch: got %s, want %s", decoded.Type, tt.position.Type)
|
|
}
|
|
if decoded.Value != tt.position.Value {
|
|
t.Errorf("Value mismatch: got %d, want %d", decoded.Value, tt.position.Value)
|
|
}
|
|
if decoded.OffsetType != tt.position.OffsetType {
|
|
t.Errorf("OffsetType mismatch: got %s, want %s", decoded.OffsetType, tt.position.OffsetType)
|
|
}
|
|
if decoded.Metadata != tt.position.Metadata {
|
|
t.Errorf("Metadata mismatch: got %s, want %s", decoded.Metadata, tt.position.Metadata)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestConsumerGroupPosition_JSONExamples(t *testing.T) {
|
|
// Test JSON format examples
|
|
jsonExamples := []string{
|
|
`{"type":"offset","value":12345}`,
|
|
`{"type":"timestamp","value":1696521600000000000}`,
|
|
`{"type":"offset","value":42,"offset_type":"EXACT_OFFSET","committed_at":1696521600000,"metadata":"test"}`,
|
|
}
|
|
|
|
for i, jsonStr := range jsonExamples {
|
|
var position ConsumerGroupPosition
|
|
if err := json.Unmarshal([]byte(jsonStr), &position); err != nil {
|
|
t.Errorf("Example %d: Failed to parse JSON: %v", i, err)
|
|
continue
|
|
}
|
|
|
|
t.Logf("Example %d: Type=%s, Value=%d", i, position.Type, position.Value)
|
|
|
|
// Verify required fields
|
|
if position.Type == "" {
|
|
t.Errorf("Example %d: Type is empty", i)
|
|
}
|
|
if position.Value == 0 {
|
|
t.Errorf("Example %d: Value is zero", i)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestConsumerGroupPosition_TypeValidation(t *testing.T) {
|
|
validTypes := []string{"offset", "timestamp"}
|
|
|
|
for _, typ := range validTypes {
|
|
position := &ConsumerGroupPosition{
|
|
Type: typ,
|
|
Value: 100,
|
|
}
|
|
|
|
jsonBytes, err := json.Marshal(position)
|
|
if err != nil {
|
|
t.Fatalf("Failed to marshal position with type '%s': %v", typ, err)
|
|
}
|
|
|
|
var decoded ConsumerGroupPosition
|
|
if err := json.Unmarshal(jsonBytes, &decoded); err != nil {
|
|
t.Fatalf("Failed to unmarshal position with type '%s': %v", typ, err)
|
|
}
|
|
|
|
if decoded.Type != typ {
|
|
t.Errorf("Type mismatch: got '%s', want '%s'", decoded.Type, typ)
|
|
}
|
|
}
|
|
}
|