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.
124 lines
4.8 KiB
Go
124 lines
4.8 KiB
Go
package volume_server_http_test
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
"testing"
|
|
|
|
"github.com/seaweedfs/seaweedfs/test/volume_server/framework"
|
|
"github.com/seaweedfs/seaweedfs/test/volume_server/matrix"
|
|
)
|
|
|
|
func TestUploadReadRangeHeadDeleteRoundTrip(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping integration test in short mode")
|
|
}
|
|
|
|
cluster := framework.StartVolumeCluster(t, matrix.P1())
|
|
conn, grpcClient := framework.DialVolumeServer(t, cluster.VolumeGRPCAddress())
|
|
defer conn.Close()
|
|
|
|
const volumeID = uint32(7)
|
|
framework.AllocateVolume(t, grpcClient, volumeID, "")
|
|
|
|
fid := framework.NewFileID(volumeID, 123456, 0xA1B2C3D4)
|
|
data := []byte("hello-volume-server-integration")
|
|
client := framework.NewHTTPClient()
|
|
|
|
uploadResp := framework.UploadBytes(t, client, cluster.VolumeAdminURL(), fid, data)
|
|
_ = framework.ReadAllAndClose(t, uploadResp)
|
|
if uploadResp.StatusCode != http.StatusCreated {
|
|
t.Fatalf("upload status: expected 201, got %d", uploadResp.StatusCode)
|
|
}
|
|
|
|
getResp := framework.ReadBytes(t, client, cluster.VolumeAdminURL(), fid)
|
|
getBody := framework.ReadAllAndClose(t, getResp)
|
|
if getResp.StatusCode != http.StatusOK {
|
|
t.Fatalf("get status: expected 200, got %d", getResp.StatusCode)
|
|
}
|
|
if string(getBody) != string(data) {
|
|
t.Fatalf("get body mismatch: got %q want %q", string(getBody), string(data))
|
|
}
|
|
etag := getResp.Header.Get("ETag")
|
|
if etag == "" {
|
|
t.Fatalf("expected ETag header from GET response")
|
|
}
|
|
|
|
notModifiedReq := mustNewRequest(t, http.MethodGet, cluster.VolumeAdminURL()+"/"+fid)
|
|
notModifiedReq.Header.Set("If-None-Match", etag)
|
|
notModifiedResp := framework.DoRequest(t, client, notModifiedReq)
|
|
_ = framework.ReadAllAndClose(t, notModifiedResp)
|
|
if notModifiedResp.StatusCode != http.StatusNotModified {
|
|
t.Fatalf("if-none-match expected 304, got %d", notModifiedResp.StatusCode)
|
|
}
|
|
|
|
rangeReq := mustNewRequest(t, http.MethodGet, cluster.VolumeAdminURL()+"/"+fid)
|
|
rangeReq.Header.Set("Range", "bytes=0-4")
|
|
rangeResp := framework.DoRequest(t, client, rangeReq)
|
|
rangeBody := framework.ReadAllAndClose(t, rangeResp)
|
|
if rangeResp.StatusCode != http.StatusPartialContent {
|
|
t.Fatalf("range status: expected 206, got %d", rangeResp.StatusCode)
|
|
}
|
|
if got, want := string(rangeBody), "hello"; got != want {
|
|
t.Fatalf("range body mismatch: got %q want %q", got, want)
|
|
}
|
|
|
|
invalidRangeReq := mustNewRequest(t, http.MethodGet, cluster.VolumeAdminURL()+"/"+fid)
|
|
invalidRangeReq.Header.Set("Range", "bytes=9999-10000")
|
|
invalidRangeResp := framework.DoRequest(t, client, invalidRangeReq)
|
|
_ = framework.ReadAllAndClose(t, invalidRangeResp)
|
|
if invalidRangeResp.StatusCode != http.StatusRequestedRangeNotSatisfiable {
|
|
t.Fatalf("invalid range expected 416, got %d", invalidRangeResp.StatusCode)
|
|
}
|
|
|
|
headResp := framework.DoRequest(t, client, mustNewRequest(t, http.MethodHead, cluster.VolumeAdminURL()+"/"+fid))
|
|
headBody := framework.ReadAllAndClose(t, headResp)
|
|
if headResp.StatusCode != http.StatusOK {
|
|
t.Fatalf("head status: expected 200, got %d", headResp.StatusCode)
|
|
}
|
|
if got := headResp.Header.Get("Content-Length"); got != strconv.Itoa(len(data)) {
|
|
t.Fatalf("head content-length mismatch: got %q want %d", got, len(data))
|
|
}
|
|
if len(headBody) != 0 {
|
|
t.Fatalf("head body should be empty, got %d bytes", len(headBody))
|
|
}
|
|
|
|
headNotModifiedReq := mustNewRequest(t, http.MethodHead, cluster.VolumeAdminURL()+"/"+fid)
|
|
headNotModifiedReq.Header.Set("If-None-Match", etag)
|
|
headNotModifiedResp := framework.DoRequest(t, client, headNotModifiedReq)
|
|
headNotModifiedBody := framework.ReadAllAndClose(t, headNotModifiedResp)
|
|
if headNotModifiedResp.StatusCode != http.StatusNotModified {
|
|
t.Fatalf("head if-none-match expected 304, got %d", headNotModifiedResp.StatusCode)
|
|
}
|
|
if len(headNotModifiedBody) != 0 {
|
|
t.Fatalf("head if-none-match body should be empty, got %d bytes", len(headNotModifiedBody))
|
|
}
|
|
|
|
deleteResp := framework.DoRequest(t, client, mustNewRequest(t, http.MethodDelete, cluster.VolumeAdminURL()+"/"+fid))
|
|
_ = framework.ReadAllAndClose(t, deleteResp)
|
|
if deleteResp.StatusCode != http.StatusAccepted {
|
|
t.Fatalf("delete status: expected 202, got %d", deleteResp.StatusCode)
|
|
}
|
|
|
|
notFoundResp := framework.ReadBytes(t, client, cluster.VolumeAdminURL(), fid)
|
|
_ = framework.ReadAllAndClose(t, notFoundResp)
|
|
if notFoundResp.StatusCode != http.StatusNotFound {
|
|
t.Fatalf("read after delete: expected 404, got %d", notFoundResp.StatusCode)
|
|
}
|
|
}
|
|
|
|
func TestInvalidReadPathReturnsBadRequest(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping integration test in short mode")
|
|
}
|
|
|
|
cluster := framework.StartVolumeCluster(t, matrix.P1())
|
|
client := framework.NewHTTPClient()
|
|
|
|
resp := framework.DoRequest(t, client, mustNewRequest(t, http.MethodGet, cluster.VolumeAdminURL()+"/invalid,needle"))
|
|
_ = framework.ReadAllAndClose(t, resp)
|
|
if resp.StatusCode != http.StatusBadRequest {
|
|
t.Fatalf("invalid read expected 400, got %d", resp.StatusCode)
|
|
}
|
|
}
|