Search in sources :

Example 81 with HandlerEvent

use of com.sequenceiq.flow.reactor.api.handler.HandlerEvent in project cloudbreak by hortonworks.

the class DiagnosticsPreFlightCheckHandlerTest method testDoAccept.

@Test
public void testDoAccept() throws FreeIpaClientException {
    // GIVEN
    given(stackService.getByIdWithListsInTransaction(STACK_ID)).willReturn(mock(Stack.class));
    given(instanceMetaDataService.findNotTerminatedForStack(STACK_ID)).willReturn(metadataSet());
    given(freeIpaNodeStatusService.nodeNetworkReport(any(), any())).willReturn(rpcResponse);
    // WHEN
    DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(PREFLIGHT_CHECK_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters());
    underTest.doAccept(new HandlerEvent<>(new Event<>(event)));
    // THEN
    verify(freeIpaNodeStatusService, times(1)).nodeNetworkReport(any(), any());
}
Also used : DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Event(reactor.bus.Event) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 82 with HandlerEvent

use of com.sequenceiq.flow.reactor.api.handler.HandlerEvent in project cloudbreak by hortonworks.

the class DiagnosticsPreFlightCheckHandlerTest method testDoAcceptWithClientException.

@Test
public void testDoAcceptWithClientException() throws FreeIpaClientException {
    // GIVEN
    given(stackService.getByIdWithListsInTransaction(STACK_ID)).willReturn(mock(Stack.class));
    given(instanceMetaDataService.findNotTerminatedForStack(STACK_ID)).willReturn(metadataSet());
    doThrow(new FreeIpaClientException("ex")).when(freeIpaNodeStatusService).nodeNetworkReport(any(), any());
    // WHEN
    DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(PREFLIGHT_CHECK_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters());
    underTest.doAccept(new HandlerEvent<>(new Event<>(event)));
    // THEN
    verify(freeIpaNodeStatusService, times(1)).nodeNetworkReport(any(), any());
}
Also used : DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Event(reactor.bus.Event) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 83 with HandlerEvent

use of com.sequenceiq.flow.reactor.api.handler.HandlerEvent in project cloudbreak by hortonworks.

the class DiagnosticsSaltPillarUpdateHandlerTest method testDoAcceptOnError.

@Test
public void testDoAcceptOnError() throws CloudbreakOrchestratorFailedException {
    // GIVEN
    doThrow(new CloudbreakOrchestratorFailedException("ex")).when(telemetryUpgradeService).upgradeTelemetrySaltPillars(anyLong(), anySet());
    // WHEN
    DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(SALT_PILLAR_UPDATE_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters());
    DiagnosticsFlowException result = assertThrows(DiagnosticsFlowException.class, () -> underTest.doAccept(new HandlerEvent<>(new Event<>(event))));
    // THEN
    assertTrue(result.getMessage().contains("Error during diagnostics operation: Salt pillar update"));
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) DiagnosticsFlowException(com.sequenceiq.freeipa.flow.freeipa.diagnostics.DiagnosticsFlowException) Test(org.junit.jupiter.api.Test)

Example 84 with HandlerEvent

use of com.sequenceiq.flow.reactor.api.handler.HandlerEvent in project cloudbreak by hortonworks.

the class DiagnosticsSaltValidationHandlerTest method testDoAccept.

@Test
public void testDoAccept() throws CloudbreakOrchestratorFailedException {
    // GIVEN
    given(diagnosticsOperationsService.applyUnresponsiveHosts(anyLong(), any())).willReturn(new DiagnosticParameters());
    // WHEN
    DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(SALT_VALIDATION_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters());
    underTest.doAccept(new HandlerEvent<>(new Event<>(event)));
    // THEN
    verify(diagnosticsOperationsService, times(1)).applyUnresponsiveHosts(anyLong(), any());
}
Also used : DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Event(reactor.bus.Event) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Test(org.junit.jupiter.api.Test)

Example 85 with HandlerEvent

use of com.sequenceiq.flow.reactor.api.handler.HandlerEvent in project cloudbreak by hortonworks.

the class UpdateDnsSoaRecordsHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<UpdateDnsSoaRecordsRequest> event) {
    UpdateDnsSoaRecordsRequest request = event.getData();
    Selectable result;
    try {
        Long stackId = request.getResourceId();
        Set<String> fqdns = request.getHosts().stream().map(hostname -> StringUtils.appendIfMissing(hostname, ".")).collect(Collectors.toSet());
        updateSoaRecords(stackId, fqdns);
        result = new UpdateDnsSoaRecordsResponse(request.getResourceId());
    } catch (Exception e) {
        LOGGER.error("Downscale updating DNS SOA records failed", e);
        result = new DownscaleFailureEvent(DOWNSCALE_UPDATE_DNS_SOA_RECORDS_FAILED_EVENT.event(), request.getResourceId(), "Downscale Update DNS SOA Records", Set.of(), Map.of(), e);
    }
    return result;
}
Also used : DOWNSCALE_UPDATE_DNS_SOA_RECORDS_FAILED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_UPDATE_DNS_SOA_RECORDS_FAILED_EVENT) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) EventSelectorUtil(com.sequenceiq.flow.event.EventSelectorUtil) IpaServer(com.sequenceiq.freeipa.client.model.IpaServer) Set(java.util.Set) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Collectors(java.util.stream.Collectors) StringUtils(org.apache.commons.lang3.StringUtils) UpdateDnsSoaRecordsResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsResponse) UpdateDnsSoaRecordsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest) Objects(java.util.Objects) Inject(javax.inject.Inject) DnsZone(com.sequenceiq.freeipa.client.model.DnsZone) Component(org.springframework.stereotype.Component) ExceptionCatcherEventHandler(com.sequenceiq.flow.reactor.api.handler.ExceptionCatcherEventHandler) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent) Event(reactor.bus.Event) Map(java.util.Map) FreeIpaClientFactory(com.sequenceiq.freeipa.service.freeipa.FreeIpaClientFactory) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) UpdateDnsSoaRecordsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent) UpdateDnsSoaRecordsResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsResponse) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException)

Aggregations

HandlerEvent (com.sequenceiq.flow.reactor.api.handler.HandlerEvent)85 Test (org.junit.jupiter.api.Test)77 Event (reactor.bus.Event)49 DiagnosticParameters (com.sequenceiq.common.model.diagnostics.DiagnosticParameters)45 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)27 DiagnosticsCollectionEvent (com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent)23 DiagnosticsCollectionEvent (com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent)22 Set (java.util.Set)20 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)19 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)18 Collectors (java.util.stream.Collectors)18 List (java.util.List)17 Map (java.util.Map)17 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)16 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)16 CloudbreakFlowMessageService (com.sequenceiq.cloudbreak.core.flow2.stack.CloudbreakFlowMessageService)15 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)15 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)15 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)15 ClusterApiConnectors (com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors)15