snapshot of https://github.com/seaweedfs/seaweedfs.git (master, 2026-09-16; blobs > 131072B omitted)
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
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
This commit is contained in:
444
weed/s3api/s3api_object_routed_write_test.go
Normal file
444
weed/s3api/s3api_object_routed_write_test.go
Normal file
@@ -0,0 +1,444 @@
|
||||
package s3api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/s3api/s3_constants"
|
||||
"github.com/seaweedfs/seaweedfs/weed/s3api/s3err"
|
||||
"github.com/seaweedfs/seaweedfs/weed/wdclient"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
func reqWith(headers map[string]string) *http.Request {
|
||||
r, _ := http.NewRequest(http.MethodPut, "/b/o", nil)
|
||||
for k, v := range headers {
|
||||
r.Header.Set(k, v)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// oneClause returns the single clause of cond, failing if it does not hold
|
||||
// exactly one.
|
||||
func oneClause(t *testing.T, cond *filer_pb.WriteCondition) *filer_pb.WriteCondition_Clause {
|
||||
t.Helper()
|
||||
if cond == nil {
|
||||
t.Fatal("expected a condition, got nil")
|
||||
}
|
||||
if len(cond.Clauses) != 1 {
|
||||
t.Fatalf("expected 1 clause, got %d", len(cond.Clauses))
|
||||
}
|
||||
return cond.Clauses[0]
|
||||
}
|
||||
|
||||
func TestBuildWriteCondition(t *testing.T) {
|
||||
t.Run("no headers is unconditional", func(t *testing.T) {
|
||||
cond, ok := buildWriteCondition(reqWith(nil))
|
||||
if !ok || cond != nil {
|
||||
t.Fatalf("want (nil, true), got (%v, %v)", cond, ok)
|
||||
}
|
||||
})
|
||||
t.Run("If-None-Match * to IF_NOT_EXISTS", func(t *testing.T) {
|
||||
cond, ok := buildWriteCondition(reqWith(map[string]string{s3_constants.IfNoneMatch: "*"}))
|
||||
if !ok {
|
||||
t.Fatal("want ok")
|
||||
}
|
||||
if c := oneClause(t, cond); c.Kind != filer_pb.WriteCondition_IF_NOT_EXISTS {
|
||||
t.Fatalf("kind = %v", c.Kind)
|
||||
}
|
||||
})
|
||||
t.Run("If-Match * to IF_EXISTS", func(t *testing.T) {
|
||||
cond, ok := buildWriteCondition(reqWith(map[string]string{s3_constants.IfMatch: "*"}))
|
||||
if !ok {
|
||||
t.Fatal("want ok")
|
||||
}
|
||||
if c := oneClause(t, cond); c.Kind != filer_pb.WriteCondition_IF_EXISTS {
|
||||
t.Fatalf("kind = %v", c.Kind)
|
||||
}
|
||||
})
|
||||
t.Run("If-Match strong etag to IF_ETAG_MATCH", func(t *testing.T) {
|
||||
cond, ok := buildWriteCondition(reqWith(map[string]string{s3_constants.IfMatch: `"abc123"`}))
|
||||
if !ok {
|
||||
t.Fatal("want ok")
|
||||
}
|
||||
c := oneClause(t, cond)
|
||||
if c.Kind != filer_pb.WriteCondition_IF_ETAG_MATCH || len(c.Etags) != 1 || c.Etags[0] != "abc123" {
|
||||
t.Fatalf("clause = %+v", c)
|
||||
}
|
||||
})
|
||||
t.Run("If-None-Match strong etag to IF_ETAG_NOT_MATCH", func(t *testing.T) {
|
||||
cond, ok := buildWriteCondition(reqWith(map[string]string{s3_constants.IfNoneMatch: `"abc123"`}))
|
||||
if !ok {
|
||||
t.Fatal("want ok")
|
||||
}
|
||||
c := oneClause(t, cond)
|
||||
if c.Kind != filer_pb.WriteCondition_IF_ETAG_NOT_MATCH || len(c.Etags) != 1 || c.Etags[0] != "abc123" {
|
||||
t.Fatalf("clause = %+v", c)
|
||||
}
|
||||
})
|
||||
t.Run("weak etag falls back", func(t *testing.T) {
|
||||
if _, ok := buildWriteCondition(reqWith(map[string]string{s3_constants.IfMatch: `W/"abc"`})); ok {
|
||||
t.Fatal("weak etag must not take the fast path")
|
||||
}
|
||||
})
|
||||
t.Run("etag list falls back", func(t *testing.T) {
|
||||
if _, ok := buildWriteCondition(reqWith(map[string]string{s3_constants.IfMatch: `"a","b"`})); ok {
|
||||
t.Fatal("etag list must not take the fast path")
|
||||
}
|
||||
})
|
||||
t.Run("both match and none-match falls back", func(t *testing.T) {
|
||||
if _, ok := buildWriteCondition(reqWith(map[string]string{
|
||||
s3_constants.IfMatch: "*",
|
||||
s3_constants.IfNoneMatch: "*",
|
||||
})); ok {
|
||||
t.Fatal("ambiguous combination must not take the fast path")
|
||||
}
|
||||
})
|
||||
t.Run("time-based falls back", func(t *testing.T) {
|
||||
if _, ok := buildWriteCondition(reqWith(map[string]string{
|
||||
"If-Unmodified-Since": "Wed, 21 Oct 2015 07:28:00 GMT",
|
||||
})); ok {
|
||||
t.Fatal("time condition must not take the fast path")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestParseConditionalHeadersAcceptsHTTPDateFormats(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
header string
|
||||
value string
|
||||
expected time.Time
|
||||
}{
|
||||
{
|
||||
name: "If-Modified-Since RFC850",
|
||||
header: s3_constants.IfModifiedSince,
|
||||
value: "Sunday, 06-Nov-94 08:49:37 GMT",
|
||||
expected: time.Date(1994, time.November, 6, 8, 49, 37, 0, time.UTC),
|
||||
},
|
||||
{
|
||||
name: "If-Unmodified-Since ANSIC",
|
||||
header: s3_constants.IfUnmodifiedSince,
|
||||
value: "Sun Nov 6 08:49:37 1994",
|
||||
expected: time.Date(1994, time.November, 6, 8, 49, 37, 0, time.UTC),
|
||||
},
|
||||
{
|
||||
// Go clients build this with t.UTC().Format(time.RFC1123); the "UTC"
|
||||
// zone is rejected by http.ParseTime but was accepted before, so the
|
||||
// RFC1123 fallback must keep it working.
|
||||
name: "If-Modified-Since RFC1123 UTC zone",
|
||||
header: s3_constants.IfModifiedSince,
|
||||
value: "Wed, 21 Oct 2015 07:28:00 UTC",
|
||||
expected: time.Date(2015, time.October, 21, 7, 28, 0, 0, time.UTC),
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
r := reqWith(map[string]string{testCase.header: testCase.value})
|
||||
|
||||
headers, errCode := parseConditionalHeaders(r)
|
||||
if errCode != s3err.ErrNone {
|
||||
t.Fatalf("expected %s to be accepted, got %v", testCase.header, errCode)
|
||||
}
|
||||
if !headers.isSet {
|
||||
t.Fatal("expected conditional headers to be marked set")
|
||||
}
|
||||
parsed := headers.ifModifiedSince
|
||||
if testCase.header == s3_constants.IfUnmodifiedSince {
|
||||
parsed = headers.ifUnmodifiedSince
|
||||
}
|
||||
if !parsed.Equal(testCase.expected) {
|
||||
t.Fatalf("expected parsed time %v, got %v", testCase.expected, parsed)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateConditionalCopyHeadersAcceptsHTTPDateFormats(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
header string
|
||||
value string
|
||||
mtime int64 // source mtime chosen so the condition passes
|
||||
}{
|
||||
{
|
||||
name: "X-Amz-Copy-Source-If-Modified-Since RFC850",
|
||||
header: s3_constants.AmzCopySourceIfModifiedSince,
|
||||
value: "Sunday, 06-Nov-94 08:49:37 GMT",
|
||||
mtime: 1577836800, // 2020-01-01, modified after the 1994 header
|
||||
},
|
||||
{
|
||||
name: "X-Amz-Copy-Source-If-Unmodified-Since ANSIC",
|
||||
header: s3_constants.AmzCopySourceIfUnmodifiedSince,
|
||||
value: "Sun Nov 6 08:49:37 1994",
|
||||
mtime: 631152000, // 1990-01-01, not modified after the 1994 header
|
||||
},
|
||||
}
|
||||
|
||||
var s3a *S3ApiServer // method does not use the receiver
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
r := reqWith(map[string]string{testCase.header: testCase.value})
|
||||
entry := &filer_pb.Entry{Attributes: &filer_pb.FuseAttributes{Mtime: testCase.mtime}}
|
||||
|
||||
if errCode := s3a.validateConditionalCopyHeaders(r, entry); errCode != s3err.ErrNone {
|
||||
t.Fatalf("expected %s to be accepted, got %v", testCase.header, errCode)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildDeleteCondition(t *testing.T) {
|
||||
t.Run("no If-Match is unconditional", func(t *testing.T) {
|
||||
cond, ok := buildDeleteCondition(reqWith(nil))
|
||||
if !ok || cond != nil {
|
||||
t.Fatalf("want (nil, true), got (%v, %v)", cond, ok)
|
||||
}
|
||||
})
|
||||
t.Run("If-Match * to IF_EXISTS", func(t *testing.T) {
|
||||
cond, ok := buildDeleteCondition(reqWith(map[string]string{s3_constants.IfMatch: "*"}))
|
||||
if !ok {
|
||||
t.Fatal("want ok")
|
||||
}
|
||||
if c := oneClause(t, cond); c.Kind != filer_pb.WriteCondition_IF_EXISTS {
|
||||
t.Fatalf("kind = %v", c.Kind)
|
||||
}
|
||||
})
|
||||
t.Run("If-Match etag to IF_ETAG_MATCH", func(t *testing.T) {
|
||||
cond, ok := buildDeleteCondition(reqWith(map[string]string{s3_constants.IfMatch: `"e"`}))
|
||||
if !ok {
|
||||
t.Fatal("want ok")
|
||||
}
|
||||
if c := oneClause(t, cond); c.Kind != filer_pb.WriteCondition_IF_ETAG_MATCH || c.Etags[0] != "e" {
|
||||
t.Fatalf("clause = %+v", c)
|
||||
}
|
||||
})
|
||||
t.Run("weak etag falls back", func(t *testing.T) {
|
||||
if _, ok := buildDeleteCondition(reqWith(map[string]string{s3_constants.IfMatch: `W/"e"`})); ok {
|
||||
t.Fatal("weak etag must not take the fast path")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestSingleStrongETag(t *testing.T) {
|
||||
cases := []struct {
|
||||
in string
|
||||
want string
|
||||
single bool
|
||||
}{
|
||||
{`"abc"`, "abc", true},
|
||||
{` "abc" `, "abc", true},
|
||||
{`abc`, "abc", true},
|
||||
{`W/"abc"`, "", false},
|
||||
{`w/"abc"`, "", false},
|
||||
{`"a","b"`, "", false},
|
||||
}
|
||||
for _, c := range cases {
|
||||
got, single := singleStrongETag(c.in)
|
||||
if single != c.single || (single && got != c.want) {
|
||||
t.Errorf("singleStrongETag(%q) = (%q, %v), want (%q, %v)", c.in, got, single, c.want, c.single)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fakeTxnFiler is a minimal SeaweedFiler gRPC server that records ObjectTransaction
|
||||
// calls, standing in for a live filer that a routed write fails over to.
|
||||
type fakeTxnFiler struct {
|
||||
filer_pb.UnimplementedSeaweedFilerServer
|
||||
calls int32
|
||||
lastReq *filer_pb.ObjectTransactionRequest
|
||||
resp *filer_pb.ObjectTransactionResponse
|
||||
err error
|
||||
}
|
||||
|
||||
func (f *fakeTxnFiler) ObjectTransaction(ctx context.Context, req *filer_pb.ObjectTransactionRequest) (*filer_pb.ObjectTransactionResponse, error) {
|
||||
atomic.AddInt32(&f.calls, 1)
|
||||
f.lastReq = req
|
||||
if f.resp != nil || f.err != nil {
|
||||
return f.resp, f.err
|
||||
}
|
||||
return &filer_pb.ObjectTransactionResponse{}, nil
|
||||
}
|
||||
|
||||
// startFakeFiler serves impl on a random localhost port and returns the S3-style
|
||||
// filer address whose ToGrpcAddress resolves back to that port.
|
||||
func startFakeFiler(t *testing.T, impl filer_pb.SeaweedFilerServer) pb.ServerAddress {
|
||||
t.Helper()
|
||||
lis, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
srv := grpc.NewServer()
|
||||
filer_pb.RegisterSeaweedFilerServer(srv, impl)
|
||||
go srv.Serve(lis)
|
||||
t.Cleanup(srv.Stop)
|
||||
port := lis.Addr().(*net.TCPAddr).Port
|
||||
return pb.ServerAddress(fmt.Sprintf("127.0.0.1:1.%d", port))
|
||||
}
|
||||
|
||||
func TestRoutedDeleteSpecificVersionUsesWormCondition(t *testing.T) {
|
||||
versionId := "672a75d526ef29c79fe6b5680cad4a0d"
|
||||
versionFile := "v_" + versionId
|
||||
filer := &fakeTxnFiler{
|
||||
resp: &filer_pb.ObjectTransactionResponse{
|
||||
Error: "precondition failed",
|
||||
ErrorCode: filer_pb.FilerError_PRECONDITION_FAILED,
|
||||
},
|
||||
}
|
||||
owner := startFakeFiler(t, filer)
|
||||
s3a := &S3ApiServer{
|
||||
option: &S3ApiServerOption{
|
||||
BucketsPath: "/buckets",
|
||||
GrpcDialOption: grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
},
|
||||
}
|
||||
|
||||
if code := s3a.routedDeleteSpecificVersion(owner, "b", "obj", versionId, true, false); code != s3err.ErrAccessDenied {
|
||||
t.Fatalf("locked version delete returned %v, want %v", code, s3err.ErrAccessDenied)
|
||||
}
|
||||
|
||||
req := filer.lastReq
|
||||
if req == nil {
|
||||
t.Fatal("expected an ObjectTransaction request")
|
||||
}
|
||||
if req.LockKey != "/buckets/b/obj" {
|
||||
t.Fatalf("LockKey = %q", req.LockKey)
|
||||
}
|
||||
if req.ConditionKey != "/buckets/b/obj.versions/"+versionFile {
|
||||
t.Fatalf("ConditionKey = %q", req.ConditionKey)
|
||||
}
|
||||
if req.RouteKey != "s3.object.write:/buckets/b/obj" {
|
||||
t.Fatalf("RouteKey = %q", req.RouteKey)
|
||||
}
|
||||
|
||||
if len(req.Condition.GetClauses()) != 2 {
|
||||
t.Fatalf("condition clauses = %d, want 2", len(req.Condition.GetClauses()))
|
||||
}
|
||||
hold := req.Condition.GetClauses()[0]
|
||||
if hold.Kind != filer_pb.WriteCondition_IF_EXTENDED_NOT_EQUAL ||
|
||||
hold.ExtKey != s3_constants.ExtLegalHoldKey ||
|
||||
hold.ExtValue != s3_constants.LegalHoldOn {
|
||||
t.Fatalf("legal hold clause = %+v", hold)
|
||||
}
|
||||
retain := req.Condition.GetClauses()[1]
|
||||
if retain.Kind != filer_pb.WriteCondition_IF_EXTENDED_TIME_ELAPSED ||
|
||||
retain.ExtKey != s3_constants.ExtRetentionUntilDateKey ||
|
||||
retain.GateKey != "" {
|
||||
t.Fatalf("retention clause = %+v", retain)
|
||||
}
|
||||
|
||||
if len(req.Mutations) != 2 {
|
||||
t.Fatalf("mutations = %d, want 2", len(req.Mutations))
|
||||
}
|
||||
recompute := req.Mutations[0]
|
||||
if recompute.Type != filer_pb.ObjectMutation_RECOMPUTE_LATEST ||
|
||||
recompute.GetRecompute().GetExcludeName() != versionFile {
|
||||
t.Fatalf("recompute mutation = %+v", recompute)
|
||||
}
|
||||
deleteVersion := req.Mutations[1]
|
||||
if deleteVersion.Type != filer_pb.ObjectMutation_DELETE ||
|
||||
deleteVersion.Directory != "/buckets/b/obj.versions" ||
|
||||
deleteVersion.Name != versionFile ||
|
||||
!deleteVersion.IsDeleteData ||
|
||||
!deleteVersion.RemoveEmptyParent {
|
||||
t.Fatalf("delete mutation = %+v", deleteVersion)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWormDeleteConditionForGovernanceBypass(t *testing.T) {
|
||||
cond := wormDeleteCondition(true, true)
|
||||
if len(cond.GetClauses()) != 2 {
|
||||
t.Fatalf("condition clauses = %d, want 2", len(cond.GetClauses()))
|
||||
}
|
||||
retain := cond.GetClauses()[1]
|
||||
if retain.Kind != filer_pb.WriteCondition_IF_EXTENDED_TIME_ELAPSED ||
|
||||
retain.ExtKey != s3_constants.ExtRetentionUntilDateKey ||
|
||||
retain.GateKey != s3_constants.ExtObjectLockModeKey ||
|
||||
retain.GateValue != s3_constants.RetentionModeCompliance {
|
||||
t.Fatalf("retention clause = %+v", retain)
|
||||
}
|
||||
}
|
||||
|
||||
// closedFilerAddress returns an address whose gRPC port has nothing listening,
|
||||
// modeling a filer whose ring address is stale after a pod restart.
|
||||
func closedFilerAddress(t *testing.T) pb.ServerAddress {
|
||||
t.Helper()
|
||||
lis, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
port := lis.Addr().(*net.TCPAddr).Port
|
||||
lis.Close()
|
||||
return pb.ServerAddress(fmt.Sprintf("127.0.0.1:1.%d", port))
|
||||
}
|
||||
|
||||
// A routed write whose owner address is dead fails over to a live filer (which
|
||||
// forwards to the real owner by route_key) instead of hanging on the dead owner,
|
||||
// so an object write survives a filer pod IP change without an S3 gateway restart.
|
||||
func TestObjectTxnFailsOverStaleOwner(t *testing.T) {
|
||||
live := &fakeTxnFiler{}
|
||||
liveAddr := startFakeFiler(t, live)
|
||||
deadOwner := closedFilerAddress(t)
|
||||
|
||||
dialOption := grpc.WithTransportCredentials(insecure.NewCredentials())
|
||||
s3a := &S3ApiServer{
|
||||
option: &S3ApiServerOption{GrpcDialOption: dialOption},
|
||||
filerClient: wdclient.NewFilerClient([]pb.ServerAddress{liveAddr}, dialOption, ""),
|
||||
}
|
||||
req := &filer_pb.ObjectTransactionRequest{LockKey: "/buckets/b/o", RouteKey: "s3.object.write:/buckets/b/o"}
|
||||
|
||||
// Owner not yet flagged: the first attempt dials it, fails fast, then fails
|
||||
// over to the live filer and flags the owner unreachable.
|
||||
resp, err := s3a.objectTxnOnFiler(deadOwner, req)
|
||||
if err != nil {
|
||||
t.Fatalf("expected failover success, got %v", err)
|
||||
}
|
||||
if resp == nil || resp.Error != "" {
|
||||
t.Fatalf("unexpected response %+v", resp)
|
||||
}
|
||||
if got := atomic.LoadInt32(&live.calls); got != 1 {
|
||||
t.Fatalf("live filer calls = %d, want 1", got)
|
||||
}
|
||||
if !s3a.ownerRecentlyUnreachable(deadOwner) {
|
||||
t.Fatal("dead owner should be flagged unreachable after the failed dial")
|
||||
}
|
||||
|
||||
// Once flagged, the owner is skipped entirely and the write still lands.
|
||||
if _, err := s3a.objectTxnOnFiler(deadOwner, req); err != nil {
|
||||
t.Fatalf("expected success while owner flagged, got %v", err)
|
||||
}
|
||||
if got := atomic.LoadInt32(&live.calls); got != 2 {
|
||||
t.Fatalf("live filer calls = %d, want 2", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRouteWriteCondition(t *testing.T) {
|
||||
// Unconditional routes either way.
|
||||
if c, ok := routeWriteCondition(reqWith(nil), false); !ok || c != nil {
|
||||
t.Fatalf("overwrite unconditional: got (%v,%v)", c, ok)
|
||||
}
|
||||
if c, ok := routeWriteCondition(reqWith(nil), true); !ok || c != nil {
|
||||
t.Fatalf("unique unconditional: got (%v,%v)", c, ok)
|
||||
}
|
||||
// An overwrite carries a reducible condition.
|
||||
if c, ok := routeWriteCondition(reqWith(map[string]string{s3_constants.IfMatch: `"e"`}), false); !ok || c == nil {
|
||||
t.Fatalf("overwrite conditional should route: got (%v,%v)", c, ok)
|
||||
}
|
||||
// A conditional unique (versioned) write bails to the lock path.
|
||||
if _, ok := routeWriteCondition(reqWith(map[string]string{s3_constants.IfMatch: `"e"`}), true); ok {
|
||||
t.Fatal("conditional unique write must not route")
|
||||
}
|
||||
// A non-reducible condition bails regardless.
|
||||
if _, ok := routeWriteCondition(reqWith(map[string]string{s3_constants.IfMatch: `W/"e"`}), false); ok {
|
||||
t.Fatal("weak etag must not route")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user