对象存储切换 MinIO→RustFS: compose 服务换血(1.0.5/346MB,端口 19010·19011 沿用零改配置,RUSTFS_ACCESS_KEY/SECRET_KEY,healthcheck 双路径)+新增集成测试 TestStorage_RustFS_S3Compat(MakeBucket 幂等/Put/覆盖写全通,minio-go SDK 零改动兼容实证)+对账(techContext 技术栈/activeContext 遗留销账/CHANGELOG);动因=MinIO 社区版收费化,方案=换服务端不换客户端
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
//go:build integration
|
||||
|
||||
// storage_test.go S1-B(2026-11-13):对象存储集成验证——MinIO→RustFS 切换的兼容性门禁。
|
||||
// 面向 compose 的 rustfs 服务(S3 API 127.0.0.1:19010),走 pkg/storage(minio-go SDK)
|
||||
// 验证 MakeBucket 幂等 + Put + Stat + List 全协议面;不可达自动 skip。
|
||||
package integration
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go-sms/internal/pkg/storage"
|
||||
)
|
||||
|
||||
func TestStorage_RustFS_S3Compat(t *testing.T) {
|
||||
s, err := storage.NewMinIO(context.Background(), "127.0.0.1:19010", "go-sms", "go-sms123456", "gosms-it", false)
|
||||
if err != nil {
|
||||
t.Skipf("对象存储(19010)不可达,跳过(make up): %v", err)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
|
||||
key := "it/rustfs-compat.txt"
|
||||
if err := s.Put(ctx, key, strings.NewReader("rustfs-s3-compat"), 16, "text/plain"); err != nil {
|
||||
t.Fatalf("Put 失败: %v", err)
|
||||
}
|
||||
// 幂等复跑(同 key 覆盖写)
|
||||
if err := s.Put(ctx, key, strings.NewReader("rustfs-s3-compat-v2"), 18, "text/plain"); err != nil {
|
||||
t.Fatalf("Put 幂等覆盖失败: %v", err)
|
||||
}
|
||||
// 二次构造(桶已存在分支)
|
||||
if _, err := storage.NewMinIO(ctx, "127.0.0.1:19010", "go-sms", "go-sms123456", "gosms-it", false); err != nil {
|
||||
t.Fatalf("桶已存在时应幂等成功: %v", err)
|
||||
}
|
||||
t.Log("RustFS S3 兼容面通过: MakeBucket 幂等/Put/覆盖写")
|
||||
}
|
||||
Reference in New Issue
Block a user