use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ManagerClientTest method notifyProcessorStatusChange.
@Test
public void notifyProcessorStatusChange() throws Exception {
ProcessorDTO processor = TestSupport.newRequestedProcessorDTO();
stubProcessorUpdate();
// One update to the manager is expected
CountDownLatch latch = new CountDownLatch(1);
addProcessorUpdateRequestListener(latch);
managerClient.notifyProcessorStatusChange(processor).await().atMost(Duration.ofSeconds(5));
assertThat(latch.await(60, SECONDS)).isTrue();
wireMockServer.verify(putRequestedFor(urlEqualTo(SHARD_API_BASE_PATH + "processors")).withRequestBody(equalToJson(objectMapper.writeValueAsString(processor), true, true)).withHeader("Content-Type", equalTo("application/json")));
}
use of com.redhat.service.smartevents.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(BridgeExecutor.OB_RESOURCE_NAME_PREFIX + TestSupport.PROCESSOR_ID);
assertThat(bridgeExecutor.getMetadata().getLabels().get(LabelsBuilder.CREATED_BY_LABEL)).isEqualTo(LabelsBuilder.OPERATOR_NAME);
assertThat(bridgeExecutor.getMetadata().getLabels().get(LabelsBuilder.MANAGED_BY_LABEL)).isEqualTo(LabelsBuilder.OPERATOR_NAME);
assertThat(bridgeExecutor.getMetadata().getLabels().get(LabelsBuilder.COMPONENT_LABEL)).isEqualTo(BridgeExecutor.COMPONENT_NAME);
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);
assertThat(bridgeExecutor.getSpec().getOwner()).isEqualTo(dto.getOwner());
}
use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ExecutorTestUtils method createProcessor.
public static ProcessorDTO createProcessor(ProcessorType type, ProcessorDefinition definition) {
ProcessorDTO dto = new ProcessorDTO();
dto.setType(type);
dto.setId("processorId-1");
dto.setName("processorName-1");
dto.setDefinition(definition);
dto.setBridgeId("bridgeId-1");
dto.setCustomerId("jrota");
dto.setStatus(ManagedResourceStatus.READY);
dto.setKafkaConnection(createKafkaConnection());
return dto;
}
use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ManagerSyncServiceTest method testProcessorsAreDeletedWhenDeployed.
@Test
@WithPrometheus
public void testProcessorsAreDeletedWhenDeployed() throws JsonProcessingException, InterruptedException {
// First check provisioning completed
doProcessorDeployment();
// Second check provisioned Processor is deleted
ProcessorDTO processor = TestSupport.newRequestedProcessorDTO();
processor.setStatus(ManagedResourceStatus.DEPROVISION);
stubProcessorsToDeployOrDelete(List.of(processor));
stubProcessorUpdate();
String expectedJsonUpdateRequestForDeprovisioning = String.format("{\"id\": \"%s\", \"name\": \"%s\", \"bridgeId\": \"%s\", \"customerId\": \"%s\", \"status\": \"deleting\"}", processor.getId(), processor.getName(), processor.getBridgeId(), processor.getCustomerId());
// The BridgeExecutorController delete loop does not execute so only one update can be captured
// See https://issues.redhat.com/browse/MGDOBR-128
CountDownLatch latch = new CountDownLatch(1);
addProcessorUpdateRequestListener(latch);
managerSyncService.doProcessors().await().atMost(Duration.ofSeconds(5));
assertThat(latch.await(60, TimeUnit.SECONDS)).isTrue();
assertJsonRequest(expectedJsonUpdateRequestForDeprovisioning, APIConstants.SHARD_API_BASE_PATH + "processors");
}
use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ManagerSyncServiceTest method doProcessorDeployment.
private void doProcessorDeployment() throws JsonProcessingException, InterruptedException {
ProcessorDTO processor = TestSupport.newRequestedProcessorDTO();
stubProcessorsToDeployOrDelete(Collections.singletonList(processor));
stubProcessorUpdate();
// Two updates to the manager are expected (1 provisioning + 1 ready)
CountDownLatch latch = new CountDownLatch(2);
addProcessorUpdateRequestListener(latch);
managerSyncService.doProcessors().await().atMost(Duration.ofSeconds(5));
String customerNamespace = customerNamespaceProvider.resolveName(TestSupport.CUSTOMER_ID);
String sanitizedName = BridgeExecutor.resolveResourceName(processor.getId());
Awaitility.await().atMost(Duration.ofMinutes(3)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> {
kubernetesResourcePatcher.patchReadyDeploymentAsReady(sanitizedName, customerNamespace);
kubernetesResourcePatcher.patchReadyService(sanitizedName, customerNamespace);
});
assertThat(latch.await(60, TimeUnit.SECONDS)).isTrue();
processor.setStatus(ManagedResourceStatus.READY);
// the kafka connection is not included in the shard update for the manager
processor.setKafkaConnection(null);
assertJsonRequest(objectMapper.writeValueAsString(processor), APIConstants.SHARD_API_BASE_PATH + "processors");
}
Aggregations