mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-19 05:36:58 +00:00
- Implement TestMain-based auto server management for all 13 S3 test suites - Fix import paths to use full module names instead of relative imports - Update Makefiles to use correct build targets and binary detection - Enhance testutil with improved binary discovery and credential handling - Fix test session creation to use explicit AWS credentials - Validate infrastructure with successful test execution - Update documentation with implementation details and usage instructions All S3 test suites now support: - make test-with-server: Auto-managed server lifecycle - make test-external: Use existing server (for CI/CD) - Consistent build and dependency checking - Proper error handling and logging
52 lines
1.5 KiB
Go
52 lines
1.5 KiB
Go
package basic
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/seaweedfs/seaweedfs/test/s3/testutil"
|
|
)
|
|
|
|
var testServer *testutil.TestServer
|
|
|
|
// TestMain sets up and tears down the test environment using weed mini
|
|
func TestMain(m *testing.M) {
|
|
var exitCode int
|
|
|
|
fmt.Println("TestMain: Starting test setup...")
|
|
|
|
// Check if we should manage the server or use an existing one
|
|
if os.Getenv("USE_EXTERNAL_SERVER") != "true" {
|
|
// Start server using weed mini
|
|
fmt.Println("TestMain: Starting weed mini server...")
|
|
config := testutil.DefaultServerConfig(nil)
|
|
config.AccessKey = "some_access_key1"
|
|
config.SecretKey = "some_secret_key1"
|
|
|
|
fmt.Println("TestMain: Setting environment variables...")
|
|
// Set AWS credentials for tests
|
|
os.Setenv("AWS_ACCESS_KEY_ID", config.AccessKey)
|
|
os.Setenv("AWS_SECRET_ACCESS_KEY", config.SecretKey)
|
|
os.Setenv("AWS_REGION", "us-east-1")
|
|
fmt.Printf("TestMain: Set AWS_ACCESS_KEY_ID=%s, AWS_SECRET_ACCESS_KEY=%s, AWS_REGION=us-east-1\n",
|
|
config.AccessKey, strings.Repeat("*", len(config.SecretKey)))
|
|
|
|
var err error
|
|
testServer, err = testutil.StartServer(config)
|
|
if err != nil {
|
|
fmt.Printf("TestMain: ERROR - Failed to start test server: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
fmt.Println("TestMain: Server started successfully")
|
|
defer testServer.Stop()
|
|
}
|
|
|
|
// Run tests
|
|
fmt.Println("TestMain: Running tests...")
|
|
exitCode = m.Run()
|
|
fmt.Printf("TestMain: Tests completed with exit code %d\n", exitCode)
|
|
os.Exit(exitCode)
|
|
}
|