mirror of
https://github.com/hanzoai/s3.git
synced 2026-10-30 14:59:09 +00:00
Full internal rename — build-verified, every module green (root + s3-rdma-sidecar
+ telemetry/server + all test modules):
- Dirs: weed/→s3/ (main tree); cmd/weed-{db,sql}→cmd/s3-{db,sql};
seaweed-volume→s3-volume; seaweedfs-rdma-sidecar→s3-rdma-sidecar;
s3/mount/weedfs_*.go→s3fs_*.go (~113 path renames).
- Imports: github.com/hanzoai/s3/weed/ → /s3/ across 1700+ files.
- gRPC proto services Seaweed/SeaweedFiler/SeaweedMessaging/... → Hanzo*
(8 services) via full protoc regeneration (correct descriptors, no sed-corruption).
- Brand SeaweedFS/Seaweed/seaweed → Hanzo/hanzo; internal X-Seaweedfs-* headers
→ X-Hanzo-*; .seaweedfs config dir → .s3.
- CLI is `s3`: go install github.com/hanzoai/s3/s3@latest | make install | Docker.
install.sh rewritten as a Hanzo S3 installer.
- External forks github.com/seaweedfs/{raft,go-fuse,goexif,cockroachdb-parser}
kept verbatim — immutable third-party module paths; NOTICE retained.
Residual (cosmetic, non-build): kafka loadtest test-proto package com.seaweedfs.loadtest.
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package pluginworkers
|
|
|
|
import (
|
|
"fmt"
|
|
"math/rand"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/hanzoai/s3/s3/storage/needle"
|
|
"github.com/hanzoai/s3/s3/storage/types"
|
|
)
|
|
|
|
// WriteTestVolumeFiles creates a minimal .dat/.idx pair for the given volume.
|
|
func WriteTestVolumeFiles(t *testing.T, baseDir string, volumeID uint32, datSize int) (string, string) {
|
|
t.Helper()
|
|
|
|
if err := os.MkdirAll(baseDir, 0755); err != nil {
|
|
t.Fatalf("create volume dir: %v", err)
|
|
}
|
|
|
|
datPath := filepath.Join(baseDir, volumeFilename(volumeID, ".dat"))
|
|
idxPath := filepath.Join(baseDir, volumeFilename(volumeID, ".idx"))
|
|
|
|
// The idx entry records the needle's data size. The actual on-disk size
|
|
// includes header + checksum + timestamp (GetActualSize). The .dat must
|
|
// be large enough to hold the full needle.
|
|
needleDataSize := types.Size(datSize)
|
|
actualSize := needle.GetActualSize(needleDataSize, needle.Version3)
|
|
data := make([]byte, actualSize)
|
|
rng := rand.New(rand.NewSource(99))
|
|
_, _ = rng.Read(data)
|
|
if err := os.WriteFile(datPath, data, 0644); err != nil {
|
|
t.Fatalf("write dat file: %v", err)
|
|
}
|
|
|
|
entry := make([]byte, types.NeedleMapEntrySize)
|
|
idEnd := types.NeedleIdSize
|
|
offsetEnd := idEnd + types.OffsetSize
|
|
sizeEnd := offsetEnd + types.SizeSize
|
|
|
|
types.NeedleIdToBytes(entry[:idEnd], types.NeedleId(1))
|
|
types.OffsetToBytes(entry[idEnd:offsetEnd], types.ToOffset(0))
|
|
types.SizeToBytes(entry[offsetEnd:sizeEnd], needleDataSize)
|
|
|
|
if err := os.WriteFile(idxPath, entry, 0644); err != nil {
|
|
t.Fatalf("write idx file: %v", err)
|
|
}
|
|
|
|
return datPath, idxPath
|
|
}
|
|
|
|
func volumeFilename(volumeID uint32, ext string) string {
|
|
return fmt.Sprintf("%d%s", volumeID, ext)
|
|
}
|