Reduce number of CLI calls to improve startup time with devtools

Update `DockerComposeLifecycleManager` so that `docker ps` is
not called multiple times.

See gh-35435
This commit is contained in:
Andy Wilkinson
2023-05-17 13:38:17 -07:00
committed by Phillip Webb
parent b0c76c1f79
commit 6ad71c9b0c
5 changed files with 7 additions and 40 deletions

View File

@@ -96,26 +96,6 @@ class DefaultDockerComposeTests {
assertThat(compose.hasDefinedServices()).isTrue();
}
@Test
void hasRunningServicesWhenPsListsRunningServiceReturnsTrue() {
willReturn(List.of(new DockerCliComposePsResponse("id", "name", "image", "exited"),
new DockerCliComposePsResponse("id", "name", "image", "running")))
.given(this.cli)
.run(new DockerCliCommand.ComposePs());
DefaultDockerCompose compose = new DefaultDockerCompose(this.cli, HOST);
assertThat(compose.hasRunningServices()).isTrue();
}
@Test
void hasRunningServicesWhenPsListReturnsAllExitedReturnsFalse() {
willReturn(List.of(new DockerCliComposePsResponse("id", "name", "image", "exited"),
new DockerCliComposePsResponse("id", "name", "image", "running")))
.given(this.cli)
.run(new DockerCliCommand.ComposePs());
DefaultDockerCompose compose = new DefaultDockerCompose(this.cli, HOST);
assertThat(compose.hasRunningServices()).isTrue();
}
@Test
void getRunningServicesReturnsServices() {
String id = "123";

View File

@@ -351,7 +351,6 @@ class DockerComposeLifecycleManagerTests {
@SuppressWarnings("unchecked")
private void setUpRunningServices(boolean started, Map<String, String> labels) {
given(this.dockerCompose.hasDefinedServices()).willReturn(true);
given(this.dockerCompose.hasRunningServices()).willReturn(true);
RunningService runningService = mock(RunningService.class);
given(runningService.labels()).willReturn(labels);
this.runningServices = List.of(runningService);