Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

s3tables: enhance test robustness and resilience

Chris Ludfdace9a1358
diff --git a/test/s3/iam/s3_iam_distributed_test.go b/test/s3/iam/s3_iam_distributed_test.go
index d6bd7ce3ad..7452858f80 100644
--- a/test/s3/iam/s3_iam_distributed_test.go
+++ b/test/s3/iam/s3_iam_distributed_test.go
@@ -129,6 +129,7 @@ func TestS3IAMDistributedTests(t *testing.T) {
errorMsg := err.Error()
return strings.Contains(errorMsg, "timeout") ||
strings.Contains(errorMsg, "connection reset") ||
+ strings.Contains(errorMsg, "connection refused") ||
strings.Contains(errorMsg, "temporary failure") ||
strings.Contains(errorMsg, "TooManyRequests") ||
strings.Contains(errorMsg, "ServiceUnavailable") ||
diff --git a/test/s3tables/s3tables_integration_test.go b/test/s3tables/s3tables_integration_test.go
index 56a5172662..27eb953d58 100644
--- a/test/s3tables/s3tables_integration_test.go
+++ b/test/s3tables/s3tables_integration_test.go
@@ -3,7 +3,6 @@ package s3tables
import (
"context"
"fmt"
- "math/rand"
"net"
"net/http"
"os"
@@ -12,6 +11,7 @@ import (
"testing"
"time"
+ cryptorand "crypto/rand"
"sync"
"github.com/stretchr/testify/assert"
@@ -495,10 +495,12 @@ func waitForS3Ready(endpoint string, timeout time.Duration) error {
// randomString generates a random string for unique naming
func randomString(length int) string {
const charset = "abcdefghijklmnopqrstuvwxyz0123456789"
- rng := rand.New(rand.NewSource(time.Now().UnixNano() + rand.Int63()))
b := make([]byte, length)
+ if _, err := cryptorand.Read(b); err != nil {
+ panic("failed to generate random string: " + err.Error())
+ }
for i := range b {
- b[i] = charset[rng.Intn(len(charset))]
+ b[i] = charset[int(b[i])%len(charset)]
}
return string(b)
}