use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class AnalysisExecutionServiceGalaxyTest method testCleanupCompletedSubmissionSuccess.
/**
* Tests successfully executing the cleanup method on a completed
* submission.
*
* @throws ExecutionManagerException
* @throws ExecutionException
* @throws InterruptedException
*/
@Test
public void testCleanupCompletedSubmissionSuccess() throws ExecutionManagerException, InterruptedException, ExecutionException {
when(analysisSubmissionService.update(analysisCompleted)).thenReturn(analysisCompletedCleaning);
when(analysisSubmissionService.update(analysisCompletedCleaning)).thenReturn(analysisCompletedCleaned);
Future<AnalysisSubmission> cleaningSubmissionFuture = workflowManagement.cleanupSubmission(analysisCompleted);
AnalysisSubmission cleaningSubmission = cleaningSubmissionFuture.get();
assertEquals(AnalysisCleanedState.CLEANED, cleaningSubmission.getAnalysisCleanedState());
verify(galaxyHistoriesService).deleteHistory(ANALYSIS_ID);
verify(galaxyLibrariesService).deleteLibrary(LIBRARY_ID);
verify(galaxyWorkflowService).deleteWorkflow(REMOTE_WORKFLOW_ID);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class AnalysisExecutionServiceGalaxyTest method testCleanupErrorSubmissionSuccess.
/**
* Tests successfully executing the cleanup method on a error submission.
*
* @throws ExecutionManagerException
* @throws ExecutionException
* @throws InterruptedException
*/
@Test
public void testCleanupErrorSubmissionSuccess() throws ExecutionManagerException, InterruptedException, ExecutionException {
when(analysisSubmissionService.update(analysisError)).thenReturn(analysisErrorCleaning);
when(analysisSubmissionService.update(analysisErrorCleaning)).thenReturn(analysisErrorCleaned);
Future<AnalysisSubmission> cleaningSubmissionFuture = workflowManagement.cleanupSubmission(analysisError);
AnalysisSubmission cleaningSubmission = cleaningSubmissionFuture.get();
assertEquals(AnalysisCleanedState.CLEANED, cleaningSubmission.getAnalysisCleanedState());
verify(galaxyHistoriesService, never()).deleteHistory(ANALYSIS_ID);
verify(galaxyLibrariesService, never()).deleteLibrary(LIBRARY_ID);
verify(galaxyWorkflowService).deleteWorkflow(REMOTE_WORKFLOW_ID);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method testPrepareAnalysisFilesParametersFailInvalidParameter.
/**
* Tests out failing to prepare paired workflow input files for execution
* with parameters due to an invalid parameter passed.
*
* @throws InterruptedException
* @throws ExecutionManagerException
* @throws IOException
* @throws IridaWorkflowException
*/
@Test(expected = IridaWorkflowParameterException.class)
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testPrepareAnalysisFilesParametersFailInvalidParameter() throws InterruptedException, ExecutionManagerException, IOException, IridaWorkflowException {
History history = new History();
history.setName("testPrepareAnalysisFilesParametersFailInvalidParameter");
HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
History createdHistory = historiesClient.create(history);
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(validWorkflowIdPairedWithParameters);
Path workflowPath = iridaWorkflow.getWorkflowStructure().getWorkflowFile();
String workflowString = new String(Files.readAllBytes(workflowPath), StandardCharsets.UTF_8);
Workflow galaxyWorkflow = workflowsClient.importWorkflow(workflowString);
Map<String, String> parameters = ImmutableMap.of("invalid", "20");
AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, pairSequenceFiles1A, pairSequenceFiles2A, referenceFilePath, parameters, validWorkflowIdPairedWithParameters);
analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
analysisWorkspaceService.prepareAnalysisFiles(analysisSubmission);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method testPrepareAnalysisFilesFail.
/**
* Tests out failure to prepare workflow input files for execution.
*
* @throws InterruptedException
* @throws ExecutionManagerException
* @throws IOException
* @throws IridaWorkflowException
*/
@Test(expected = WorkflowException.class)
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testPrepareAnalysisFilesFail() throws InterruptedException, ExecutionManagerException, IOException, IridaWorkflowException {
History history = new History();
history.setName("testPrepareAnalysisFilesFail");
HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
History createdHistory = historiesClient.create(history);
AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePathA, referenceFilePath, validWorkflowIdSingle, false);
analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
analysisSubmission.setRemoteWorkflowId("invalid");
analysisWorkspaceService.prepareAnalysisFiles(analysisSubmission);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method testPrepareAnalysisFilesSinglePairSuccess.
/**
* Tests out successfully preparing paired and single workflow input files
* for execution.
*
* @throws InterruptedException
* @throws ExecutionManagerException
* @throws IOException
* @throws IridaWorkflowException
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testPrepareAnalysisFilesSinglePairSuccess() throws InterruptedException, ExecutionManagerException, IOException, IridaWorkflowException {
History history = new History();
history.setName("testPrepareAnalysisFilesPairSuccess");
HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
History createdHistory = historiesClient.create(history);
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(validWorkflowIdSinglePaired);
Path workflowPath = iridaWorkflow.getWorkflowStructure().getWorkflowFile();
String workflowString = new String(Files.readAllBytes(workflowPath), StandardCharsets.UTF_8);
Workflow galaxyWorkflow = workflowsClient.importWorkflow(workflowString);
AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupSinglePairSubmissionInDatabaseDifferentSample(1L, 2L, pairSequenceFiles1A, pairSequenceFiles2A, sequenceFilePath3, referenceFilePath, validWorkflowIdSinglePaired);
analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
PreparedWorkflowGalaxy preparedWorkflow = analysisWorkspaceService.prepareAnalysisFiles(analysisSubmission);
assertEquals("the response history id should match the input history id", createdHistory.getId(), preparedWorkflow.getRemoteAnalysisId());
WorkflowInputsGalaxy workflowInputsGalaxy = preparedWorkflow.getWorkflowInputs();
assertNotNull("the returned workflow inputs should not be null", workflowInputsGalaxy);
// verify correct files have been uploaded
List<HistoryContents> historyContents = historiesClient.showHistoryContents(createdHistory.getId());
assertEquals("the created history has an invalid number of elements", 6, historyContents.size());
Map<String, HistoryContents> contentsMap = historyContentsAsMap(historyContents);
assertTrue("the created history should contain the file " + sequenceFilePathA.toFile().getName(), contentsMap.containsKey(sequenceFilePathA.toFile().getName()));
assertTrue("the created history should contain the file " + sequenceFilePath2A.toFile().getName(), contentsMap.containsKey(sequenceFilePath2A.toFile().getName()));
assertTrue("the created history should contain the file " + sequenceFilePath3.toFile().getName(), contentsMap.containsKey(sequenceFilePath3.toFile().getName()));
assertTrue("the created history should contain the file " + referenceFilePath.toFile().getName(), contentsMap.containsKey(referenceFilePath.toFile().getName()));
assertTrue("the created history should contain a dataset collection with the name " + INPUTS_SINGLE_NAME, contentsMap.containsKey(INPUTS_SINGLE_NAME));
assertTrue("the created history should contain a dataset collection with the name " + INPUTS_PAIRED_NAME, contentsMap.containsKey(INPUTS_PAIRED_NAME));
// make sure workflow inputs contains correct information
Map<String, WorkflowInput> workflowInputsMap = preparedWorkflow.getWorkflowInputs().getInputsObject().getInputs();
assertEquals("the created workflow inputs has an invalid number of elements", 3, workflowInputsMap.size());
}
Aggregations