s3tables: Add t field to TestCluster for logging

Add *testing.T field to TestCluster struct and initialize it in
startMiniCluster. This allows Stop() to properly log warnings when
cluster shutdown times out. Includes the t field in the test cluster
initialization and restores the logging statement in Stop().
This commit is contained in:
Chris Lu
2026-01-28 17:02:53 -08:00
parent 6658a655f6
commit fe856928c4
2 changed files with 4 additions and 1 deletions

View File

@@ -416,6 +416,7 @@ func startMiniCluster(t *testing.T) (*TestCluster, error) {
s3Endpoint := fmt.Sprintf("http://127.0.0.1:%d", s3Port) s3Endpoint := fmt.Sprintf("http://127.0.0.1:%d", s3Port)
cluster := &TestCluster{ cluster := &TestCluster{
t: t,
dataDir: testDir, dataDir: testDir,
ctx: ctx, ctx: ctx,
cancel: cancel, cancel: cancel,
@@ -526,7 +527,7 @@ func (c *TestCluster) Stop() {
case <-timer.C: case <-timer.C:
// Timeout - goroutine doesn't respond to context cancel // Timeout - goroutine doesn't respond to context cancel
// This may indicate the mini cluster didn't shut down cleanly // This may indicate the mini cluster didn't shut down cleanly
// (Note: Warning is logged at test level when tests access cluster.Stop()) c.t.Log("Warning: Test cluster shutdown timed out after 2 seconds")
} }
// Reset the global cmdMini flags to prevent state leakage to other tests // Reset the global cmdMini flags to prevent state leakage to other tests

View File

@@ -4,11 +4,13 @@ import (
"context" "context"
"net/http" "net/http"
"sync" "sync"
"testing"
"time" "time"
) )
// TestCluster manages the weed mini instance for integration testing // TestCluster manages the weed mini instance for integration testing
type TestCluster struct { type TestCluster struct {
t *testing.T
dataDir string dataDir string
ctx context.Context ctx context.Context
cancel context.CancelFunc cancel context.CancelFunc