use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ExecutorServiceTest method before.
@BeforeEach
public void before() {
executor = mock(Executor.class);
BridgeDTO bridgeDTO = mock(BridgeDTO.class);
when(bridgeDTO.getId()).thenReturn(BRIDGE_ID);
ProcessorDTO processorDTO = mock(ProcessorDTO.class);
when(processorDTO.getBridgeId()).thenReturn(BRIDGE_ID);
when(executor.getProcessor()).thenReturn(processorDTO);
when(executorsProvider.getExecutor()).thenReturn(executor);
}
use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeExecutorServiceTest method testBridgeExecutorCreation.
@Test
public void testBridgeExecutorCreation() {
// Given
ProcessorDTO dto = TestSupport.newRequestedProcessorDTO();
// When
bridgeExecutorService.createBridgeExecutor(dto);
// Then
BridgeExecutor bridgeExecutor = kubernetesClient.resources(BridgeExecutor.class).inNamespace(customerNamespaceProvider.resolveName(dto.getCustomerId())).withName(BridgeExecutor.resolveResourceName(dto.getId())).get();
assertThat(bridgeExecutor).isNotNull();
Secret secret = fetchBridgeExecutorSecret(dto);
assertThat(secret).isNotNull();
assertThat(secret.getMetadata().getName()).isEqualTo(bridgeExecutor.getMetadata().getName());
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_BOOTSTRAP_SERVERS_ENV_VAR).length()).isGreaterThan(0);
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_CLIENT_ID_ENV_VAR).length()).isGreaterThan(0);
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_CLIENT_SECRET_ENV_VAR).length()).isGreaterThan(0);
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_SECURITY_PROTOCOL_ENV_VAR).length()).isGreaterThan(0);
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_TOPIC_ENV_VAR).length()).isGreaterThan(0);
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_GROUP_ID_ENV_VAR).length()).isGreaterThan(0);
}
use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeExecutorServiceTest method testFetchOrCreateBridgeExecutorDeploymentRedeployment.
@Test
public void testFetchOrCreateBridgeExecutorDeploymentRedeployment() {
// Given
ProcessorDTO dto = TestSupport.newRequestedProcessorDTO();
String patchedImage = TestSupport.EXECUTOR_IMAGE + "-patched";
// When
bridgeExecutorService.createBridgeExecutor(dto);
// Wait until deployment is created by the controller.
Awaitility.await().atMost(Duration.ofMinutes(2)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> {
// The deployment is deployed by the controller
Deployment deployment = fetchBridgeExecutorDeployment(dto);
assertThat(deployment).isNotNull();
});
// Patch the deployment and replace
Deployment deployment = fetchBridgeExecutorDeployment(dto);
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setImage(patchedImage);
kubernetesClient.apps().deployments().inNamespace(deployment.getMetadata().getNamespace()).createOrReplace(deployment);
// Then
deployment = bridgeExecutorService.fetchOrCreateBridgeExecutorDeployment(fetchBridgeIngress(dto), fetchBridgeExecutorSecret(dto));
assertThat(deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage()).isEqualTo(TestSupport.EXECUTOR_IMAGE);
}
use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeExecutorTest method fromDTO.
@Test
public void fromDTO() {
ProcessorDTO dto = TestSupport.newRequestedProcessorDTO();
BridgeExecutor bridgeExecutor = BridgeExecutor.fromDTO(dto, "ns", "image");
assertThat(bridgeExecutor.getMetadata().getNamespace()).isEqualTo("ns");
assertThat(bridgeExecutor.getMetadata().getName()).isEqualTo(OB_RESOURCE_NAME_PREFIX + TestSupport.PROCESSOR_ID);
assertThat(bridgeExecutor.getSpec().getProcessorName()).isEqualTo(dto.getName());
assertThat(bridgeExecutor.getSpec().getId()).isEqualTo(dto.getId());
assertThat(bridgeExecutor.getSpec().getImage()).isEqualTo("image");
assertThat(bridgeExecutor.getSpec().getBridgeId()).isEqualTo(TestSupport.BRIDGE_ID);
}
Aggregations