Search in sources :

Example 16 with HandlerEvent

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

the class StartBindUserCreationHandlerTest method testRetryExceptionReceived.

@Test
public void testRetryExceptionReceived() {
    StackView stackView = new StackView();
    stackView.setId(1L);
    when(stackViewService.getById(1L)).thenReturn(stackView);
    Event<StartBindUserCreationEvent> event = new Event<>(new StartBindUserCreationEvent(1L));
    RetryException retryException = new RetryException();
    when(startBindUserCreationService.startBindUserCreation(stackView)).thenThrow(retryException);
    StackFailureEvent result = (StackFailureEvent) underTest.doAccept(new HandlerEvent<>(event));
    assertEquals(VALIDATE_KERBEROS_CONFIG_FAILED_EVENT.event(), result.selector());
    assertEquals(1L, result.getResourceId());
    assertEquals(retryException, result.getException());
}
Also used : StartBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) StartBindUserCreationEvent(com.sequenceiq.cloudbreak.core.flow2.validate.kerberosconfig.event.StartBindUserCreationEvent) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) StackFailureEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackFailureEvent) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) Event(reactor.bus.Event) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) RetryException(com.sequenceiq.cloudbreak.retry.RetryException) Test(org.junit.jupiter.api.Test)

Example 17 with HandlerEvent

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

the class DiagnosticsPreFlightCheckHandler method executeOperation.

@Override
public Selectable executeOperation(HandlerEvent<DiagnosticsCollectionEvent> event) throws Exception {
    DiagnosticsCollectionEvent data = event.getData();
    Long resourceId = data.getResourceId();
    String resourceCrn = data.getResourceCrn();
    DiagnosticParameters parameters = data.getParameters();
    Stack stack = stackService.getByIdWithListsInTransaction(resourceId);
    Set<InstanceMetaData> instanceMetaDataSet = instanceMetaDataService.findNotTerminatedForStack(resourceId);
    instanceMetaDataSet.stream().filter(im -> im.getInstanceMetadataType() == InstanceMetadataType.GATEWAY_PRIMARY).forEach(instance -> executeNetworkReport(stack, instance));
    return DiagnosticsCollectionEvent.builder().withResourceCrn(resourceCrn).withResourceId(resourceId).withSelector(START_DIAGNOSTICS_INIT_EVENT.selector()).withParameters(parameters).build();
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceMetaDataService(com.sequenceiq.freeipa.service.stack.instance.InstanceMetaDataService) Logger(org.slf4j.Logger) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) LoggerFactory(org.slf4j.LoggerFactory) START_DIAGNOSTICS_INIT_EVENT(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionStateSelectors.START_DIAGNOSTICS_INIT_EVENT) 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) NodeStatusProto(com.cloudera.thunderhead.telemetry.nodestatus.NodeStatusProto) InstanceMetadataType(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceMetadataType) Inject(javax.inject.Inject) FreeIpaNodeStatusService(com.sequenceiq.freeipa.service.stack.FreeIpaNodeStatusService) Component(org.springframework.stereotype.Component) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) StackService(com.sequenceiq.freeipa.service.stack.StackService) PREFLIGHT_CHECK_DIAGNOSTICS_EVENT(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionHandlerSelectors.PREFLIGHT_CHECK_DIAGNOSTICS_EVENT) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 18 with HandlerEvent

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

the class DiagnosticsVmPreFlightCheckHandlerTest method testDoAccept.

@Test
public void testDoAccept() throws CloudbreakOrchestratorFailedException {
    // GIVEN
    doNothing().when(diagnosticsOperationsService).vmPreflightCheck(anyLong(), any());
    // WHEN
    DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(VM_PREFLIGHT_CHECK_DIAGNOSTICS_EVENT.selector(), STACK_ID, "crn", new DiagnosticParameters(), Set.of(), Set.of(), Set.of());
    underTest.doAccept(new HandlerEvent<>(new Event<>(event)));
    // THEN
    verify(diagnosticsOperationsService, times(1)).vmPreflightCheck(anyLong(), any());
}
Also used : DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) Event(reactor.bus.Event) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) DiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent) DiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent) Test(org.junit.jupiter.api.Test)

Example 19 with HandlerEvent

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

the class CloudProviderUpdateCheckHandlerTest method doAcceptShouldCallPlatformConnectorsGet.

@Test
void doAcceptShouldCallPlatformConnectorsGet() {
    when(cloudPlatformConnectors.get(any(), any())).thenReturn(cloudConnector);
    CloudStack cloudStack = new CloudStack(List.of(), null, null, Map.of(), Map.of(), "", null, "", "", null);
    CloudContext cloudContext = CloudContext.Builder.builder().withId(0L).build();
    ClusterUpgradeUpdateCheckRequest checkRequest = new ClusterUpgradeUpdateCheckRequest(0L, cloudStack, new CloudCredential(), cloudContext, List.of());
    underTest.doAccept(new HandlerEvent<>(new Event<>(checkRequest)));
    verify(cloudPlatformConnectors, times(1)).get(any(), any());
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) Event(reactor.bus.Event) ClusterUpgradeUpdateCheckRequest(com.sequenceiq.cloudbreak.core.flow2.cluster.datalake.upgrade.validation.event.ClusterUpgradeUpdateCheckRequest) CloudStack(com.sequenceiq.cloudbreak.cloud.model.CloudStack) Test(org.junit.jupiter.api.Test)

Example 20 with HandlerEvent

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

the class DiagnosticsEnsureMachineUserHandlerTest method testDoAcceptOnError.

@Test
public void testDoAcceptOnError() throws IOException {
    // GIVEN
    doThrow(new IOException("ex")).when(altusMachineUserService).getOrCreateDataBusCredentialIfNeeded(anyLong());
    DiagnosticParameters diagnosticParameters = new DiagnosticParameters();
    diagnosticParameters.setDestination(DiagnosticsDestination.SUPPORT);
    // WHEN
    DiagnosticsCollectionEvent event = new DiagnosticsCollectionEvent(ENSURE_MACHINE_USER_EVENT.selector(), STACK_ID, "crn", diagnosticParameters, Set.of(), Set.of(), Set.of());
    DiagnosticsFlowException result = assertThrows(DiagnosticsFlowException.class, () -> underTest.doAccept(new HandlerEvent<>(new Event<>(event))));
    // THEN
    assertTrue(result.getMessage().contains("Error during diagnostics operation: UMS resource check"));
}
Also used : DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) IOException(java.io.IOException) DiagnosticsCollectionEvent(com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent) DiagnosticsFlowException(com.sequenceiq.cloudbreak.core.flow2.diagnostics.DiagnosticsFlowException) Test(org.junit.jupiter.api.Test)

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