use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class SampleServiceImplIT method testGetSamplesForAnalysisSubmission.
@Test
@WithMockUser(username = "fbristow", roles = "USER")
public void testGetSamplesForAnalysisSubmission() {
AnalysisSubmission submission = analysisSubmissionService.read(1L);
Collection<Sample> samples = sampleService.getSamplesForAnalysisSubmission(submission);
assertEquals("should be 2 samples", 2, samples.size());
Set<Long> ids = Sets.newHashSet(8L, 9L);
samples.forEach(s -> ids.remove(s.getId()));
assertTrue("all sample ids should be found", ids.isEmpty());
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class AnalysisExecutionScheduledTaskImplTest method testPrepareAnalysisPriorities.
@Test
public void testPrepareAnalysisPriorities() throws ExecutionManagerException, IOException, IridaWorkflowNotFoundException {
AnalysisSubmission low = AnalysisSubmission.builder(workflowId).name("low").inputFiles(sequenceFiles).priority(AnalysisSubmission.Priority.LOW).build();
AnalysisSubmission medium = AnalysisSubmission.builder(workflowId).name("medium").inputFiles(sequenceFiles).priority(AnalysisSubmission.Priority.MEDIUM).build();
AnalysisSubmission high = AnalysisSubmission.builder(workflowId).name("high").inputFiles(sequenceFiles).priority(AnalysisSubmission.Priority.HIGH).build();
when(analysisSubmissionRepository.findByAnalysisState(AnalysisState.NEW)).thenReturn(Arrays.asList(medium, high, low));
when(analysisExecutionService.getCapacity()).thenReturn(2);
analysisExecutionScheduledTask.prepareAnalyses();
verify(analysisExecutionService).prepareSubmission(high);
verify(analysisExecutionService).prepareSubmission(medium);
verify(analysisExecutionService, times(0)).prepareSubmission(low);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class AnalysisControllerTest method testGetAnalysisDetailsTree.
@Test
public void testGetAnalysisDetailsTree() throws IOException, IridaWorkflowNotFoundException {
Long submissionId = 1L;
ExtendedModelMap model = new ExtendedModelMap();
Locale locale = Locale.ENGLISH;
final IridaWorkflowInput input = new IridaWorkflowInput("single", "paired", "reference", true);
AnalysisSubmission submission = TestDataFactory.constructAnalysisSubmission();
IridaWorkflowDescription description = new IridaWorkflowDescription(submission.getWorkflowId(), "My Workflow", "V1", AnalysisType.PHYLOGENOMICS, input, Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList());
IridaWorkflow iridaWorkflow = new IridaWorkflow(description, null);
submission.setAnalysisState(AnalysisState.COMPLETED);
when(analysisSubmissionServiceMock.read(submissionId)).thenReturn(submission);
when(iridaWorkflowsServiceMock.getIridaWorkflow(submission.getWorkflowId())).thenReturn(iridaWorkflow);
String detailsPage = analysisController.getDetailsPage(submissionId, model, locale);
assertEquals("should be details page", AnalysisController.PAGE_DETAILS_DIRECTORY + "tree", detailsPage);
assertEquals("Tree preview should be set", "tree", model.get("preview"));
assertEquals("submission should be in model", submission, model.get("analysisSubmission"));
assertEquals("submission reference file should be in model.", submission.getReferenceFile().get(), model.get("referenceFile"));
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class AnalysisExecutionScheduledTaskImplIT method testFullAnalysisRunSuccessTwoSubmissions.
/**
* Tests out successfully executing two analyses submissions, from newly
* created to downloading results.
*
* @throws Exception
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testFullAnalysisRunSuccessTwoSubmissions() throws Exception {
AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePath, referenceFilePath, validIridaWorkflowId, false);
AnalysisSubmission analysisSubmission2 = analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePath2, referenceFilePath2, validIridaWorkflowId, false);
validateFullAnalysisWithCleanup(Sets.newHashSet(analysisSubmission, analysisSubmission2), 2);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class AnalysisExecutionScheduledTaskImplIT method testFullAnalysisRunCleanupFailInvalidRemoteAnalysisId.
/**
* Tests out failing to complete execution of a workflow due to an error
* with the remote analysis id, then failing to clean up the intermediate
* files.
*
* @throws Throwable
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testFullAnalysisRunCleanupFailInvalidRemoteAnalysisId() throws Throwable {
analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePath, referenceFilePath, validIridaWorkflowId, false);
// PREPARE SUBMISSION
Set<Future<AnalysisSubmission>> submissionsFutureSet = analysisExecutionScheduledTask.prepareAnalyses();
assertEquals(1, submissionsFutureSet.size());
// wait until finished
for (Future<AnalysisSubmission> submissionFuture : submissionsFutureSet) {
AnalysisSubmission returnedSubmission = submissionFuture.get();
assertEquals(AnalysisState.PREPARED, returnedSubmission.getAnalysisState());
}
// EXECUTE SUBMISSION
submissionsFutureSet = analysisExecutionScheduledTask.executeAnalyses();
assertEquals(1, submissionsFutureSet.size());
// wait until finished
AnalysisSubmission returnedSubmission = submissionsFutureSet.iterator().next().get();
assertEquals(AnalysisState.RUNNING, returnedSubmission.getAnalysisState());
// Modify remoteAnalysisId so getting the status fails
returnedSubmission.setRemoteAnalysisId("invalid");
analysisSubmissionRepository.save(returnedSubmission);
// CHECK GALAXY STATUS
submissionsFutureSet = analysisExecutionScheduledTask.monitorRunningAnalyses();
// Should be in error state
assertEquals(1, submissionsFutureSet.size());
returnedSubmission = submissionsFutureSet.iterator().next().get();
assertEquals(AnalysisState.ERROR, returnedSubmission.getAnalysisState());
submissionsFutureSet = analysisExecutionScheduledTask.cleanupAnalysisSubmissions();
// Should be in cleaning_error state
assertEquals("invalid number of analyses returned", 1, submissionsFutureSet.size());
try {
returnedSubmission = submissionsFutureSet.iterator().next().get();
fail("No exception thrown");
} catch (ExecutionException e) {
assertEquals("Invalid cleaned state", AnalysisCleanedState.CLEANING_ERROR, analysisSubmissionRepository.findOne(returnedSubmission.getId()).getAnalysisCleanedState());
}
}
Aggregations