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
test/foundationdb/foundationdb_concurrent_test.go
Normal file
444
test/foundationdb/foundationdb_concurrent_test.go
Normal file
@@ -0,0 +1,444 @@
|
||||
//go:build foundationdb
|
||||
|
||||
package foundationdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/filer"
|
||||
"github.com/seaweedfs/seaweedfs/weed/filer/foundationdb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
)
|
||||
|
||||
func TestFoundationDBStore_ConcurrentInserts(t *testing.T) {
|
||||
store := createTestStore(t)
|
||||
defer store.Shutdown()
|
||||
|
||||
ctx := context.Background()
|
||||
numGoroutines := 10
|
||||
entriesPerGoroutine := 100
|
||||
|
||||
var wg sync.WaitGroup
|
||||
errors := make(chan error, numGoroutines*entriesPerGoroutine)
|
||||
|
||||
// Launch concurrent insert operations
|
||||
for g := 0; g < numGoroutines; g++ {
|
||||
wg.Add(1)
|
||||
go func(goroutineID int) {
|
||||
defer wg.Done()
|
||||
|
||||
for i := 0; i < entriesPerGoroutine; i++ {
|
||||
entry := &filer.Entry{
|
||||
FullPath: util.NewFullPath("/concurrent", fmt.Sprintf("g%d_file%d.txt", goroutineID, i)),
|
||||
Attr: filer.Attr{
|
||||
Mode: 0644,
|
||||
Uid: uint32(goroutineID),
|
||||
Gid: 1000,
|
||||
Mtime: time.Now(),
|
||||
},
|
||||
}
|
||||
|
||||
err := store.InsertEntry(ctx, entry)
|
||||
if err != nil {
|
||||
errors <- fmt.Errorf("goroutine %d, entry %d: %v", goroutineID, i, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}(g)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(errors)
|
||||
|
||||
// Check for errors
|
||||
for err := range errors {
|
||||
t.Errorf("Concurrent insert error: %v", err)
|
||||
}
|
||||
|
||||
// Verify all entries were inserted
|
||||
expectedTotal := numGoroutines * entriesPerGoroutine
|
||||
actualCount := 0
|
||||
|
||||
_, err := store.ListDirectoryEntries(ctx, "/concurrent", "", true, 10000, func(entry *filer.Entry) (bool, error) {
|
||||
actualCount++
|
||||
return true, nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("ListDirectoryEntries failed: %v", err)
|
||||
}
|
||||
|
||||
if actualCount != expectedTotal {
|
||||
t.Errorf("Expected %d entries, found %d", expectedTotal, actualCount)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFoundationDBStore_ConcurrentReadsAndWrites(t *testing.T) {
|
||||
store := createTestStore(t)
|
||||
defer store.Shutdown()
|
||||
|
||||
ctx := context.Background()
|
||||
numReaders := 5
|
||||
numWriters := 5
|
||||
operationsPerGoroutine := 50
|
||||
testFile := "/concurrent/rw_test_file.txt"
|
||||
|
||||
// Insert initial file
|
||||
initialEntry := &filer.Entry{
|
||||
FullPath: testFile,
|
||||
Attr: filer.Attr{
|
||||
Mode: 0644,
|
||||
Uid: 1000,
|
||||
Gid: 1000,
|
||||
Mtime: time.Now(),
|
||||
},
|
||||
}
|
||||
err := store.InsertEntry(ctx, initialEntry)
|
||||
if err != nil {
|
||||
t.Fatalf("Initial InsertEntry failed: %v", err)
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
errors := make(chan error, (numReaders+numWriters)*operationsPerGoroutine)
|
||||
|
||||
// Launch reader goroutines
|
||||
for r := 0; r < numReaders; r++ {
|
||||
wg.Add(1)
|
||||
go func(readerID int) {
|
||||
defer wg.Done()
|
||||
|
||||
for i := 0; i < operationsPerGoroutine; i++ {
|
||||
_, err := store.FindEntry(ctx, testFile)
|
||||
if err != nil {
|
||||
errors <- fmt.Errorf("reader %d, operation %d: %v", readerID, i, err)
|
||||
return
|
||||
}
|
||||
|
||||
// Small delay to allow interleaving with writes
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
}
|
||||
}(r)
|
||||
}
|
||||
|
||||
// Launch writer goroutines
|
||||
for w := 0; w < numWriters; w++ {
|
||||
wg.Add(1)
|
||||
go func(writerID int) {
|
||||
defer wg.Done()
|
||||
|
||||
for i := 0; i < operationsPerGoroutine; i++ {
|
||||
entry := &filer.Entry{
|
||||
FullPath: testFile,
|
||||
Attr: filer.Attr{
|
||||
Mode: 0644,
|
||||
Uid: uint32(writerID + 1000),
|
||||
Gid: uint32(i),
|
||||
Mtime: time.Now(),
|
||||
},
|
||||
}
|
||||
|
||||
err := store.UpdateEntry(ctx, entry)
|
||||
if err != nil {
|
||||
errors <- fmt.Errorf("writer %d, operation %d: %v", writerID, i, err)
|
||||
return
|
||||
}
|
||||
|
||||
// Small delay to allow interleaving with reads
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
}
|
||||
}(w)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(errors)
|
||||
|
||||
// Check for errors
|
||||
for err := range errors {
|
||||
t.Errorf("Concurrent read/write error: %v", err)
|
||||
}
|
||||
|
||||
// Verify final state
|
||||
finalEntry, err := store.FindEntry(ctx, testFile)
|
||||
if err != nil {
|
||||
t.Fatalf("Final FindEntry failed: %v", err)
|
||||
}
|
||||
|
||||
if finalEntry.FullPath != testFile {
|
||||
t.Errorf("Expected final path %s, got %s", testFile, finalEntry.FullPath)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFoundationDBStore_ConcurrentTransactions(t *testing.T) {
|
||||
store := createTestStore(t)
|
||||
defer store.Shutdown()
|
||||
|
||||
ctx := context.Background()
|
||||
numTransactions := 5
|
||||
entriesPerTransaction := 10
|
||||
|
||||
var wg sync.WaitGroup
|
||||
errors := make(chan error, numTransactions)
|
||||
successfulTx := make(chan int, numTransactions)
|
||||
|
||||
// Launch concurrent transactions
|
||||
for tx := 0; tx < numTransactions; tx++ {
|
||||
wg.Add(1)
|
||||
go func(txID int) {
|
||||
defer wg.Done()
|
||||
|
||||
// Note: FoundationDB has optimistic concurrency control
|
||||
// Some transactions may need to retry due to conflicts
|
||||
maxRetries := 3
|
||||
for attempt := 0; attempt < maxRetries; attempt++ {
|
||||
txCtx, err := store.BeginTransaction(ctx)
|
||||
if err != nil {
|
||||
if attempt == maxRetries-1 {
|
||||
errors <- fmt.Errorf("tx %d: failed to begin after %d attempts: %v", txID, maxRetries, err)
|
||||
}
|
||||
time.Sleep(time.Duration(attempt+1) * 10 * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
|
||||
// Insert multiple entries in transaction
|
||||
success := true
|
||||
for i := 0; i < entriesPerTransaction; i++ {
|
||||
entry := &filer.Entry{
|
||||
FullPath: util.NewFullPath("/transactions", fmt.Sprintf("tx%d_file%d.txt", txID, i)),
|
||||
Attr: filer.Attr{
|
||||
Mode: 0644,
|
||||
Uid: uint32(txID),
|
||||
Gid: uint32(i),
|
||||
Mtime: time.Now(),
|
||||
},
|
||||
}
|
||||
|
||||
err = store.InsertEntry(txCtx, entry)
|
||||
if err != nil {
|
||||
errors <- fmt.Errorf("tx %d, entry %d: insert failed: %v", txID, i, err)
|
||||
store.RollbackTransaction(txCtx)
|
||||
success = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if success {
|
||||
err = store.CommitTransaction(txCtx)
|
||||
if err != nil {
|
||||
if attempt == maxRetries-1 {
|
||||
errors <- fmt.Errorf("tx %d: commit failed after %d attempts: %v", txID, maxRetries, err)
|
||||
}
|
||||
time.Sleep(time.Duration(attempt+1) * 10 * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
successfulTx <- txID
|
||||
return
|
||||
}
|
||||
}
|
||||
}(tx)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(errors)
|
||||
close(successfulTx)
|
||||
|
||||
// Check for errors
|
||||
for err := range errors {
|
||||
t.Errorf("Concurrent transaction error: %v", err)
|
||||
}
|
||||
|
||||
// Count successful transactions
|
||||
successCount := 0
|
||||
successfulTxIDs := make([]int, 0)
|
||||
for txID := range successfulTx {
|
||||
successCount++
|
||||
successfulTxIDs = append(successfulTxIDs, txID)
|
||||
}
|
||||
|
||||
t.Logf("Successful transactions: %d/%d (IDs: %v)", successCount, numTransactions, successfulTxIDs)
|
||||
|
||||
// Verify entries from successful transactions
|
||||
totalExpectedEntries := successCount * entriesPerTransaction
|
||||
actualCount := 0
|
||||
|
||||
_, err := store.ListDirectoryEntries(ctx, "/transactions", "", true, 10000, func(entry *filer.Entry) (bool, error) {
|
||||
actualCount++
|
||||
return true, nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("ListDirectoryEntries failed: %v", err)
|
||||
}
|
||||
|
||||
if actualCount != totalExpectedEntries {
|
||||
t.Errorf("Expected %d entries from successful transactions, found %d", totalExpectedEntries, actualCount)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFoundationDBStore_ConcurrentDirectoryOperations(t *testing.T) {
|
||||
store := createTestStore(t)
|
||||
defer store.Shutdown()
|
||||
|
||||
ctx := context.Background()
|
||||
numWorkers := 10
|
||||
directoriesPerWorker := 20
|
||||
filesPerDirectory := 5
|
||||
|
||||
var wg sync.WaitGroup
|
||||
errors := make(chan error, numWorkers*directoriesPerWorker*filesPerDirectory)
|
||||
|
||||
// Launch workers that create directories with files
|
||||
for w := 0; w < numWorkers; w++ {
|
||||
wg.Add(1)
|
||||
go func(workerID int) {
|
||||
defer wg.Done()
|
||||
|
||||
for d := 0; d < directoriesPerWorker; d++ {
|
||||
dirPath := fmt.Sprintf("/worker%d/dir%d", workerID, d)
|
||||
|
||||
// Create files in directory
|
||||
for f := 0; f < filesPerDirectory; f++ {
|
||||
entry := &filer.Entry{
|
||||
FullPath: util.NewFullPath(dirPath, fmt.Sprintf("file%d.txt", f)),
|
||||
Attr: filer.Attr{
|
||||
Mode: 0644,
|
||||
Uid: uint32(workerID),
|
||||
Gid: uint32(d),
|
||||
Mtime: time.Now(),
|
||||
},
|
||||
}
|
||||
|
||||
err := store.InsertEntry(ctx, entry)
|
||||
if err != nil {
|
||||
errors <- fmt.Errorf("worker %d, dir %d, file %d: %v", workerID, d, f, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}(w)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(errors)
|
||||
|
||||
// Check for errors
|
||||
for err := range errors {
|
||||
t.Errorf("Concurrent directory operation error: %v", err)
|
||||
}
|
||||
|
||||
// Verify directory structure
|
||||
for w := 0; w < numWorkers; w++ {
|
||||
for d := 0; d < directoriesPerWorker; d++ {
|
||||
dirPath := fmt.Sprintf("/worker%d/dir%d", w, d)
|
||||
|
||||
fileCount := 0
|
||||
_, err := store.ListDirectoryEntries(ctx, dirPath, "", true, 1000, func(entry *filer.Entry) (bool, error) {
|
||||
fileCount++
|
||||
return true, nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("ListDirectoryEntries failed for %s: %v", dirPath, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if fileCount != filesPerDirectory {
|
||||
t.Errorf("Expected %d files in %s, found %d", filesPerDirectory, dirPath, fileCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFoundationDBStore_ConcurrentKVOperations(t *testing.T) {
|
||||
store := createTestStore(t)
|
||||
defer store.Shutdown()
|
||||
|
||||
ctx := context.Background()
|
||||
numWorkers := 8
|
||||
operationsPerWorker := 100
|
||||
|
||||
var wg sync.WaitGroup
|
||||
errors := make(chan error, numWorkers*operationsPerWorker)
|
||||
|
||||
// Launch workers performing KV operations
|
||||
for w := 0; w < numWorkers; w++ {
|
||||
wg.Add(1)
|
||||
go func(workerID int) {
|
||||
defer wg.Done()
|
||||
|
||||
for i := 0; i < operationsPerWorker; i++ {
|
||||
key := []byte(fmt.Sprintf("worker%d_key%d", workerID, i))
|
||||
value := []byte(fmt.Sprintf("worker%d_value%d_timestamp%d", workerID, i, time.Now().UnixNano()))
|
||||
|
||||
// Put operation
|
||||
err := store.KvPut(ctx, key, value)
|
||||
if err != nil {
|
||||
errors <- fmt.Errorf("worker %d, operation %d: KvPut failed: %v", workerID, i, err)
|
||||
continue
|
||||
}
|
||||
|
||||
// Get operation
|
||||
retrievedValue, err := store.KvGet(ctx, key)
|
||||
if err != nil {
|
||||
errors <- fmt.Errorf("worker %d, operation %d: KvGet failed: %v", workerID, i, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if string(retrievedValue) != string(value) {
|
||||
errors <- fmt.Errorf("worker %d, operation %d: value mismatch", workerID, i)
|
||||
continue
|
||||
}
|
||||
|
||||
// Delete operation (for some keys)
|
||||
if i%5 == 0 {
|
||||
err = store.KvDelete(ctx, key)
|
||||
if err != nil {
|
||||
errors <- fmt.Errorf("worker %d, operation %d: KvDelete failed: %v", workerID, i, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}(w)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
close(errors)
|
||||
|
||||
// Check for errors
|
||||
errorCount := 0
|
||||
for err := range errors {
|
||||
t.Errorf("Concurrent KV operation error: %v", err)
|
||||
errorCount++
|
||||
}
|
||||
|
||||
if errorCount > 0 {
|
||||
t.Errorf("Total errors in concurrent KV operations: %d", errorCount)
|
||||
}
|
||||
}
|
||||
|
||||
func createTestStore(t *testing.T) *foundationdb.FoundationDBStore {
|
||||
// Skip test if FoundationDB cluster file doesn't exist
|
||||
clusterFile := os.Getenv("FDB_CLUSTER_FILE")
|
||||
if clusterFile == "" {
|
||||
clusterFile = "/var/fdb/config/fdb.cluster"
|
||||
}
|
||||
|
||||
if _, err := os.Stat(clusterFile); os.IsNotExist(err) {
|
||||
t.Skip("FoundationDB cluster file not found, skipping test")
|
||||
}
|
||||
|
||||
config := util.GetViper()
|
||||
config.Set("foundationdb.cluster_file", clusterFile)
|
||||
config.Set("foundationdb.api_version", 740)
|
||||
config.Set("foundationdb.timeout", "10s")
|
||||
config.Set("foundationdb.max_retry_delay", "2s")
|
||||
config.Set("foundationdb.directory_prefix", fmt.Sprintf("seaweedfs_concurrent_test_%d", time.Now().UnixNano()))
|
||||
|
||||
store := &foundationdb.FoundationDBStore{}
|
||||
err := store.Initialize(config, "foundationdb.")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to initialize FoundationDB store: %v", err)
|
||||
}
|
||||
|
||||
return store
|
||||
}
|
||||
Reference in New Issue
Block a user