Search in sources :

Example 26 with BridgeDTO

use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ManagerSyncServiceTest method testBridgesAreDeployed.

@Test
@WithPrometheus
public void testBridgesAreDeployed() throws JsonProcessingException, InterruptedException {
    List<BridgeDTO> bridgeDTOS = new ArrayList<>();
    bridgeDTOS.add(new BridgeDTO("myId-1", "myName-1", "myEndpoint", TestSupport.CUSTOMER_ID, ManagedResourceStatus.ACCEPTED, TestSupport.KAFKA_CONNECTION_DTO));
    bridgeDTOS.add(new BridgeDTO("myId-2", "myName-2", "myEndpoint", TestSupport.CUSTOMER_ID, ManagedResourceStatus.ACCEPTED, TestSupport.KAFKA_CONNECTION_DTO));
    stubBridgesToDeployOrDelete(bridgeDTOS);
    stubBridgeUpdate();
    String expectedJsonUpdateProvisioningRequest = String.format("{\"id\": \"myId-1\", \"name\": \"myName-1\", \"endpoint\": \"myEndpoint\", \"customerId\": \"%s\", \"status\": \"provisioning\"}", TestSupport.CUSTOMER_ID);
    String expectedJsonUpdateAvailableRequest = String.format("{\"id\": \"myId-1\", \"name\": \"myName-1\", \"endpoint\": \"http://192.168.2.49/ob-myid-1\", \"customerId\": \"%s\", \"status\": \"ready\"}", TestSupport.CUSTOMER_ID);
    // Four updates to the manager are expected (2 PROVISIONING + 2 READY)
    CountDownLatch latch = new CountDownLatch(4);
    addBridgeUpdateRequestListener(latch);
    managerSyncService.fetchAndProcessBridgesToDeployOrDelete().await().atMost(Duration.ofSeconds(5));
    String customerNamespace = customerNamespaceProvider.resolveName(TestSupport.CUSTOMER_ID);
    String firstBridgeName = BridgeIngress.resolveResourceName("myId-1");
    String secondBridgeName = BridgeIngress.resolveResourceName("myId-2");
    Awaitility.await().atMost(Duration.ofMinutes(3)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> {
        kubernetesResourcePatcher.patchReadyDeploymentAsReady(firstBridgeName, customerNamespace);
        kubernetesResourcePatcher.patchReadyDeploymentAsReady(secondBridgeName, customerNamespace);
        kubernetesResourcePatcher.patchReadyService(firstBridgeName, customerNamespace);
        kubernetesResourcePatcher.patchReadyService(secondBridgeName, customerNamespace);
        kubernetesResourcePatcher.patchReadyNetworkResource(firstBridgeName, customerNamespace);
        kubernetesResourcePatcher.patchReadyNetworkResource(secondBridgeName, customerNamespace);
    });
    assertThat(latch.await(60, TimeUnit.SECONDS)).isTrue();
    wireMockServer.verify(putRequestedFor(urlEqualTo(APIConstants.SHARD_API_BASE_PATH)).withRequestBody(equalToJson(expectedJsonUpdateProvisioningRequest, true, true)).withHeader("Content-Type", equalTo("application/json")));
    wireMockServer.verify(putRequestedFor(urlEqualTo(APIConstants.SHARD_API_BASE_PATH)).withRequestBody(equalToJson(expectedJsonUpdateAvailableRequest, true, true)).withHeader("Content-Type", equalTo("application/json")));
}
Also used : BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 27 with BridgeDTO

use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeIngressTest method fromDTO.

@Test
public void fromDTO() {
    BridgeDTO dto = TestSupport.newRequestedBridgeDTO();
    BridgeIngress bridgeIngress = BridgeIngress.fromDTO(dto, "ns", "image");
    assertThat(bridgeIngress.getMetadata().getNamespace()).isEqualTo("ns");
    assertThat(bridgeIngress.getMetadata().getName()).isEqualTo(OB_RESOURCE_NAME_PREFIX + TestSupport.BRIDGE_ID);
    assertThat(bridgeIngress.getSpec().getBridgeName()).isEqualTo(dto.getName());
    assertThat(bridgeIngress.getSpec().getId()).isEqualTo(dto.getId());
    assertThat(bridgeIngress.getSpec().getImage()).isEqualTo("image");
    assertThat(bridgeIngress.getSpec().getCustomerId()).isEqualTo(dto.getCustomerId());
}
Also used : BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) Test(org.junit.jupiter.api.Test)

Example 28 with BridgeDTO

use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeIngress method toDTO.

public BridgeDTO toDTO() {
    BridgeDTO bridgeDTO = new BridgeDTO();
    bridgeDTO.setId(this.getSpec().getId());
    bridgeDTO.setCustomerId(this.getSpec().getCustomerId());
    bridgeDTO.setName(this.getSpec().getBridgeName());
    bridgeDTO.setEndpoint(this.getStatus().getEndpoint());
    return bridgeDTO;
}
Also used : BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO)

Example 29 with BridgeDTO

use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgesServiceImpl method toDTO.

@Override
public BridgeDTO toDTO(Bridge bridge) {
    KafkaConnectionDTO kafkaConnectionDTO = new KafkaConnectionDTO(internalKafkaConfigurationProvider.getBootstrapServers(), internalKafkaConfigurationProvider.getClientId(), internalKafkaConfigurationProvider.getClientSecret(), internalKafkaConfigurationProvider.getSecurityProtocol(), getBridgeTopicName(bridge));
    BridgeDTO dto = new BridgeDTO();
    dto.setId(bridge.getId());
    dto.setName(bridge.getName());
    dto.setEndpoint(bridge.getEndpoint());
    dto.setStatus(bridge.getStatus());
    dto.setCustomerId(bridge.getCustomerId());
    dto.setKafkaConnection(kafkaConnectionDTO);
    return dto;
}
Also used : BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) KafkaConnectionDTO(com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)

Aggregations

BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)29 Test (org.junit.jupiter.api.Test)24 QuarkusTest (io.quarkus.test.junit.QuarkusTest)23 TestSecurity (io.quarkus.test.security.TestSecurity)11 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)10 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)10 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)9 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)9 List (java.util.List)9 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)8 BridgeIngress (com.redhat.service.bridge.shard.operator.resources.BridgeIngress)6 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)5 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)5 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)4 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)4 TypeRef (io.restassured.common.mapper.TypeRef)4 ResponseLoggingFilter (io.restassured.filter.log.ResponseLoggingFilter)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 KafkaTopicAction (com.redhat.service.bridge.actions.kafkatopic.KafkaTopicAction)3 WebhookAction (com.redhat.service.bridge.actions.webhook.WebhookAction)3