Search in sources :

Example 6 with DatalakeRestoreStatusResponse

use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse in project cloudbreak by hortonworks.

the class GrpcStatusResponseToDatalakeBackupStatusResponseConverterTest method testFailedRestoreAdminOperations.

@Test
public void testFailedRestoreAdminOperations() {
    datalakeDRProto.AdminOperationsBackupRestoreState.Builder adminBuilder = datalakeDRProto.AdminOperationsBackupRestoreState.newBuilder().setStopServices(createStatus(FAILED_STATE, FAILURE_REASON)).setStartServices(createStatus(FAILED_STATE, FAILURE_REASON2));
    datalakeDRProto.InternalBackupRestoreState.Builder stateBuilder = datalakeDRProto.InternalBackupRestoreState.newBuilder().setAdminOperations(adminBuilder);
    datalakeDRProto.RestoreDatalakeStatusResponse.Builder builder = datalakeDRProto.RestoreDatalakeStatusResponse.newBuilder().setOverallState(FAILED_STATE).setOperationStates(stateBuilder);
    String expectedFailure = getFailureString(OperationEnum.STOP_SERVICES.description(), FAILURE_REASON) + ", " + getFailureString(OperationEnum.START_SERVICES.description(), FAILURE_REASON2);
    DatalakeRestoreStatusResponse response = underTest.convert(builder.build());
    assertEquals(DatalakeRestoreStatusResponse.State.FAILED, response.getState());
    assertEquals(expectedFailure, response.getFailureReason());
    assert response.isComplete();
}
Also used : DatalakeRestoreStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse) Test(org.junit.Test)

Example 7 with DatalakeRestoreStatusResponse

use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse in project cloudbreak by hortonworks.

the class GrpcStatusResponseToDatalakeBackupStatusResponseConverterTest method testRestoreLegacyFailureReason.

@Test
public void testRestoreLegacyFailureReason() {
    datalakeDRProto.RestoreDatalakeStatusResponse.Builder builder = datalakeDRProto.RestoreDatalakeStatusResponse.newBuilder().setOverallState(FAILED_STATE).setFailureReason(FAILURE_REASON);
    DatalakeRestoreStatusResponse response = underTest.convert(builder.build());
    assertEquals(DatalakeRestoreStatusResponse.State.FAILED, response.getState());
    assertEquals(FAILURE_REASON, response.getFailureReason());
    assert response.isComplete();
}
Also used : DatalakeRestoreStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse) Test(org.junit.Test)

Example 8 with DatalakeRestoreStatusResponse

use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse in project cloudbreak by hortonworks.

the class GrpcStatusResponseToDatalakeBackupStatusResponseConverterTest method testFailedHbaseRestoreSameFailureReason.

@Test
public void testFailedHbaseRestoreSameFailureReason() {
    datalakeDRProto.HbaseBackupRestoreState.Builder hbaseBuilder = datalakeDRProto.HbaseBackupRestoreState.newBuilder().setAtlasJanusTable(createStatus(FAILED_STATE, FAILURE_REASON)).setAtlasEntityAuditEventTable(createStatus(FAILED_STATE, FAILURE_REASON));
    datalakeDRProto.InternalBackupRestoreState.Builder stateBuilder = datalakeDRProto.InternalBackupRestoreState.newBuilder().setHbase(hbaseBuilder);
    datalakeDRProto.RestoreDatalakeStatusResponse.Builder builder = datalakeDRProto.RestoreDatalakeStatusResponse.newBuilder().setOverallState(FAILED_STATE).setOperationStates(stateBuilder);
    String expectedFailure = getFailureString(OperationEnum.HBASE.description(), FAILURE_REASON);
    DatalakeRestoreStatusResponse response = underTest.convert(builder.build());
    assertEquals(DatalakeRestoreStatusResponse.State.FAILED, response.getState());
    assertEquals(expectedFailure, response.getFailureReason());
    assert response.isComplete();
}
Also used : DatalakeRestoreStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse) Test(org.junit.Test)

Example 9 with DatalakeRestoreStatusResponse

use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse in project cloudbreak by hortonworks.

the class GrpcStatusResponseToDatalakeBackupStatusResponseConverterTest method testFailedSolrRestoreSameFailureReasonWithDelete.

@Test
public void testFailedSolrRestoreSameFailureReasonWithDelete() {
    datalakeDRProto.SolrBackupRestoreState.Builder solrBuilder = datalakeDRProto.SolrBackupRestoreState.newBuilder().setEdgeIndexCollection(createStatus(FAILED_STATE, FAILURE_REASON)).setFulltextIndexCollection(createStatus(FAILED_STATE, FAILURE_REASON)).setRangerAuditsCollection(createStatus(FAILED_STATE, FAILURE_REASON)).setVertexIndexCollection(createStatus(FAILED_STATE, FAILURE_REASON)).setEdgeIndexCollectionDelete(createStatus(FAILED_STATE, FAILURE_REASON2)).setFulltextIndexCollectionDelete(createStatus(FAILED_STATE, FAILURE_REASON2)).setRangerAuditsCollectionDelete(createStatus(FAILED_STATE, FAILURE_REASON2)).setVertexIndexCollectionDelete(createStatus(FAILED_STATE, FAILURE_REASON2));
    datalakeDRProto.InternalBackupRestoreState.Builder stateBuilder = datalakeDRProto.InternalBackupRestoreState.newBuilder().setSolr(solrBuilder);
    datalakeDRProto.RestoreDatalakeStatusResponse.Builder builder = datalakeDRProto.RestoreDatalakeStatusResponse.newBuilder().setOverallState(FAILED_STATE).setOperationStates(stateBuilder);
    String expectedFailure = getFailureString(OperationEnum.SOLR.description(), FAILURE_REASON) + ", " + getFailureString(OperationEnum.SOLR_DELETE.description(), FAILURE_REASON2);
    DatalakeRestoreStatusResponse response = underTest.convert(builder.build());
    assertEquals(DatalakeRestoreStatusResponse.State.FAILED, response.getState());
    assertEquals(expectedFailure, response.getFailureReason());
    assert response.isComplete();
}
Also used : DatalakeRestoreStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse) Test(org.junit.Test)

Example 10 with DatalakeRestoreStatusResponse

use of com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse in project cloudbreak by hortonworks.

the class DatalakeRestoreActionsTest method testRestoreWithNoFlowChain.

@Test
public void testRestoreWithNoFlowChain() throws Exception {
    when(sdxBackupRestoreService.triggerDatalakeRestore(eq(OLD_SDX_ID), any(), any(), eq(USER_CRN))).thenReturn(new DatalakeRestoreStatusResponse(BACKUP_ID, RESTORE_ID, State.STARTED, Optional.empty()));
    DatalakeTriggerRestoreEvent event = new DatalakeTriggerRestoreEvent(DATALAKE_TRIGGER_RESTORE_EVENT.event(), OLD_SDX_ID, DATALAKE_NAME, USER_CRN, null, BACKUP_LOCATION, null, DatalakeRestoreFailureReason.RESTORE_ON_RESIZE);
    AbstractAction action = (AbstractAction) underTest.triggerDatalakeRestore();
    initActionPrivateFields(action);
    AbstractActionTestSupport testSupport = new AbstractActionTestSupport(action);
    SdxContext context = SdxContext.from(new FlowParameters(FLOW_ID, FLOW_ID, null), event);
    testSupport.doExecute(context, event, new HashMap());
    ArgumentCaptor<DatalakeDatabaseRestoreStartEvent> captor = ArgumentCaptor.forClass(DatalakeDatabaseRestoreStartEvent.class);
    verify(reactorEventFactory, times(1)).createEvent(any(), captor.capture());
    DatalakeDatabaseRestoreStartEvent captorValue = captor.getValue();
    Assertions.assertEquals(OLD_SDX_ID, captorValue.getResourceId());
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) DatalakeTriggerRestoreEvent(com.sequenceiq.datalake.flow.dr.restore.event.DatalakeTriggerRestoreEvent) HashMap(java.util.HashMap) AbstractActionTestSupport(com.sequenceiq.flow.core.AbstractActionTestSupport) DatalakeDatabaseRestoreStartEvent(com.sequenceiq.datalake.flow.dr.restore.event.DatalakeDatabaseRestoreStartEvent) AbstractAction(com.sequenceiq.flow.core.AbstractAction) DatalakeRestoreStatusResponse(com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Test(org.junit.jupiter.api.Test)

Aggregations

DatalakeRestoreStatusResponse (com.sequenceiq.cloudbreak.datalakedr.model.DatalakeRestoreStatusResponse)12 Test (org.junit.Test)9 SdxContext (com.sequenceiq.datalake.flow.SdxContext)3 DatalakeTriggerRestoreEvent (com.sequenceiq.datalake.flow.dr.restore.event.DatalakeTriggerRestoreEvent)3 FlowParameters (com.sequenceiq.flow.core.FlowParameters)3 DatalakeDatabaseRestoreStartEvent (com.sequenceiq.datalake.flow.dr.restore.event.DatalakeDatabaseRestoreStartEvent)2 AbstractAction (com.sequenceiq.flow.core.AbstractAction)2 AbstractActionTestSupport (com.sequenceiq.flow.core.AbstractActionTestSupport)2 HashMap (java.util.HashMap)2 Test (org.junit.jupiter.api.Test)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)1 FlowChainLog (com.sequenceiq.flow.domain.FlowChainLog)1 FlowLog (com.sequenceiq.flow.domain.FlowLog)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1