mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(msk): create a serverless cluster without Docker as a provisioned one is (#5808)
This commit is contained in:
1 parent
c67a5afbc3
commit
9cd8b32670
3 files changed
+58
-16
No files matched your search
@@ -1024,4 +1024,25 @@ class MskServiceTest {
|
||||
|
||||
assertThrows(AwsException.class, () -> mskService.createCluster(request));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createServerlessClusterWithoutDockerDaemonStillReachesActive() {
|
||||
when(config.services().msk().mock()).thenReturn(false);
|
||||
Mockito.doThrow(new RuntimeException("Cannot connect to the Docker daemon"))
|
||||
.when(redpandaManager).startContainer(Mockito.any());
|
||||
when(redpandaManager.tryStartContainer(Mockito.any())).thenReturn(false);
|
||||
|
||||
Serverless serverless = new Serverless();
|
||||
serverless.setVpcConfigs(List.of(new VpcConfig()));
|
||||
CreateClusterV2Request request = new CreateClusterV2Request();
|
||||
request.setClusterName("no-docker-serverless");
|
||||
request.setServerless(serverless);
|
||||
|
||||
MskCluster cluster = mskService.createCluster(request);
|
||||
|
||||
assertEquals(ClusterState.ACTIVE, cluster.getState());
|
||||
assertEquals("localhost:9092", cluster.getBootstrapBrokers());
|
||||
assertEquals(ClusterState.ACTIVE,
|
||||
mskService.describeCluster(cluster.getClusterArn()).getState());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.github.hectorvent.floci.services.msk;
|
||||
|
||||
import com.github.dockerjava.api.DockerClient;
|
||||
import com.github.dockerjava.api.exception.NotFoundException;
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
@@ -358,6 +359,27 @@ class RedpandaManagerTest {
|
||||
verify(lifecycleManager, never()).createAndStart(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void tryStartContainerReportsUnavailableWhenNoDaemonAnswers() {
|
||||
when(lifecycleManager.createAndStart(any()))
|
||||
.thenThrow(new RuntimeException("java.net.SocketException: No such file or directory"));
|
||||
when(lifecycleManager.getDockerClient())
|
||||
.thenThrow(new RuntimeException("java.net.SocketException: No such file or directory"));
|
||||
|
||||
assertFalse(manager.tryStartContainer(newCluster()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void tryStartContainerPropagatesFailuresWhileTheDaemonIsReachable() {
|
||||
when(lifecycleManager.createAndStart(any()))
|
||||
.thenThrow(new RuntimeException("no such image: redpandadata/redpanda:latest"));
|
||||
when(lifecycleManager.getDockerClient()).thenReturn(mock(DockerClient.class, RETURNS_DEEP_STUBS));
|
||||
|
||||
RuntimeException failure = assertThrows(RuntimeException.class,
|
||||
() -> manager.tryStartContainer(newCluster()));
|
||||
assertEquals("no such image: redpandadata/redpanda:latest", failure.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void movesToTheNextHostPortWhenDockerReportsTheChosenOneInUse() {
|
||||
// From inside a container, allocate() cannot see a host process holding a port, so the
|
||||
|
||||
Reference in new issue
Block a user