Skip to content

Conversation

@sugh01
Copy link
Collaborator

@sugh01 sugh01 commented Nov 28, 2025

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2025

🤖 Claude Code Review

Status: Complete


Current Review:
One potential resource leak identified - see inline comment on test/utils/containers/container_manager.go:157

History:

  • ✅ Fixed: Container resource leak in TestDaemon initialization (cleanup now registered with t.Cleanup())
  • ⚠️ New: PostgreSQL container may leak if ConnectionString() or URL parsing fails

Summary:
This PR introduces a unified container management approach that significantly reduces boilerplate (10+ lines per test) and ensures consistent setup. The new ContainerManager centralizes lifecycle management for Aerospike, PostgreSQL, and SQLite, replacing scattered initialization code. Strong refactoring overall - the one resource leak issue is minor and easily fixed.

containerManager, err = containers.NewContainerManager(containers.UTXOStoreType(opts.UTXOStoreType))
require.NoError(t, err, "Failed to create container manager")

utxoStoreURL, err := containerManager.Initialize(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resource leak: If daemon initialization fails after this point, the container won't be cleaned up because td.Stop() is never called. Register cleanup with t.Cleanup() immediately after container initialization to prevent leaks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Fixed: Cleanup is now registered with t.Cleanup() immediately after container initialization (line 332-336).


cm.postgresContainer = postgresC

connStr, err := postgresC.ConnectionString(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential resource leak: If ConnectionString() (line 157) or url.Parse() (line 185) fails after the container is successfully created, the PostgreSQL container will not be terminated. Consider assigning cm.cleanupFunc immediately after line 155 (before operations that might fail) to ensure the container is cleaned up on all error paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant