Search in sources :

Example 56 with AnalysisSubmission

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());
}
Also used : Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 57 with AnalysisSubmission

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);
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) Test(org.junit.Test)

Example 58 with AnalysisSubmission

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"));
}
Also used : Locale(java.util.Locale) ExtendedModelMap(org.springframework.ui.ExtendedModelMap) IridaWorkflowInput(ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowInput) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) IridaWorkflowDescription(ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription) Test(org.junit.Test)

Example 59 with AnalysisSubmission

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);
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 60 with AnalysisSubmission

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());
    }
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) Future(java.util.concurrent.Future) ExecutionException(java.util.concurrent.ExecutionException) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)183 Test (org.junit.Test)121 WithMockUser (org.springframework.security.test.context.support.WithMockUser)95 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)30 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)30 Path (java.nio.file.Path)25 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)23 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)20 Project (ca.corefacility.bioinformatics.irida.model.project.Project)19 History (com.github.jmchilton.blend4j.galaxy.beans.History)19 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)18 AnalysisOutputFile (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile)18 WorkflowsClient (com.github.jmchilton.blend4j.galaxy.WorkflowsClient)18 Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)18 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)15 User (ca.corefacility.bioinformatics.irida.model.user.User)15 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)12 ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)12 ProjectAnalysisSubmissionJoin (ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin)12 ToolExecution (ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution)11