-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
I noticed, that when I specify port_bindings
, the wait_for
isn't being set properly.
Below you can find a step by step expanation why it's happening:
PostgresContainer
constructor calls parent constructor https://github.com/testcontainers/testcontainers-ruby/blob/main/postgres/lib/testcontainers/postgres.rb#L34DockerContainer
constructor callsadd_wait_for
https://github.com/testcontainers/testcontainers-ruby/blob/main/core/lib/testcontainers/docker_container.rb#L59- The
method
parameter is nil and@exposed_ports
field is present, so it sets a@wait_for
that tries to connect to the bound port https://github.com/testcontainers/testcontainers-ruby/blob/main/core/lib/testcontainers/docker_container.rb#L270 - Going back to
PostgresContainer
's constructor - it does a conditional assignment to@wait_for
, but it has been already set to a non-nil value, even though nowait_for
option was specified https://github.com/testcontainers/testcontainers-ruby/blob/main/postgres/lib/testcontainers/postgres.rb#L39
This can be worked around by specifying the wait_for
option explicitly
Testcontainers::PostgresContainer.new(
'postgres:16',
username: test_db_config['username'],
password: test_db_config['password'],
port_bindings: { '5432': test_db_config['port'] },
wait_for: :healthcheck
)
Metadata
Metadata
Assignees
Labels
No labels