Some checks failed
go: build dev binaries / cleanup (push) Successful in 4s
Codespell / Check for spelling errors (push) Failing after 3s
docker: build dev containers / build-rust-binaries (amd64, x86_64-unknown-linux-musl) (push) Failing after 3s
docker: build dev containers / build-dev-containers (push) Has been skipped
docker: build dev containers / build-rust-binaries (arm64, true, aarch64-unknown-linux-musl) (push) Failing after 3s
End to End / FUSE Mount (push) Failing after 2s
EC Integration Tests / EC Integration Tests (push) Failing after 30s
FUSE DLM Integration Tests / FUSE DLM Integration Tests (push) Failing after 3s
FUSE Volume Server Failover Tests / FUSE Volume Server Failover (push) Failing after 3s
FUSE Integration Tests / FUSE Integration Testing (push) Failing after 2s
FUSE P2P Peer Chunk Sharing Integration Tests / FUSE P2P Peer Chunk Sharing (push) Failing after 3s
go: build binary / Go Vet (push) Failing after 2s
go: build binary / Go Vet 32-bit (push) Failing after 3s
go: build binary / Build (push) Failing after 4s
go: build binary / Build cross-platform (freebsd/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/amd64) (push) Failing after 3s
go: build binary / Build cross-platform (darwin/arm64) (push) Failing after 3s
go: build binary / Build cross-platform (windows/arm64) (push) Failing after 3s
go: build binary / Test (push) Failing after 2s
go: build binary / Test 32-bit (push) Failing after 3s
helm: lint and test charts / lint-test (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (11) (push) Failing after 3s
Java Client Integration Tests / Java Integration Tests (17) (push) Failing after 3s
go: build dev binaries / build_dev_linux_windows (amd64, linux) (push) Failing after 2s
go: build dev binaries / build_dev_linux_windows (amd64, windows) (push) Failing after 3s
go: build dev binaries / build_dev_darwin (amd64, darwin) (push) Has been skipped
go: build dev binaries / build_dev_darwin (arm64, darwin) (push) Has been skipped
Java Client Unit Tests / Java Unit Tests (11) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (17) (push) Failing after 2s
Java Client Unit Tests / Java Unit Tests (21) (push) Failing after 3s
Java Client Unit Tests / Java Unit Tests (8) (push) Failing after 3s
Kafka Quick Test (Load Test with Schema Registry) / Kafka Client Load Test (Quick) (push) Failing after 3s
Kafka Gateway Tests / Kafka Unit Tests (unit-tests-1) (push) Failing after 11s
Kafka Gateway Tests / Kafka Integration Tests (Critical) (integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka End-to-End Tests (with SMQ) (e2e-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Consumer Group Tests (Highly Isolated) (consumer-group-1) (push) Failing after 2s
Kafka Gateway Tests / Kafka Client Compatibility (with SMQ) (client-compat-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka SMQ Integration Tests (Full Stack) (smq-integration-1) (push) Failing after 3s
Kafka Gateway Tests / Kafka Protocol Tests (Isolated) (protocol-1) (push) Failing after 3s
KMS Tests / KMS Provider Integration Tests (push) Failing after 2s
KMS Tests / S3 KMS End-to-End Tests (push) Failing after 3s
Master Cold Start Tests / Master Cold Start Tests (push) Failing after 4s
Metadata Subscribe Integration Tests / Metadata Subscribe Integration Tests (push) Failing after 3s
Multi-Master Tests / Multi-Master Failover Tests (push) Failing after 3s
Performance / CPU and Heap Profile (push) Failing after 2s
Performance / S3 Read/Write Benchmark (rust volume) (push) Failing after 3s
pjdfstest POSIX Compliance / pjdfstest (push) Failing after 2s
Plugin Worker Integration Tests / Plugin Worker: erasure_coding (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: vacuum (push) Failing after 3s
Rust Volume Server Tests / Rust Integration Tests (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 1) (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 1) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 2) (push) Failing after 3s
Rust Volume Server Tests / Go Tests with Rust Volume (grpc - Shard 3) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Distributed Tests (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Performance Tests (push) Failing after 3s
Performance / Throughput Benchmark (go volume) (push) Failing after 3s
Performance / Throughput Benchmark (rust volume) (push) Failing after 2s
Performance / S3 Read/Write Benchmark (go volume) (push) Failing after 3s
Plugin Worker Integration Tests / Plugin Worker: volume_balance (push) Failing after 3s
PostgreSQL Gateway Tests / PostgreSQL Basic Tests (push) Failing after 3s
Rust Volume Server Tests / Rust Unit Tests (push) Failing after 2s
Rust Volume Server Tests / Go Tests with Rust Volume (http - Shard 3) (push) Failing after 3s
Rust Plugin Worker Tests / Rust Plugin Worker Build and Unit Tests (push) Failing after 3s
rust: build dev volume server binaries / cleanup (push) Successful in 3s
S3 ETag and ACL Tests / S3 ETag + ACL Integration Tests (push) Failing after 3s
S3 IAM Integration Tests / IAM Unit Tests (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (advanced) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (basic) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (group) (push) Failing after 3s
S3 IAM Integration Tests / S3 IAM Integration Tests (policy-enforcement) (push) Failing after 2s
S3 IAM Integration Tests / S3 IAM Integration Tests (sts) (push) Failing after 4s
S3 Keycloak Integration Tests / S3 Keycloak Integration Tests (push) Failing after 3s
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.11) (push) Failing after 3s
S3 PyArrow Parquet Tests / Go Unit Tests (Implicit Directory) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.12) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-amd64, x86_64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-darwin (darwin-arm64, aarch64-apple-darwin) (push) Has been cancelled
rust: build dev volume server binaries / build-rust-volume-dev-linux (linux-amd64, x86_64-unknown-linux-gnu) (push) Has been cancelled
S3 PyArrow Parquet Tests / PyArrow Parquet Tests (Python 3.9) (push) Has been cancelled
S3 Proxy Signature Tests / S3 Proxy Signature Verification Tests (push) Has been cancelled
S3 SDK V2 Route Disambiguation Tests / S3 SDK V2 Routing Tests (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (quick) (push) Has been cancelled
S3 SSE Tests / S3 SSE Compatibility Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Metadata Persistence Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Copy Operations Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Multipart Upload Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Performance Test (push) Has been cancelled
S3 SSE Tests / S3 Volume Encryption Test (push) Has been cancelled
S3 SSE Tests / S3 SSE Integration Tests (comprehensive) (push) Has been cancelled
Spark Integration Tests / Spark Integration Tests (push) Failing after 2s
Telemetry Integration Tests / telemetry-integration-test (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 1) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 1) (push) Failing after 3s
Ceph S3 tests / Basic S3 tests (KV store) (push) Has been cancelled
Ceph S3 tests / S3 Versioning & Object Lock tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Unit Tests (push) Failing after 3s
Ceph S3 tests / S3 CORS tests (push) Has been cancelled
Ceph S3 tests / SeaweedFS Custom S3 Copy tests (push) Has been cancelled
Ceph S3 tests / Basic S3 tests (SQL store) (push) Has been cancelled
test s3 over https using aws-cli / awscli-tests (push) Has been cancelled
TLS Rotation Integration Tests / TLS Rotation Integration Tests (push) Has been cancelled
Vacuum Integration Tests / Vacuum Integration Tests (push) Has been cancelled
S3 Policy Integration Tests / S3 Policy Variables Integration Tests (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (advanced-policy) (push) Failing after 3s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (basic-policy) (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Enforcement Integration Tests (contextual-policy) (push) Failing after 4s
S3 Policy Integration Tests / Trusted Proxy Detection Tests (push) Failing after 2s
S3 Policy Integration Tests / S3 Policy Shell Integration Tests (push) Failing after 3s
Samba on FUSE Integration / samba-integration (push) Failing after 2s
SFTP Integration Tests / SFTP Integration Testing (push) Failing after 3s
terraform: validate and test modules / fmt, validate, plan-level tests (push) Failing after 3s
terraform: validate and test modules / local cluster smoke test (real weed) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 3) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (grpc - Shard 2) (push) Failing after 3s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 2) (push) Failing after 2s
Volume Server Integration Tests / Volume Server Integration Tests (http - Shard 3) (push) Failing after 5s
mount: windows conformance / WinFsp conformance (push) Has been cancelled
mount: windows / Mount on Windows (push) Has been cancelled
181 lines
6.0 KiB
Go
181 lines
6.0 KiB
Go
package mount
|
||
|
||
import (
|
||
"context"
|
||
"crypto/md5"
|
||
"encoding/base64"
|
||
"encoding/hex"
|
||
"testing"
|
||
|
||
"google.golang.org/grpc"
|
||
"google.golang.org/grpc/credentials/insecure"
|
||
)
|
||
|
||
// newTestFetchServer stands up a minimal MountPeer gRPC server that only
|
||
// serves FetchChunk out of a fakeChunkCache. Goes through the same
|
||
// PeerGrpcServer.Start path production uses (via pb.NewGrpcServer with
|
||
// the standard keepalive + msg-size options) so future default server
|
||
// options are exercised by these tests too.
|
||
func newTestFetchServer(t *testing.T, cache *fakeChunkCache) (addr string, stop func()) {
|
||
t.Helper()
|
||
dir := NewPeerDirectory()
|
||
srv := NewPeerGrpcServer(cache, dir, nil, "")
|
||
if err := srv.Start("127.0.0.1:0"); err != nil {
|
||
t.Fatalf("start: %v", err)
|
||
}
|
||
return srv.Addr(), func() { srv.Stop() }
|
||
}
|
||
|
||
func etagOf(b []byte) string {
|
||
sum := md5.Sum(b)
|
||
return hex.EncodeToString(sum[:])
|
||
}
|
||
|
||
// etagOfBase64 mirrors how the real upload path produces FileChunk.ETag:
|
||
// base64 of the raw 16-byte MD5 digest. Kept alongside the hex form so
|
||
// we can test that both encodings work end-to-end.
|
||
func etagOfBase64(b []byte) string {
|
||
sum := md5.Sum(b)
|
||
return base64.StdEncoding.EncodeToString(sum[:])
|
||
}
|
||
|
||
func TestFetchChunkFromPeer_Hit(t *testing.T) {
|
||
cache := newFakeChunkCache()
|
||
payload := []byte("hello from peer stream")
|
||
cache.Put("3,abc", payload)
|
||
addr, stop := newTestFetchServer(t, cache)
|
||
defer stop()
|
||
|
||
dial := DefaultMountPeerDialer(grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||
got, err := fetchChunkFromPeer(context.Background(), dial, addr, "3,abc", uint64(len(payload)), etagOf(payload))
|
||
if err != nil {
|
||
t.Fatalf("fetch: %v", err)
|
||
}
|
||
if string(got) != string(payload) {
|
||
t.Errorf("bytes mismatch: got %q want %q", got, payload)
|
||
}
|
||
}
|
||
|
||
// TestFetchChunkFromPeer_Base64Etag mirrors the real upload path where
|
||
// FileChunk.ETag is base64(md5) rather than hex(md5). A regression
|
||
// there would reject every valid peer response in production.
|
||
func TestFetchChunkFromPeer_Base64Etag(t *testing.T) {
|
||
cache := newFakeChunkCache()
|
||
payload := []byte("base64-etag peer bytes")
|
||
cache.Put("3,b64", payload)
|
||
addr, stop := newTestFetchServer(t, cache)
|
||
defer stop()
|
||
|
||
dial := DefaultMountPeerDialer(grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||
got, err := fetchChunkFromPeer(context.Background(), dial, addr, "3,b64", uint64(len(payload)), etagOfBase64(payload))
|
||
if err != nil {
|
||
t.Fatalf("fetch: %v", err)
|
||
}
|
||
if string(got) != string(payload) {
|
||
t.Errorf("bytes mismatch: got %q want %q", got, payload)
|
||
}
|
||
}
|
||
|
||
func TestFetchChunkFromPeer_EtagMismatch(t *testing.T) {
|
||
cache := newFakeChunkCache()
|
||
payload := []byte("unexpected bytes")
|
||
cache.Put("3,abc", payload)
|
||
addr, stop := newTestFetchServer(t, cache)
|
||
defer stop()
|
||
|
||
dial := DefaultMountPeerDialer(grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||
_, err := fetchChunkFromPeer(context.Background(), dial, addr, "3,abc", 0, "not-the-real-etag")
|
||
if err == nil {
|
||
t.Fatalf("expected etag mismatch error, got nil")
|
||
}
|
||
}
|
||
|
||
func TestFetchChunkFromPeer_NotFound(t *testing.T) {
|
||
cache := newFakeChunkCache()
|
||
addr, stop := newTestFetchServer(t, cache)
|
||
defer stop()
|
||
|
||
dial := DefaultMountPeerDialer(grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||
_, err := fetchChunkFromPeer(context.Background(), dial, addr, "3,missing", 0, "")
|
||
if err == nil {
|
||
t.Errorf("expected error for missing fid, got nil")
|
||
}
|
||
}
|
||
|
||
// TestSortHoldersByLocality verifies that same-rack peers sort ahead of
|
||
// same-DC-different-rack peers, which in turn sort ahead of cross-DC
|
||
// peers, and that LRU order is preserved within each bucket.
|
||
func TestSortHoldersByLocality(t *testing.T) {
|
||
selfDC, selfRack := "dc1", "r1"
|
||
// Input order mimics a server-side LRU list (newest first).
|
||
holders := []peerHolder{
|
||
{addr: "far-newest", dc: "dc2", rack: "r9"}, // bucket 2 (diff DC)
|
||
{addr: "mid-newer", dc: "dc1", rack: "r2"}, // bucket 1 (same DC, diff rack)
|
||
{addr: "local-newer", dc: "dc1", rack: "r1"}, // bucket 0 (same rack)
|
||
{addr: "far-older", dc: "dc2", rack: "r9"}, // bucket 2
|
||
{addr: "mid-older", dc: "dc1", rack: "r2"}, // bucket 1
|
||
{addr: "local-older", dc: "dc1", rack: "r1"}, // bucket 0
|
||
{addr: "unlabeled-older", dc: "", rack: ""}, // bucket 2 (unknown)
|
||
}
|
||
|
||
sortHoldersByLocality(holders, selfDC, selfRack)
|
||
|
||
want := []string{
|
||
"local-newer", "local-older",
|
||
"mid-newer", "mid-older",
|
||
"far-newest", "far-older", "unlabeled-older",
|
||
}
|
||
if len(holders) != len(want) {
|
||
t.Fatalf("len got %d want %d", len(holders), len(want))
|
||
}
|
||
for i, w := range want {
|
||
if holders[i].addr != w {
|
||
t.Errorf("pos %d: got %q want %q (full: %+v)", i, holders[i].addr, w, holders)
|
||
}
|
||
}
|
||
}
|
||
|
||
// TestSortHoldersByLocality_NoSelfLabels — when the caller has no DC/rack
|
||
// labels, every peer falls to bucket 2 and the server-returned LRU order
|
||
// must pass through unchanged.
|
||
func TestSortHoldersByLocality_NoSelfLabels(t *testing.T) {
|
||
holders := []peerHolder{
|
||
{addr: "a", dc: "dc1", rack: "r1"},
|
||
{addr: "b", dc: "dc2", rack: "r2"},
|
||
{addr: "c", dc: "", rack: ""},
|
||
}
|
||
sortHoldersByLocality(holders, "", "")
|
||
want := []string{"a", "b", "c"}
|
||
for i, w := range want {
|
||
if holders[i].addr != w {
|
||
t.Errorf("pos %d: got %q want %q", i, holders[i].addr, w)
|
||
}
|
||
}
|
||
}
|
||
|
||
func TestFetchChunkFromPeer_MultiFrameChunkAssembledCorrectly(t *testing.T) {
|
||
cache := newFakeChunkCache()
|
||
// Just over 2× the stream frame size so we get at least three frames.
|
||
payload := make([]byte, fetchChunkStreamSize*2+42)
|
||
for i := range payload {
|
||
payload[i] = byte((i * 7) & 0xff)
|
||
}
|
||
cache.Put("3,large", payload)
|
||
addr, stop := newTestFetchServer(t, cache)
|
||
defer stop()
|
||
|
||
dial := DefaultMountPeerDialer(grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||
got, err := fetchChunkFromPeer(context.Background(), dial, addr, "3,large", uint64(len(payload)), etagOf(payload))
|
||
if err != nil {
|
||
t.Fatalf("fetch: %v", err)
|
||
}
|
||
if len(got) != len(payload) {
|
||
t.Fatalf("len got %d want %d", len(got), len(payload))
|
||
}
|
||
for i := range payload {
|
||
if got[i] != payload[i] {
|
||
t.Fatalf("mismatch at offset %d", i)
|
||
}
|
||
}
|
||
}
|