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.
162 lines
5.4 KiB
Go
162 lines
5.4 KiB
Go
package volume_balance_test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
pluginworkers "github.com/seaweedfs/seaweedfs/test/plugin_workers"
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/plugin_pb"
|
|
"github.com/seaweedfs/seaweedfs/weed/pb/worker_pb"
|
|
pluginworker "github.com/seaweedfs/seaweedfs/weed/plugin/worker"
|
|
"github.com/seaweedfs/seaweedfs/weed/worker/tasks/balance"
|
|
"github.com/stretchr/testify/require"
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/credentials/insecure"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
const testVolumeDatSize = 1 * 1024 * 1024
|
|
|
|
func TestVolumeBalanceExecutionIntegration(t *testing.T) {
|
|
volumeID := uint32(303)
|
|
|
|
dialOption := grpc.WithTransportCredentials(insecure.NewCredentials())
|
|
handler := balance.NewVolumeBalanceHandler(dialOption)
|
|
harness := pluginworkers.NewHarness(t, pluginworkers.HarnessConfig{
|
|
WorkerOptions: pluginworker.WorkerOptions{
|
|
GrpcDialOption: dialOption,
|
|
},
|
|
Handlers: []pluginworker.JobHandler{handler},
|
|
})
|
|
harness.WaitForJobType("volume_balance")
|
|
|
|
source := pluginworkers.NewVolumeServer(t, "")
|
|
target := pluginworkers.NewVolumeServer(t, "")
|
|
pluginworkers.WriteTestVolumeFiles(t, source.BaseDir(), volumeID, testVolumeDatSize)
|
|
|
|
job := &plugin_pb.JobSpec{
|
|
JobId: fmt.Sprintf("balance-job-%d", volumeID),
|
|
JobType: "volume_balance",
|
|
Parameters: map[string]*plugin_pb.ConfigValue{
|
|
"volume_id": {
|
|
Kind: &plugin_pb.ConfigValue_Int64Value{Int64Value: int64(volumeID)},
|
|
},
|
|
"collection": {
|
|
Kind: &plugin_pb.ConfigValue_StringValue{StringValue: "balance"},
|
|
},
|
|
"source_server": {
|
|
Kind: &plugin_pb.ConfigValue_StringValue{StringValue: source.Address()},
|
|
},
|
|
"target_server": {
|
|
Kind: &plugin_pb.ConfigValue_StringValue{StringValue: target.Address()},
|
|
},
|
|
},
|
|
}
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
defer cancel()
|
|
|
|
result, err := harness.Plugin().ExecuteJob(ctx, job, nil, 1)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, result)
|
|
require.True(t, result.Success)
|
|
|
|
require.GreaterOrEqual(t, source.MarkReadonlyCount(), 1)
|
|
require.GreaterOrEqual(t, len(source.DeleteRequests()), 1)
|
|
|
|
copyCalls, _, tailCalls := target.BalanceStats()
|
|
require.GreaterOrEqual(t, copyCalls, 1)
|
|
require.GreaterOrEqual(t, tailCalls, 1)
|
|
}
|
|
|
|
func TestVolumeBalanceBatchExecutionIntegration(t *testing.T) {
|
|
dialOption := grpc.WithTransportCredentials(insecure.NewCredentials())
|
|
handler := balance.NewVolumeBalanceHandler(dialOption)
|
|
harness := pluginworkers.NewHarness(t, pluginworkers.HarnessConfig{
|
|
WorkerOptions: pluginworker.WorkerOptions{
|
|
GrpcDialOption: dialOption,
|
|
},
|
|
Handlers: []pluginworker.JobHandler{handler},
|
|
})
|
|
harness.WaitForJobType("volume_balance")
|
|
|
|
// Create one source and one target fake volume server.
|
|
source := pluginworkers.NewVolumeServer(t, "")
|
|
target := pluginworkers.NewVolumeServer(t, "")
|
|
|
|
// Build a batch job with 3 volume moves from source → target.
|
|
volumeIDs := []uint32{401, 402, 403}
|
|
for _, vid := range volumeIDs {
|
|
pluginworkers.WriteTestVolumeFiles(t, source.BaseDir(), vid, testVolumeDatSize)
|
|
}
|
|
moves := make([]*worker_pb.BalanceMoveSpec, len(volumeIDs))
|
|
for i, vid := range volumeIDs {
|
|
moves[i] = &worker_pb.BalanceMoveSpec{
|
|
VolumeId: vid,
|
|
SourceNode: source.Address(),
|
|
TargetNode: target.Address(),
|
|
Collection: "batch-test",
|
|
}
|
|
}
|
|
|
|
params := &worker_pb.TaskParams{
|
|
TaskId: "batch-balance-test",
|
|
TaskParams: &worker_pb.TaskParams_BalanceParams{
|
|
BalanceParams: &worker_pb.BalanceTaskParams{
|
|
MaxConcurrentMoves: 2,
|
|
Moves: moves,
|
|
},
|
|
},
|
|
}
|
|
paramBytes, err := proto.Marshal(params)
|
|
require.NoError(t, err)
|
|
|
|
job := &plugin_pb.JobSpec{
|
|
JobId: "batch-balance-test",
|
|
JobType: "volume_balance",
|
|
Parameters: map[string]*plugin_pb.ConfigValue{
|
|
"task_params_pb": {
|
|
Kind: &plugin_pb.ConfigValue_BytesValue{BytesValue: paramBytes},
|
|
},
|
|
},
|
|
}
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
defer cancel()
|
|
|
|
result, err := harness.Plugin().ExecuteJob(ctx, job, nil, 1)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, result)
|
|
require.True(t, result.Success, "batch balance job should succeed; result: %+v", result)
|
|
|
|
// Each of the 3 moves should have marked the source readonly and deleted.
|
|
require.Equal(t, len(volumeIDs), source.MarkReadonlyCount(),
|
|
"each move should mark source volume readonly")
|
|
require.Equal(t, len(volumeIDs), len(source.DeleteRequests()),
|
|
"each move should delete the source volume")
|
|
|
|
// Verify delete requests reference the expected volume IDs.
|
|
deletedVols := make(map[uint32]bool)
|
|
for _, req := range source.DeleteRequests() {
|
|
deletedVols[req.VolumeId] = true
|
|
}
|
|
for _, vid := range volumeIDs {
|
|
require.True(t, deletedVols[vid], "volume %d should have been deleted from source", vid)
|
|
}
|
|
|
|
// Each move reads source status once before copy and once inside the
|
|
// target's fake VolumeCopy implementation, then reads target status once
|
|
// before deleting the source.
|
|
require.Equal(t, len(volumeIDs)*2, source.ReadFileStatusCount(),
|
|
"each move should read source volume status before copy and during target copy")
|
|
require.Equal(t, len(volumeIDs), target.ReadFileStatusCount(),
|
|
"each move should read target volume status before delete")
|
|
|
|
// Target should have received copy and tail calls for all 3 volumes.
|
|
copyCalls, _, tailCalls := target.BalanceStats()
|
|
require.Equal(t, len(volumeIDs), copyCalls, "target should receive one copy per volume")
|
|
require.Equal(t, len(volumeIDs), tailCalls, "target should receive one tail per volume")
|
|
}
|