The java version of DockerComposeEnvironment supports getServicePort, which can be used to retrieve dynamic port mappings.
In my usecase I want to start a Compose file with randomized exposed ports for test isolation, but the application under test should still be able to communicate with the services.
A workaround is to use this:
const pgContainer = startedComposeEnv.getContainer('postgres-1');
const pgPort = pgContainer.getMappedPort('5432/tcp')
Is the workaround I presented really a workaround, or did you explicitly decide not to do it the java way?
The java version of
DockerComposeEnvironmentsupportsgetServicePort, which can be used to retrieve dynamic port mappings.In my usecase I want to start a Compose file with randomized exposed ports for test isolation, but the application under test should still be able to communicate with the services.
A workaround is to use this:
Is the workaround I presented really a workaround, or did you explicitly decide not to do it the java way?