Search in sources :

Example 36 with ProcessorDTO

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);
}
Also used : BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 37 with ProcessorDTO

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);
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) BridgeExecutor(com.redhat.service.bridge.shard.operator.resources.BridgeExecutor) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 38 with ProcessorDTO

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);
}
Also used : ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 39 with ProcessorDTO

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);
}
Also used : ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)39 Test (org.junit.jupiter.api.Test)28 QuarkusTest (io.quarkus.test.junit.QuarkusTest)21 ProcessorDefinition (com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)11 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)10 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)8 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)8 BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)6 HashSet (java.util.HashSet)6 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)5 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)5 CloudEvent (io.cloudevents.CloudEvent)5 TestSecurity (io.quarkus.test.security.TestSecurity)5 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)4 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)4 HashMap (java.util.HashMap)4 List (java.util.List)4 ActionInvoker (com.redhat.service.bridge.actions.ActionInvoker)2 ValidationResult (com.redhat.service.bridge.actions.ValidationResult)2 ActionProviderException (com.redhat.service.bridge.infra.exceptions.definitions.user.ActionProviderException)2