Files
upstream-seaweedfs/weed/replication/sink/azuresink/azure_sink_test.go
upstream-mirror 89f5be005d
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
snapshot of https://github.com/seaweedfs/seaweedfs.git (master, 2026-09-16; blobs > 131072B omitted)
2026-09-16 03:23:42 +05:00

477 lines
13 KiB
Go

package azuresink
import (
"context"
"os"
"testing"
"time"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
)
// MockConfiguration for testing
type mockConfiguration struct {
values map[string]interface{}
}
func newMockConfiguration() *mockConfiguration {
return &mockConfiguration{
values: make(map[string]interface{}),
}
}
func (m *mockConfiguration) GetString(key string) string {
if v, ok := m.values[key]; ok {
return v.(string)
}
return ""
}
func (m *mockConfiguration) GetBool(key string) bool {
if v, ok := m.values[key]; ok {
return v.(bool)
}
return false
}
func (m *mockConfiguration) GetInt(key string) int {
if v, ok := m.values[key]; ok {
return v.(int)
}
return 0
}
func (m *mockConfiguration) GetInt64(key string) int64 {
if v, ok := m.values[key]; ok {
return v.(int64)
}
return 0
}
func (m *mockConfiguration) GetFloat64(key string) float64 {
if v, ok := m.values[key]; ok {
return v.(float64)
}
return 0.0
}
func (m *mockConfiguration) GetStringSlice(key string) []string {
if v, ok := m.values[key]; ok {
return v.([]string)
}
return nil
}
func (m *mockConfiguration) SetDefault(key string, value interface{}) {
if _, exists := m.values[key]; !exists {
m.values[key] = value
}
}
// Test the AzureSink interface implementation
func TestAzureSinkInterface(t *testing.T) {
sink := &AzureSink{}
if sink.GetName() != "azure" {
t.Errorf("Expected name 'azure', got '%s'", sink.GetName())
}
// Test directory setting
sink.dir = "/test/dir"
if sink.GetSinkToDirectory() != "/test/dir" {
t.Errorf("Expected directory '/test/dir', got '%s'", sink.GetSinkToDirectory())
}
// Test incremental setting
sink.isIncremental = true
if !sink.IsIncremental() {
t.Error("Expected isIncremental to be true")
}
}
// Test Azure sink initialization
func TestAzureSinkInitialization(t *testing.T) {
accountName := os.Getenv("AZURE_STORAGE_ACCOUNT")
accountKey := os.Getenv("AZURE_STORAGE_ACCESS_KEY")
testContainer := os.Getenv("AZURE_TEST_CONTAINER")
if accountName == "" || accountKey == "" {
t.Skip("Skipping Azure sink test: AZURE_STORAGE_ACCOUNT or AZURE_STORAGE_ACCESS_KEY not set")
}
if testContainer == "" {
testContainer = "seaweedfs-test"
}
sink := &AzureSink{}
err := sink.initialize(accountName, accountKey, "", "", testContainer, "/test")
if err != nil {
t.Fatalf("Failed to initialize Azure sink: %v", err)
}
if sink.container != testContainer {
t.Errorf("Expected container '%s', got '%s'", testContainer, sink.container)
}
if sink.dir != "/test" {
t.Errorf("Expected dir '/test', got '%s'", sink.dir)
}
if sink.client == nil {
t.Error("Expected client to be initialized")
}
}
// Test configuration-based initialization
func TestAzureSinkInitializeFromConfig(t *testing.T) {
accountName := os.Getenv("AZURE_STORAGE_ACCOUNT")
accountKey := os.Getenv("AZURE_STORAGE_ACCESS_KEY")
testContainer := os.Getenv("AZURE_TEST_CONTAINER")
if accountName == "" || accountKey == "" {
t.Skip("Skipping Azure sink config test: AZURE_STORAGE_ACCOUNT or AZURE_STORAGE_ACCESS_KEY not set")
}
if testContainer == "" {
testContainer = "seaweedfs-test"
}
config := newMockConfiguration()
config.values["azure.account_name"] = accountName
config.values["azure.account_key"] = accountKey
config.values["azure.container"] = testContainer
config.values["azure.directory"] = "/test"
config.values["azure.is_incremental"] = true
sink := &AzureSink{}
err := sink.Initialize(config, "azure.")
if err != nil {
t.Fatalf("Failed to initialize from config: %v", err)
}
if !sink.IsIncremental() {
t.Error("Expected incremental to be true")
}
}
// Test cleanKey function
func TestCleanKey(t *testing.T) {
tests := []struct {
input string
expected string
}{
{"/test/file.txt", "test/file.txt"},
{"test/file.txt", "test/file.txt"},
{"/", ""},
{"", ""},
{"/a/b/c", "a/b/c"},
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
result := cleanKey(tt.input)
if result != tt.expected {
t.Errorf("cleanKey(%q) = %q, want %q", tt.input, result, tt.expected)
}
})
}
}
// Test entry operations (requires valid credentials)
func TestAzureSinkEntryOperations(t *testing.T) {
accountName := os.Getenv("AZURE_STORAGE_ACCOUNT")
accountKey := os.Getenv("AZURE_STORAGE_ACCESS_KEY")
testContainer := os.Getenv("AZURE_TEST_CONTAINER")
if accountName == "" || accountKey == "" {
t.Skip("Skipping Azure sink entry test: credentials not set")
}
if testContainer == "" {
testContainer = "seaweedfs-test"
}
sink := &AzureSink{}
err := sink.initialize(accountName, accountKey, "", "", testContainer, "/test")
if err != nil {
t.Fatalf("Failed to initialize: %v", err)
}
// Test CreateEntry with directory (should be no-op)
t.Run("CreateDirectory", func(t *testing.T) {
entry := &filer_pb.Entry{
IsDirectory: true,
}
err := sink.CreateEntry("/test/dir", entry, nil)
if err != nil {
t.Errorf("CreateEntry for directory should not error: %v", err)
}
})
// Test CreateEntry with file
testKey := "/test-sink-file-" + time.Now().Format("20060102-150405") + ".txt"
t.Run("CreateFile", func(t *testing.T) {
entry := &filer_pb.Entry{
IsDirectory: false,
Content: []byte("Test content for Azure sink"),
Attributes: &filer_pb.FuseAttributes{
Mtime: time.Now().Unix(),
},
}
err := sink.CreateEntry(testKey, entry, nil)
if err != nil {
t.Fatalf("Failed to create entry: %v", err)
}
})
// Test UpdateEntry
t.Run("UpdateEntry", func(t *testing.T) {
oldEntry := &filer_pb.Entry{
Content: []byte("Old content"),
}
newEntry := &filer_pb.Entry{
Content: []byte("New content for update test"),
Attributes: &filer_pb.FuseAttributes{
Mtime: time.Now().Unix(),
},
}
found, err := sink.UpdateEntry(testKey, oldEntry, "/test", newEntry, false, nil)
if err != nil {
t.Fatalf("Failed to update entry: %v", err)
}
if !found {
t.Error("Expected found to be true")
}
})
// Test DeleteEntry
t.Run("DeleteFile", func(t *testing.T) {
err := sink.DeleteEntry(testKey, false, false, nil)
if err != nil {
t.Fatalf("Failed to delete entry: %v", err)
}
})
// Test DeleteEntry with directory marker
testDirKey := "/test-dir-" + time.Now().Format("20060102-150405")
t.Run("DeleteDirectory", func(t *testing.T) {
// First create a directory marker
entry := &filer_pb.Entry{
IsDirectory: false,
Content: []byte(""),
}
err := sink.CreateEntry(testDirKey+"/", entry, nil)
if err != nil {
t.Logf("Warning: Failed to create directory marker: %v", err)
}
// Then delete it
err = sink.DeleteEntry(testDirKey, true, false, nil)
if err != nil {
t.Logf("Warning: Failed to delete directory: %v", err)
}
})
}
// Test CreateEntry with precondition (IfUnmodifiedSince)
func TestAzureSinkPrecondition(t *testing.T) {
accountName := os.Getenv("AZURE_STORAGE_ACCOUNT")
accountKey := os.Getenv("AZURE_STORAGE_ACCESS_KEY")
testContainer := os.Getenv("AZURE_TEST_CONTAINER")
if accountName == "" || accountKey == "" {
t.Skip("Skipping Azure sink precondition test: credentials not set")
}
if testContainer == "" {
testContainer = "seaweedfs-test"
}
sink := &AzureSink{}
err := sink.initialize(accountName, accountKey, "", "", testContainer, "/test")
if err != nil {
t.Fatalf("Failed to initialize: %v", err)
}
testKey := "/test-precondition-" + time.Now().Format("20060102-150405") + ".txt"
// Create initial entry
entry := &filer_pb.Entry{
Content: []byte("Initial content"),
Attributes: &filer_pb.FuseAttributes{
Mtime: time.Now().Unix(),
},
}
err = sink.CreateEntry(testKey, entry, nil)
if err != nil {
t.Fatalf("Failed to create initial entry: %v", err)
}
// Try to create again with old mtime (should be skipped due to precondition)
oldEntry := &filer_pb.Entry{
Content: []byte("Should not overwrite"),
Attributes: &filer_pb.FuseAttributes{
Mtime: time.Now().Add(-1 * time.Hour).Unix(), // Old timestamp
},
}
err = sink.CreateEntry(testKey, oldEntry, nil)
// Should either succeed (skip) or fail with precondition error
if err != nil {
t.Logf("Create with old mtime: %v (expected)", err)
}
// Clean up
sink.DeleteEntry(testKey, false, false, nil)
}
// Helper function to get blob content length with timeout
func getBlobContentLength(t *testing.T, sink *AzureSink, key string) int64 {
t.Helper()
containerClient := sink.client.ServiceClient().NewContainerClient(sink.container)
blobClient := containerClient.NewAppendBlobClient(cleanKey(key))
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
props, err := blobClient.GetProperties(ctx, nil)
if err != nil {
t.Fatalf("Failed to get blob properties: %v", err)
}
if props.ContentLength == nil {
return 0
}
return *props.ContentLength
}
// Test that repeated creates don't result in zero-byte files (regression test for critical bug)
func TestAzureSinkIdempotentCreate(t *testing.T) {
accountName := os.Getenv("AZURE_STORAGE_ACCOUNT")
accountKey := os.Getenv("AZURE_STORAGE_ACCESS_KEY")
testContainer := os.Getenv("AZURE_TEST_CONTAINER")
if accountName == "" || accountKey == "" {
t.Skip("Skipping Azure sink idempotent create test: credentials not set")
}
if testContainer == "" {
testContainer = "seaweedfs-test"
}
sink := &AzureSink{}
err := sink.initialize(accountName, accountKey, "", "", testContainer, "/test")
if err != nil {
t.Fatalf("Failed to initialize: %v", err)
}
testKey := "/test-idempotent-" + time.Now().Format("20060102-150405") + ".txt"
testContent := []byte("This is test content that should never be empty!")
// Use fixed time reference for deterministic behavior
testTime := time.Now()
// Clean up at the end
defer sink.DeleteEntry(testKey, false, false, nil)
// Test 1: Create a file with content
t.Run("FirstCreate", func(t *testing.T) {
entry := &filer_pb.Entry{
Content: testContent,
Attributes: &filer_pb.FuseAttributes{
Mtime: testTime.Unix(),
},
}
err := sink.CreateEntry(testKey, entry, nil)
if err != nil {
t.Fatalf("Failed to create entry: %v", err)
}
// Verify the file has content (not zero bytes)
contentLength := getBlobContentLength(t, sink, testKey)
if contentLength == 0 {
t.Errorf("File has zero bytes after creation! Expected %d bytes", len(testContent))
} else if contentLength != int64(len(testContent)) {
t.Errorf("File size mismatch: expected %d, got %d", len(testContent), contentLength)
} else {
t.Logf("File created with correct size: %d bytes", contentLength)
}
})
// Test 2: Create the same file again (idempotent operation - simulates replication running multiple times)
// This is where the zero-byte bug occurred: blob existed, precondition failed, returned early without writing data
t.Run("IdempotentCreate", func(t *testing.T) {
entry := &filer_pb.Entry{
Content: testContent,
Attributes: &filer_pb.FuseAttributes{
Mtime: testTime.Add(1 * time.Second).Unix(), // Slightly newer mtime
},
}
err := sink.CreateEntry(testKey, entry, nil)
if err != nil {
t.Fatalf("Failed on idempotent create: %v", err)
}
// CRITICAL: Verify the file STILL has content (not zero bytes)
contentLength := getBlobContentLength(t, sink, testKey)
if contentLength == 0 {
t.Errorf("ZERO-BYTE BUG: File became empty after idempotent create! Expected %d bytes", len(testContent))
} else if contentLength < int64(len(testContent)) {
t.Errorf("File lost content: expected at least %d bytes, got %d", len(testContent), contentLength)
} else {
t.Logf("File still has content after idempotent create: %d bytes", contentLength)
}
})
// Test 3: Try creating with older mtime (should skip but not leave zero bytes)
t.Run("CreateWithOlderMtime", func(t *testing.T) {
entry := &filer_pb.Entry{
Content: []byte("This content should be skipped"),
Attributes: &filer_pb.FuseAttributes{
Mtime: testTime.Add(-1 * time.Hour).Unix(), // Older timestamp
},
}
err := sink.CreateEntry(testKey, entry, nil)
// Should succeed by skipping (no error expected)
if err != nil {
t.Fatalf("Create with older mtime should be skipped and return no error, but got: %v", err)
}
// Verify file STILL has content
contentLength := getBlobContentLength(t, sink, testKey)
if contentLength == 0 {
t.Errorf("File became empty after create with older mtime!")
} else {
t.Logf("File preserved content despite older mtime: %d bytes", contentLength)
}
})
}
// Benchmark tests
func BenchmarkCleanKey(b *testing.B) {
keys := []string{
"/simple/path.txt",
"no/leading/slash.txt",
"/",
"/complex/path/with/many/segments/file.txt",
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
cleanKey(keys[i%len(keys)])
}
}
// Test error handling with invalid credentials
func TestAzureSinkInvalidCredentials(t *testing.T) {
sink := &AzureSink{}
err := sink.initialize("invalid-account", "aW52YWxpZGtleQ==", "", "", "test-container", "/test")
if err != nil {
t.Skip("Invalid credentials correctly rejected at initialization")
}
// If initialization succeeded, operations should fail
entry := &filer_pb.Entry{
Content: []byte("test"),
}
err = sink.CreateEntry("/test.txt", entry, nil)
if err == nil {
t.Log("Expected error with invalid credentials, but got none (might be cached)")
}
}