From 2035e3107ab8a362e31f58bdafd4b4b2a53d4f4a Mon Sep 17 00:00:00 2001 From: maxdml Date: Fri, 26 Sep 2025 11:40:47 -0700 Subject: [PATCH 1/2] run goleaks in places where it is missing --- cmd/dbos/cli_integration_test.go | 6 ++++++ dbos/admin_server_test.go | 6 ++++++ dbos/dbos_test.go | 16 ++++++++++++++++ dbos/logger_test.go | 6 ++++++ dbos/system_database_test.go | 3 +++ dbos/workflows_test.go | 8 ++++---- integration/mocks_test.go | 2 ++ 7 files changed, 43 insertions(+), 4 deletions(-) diff --git a/cmd/dbos/cli_integration_test.go b/cmd/dbos/cli_integration_test.go index 4268100c..f7c88265 100644 --- a/cmd/dbos/cli_integration_test.go +++ b/cmd/dbos/cli_integration_test.go @@ -23,6 +23,7 @@ import ( _ "github.com/jackc/pgx/v5/stdlib" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uber.org/goleak" ) //go:embed cli_test_app.go.test @@ -51,6 +52,11 @@ func getDatabaseURL() string { // TestCLIWorkflow provides comprehensive integration testing of the DBOS CLI func TestCLIWorkflow(t *testing.T) { + defer goleak.VerifyNone(t, + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"), + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"), + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"), + ) // Build the CLI once at the beginning cliPath := buildCLI(t) t.Logf("Built CLI at: %s", cliPath) diff --git a/dbos/admin_server_test.go b/dbos/admin_server_test.go index 37ac1128..c70f770f 100644 --- a/dbos/admin_server_test.go +++ b/dbos/admin_server_test.go @@ -14,9 +14,15 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uber.org/goleak" ) func TestAdminServer(t *testing.T) { + defer goleak.VerifyNone(t, + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"), + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"), + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"), + ) databaseURL := getDatabaseURL() t.Run("Admin server is not started by default", func(t *testing.T) { diff --git a/dbos/dbos_test.go b/dbos/dbos_test.go index 7feee4c2..e924aff5 100644 --- a/dbos/dbos_test.go +++ b/dbos/dbos_test.go @@ -11,9 +11,15 @@ import ( "github.com/jackc/pgx/v5/pgxpool" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uber.org/goleak" ) func TestConfig(t *testing.T) { + defer goleak.VerifyNone(t, + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"), + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"), + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"), + ) databaseURL := getDatabaseURL() t.Run("CreatesDBOSContext", func(t *testing.T) { @@ -275,6 +281,11 @@ func TestConfig(t *testing.T) { } func TestCustomSystemDBSchema(t *testing.T) { + defer goleak.VerifyNone(t, + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"), + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"), + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"), + ) t.Setenv("DBOS__APPVERSION", "v1.0.0") t.Setenv("DBOS__APPID", "test-custom-schema") t.Setenv("DBOS__VMID", "test-executor-id") @@ -464,6 +475,11 @@ func TestCustomSystemDBSchema(t *testing.T) { } func TestCustomPool(t *testing.T) { + defer goleak.VerifyNone(t, + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"), + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"), + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"), + ) // Test workflows for custom pool testing type customPoolWorkflowInput struct { PartnerWorkflowID string diff --git a/dbos/logger_test.go b/dbos/logger_test.go index d83047d8..78e3f379 100644 --- a/dbos/logger_test.go +++ b/dbos/logger_test.go @@ -9,9 +9,15 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.uber.org/goleak" ) func TestLogger(t *testing.T) { + defer goleak.VerifyNone(t, + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"), + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"), + goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"), + ) databaseURL := getDatabaseURL() t.Run("Default logger", func(t *testing.T) { diff --git a/dbos/system_database_test.go b/dbos/system_database_test.go index cc783414..fe9ebd75 100644 --- a/dbos/system_database_test.go +++ b/dbos/system_database_test.go @@ -3,6 +3,8 @@ package dbos import ( "testing" "time" + + "go.uber.org/goleak" ) var backoffWithJitterTestcases = []struct { @@ -38,6 +40,7 @@ var backoffWithJitterTestcases = []struct { } func TestBackoffWithJitter(t *testing.T) { + defer goleak.VerifyNone(t) for _, testcase := range backoffWithJitterTestcases { t.Run(testcase.name, func(t *testing.T) { got := backoffWithJitter(testcase.retryAttempt) diff --git a/dbos/workflows_test.go b/dbos/workflows_test.go index be66a7ee..9d770144 100644 --- a/dbos/workflows_test.go +++ b/dbos/workflows_test.go @@ -284,7 +284,7 @@ func TestWorkflowsRegistration(t *testing.T) { t.Run("DoubleRegistrationWithoutName", func(t *testing.T) { // Create a fresh DBOS context for this test - freshCtx := setupDBOS(t, false, false) // Don't check for leaks and don't reset DB + freshCtx := setupDBOS(t, false, true) // Don't reset DB but do check for leaks // First registration should work RegisterWorkflow(freshCtx, simpleWorkflow) @@ -302,7 +302,7 @@ func TestWorkflowsRegistration(t *testing.T) { t.Run("DoubleRegistrationWithCustomName", func(t *testing.T) { // Create a fresh DBOS context for this test - freshCtx := setupDBOS(t, false, false) // Don't check for leaks and don't reset DB + freshCtx := setupDBOS(t, false, true) // Don't reset DB but do check for leaks // First registration with custom name should work RegisterWorkflow(freshCtx, simpleWorkflow, WithWorkflowName("custom-workflow")) @@ -320,7 +320,7 @@ func TestWorkflowsRegistration(t *testing.T) { t.Run("DifferentWorkflowsSameCustomName", func(t *testing.T) { // Create a fresh DBOS context for this test - freshCtx := setupDBOS(t, false, false) // Don't check for leaks and don't reset DB + freshCtx := setupDBOS(t, false, true) // Don't reset DB but do check for leaks // First registration with custom name should work RegisterWorkflow(freshCtx, simpleWorkflow, WithWorkflowName("same-name")) @@ -338,7 +338,7 @@ func TestWorkflowsRegistration(t *testing.T) { t.Run("RegisterAfterLaunchPanics", func(t *testing.T) { // Create a fresh DBOS context for this test - freshCtx := setupDBOS(t, false, false) // Don't check for leaks and don't reset DB + freshCtx := setupDBOS(t, false, true) // Don't reset DB but do check for leaks // Launch DBOS context err := freshCtx.Launch() diff --git a/integration/mocks_test.go b/integration/mocks_test.go index 520bca3f..eb7347fe 100644 --- a/integration/mocks_test.go +++ b/integration/mocks_test.go @@ -10,6 +10,7 @@ import ( "github.com/dbos-inc/dbos-transact-golang/dbos" "github.com/stretchr/testify/mock" + "go.uber.org/goleak" ) func step(ctx context.Context) (int, error) { @@ -142,6 +143,7 @@ func aRealProgramFunction(dbosCtx dbos.DBOSContext) error { } func TestMocks(t *testing.T) { + defer goleak.VerifyNone(t) mockCtx := mocks.NewMockDBOSContext(t) // Context lifecycle From 96d6dd3841ded9c269c9e6661f77cd4dd37efbd4 Mon Sep 17 00:00:00 2001 From: maxdml Date: Fri, 26 Sep 2025 11:48:36 -0700 Subject: [PATCH 2/2] not here --- dbos/system_database_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/dbos/system_database_test.go b/dbos/system_database_test.go index fe9ebd75..cc783414 100644 --- a/dbos/system_database_test.go +++ b/dbos/system_database_test.go @@ -3,8 +3,6 @@ package dbos import ( "testing" "time" - - "go.uber.org/goleak" ) var backoffWithJitterTestcases = []struct { @@ -40,7 +38,6 @@ var backoffWithJitterTestcases = []struct { } func TestBackoffWithJitter(t *testing.T) { - defer goleak.VerifyNone(t) for _, testcase := range backoffWithJitterTestcases { t.Run(testcase.name, func(t *testing.T) { got := backoffWithJitter(testcase.retryAttempt)