mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat: implement Amazon MSK service with Redpanda orchestration (#419)
* feat: implement Amazon MSK service with Redpanda orchestration * fix: adding missing msk service on the test
This commit is contained in:
1 parent
ed553c6cbf
commit
91071aaae7
24 files changed
+852
-12
No files matched your search
+1
@@ -23,6 +23,7 @@ class HealthControllerIntegrationTest {
|
||||
"lambda": "running",
|
||||
"apigateway": "running",
|
||||
"iam": "running",
|
||||
"kafka": "running",
|
||||
"elasticache": "running",
|
||||
"rds": "running",
|
||||
"events": "running",
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package io.github.hectorvent.floci.services.msk;
|
||||
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.msk.model.ClusterState;
|
||||
import io.github.hectorvent.floci.services.msk.model.MskCluster;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class MskServiceTest {
|
||||
|
||||
private MskService mskService;
|
||||
private StorageFactory storageFactory;
|
||||
private EmulatorConfig config;
|
||||
private RedpandaManager redpandaManager;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
storageFactory = Mockito.mock(StorageFactory.class);
|
||||
when(storageFactory.create(Mockito.anyString(), Mockito.anyString(), Mockito.any()))
|
||||
.thenReturn(new InMemoryStorage<>());
|
||||
|
||||
config = Mockito.mock(EmulatorConfig.class);
|
||||
var servicesConfig = Mockito.mock(EmulatorConfig.ServicesConfig.class);
|
||||
var mskConfig = Mockito.mock(EmulatorConfig.MskServiceConfig.class);
|
||||
|
||||
when(config.services()).thenReturn(servicesConfig);
|
||||
when(servicesConfig.msk()).thenReturn(mskConfig);
|
||||
when(mskConfig.mock()).thenReturn(true); // Mock mode for unit tests
|
||||
|
||||
redpandaManager = Mockito.mock(RedpandaManager.class);
|
||||
mskService = new MskService(storageFactory, config, redpandaManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createCluster() {
|
||||
MskCluster cluster = mskService.createCluster("test-cluster");
|
||||
assertNotNull(cluster);
|
||||
assertEquals("test-cluster", cluster.getClusterName());
|
||||
assertEquals(ClusterState.ACTIVE, cluster.getState());
|
||||
assertTrue(cluster.getClusterArn().contains("test-cluster"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void describeCluster() {
|
||||
MskCluster created = mskService.createCluster("test-cluster");
|
||||
MskCluster described = mskService.describeCluster(created.getClusterArn());
|
||||
assertEquals(created.getClusterArn(), described.getClusterArn());
|
||||
}
|
||||
|
||||
@Test
|
||||
void listClusters() {
|
||||
mskService.createCluster("cluster-1");
|
||||
mskService.createCluster("cluster-2");
|
||||
List<MskCluster> clusters = mskService.listClusters();
|
||||
assertEquals(2, clusters.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteCluster() {
|
||||
MskCluster cluster = mskService.createCluster("test-cluster");
|
||||
mskService.deleteCluster(cluster.getClusterArn());
|
||||
assertTrue(mskService.listClusters().isEmpty());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user