1 /* Copyright (c) 2009 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
18 package compbio.runner._impl;
\r
20 import static org.testng.AssertJUnit.assertEquals;
\r
21 import static org.testng.AssertJUnit.assertFalse;
\r
22 import static org.testng.AssertJUnit.assertNotNull;
\r
23 import static org.testng.AssertJUnit.assertTrue;
\r
24 import static org.testng.AssertJUnit.fail;
\r
26 import java.text.ParseException;
\r
28 import org.ggf.drmaa.DrmaaException;
\r
29 import org.ggf.drmaa.JobInfo;
\r
30 import org.testng.annotations.Test;
\r
32 import compbio.engine.cluster.drmaa.ClusterUtil;
\r
33 import compbio.engine.cluster.drmaa.JobRunner;
\r
34 import compbio.engine.cluster.drmaa.StatisticManager;
\r
35 import compbio.metadata.AllTestSuit;
\r
36 import compbio.metadata.JobExecutionException;
\r
37 import compbio.metadata.JobStatus;
\r
38 import compbio.metadata.JobSubmissionException;
\r
41 * TODO this needs fixing! Executable does not work
\r
46 public class OBTester {
\r
48 public static String test_input = "/homes/pvtroshin/TO1381.fasta";
\r
49 public static String test_outfile = "/homes/pvtroshin/TO1381.OB.out";
\r
52 public void testGetTestCommand() {
\r
53 System.out.println(OB.getTestCommand());
\r
57 public void testGetTestArgsCommand() {
\r
58 System.out.println(new OB().getTestArgs());
\r
61 @Test(enabled = false, groups = { AllTestSuit.test_group_cluster,
\r
62 AllTestSuit.test_group_runner })
\r
63 public void testBuildCommand() {
\r
64 OB ob = new OB(AllTestSuit.OUTPUT_DIR_ABSOLUTE);
\r
65 // TODO ob.setInput(test_input).setOutput(test_outfile);
\r
66 // ob.setParameters(ob.getTestArgs());
\r
69 JobRunner runner = JobRunner.getInstance(null);
\r
70 assertNotNull("Runner is NULL", runner);
\r
71 runner.executeJob();
\r
72 // assertNotNull("Job id is null", jobId1);
\r
73 JobStatus status = runner.getJobStatus();
\r
74 assertTrue("Status is not queing but " + status,
\r
75 status == JobStatus.PENDING || status == JobStatus.RUNNING);
\r
76 JobInfo info = runner.getJobInfo();
\r
77 assertNotNull("JobInfo is null", info);
\r
78 StatisticManager sm = new StatisticManager(info);
\r
79 assertNotNull("Stat manager is null", sm);
\r
81 String time_s = sm.getCalculationTime();
\r
82 assertNotNull("Time is null", time_s);
\r
83 float time = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(time_s)
\r
85 String exits = sm.getExitStatus();
\r
86 assertNotNull("Exit status is null", exits);
\r
87 int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits)
\r
89 assertEquals("Exit status is not 0", 0, exitsInt);
\r
90 System.out.println(sm.getAllStats());
\r
92 } catch (ParseException e) {
\r
93 e.printStackTrace();
\r
94 fail("Parse Exception: " + e.getLocalizedMessage());
\r
97 assertTrue("Process exited:", sm.hasExited());
\r
98 assertFalse("Process aborted:", sm.wasAborted());
\r
99 assertFalse("Process hasdump:", sm.hasDump());
\r
100 assertFalse("Process signaled:", sm.hasSignaled());
\r
102 } catch (DrmaaException e) {
\r
103 e.printStackTrace();
\r
104 fail("Drmaa exception: " + e.getLocalizedMessage());
\r
105 } catch (JobSubmissionException e) {
\r
106 e.printStackTrace();
\r
107 fail("JobSubmission failure: " + e.getLocalizedMessage());
\r
108 } catch (JobExecutionException e) {
\r
109 e.printStackTrace();
\r
110 fail("JobSubmission failure: " + e.getLocalizedMessage());
\r