Search in sources :

Example 91 with FlowLog

use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.

the class CcmUpgradeFlowIntegrationTest method testCcmUpgradeWhenSuccessful.

@Test
public void testCcmUpgradeWhenSuccessful() {
    FlowIdentifier flowIdentifier = triggerFlow();
    letItFlow(flowIdentifier);
    ArgumentCaptor<FlowLog> flowLog = ArgumentCaptor.forClass(FlowLog.class);
    verify(flowLogRepository, times(2)).save(flowLog.capture());
    Assertions.assertTrue(flowLog.getAllValues().stream().anyMatch(f -> f.getFinalized()), "flow has not finalized");
    verify(ccmUpgradeService, times(1)).reregister(STACK_ID);
    verify(ccmUpgradeService, times(1)).unregister(STACK_ID);
    verify(ccmUpgradeService, times(1)).prepare(STACK_ID);
    verify(ccmUpgradeService, times(1)).removeAutoSsh(STACK_ID);
    verify(ccmUpgradeService, never()).ccmUpgradeFailed(STACK_ID);
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) StackView(com.sequenceiq.cloudbreak.domain.view.StackView) BeforeEach(org.junit.jupiter.api.BeforeEach) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) CcmRemoveAutoSshHandler(com.sequenceiq.cloudbreak.reactor.handler.cluster.upgrade.ccm.CcmRemoveAutoSshHandler) SecretService(com.sequenceiq.cloudbreak.service.secret.service.SecretService) MockReset(org.springframework.boot.test.mock.mockito.MockReset) ClusterService(com.sequenceiq.cloudbreak.service.cluster.ClusterService) Scheduler(org.quartz.Scheduler) TestConfiguration(org.springframework.boot.test.context.TestConfiguration) Mockito.doThrow(org.mockito.Mockito.doThrow) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) Reporter(io.jaegertracing.spi.Reporter) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) FlowOperationStatisticsService(com.sequenceiq.flow.core.stats.FlowOperationStatisticsService) CloudbreakFlowMessageService(com.sequenceiq.cloudbreak.core.flow2.stack.CloudbreakFlowMessageService) FlowChainLogRepository(com.sequenceiq.flow.repository.FlowChainLogRepository) CcmReregisterClusterToClusterProxyHandler(com.sequenceiq.cloudbreak.reactor.handler.cluster.upgrade.ccm.CcmReregisterClusterToClusterProxyHandler) Sampler(io.jaegertracing.spi.Sampler) StackUpdater(com.sequenceiq.cloudbreak.service.StackUpdater) BadRequestException(javax.ws.rs.BadRequestException) MockBean(org.springframework.boot.test.mock.mockito.MockBean) ConstSampler(io.jaegertracing.internal.samplers.ConstSampler) FlowLog(com.sequenceiq.flow.domain.FlowLog) SpyBean(org.springframework.boot.test.mock.mockito.SpyBean) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) EventBus(reactor.bus.EventBus) UUID(java.util.UUID) MpscDispatcher(reactor.core.dispatch.MpscDispatcher) Test(org.junit.jupiter.api.Test) TransactionMetricsService(com.sequenceiq.cloudbreak.common.service.TransactionMetricsService) StackUtil(com.sequenceiq.cloudbreak.util.StackUtil) ClusterView(com.sequenceiq.cloudbreak.domain.view.ClusterView) FreeIpaV1Endpoint(com.sequenceiq.freeipa.api.v1.freeipa.stack.FreeIpaV1Endpoint) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) JaegerTracer(io.jaegertracing.internal.JaegerTracer) Mockito.mock(org.mockito.Mockito.mock) FlowRegister(com.sequenceiq.flow.core.FlowRegister) Clock(com.sequenceiq.cloudbreak.common.service.Clock) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ConsumerNotFoundHandler(com.sequenceiq.flow.reactor.handler.ConsumerNotFoundHandler) Client(javax.ws.rs.client.Client) OwnerAssignmentService(com.sequenceiq.authorization.service.OwnerAssignmentService) ClusterPublicEndpointManagementService(com.sequenceiq.cloudbreak.service.publicendpoint.ClusterPublicEndpointManagementService) StackEvent(com.sequenceiq.cloudbreak.reactor.api.event.StackEvent) StackStatusFinalizer(com.sequenceiq.cloudbreak.core.flow2.StackStatusFinalizer) CCM_UPGRADE_EVENT(com.sequenceiq.cloudbreak.core.flow2.cluster.ccm.upgrade.CcmUpgradeEvent.CCM_UPGRADE_EVENT) Inject(javax.inject.Inject) ConsumerCheckerEventBus(com.sequenceiq.flow.reactor.eventbus.ConsumerCheckerEventBus) ArgumentCaptor(org.mockito.ArgumentCaptor) ReactorNotifier(com.sequenceiq.cloudbreak.core.flow2.service.ReactorNotifier) FlowLogRepository(com.sequenceiq.flow.repository.FlowLogRepository) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) NotificationService(com.sequenceiq.notification.NotificationService) CcmUpgradePreparationHandler(com.sequenceiq.cloudbreak.reactor.handler.cluster.upgrade.ccm.CcmUpgradePreparationHandler) CbEventParameterFactory(com.sequenceiq.cloudbreak.core.flow2.service.CbEventParameterFactory) SpringExtension(org.springframework.test.context.junit.jupiter.SpringExtension) Import(org.springframework.context.annotation.Import) CcmUnregisterHostsHandler(com.sequenceiq.cloudbreak.reactor.handler.cluster.upgrade.ccm.CcmUnregisterHostsHandler) Mockito.times(org.mockito.Mockito.times) InMemoryReporter(io.jaegertracing.internal.reporters.InMemoryReporter) Mockito.when(org.mockito.Mockito.when) FlowNotTriggerableException(com.sequenceiq.flow.core.exception.FlowNotTriggerableException) EventBusSpec(reactor.bus.spec.EventBusSpec) ComponentScan(org.springframework.context.annotation.ComponentScan) Mockito.verify(org.mockito.Mockito.verify) MDCCleanerThreadPoolExecutor(com.sequenceiq.cloudbreak.logger.concurrent.MDCCleanerThreadPoolExecutor) Mockito.never(org.mockito.Mockito.never) CloudbreakFlowInformation(com.sequenceiq.cloudbreak.core.flow2.CloudbreakFlowInformation) Assertions(org.junit.jupiter.api.Assertions) Bean(org.springframework.context.annotation.Bean) Environment(reactor.Environment) FlowLog(com.sequenceiq.flow.domain.FlowLog) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Test(org.junit.jupiter.api.Test)

Example 92 with FlowLog

use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.

the class ResizeRecoveryService method validateRecovery.

public SdxRecoverableResponse validateRecovery(SdxCluster sdxCluster) {
    Optional<FlowLog> flowLogOptional = flow2Handler.getFirstStateLogfromLatestFlow(sdxCluster.getId());
    if (flowLogOptional.isEmpty()) {
        return new SdxRecoverableResponse("No recent actions on this cluster", RecoveryStatus.NON_RECOVERABLE);
    }
    if (entitlementService.isDatalakeResizeRecoveryEnabled(ThreadBasedUserCrnProvider.getAccountId())) {
        if (!DatalakeResizeFlowEventChainFactory.class.getSimpleName().equals(flowChainLogService.getFlowChainType(flowLogOptional.get().getFlowChainId()))) {
            return new SdxRecoverableResponse("No recent resize operation", RecoveryStatus.NON_RECOVERABLE);
        }
    } else {
        return new SdxRecoverableResponse("Resize Recovery entitlement not enabled", RecoveryStatus.NON_RECOVERABLE);
    }
    SdxStatusEntity actualStatusForSdx = sdxStatusService.getActualStatusForSdx(sdxCluster);
    switch(actualStatusForSdx.getStatus()) {
        case STOP_FAILED:
            return new SdxRecoverableResponse("Resize can be recovered from a failed stop", RecoveryStatus.RECOVERABLE);
        case PROVISIONING_FAILED:
            return new SdxRecoverableResponse("Failed to provision, recovery will restart original data lake, and delete the new one", RecoveryStatus.RECOVERABLE);
        case DATALAKE_RESTORE_FAILED:
            return new SdxRecoverableResponse("Failed to restore backup to new data lake, recovery will restart original data lake, and delete the new one", RecoveryStatus.RECOVERABLE);
        case DELETE_FAILED:
            return new SdxRecoverableResponse("Failed to delete original data lake, not a recoverable error", RecoveryStatus.NON_RECOVERABLE);
        default:
            return new SdxRecoverableResponse("Resize can not be recovered from this point", RecoveryStatus.NON_RECOVERABLE);
    }
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) SdxRecoverableResponse(com.sequenceiq.sdx.api.model.SdxRecoverableResponse)

Aggregations

FlowLog (com.sequenceiq.flow.domain.FlowLog)92 Test (org.junit.jupiter.api.Test)25 Test (org.junit.Test)23 ArrayList (java.util.ArrayList)21 List (java.util.List)13 FlowConfiguration (com.sequenceiq.flow.core.config.FlowConfiguration)12 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)11 Mockito.times (org.mockito.Mockito.times)11 Mockito.verify (org.mockito.Mockito.verify)11 Mockito.when (org.mockito.Mockito.when)11 HelloWorldFlowConfig (com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig)10 Map (java.util.Map)10 UUID (java.util.UUID)10 Collectors (java.util.stream.Collectors)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 Clock (com.sequenceiq.cloudbreak.common.service.Clock)9 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)9 FlowRegister (com.sequenceiq.flow.core.FlowRegister)9 SecureRandom (java.security.SecureRandom)9 Random (java.util.Random)9