use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus in project irida by phac-nml.
the class GalaxyWorkflowsIT method testExecuteWorkflow.
/**
* Tests executing a single workflow in Galaxy.
* @throws ExecutionManagerException
*/
@Test
public void testExecuteWorkflow() throws ExecutionManagerException {
String workflowId = localGalaxy.getSingleInputWorkflowId();
String workflowInputLabel = localGalaxy.getSingleInputWorkflowLabel();
WorkflowOutputs workflowOutput = runSingleFileWorkflow(dataFile1, FILE_TYPE, workflowId, workflowInputLabel);
assertNotNull(workflowOutput);
assertNotNull(workflowOutput.getHistoryId());
// history should exist
HistoryDetails historyDetails = historiesClient.showHistory(workflowOutput.getHistoryId());
assertNotNull(historyDetails);
// outputs should exist
assertNotNull(workflowOutput.getOutputIds());
assertTrue(workflowOutput.getOutputIds().size() > 0);
// each output dataset should exist
for (String outputId : workflowOutput.getOutputIds()) {
Dataset dataset = historiesClient.showDataset(workflowOutput.getHistoryId(), outputId);
assertNotNull(dataset);
}
// test get workflow status
GalaxyWorkflowStatus workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
float percentComplete = workflowStatus.getProportionComplete();
assertTrue(0.0f <= percentComplete && percentComplete <= 1.0f);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus in project irida by phac-nml.
the class GalaxyWorkflowsIT method testGetWorkflowStatusErrorWhileRunning.
/**
* Tests executing a single workflow in Galaxy and getting an error status if one of the tools is in error even while running.
* @throws ExecutionManagerException
* @throws InterruptedException
* @throws TimeoutException
*/
@Test
public void testGetWorkflowStatusErrorWhileRunning() throws ExecutionManagerException, TimeoutException, InterruptedException {
final String SLEEP_TIME_SECONDS = "30";
History history = galaxyHistory.newHistoryForWorkflow();
WorkflowOutputs workflowOutput = runSingleFileTabularWorkflowFilterTool(history, dataFile1, INVALID_FILTER_PARAMETER);
Util.waitUntilHistoryComplete(workflowOutput.getHistoryId(), galaxyHistory, 60);
// test get workflow status, should be in error
GalaxyWorkflowStatus workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
assertEquals("final workflow state is invalid", GalaxyWorkflowState.ERROR, workflowStatus.getState());
// run a sleep workflow to keep busy
runSingleFileTabularWorkflowSleepTool(history, dataFile2, SLEEP_TIME_SECONDS);
// check status. I'm assuming the tasks launched above are not complete.
workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
assertTrue("workflow should still be running", workflowStatus.isRunning());
assertTrue("an error should have occured even while running", workflowStatus.errorOccurred());
Util.waitUntilHistoryComplete(workflowOutput.getHistoryId(), galaxyHistory, 60);
workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
assertEquals("workflow state should be in error after completion", GalaxyWorkflowState.ERROR, workflowStatus.getState());
assertTrue("workflow is not in error state", workflowStatus.errorOccurred());
}
use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus in project irida by phac-nml.
the class Util method waitUntilHistoryComplete.
/**
* Waits for the given history to complete or until a timeout occurs.
* @param historyId The id of the history to wait for.
* @param historyService The history service to get the status of the history.
* @param timeout The timeout, in seconds.
* @throws TimeoutException If a timeout occurs
* @throws ExecutionManagerException
* @throws InterruptedException
*/
public static void waitUntilHistoryComplete(String historyId, GalaxyHistoriesService historyService, int timeout) throws TimeoutException, ExecutionManagerException, InterruptedException {
GalaxyWorkflowStatus workflowStatus;
long timeBefore = System.currentTimeMillis();
do {
workflowStatus = historyService.getStatusForHistory(historyId);
long timeAfter = System.currentTimeMillis();
double deltaSeconds = (timeAfter - timeBefore) / 1000.0;
if (deltaSeconds <= timeout) {
Thread.sleep(2000);
} else {
throw new TimeoutException("Timeout for history " + historyId + " " + deltaSeconds + "s > " + timeout + "s");
}
} while (!(GalaxyWorkflowState.OK.equals(workflowStatus.getState()) || GalaxyWorkflowState.ERROR.equals(workflowStatus.getState())));
}
use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus in project irida by phac-nml.
the class GalaxyWorkflowStatusTest method testBuildWorkflowStatusFromHistoryDetailsSuccessComplete.
/**
* Tests successfully building a workflow status from history details
* (everything complete).
*/
@Test
public void testBuildWorkflowStatusFromHistoryDetailsSuccessComplete() {
HistoryDetails historyDetails = new HistoryDetails();
historyDetails.setState("ok");
historyDetails.setStateIds(Util.buildStateIdsWithStateFilled("ok", Lists.newArrayList(DATASET_ID)));
GalaxyWorkflowStatus workflowStatus = GalaxyWorkflowStatus.builder(historyDetails).build();
assertEquals("workflow status not in correct state", GalaxyWorkflowState.OK, workflowStatus.getState());
assertEquals("percentage complete not correct", 1.0f, workflowStatus.getProportionComplete(), DELTA);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus in project irida by phac-nml.
the class GalaxyWorkflowStatusTest method testErrorOccuredDiscarded.
/**
* Tests whether or not this workflow is in an error state when it is discarded.
*/
@Test
public void testErrorOccuredDiscarded() {
HistoryDetails historyDetails = new HistoryDetails();
historyDetails.setState("discarded");
historyDetails.setStateIds(Util.buildStateIdsWithStateFilled("discarded", Lists.newArrayList(DATASET_ID)));
GalaxyWorkflowStatus workflowStatus = GalaxyWorkflowStatus.builder(historyDetails).build();
assertTrue("Workflow is not in an error state", workflowStatus.errorOccurred());
}
Aggregations