use of com.sequenceiq.sdx.api.model.SdxDatabaseBackupRequest in project cloudbreak by hortonworks.
the class SdxBackupRestoreServiceTest method triggerDatabaseBackupSuccess.
@Test
public void triggerDatabaseBackupSuccess() {
when(sdxReactorFlowManager.triggerDatalakeDatabaseBackupFlow(any(DatalakeDatabaseBackupStartEvent.class), anyString())).thenReturn(FLOW_IDENTIFIER);
SdxDatabaseBackupRequest backupRequest = new SdxDatabaseBackupRequest();
backupRequest.setBackupId(BACKUP_ID);
backupRequest.setBackupLocation(BACKUP_LOCATION);
backupRequest.setCloseConnections(true);
SdxDatabaseBackupResponse backupResponse = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> sdxBackupRestoreService.triggerDatabaseBackup(sdxCluster, backupRequest));
assertEquals(FLOW_IDENTIFIER, backupResponse.getFlowIdentifier());
ArgumentCaptor<DatalakeDatabaseBackupStartEvent> eventArgumentCaptor = ArgumentCaptor.forClass(DatalakeDatabaseBackupStartEvent.class);
verify(sdxReactorFlowManager, times(1)).triggerDatalakeDatabaseBackupFlow(eventArgumentCaptor.capture(), anyString());
assertEquals(BACKUP_ID, eventArgumentCaptor.getValue().getBackupRequest().getBackupId());
assertEquals(BACKUP_LOCATION, eventArgumentCaptor.getValue().getBackupRequest().getBackupLocation());
assertEquals(USER_CRN, eventArgumentCaptor.getValue().getUserId());
assertEquals(sdxCluster.getId(), eventArgumentCaptor.getValue().getResourceId());
assertTrue(isUUID(eventArgumentCaptor.getValue().getDrStatus().getOperationId()));
}
use of com.sequenceiq.sdx.api.model.SdxDatabaseBackupRequest in project cloudbreak by hortonworks.
the class SdxBackupController method backupDatabaseByName.
@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.BACKUP_DATALAKE)
public SdxDatabaseBackupResponse backupDatabaseByName(@ResourceName String name, String backupId, String backupLocation) {
SdxCluster sdxCluster = getSdxClusterByName(name);
try {
SdxDatabaseBackupStatusResponse response = sdxBackupRestoreService.getDatabaseBackupStatus(sdxCluster, backupId);
SdxDatabaseBackupResponse sdxDatabaseBackupResponse = new SdxDatabaseBackupResponse();
sdxDatabaseBackupResponse.setOperationId(backupId);
return sdxDatabaseBackupResponse;
} catch (NotFoundException notFoundException) {
SdxDatabaseBackupRequest backupRequest = new SdxDatabaseBackupRequest();
backupRequest.setBackupId(backupId);
backupRequest.setBackupLocation(backupLocation);
backupRequest.setCloseConnections(true);
return sdxBackupRestoreService.triggerDatabaseBackup(sdxCluster, backupRequest);
}
}
Aggregations