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/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