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.
233 lines
9.2 KiB
Go
233 lines
9.2 KiB
Go
package volume_server_http_test
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/seaweedfs/seaweedfs/test/volume_server/framework"
|
|
"github.com/seaweedfs/seaweedfs/test/volume_server/matrix"
|
|
"github.com/seaweedfs/seaweedfs/weed/operation"
|
|
)
|
|
|
|
func TestChunkManifestExpansionAndBypass(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping integration test in short mode")
|
|
}
|
|
|
|
clusterHarness := framework.StartVolumeCluster(t, matrix.P1())
|
|
conn, grpcClient := framework.DialVolumeServer(t, clusterHarness.VolumeGRPCAddress())
|
|
defer conn.Close()
|
|
|
|
const volumeID = uint32(102)
|
|
framework.AllocateVolume(t, grpcClient, volumeID, "")
|
|
|
|
client := framework.NewHTTPClient()
|
|
|
|
chunkFID := framework.NewFileID(volumeID, 772005, 0x5E6F7081)
|
|
chunkPayload := []byte("chunk-manifest-expanded-content")
|
|
chunkUploadResp := framework.UploadBytes(t, client, clusterHarness.VolumeAdminURL(), chunkFID, chunkPayload)
|
|
_ = framework.ReadAllAndClose(t, chunkUploadResp)
|
|
if chunkUploadResp.StatusCode != http.StatusCreated {
|
|
t.Fatalf("chunk upload expected 201, got %d", chunkUploadResp.StatusCode)
|
|
}
|
|
|
|
manifest := &operation.ChunkManifest{
|
|
Name: "manifest.bin",
|
|
Mime: "application/octet-stream",
|
|
Size: int64(len(chunkPayload)),
|
|
Chunks: []*operation.ChunkInfo{
|
|
{
|
|
Fid: chunkFID,
|
|
Offset: 0,
|
|
Size: int64(len(chunkPayload)),
|
|
},
|
|
},
|
|
}
|
|
manifestBytes, err := json.Marshal(manifest)
|
|
if err != nil {
|
|
t.Fatalf("marshal chunk manifest: %v", err)
|
|
}
|
|
|
|
manifestFID := framework.NewFileID(volumeID, 772006, 0x6F708192)
|
|
manifestUploadReq, err := http.NewRequest(http.MethodPost, clusterHarness.VolumeAdminURL()+"/"+manifestFID+"?cm=true", bytes.NewReader(manifestBytes))
|
|
if err != nil {
|
|
t.Fatalf("create manifest upload request: %v", err)
|
|
}
|
|
manifestUploadReq.Header.Set("Content-Type", "application/json")
|
|
manifestUploadResp := framework.DoRequest(t, client, manifestUploadReq)
|
|
_ = framework.ReadAllAndClose(t, manifestUploadResp)
|
|
if manifestUploadResp.StatusCode != http.StatusCreated {
|
|
t.Fatalf("manifest upload expected 201, got %d", manifestUploadResp.StatusCode)
|
|
}
|
|
|
|
expandedReadResp := framework.ReadBytes(t, client, clusterHarness.VolumeAdminURL(), manifestFID)
|
|
expandedReadBody := framework.ReadAllAndClose(t, expandedReadResp)
|
|
if expandedReadResp.StatusCode != http.StatusOK {
|
|
t.Fatalf("manifest expanded read expected 200, got %d", expandedReadResp.StatusCode)
|
|
}
|
|
if string(expandedReadBody) != string(chunkPayload) {
|
|
t.Fatalf("manifest expanded read mismatch: got %q want %q", string(expandedReadBody), string(chunkPayload))
|
|
}
|
|
if expandedReadResp.Header.Get("X-File-Store") != "chunked" {
|
|
t.Fatalf("manifest expanded read expected X-File-Store=chunked, got %q", expandedReadResp.Header.Get("X-File-Store"))
|
|
}
|
|
|
|
bypassReadResp := framework.DoRequest(t, client, mustNewRequest(t, http.MethodGet, clusterHarness.VolumeAdminURL()+"/"+manifestFID+"?cm=false"))
|
|
bypassReadBody := framework.ReadAllAndClose(t, bypassReadResp)
|
|
if bypassReadResp.StatusCode != http.StatusOK {
|
|
t.Fatalf("manifest bypass read expected 200, got %d", bypassReadResp.StatusCode)
|
|
}
|
|
if bypassReadResp.Header.Get("X-File-Store") != "" {
|
|
t.Fatalf("manifest bypass read expected empty X-File-Store header, got %q", bypassReadResp.Header.Get("X-File-Store"))
|
|
}
|
|
|
|
var gotManifest operation.ChunkManifest
|
|
if err = json.Unmarshal(bypassReadBody, &gotManifest); err != nil {
|
|
t.Fatalf("manifest bypass read expected JSON payload, got decode error: %v body=%q", err, string(bypassReadBody))
|
|
}
|
|
if len(gotManifest.Chunks) != 1 || gotManifest.Chunks[0].Fid != chunkFID {
|
|
t.Fatalf("manifest bypass read payload mismatch: %+v", gotManifest)
|
|
}
|
|
}
|
|
|
|
func TestChunkManifestDeleteRemovesChildChunks(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping integration test in short mode")
|
|
}
|
|
|
|
clusterHarness := framework.StartVolumeCluster(t, matrix.P1())
|
|
conn, grpcClient := framework.DialVolumeServer(t, clusterHarness.VolumeGRPCAddress())
|
|
defer conn.Close()
|
|
|
|
const volumeID = uint32(104)
|
|
framework.AllocateVolume(t, grpcClient, volumeID, "")
|
|
|
|
client := framework.NewHTTPClient()
|
|
|
|
chunkFID := framework.NewFileID(volumeID, 772008, 0x8192A3B4)
|
|
chunkPayload := []byte("chunk-manifest-delete-content")
|
|
chunkUploadResp := framework.UploadBytes(t, client, clusterHarness.VolumeAdminURL(), chunkFID, chunkPayload)
|
|
_ = framework.ReadAllAndClose(t, chunkUploadResp)
|
|
if chunkUploadResp.StatusCode != http.StatusCreated {
|
|
t.Fatalf("chunk upload expected 201, got %d", chunkUploadResp.StatusCode)
|
|
}
|
|
|
|
manifest := &operation.ChunkManifest{
|
|
Name: "manifest-delete.bin",
|
|
Mime: "application/octet-stream",
|
|
Size: int64(len(chunkPayload)),
|
|
Chunks: []*operation.ChunkInfo{
|
|
{
|
|
Fid: chunkFID,
|
|
Offset: 0,
|
|
Size: int64(len(chunkPayload)),
|
|
},
|
|
},
|
|
}
|
|
manifestBytes, err := json.Marshal(manifest)
|
|
if err != nil {
|
|
t.Fatalf("marshal chunk manifest: %v", err)
|
|
}
|
|
|
|
manifestFID := framework.NewFileID(volumeID, 772009, 0x92A3B4C5)
|
|
manifestUploadReq, err := http.NewRequest(http.MethodPost, clusterHarness.VolumeAdminURL()+"/"+manifestFID+"?cm=true", bytes.NewReader(manifestBytes))
|
|
if err != nil {
|
|
t.Fatalf("create manifest upload request: %v", err)
|
|
}
|
|
manifestUploadReq.Header.Set("Content-Type", "application/json")
|
|
manifestUploadResp := framework.DoRequest(t, client, manifestUploadReq)
|
|
_ = framework.ReadAllAndClose(t, manifestUploadResp)
|
|
if manifestUploadResp.StatusCode != http.StatusCreated {
|
|
t.Fatalf("manifest upload expected 201, got %d", manifestUploadResp.StatusCode)
|
|
}
|
|
|
|
deleteResp := framework.DoRequest(t, client, mustNewRequest(t, http.MethodDelete, clusterHarness.VolumeAdminURL()+"/"+manifestFID))
|
|
deleteBody := framework.ReadAllAndClose(t, deleteResp)
|
|
if deleteResp.StatusCode != http.StatusAccepted {
|
|
t.Fatalf("manifest delete expected 202, got %d", deleteResp.StatusCode)
|
|
}
|
|
var deleteResult map[string]int64
|
|
if err = json.Unmarshal(deleteBody, &deleteResult); err != nil {
|
|
t.Fatalf("decode manifest delete response: %v body=%q", err, string(deleteBody))
|
|
}
|
|
if deleteResult["size"] != int64(len(chunkPayload)) {
|
|
t.Fatalf("manifest delete expected size=%d, got %d", len(chunkPayload), deleteResult["size"])
|
|
}
|
|
|
|
manifestReadAfterDelete := framework.ReadBytes(t, client, clusterHarness.VolumeAdminURL(), manifestFID)
|
|
_ = framework.ReadAllAndClose(t, manifestReadAfterDelete)
|
|
if manifestReadAfterDelete.StatusCode != http.StatusNotFound {
|
|
t.Fatalf("manifest read after delete expected 404, got %d", manifestReadAfterDelete.StatusCode)
|
|
}
|
|
|
|
chunkReadAfterDelete := framework.ReadBytes(t, client, clusterHarness.VolumeAdminURL(), chunkFID)
|
|
_ = framework.ReadAllAndClose(t, chunkReadAfterDelete)
|
|
if chunkReadAfterDelete.StatusCode != http.StatusNotFound {
|
|
t.Fatalf("chunk read after manifest delete expected 404, got %d", chunkReadAfterDelete.StatusCode)
|
|
}
|
|
}
|
|
|
|
func TestChunkManifestDeleteFailsWhenChildDeletionFails(t *testing.T) {
|
|
if testing.Short() {
|
|
t.Skip("skipping integration test in short mode")
|
|
}
|
|
|
|
clusterHarness := framework.StartVolumeCluster(t, matrix.P1())
|
|
conn, grpcClient := framework.DialVolumeServer(t, clusterHarness.VolumeGRPCAddress())
|
|
defer conn.Close()
|
|
|
|
const volumeID = uint32(105)
|
|
framework.AllocateVolume(t, grpcClient, volumeID, "")
|
|
|
|
client := framework.NewHTTPClient()
|
|
manifest := &operation.ChunkManifest{
|
|
Name: "manifest-delete-failure.bin",
|
|
Mime: "application/octet-stream",
|
|
Size: 1,
|
|
Chunks: []*operation.ChunkInfo{
|
|
{
|
|
Fid: "not-a-valid-fid",
|
|
Offset: 0,
|
|
Size: 1,
|
|
},
|
|
},
|
|
}
|
|
manifestBytes, err := json.Marshal(manifest)
|
|
if err != nil {
|
|
t.Fatalf("marshal chunk manifest: %v", err)
|
|
}
|
|
|
|
manifestFID := framework.NewFileID(volumeID, 772010, 0xA3B4C5D6)
|
|
manifestUploadReq, err := http.NewRequest(http.MethodPost, clusterHarness.VolumeAdminURL()+"/"+manifestFID+"?cm=true", bytes.NewReader(manifestBytes))
|
|
if err != nil {
|
|
t.Fatalf("create manifest upload request: %v", err)
|
|
}
|
|
manifestUploadReq.Header.Set("Content-Type", "application/json")
|
|
manifestUploadResp := framework.DoRequest(t, client, manifestUploadReq)
|
|
_ = framework.ReadAllAndClose(t, manifestUploadResp)
|
|
if manifestUploadResp.StatusCode != http.StatusCreated {
|
|
t.Fatalf("manifest upload expected 201, got %d", manifestUploadResp.StatusCode)
|
|
}
|
|
|
|
deleteResp := framework.DoRequest(t, client, mustNewRequest(t, http.MethodDelete, clusterHarness.VolumeAdminURL()+"/"+manifestFID))
|
|
deleteBody := framework.ReadAllAndClose(t, deleteResp)
|
|
if deleteResp.StatusCode != http.StatusInternalServerError {
|
|
t.Fatalf("manifest delete with invalid child fid expected 500, got %d body=%q", deleteResp.StatusCode, string(deleteBody))
|
|
}
|
|
|
|
manifestBypassRead := framework.DoRequest(t, client, mustNewRequest(t, http.MethodGet, clusterHarness.VolumeAdminURL()+"/"+manifestFID+"?cm=false"))
|
|
manifestBypassBody := framework.ReadAllAndClose(t, manifestBypassRead)
|
|
if manifestBypassRead.StatusCode != http.StatusOK {
|
|
t.Fatalf("manifest bypass read after failed delete expected 200, got %d", manifestBypassRead.StatusCode)
|
|
}
|
|
var gotManifest operation.ChunkManifest
|
|
if err = json.Unmarshal(manifestBypassBody, &gotManifest); err != nil {
|
|
t.Fatalf("manifest bypass read expected JSON payload, got decode error: %v body=%q", err, string(manifestBypassBody))
|
|
}
|
|
if len(gotManifest.Chunks) != 1 || gotManifest.Chunks[0].Fid != "not-a-valid-fid" {
|
|
t.Fatalf("manifest payload mismatch after failed delete: %+v", gotManifest)
|
|
}
|
|
}
|