Implement changes suggested by testcontainer dev (#426)

* Implement changes suggested by testcontainer dev

See https://github.com/google/nomulus/issues/401
Specifically:
- Use getContainerIpAddress() instead of localhost to insulate us from
  off-machine docker usage.
- Remove shutdown hook to close the container, as testcontainers does this for
  us.
This commit is contained in:
Michael Muller 2020-01-08 10:41:36 -05:00 committed by GitHub
parent eb7d779bc8
commit b523b3835f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -97,7 +97,6 @@ abstract class JpaTransactionManagerRule extends ExternalResource {
new PostgreSQLContainer(NomulusPostgreSql.getDockerTag())
.withDatabaseName(MANAGEMENT_DB_NAME);
container.start();
Runtime.getRuntime().addShutdownHook(new Thread(() -> container.close()));
return container;
}

View file

@ -52,7 +52,8 @@ class DockerWebDriverRule extends ExternalResource {
url =
new URL(
String.format(
"http://localhost:%d/wd/hub",
"http://%s:%d/wd/hub",
container.getContainerIpAddress(),
container.getMappedPort(CHROME_DRIVER_SERVICE_PORT)));
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);