Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,8 @@ public SELF withStartupTimeout(Duration startupTimeout) {
}

public Optional<ContainerState> getContainerByServiceName(String serviceName) {
return Optional.ofNullable(serviceInstanceMap.get(serviceName));
String serviceInstantName = getServiceInstanceName(serviceName);
return Optional.ofNullable(serviceInstanceMap.get(serviceInstantName));
}

private void followLogs(String containerId, Consumer<OutputFrame> consumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void testGetServicePort() {
public void shouldRetrieveContainerByServiceName() {
String existingServiceName = "db_1";
Optional<ContainerState> result = environment.getContainerByServiceName(existingServiceName);

assertThat(result)
.as(String.format("Container should be found by service name %s", existingServiceName))
.isPresent();
Expand All @@ -52,6 +53,19 @@ public void shouldRetrieveContainerByServiceName() {
.isEqualTo(result.get().getExposedPorts());
}

@Test
public void shouldRetrieveContainerByServiceNameWithoutNumberedSuffix() {
String existingServiceName = "db";
Optional<ContainerState> result = environment.getContainerByServiceName(existingServiceName);

assertThat(result)
.as(String.format("Container should be found by service name %s", existingServiceName))
.isPresent();
assertThat(result.get().getExposedPorts())
.as("Mapped port for result container was wrong, perhaps wrong container was found")
.isEqualTo(Collections.singletonList(3306));
}

@Test
public void shouldReturnEmptyResultOnNoneExistingService() {
String notExistingServiceName = "db_256";
Expand Down