package compbio.runner.disorder;\r
\r
import static org.testng.Assert.assertEquals;\r
-import static org.testng.Assert.*;\r
+import static org.testng.Assert.assertFalse;\r
import static org.testng.Assert.assertNotNull;\r
+import static org.testng.Assert.assertNull;\r
import static org.testng.Assert.assertTrue;\r
import static org.testng.Assert.fail;\r
\r
\r
public class JronnTester {\r
\r
- public static String test_outfile = "TO1381.jronn.out"; // "/homes/pvtroshin/TO1381.clustal.cluster.out\r
+ public static String test_outfile = "TO1381.jronn.out"; // "/homes/pvtroshin/TO1381.clustal.cluster.out\r
\r
- private Jronn jronn;\r
+ private Jronn jronn;\r
\r
- @BeforeMethod(alwaysRun = true)\r
- void init() {\r
- jronn = new Jronn();\r
- jronn.setInput(AllTestSuit.test_input).setOutput(test_outfile);\r
- }\r
+ @BeforeMethod(alwaysRun = true)\r
+ void init() {\r
+ jronn = new Jronn();\r
+ jronn.setInput(AllTestSuit.test_input).setOutput(test_outfile);\r
+ }\r
\r
- @Test(groups = { AllTestSuit.test_group_cluster,\r
- AllTestSuit.test_group_runner })\r
- public void testRunOnCluster() {\r
- assertFalse(SysPrefs.isWindows,\r
- "Cluster execution can only be in unix environment");\r
- try {\r
- ConfiguredExecutable<Jronn> confJronn = Configurator\r
- .configureExecutable(jronn, Executable.ExecProvider.Cluster);\r
- JobRunner runner = JobRunner.getInstance(confJronn);\r
+ @Test(groups = { AllTestSuit.test_group_cluster,\r
+ AllTestSuit.test_group_runner })\r
+ public void testRunOnCluster() {\r
+ assertFalse(SysPrefs.isWindows,\r
+ "Cluster execution can only be in unix environment");\r
+ try {\r
+ ConfiguredExecutable<Jronn> confJronn = Configurator\r
+ .configureExecutable(jronn, Executable.ExecProvider.Cluster);\r
+ JobRunner runner = JobRunner.getInstance(confJronn);\r
\r
- assertNotNull(runner, "Runner is NULL");\r
- runner.executeJob();\r
- // assertNotNull("JobId is null", jobId1);\r
- JobStatus status = runner.getJobStatus();\r
- assertTrue(status == JobStatus.PENDING\r
- || status == JobStatus.RUNNING,\r
- "Status of the process is wrong!");\r
- JobInfo info = runner.getJobInfo();\r
- assertNotNull(info, "JobInfo is null");\r
- StatisticManager sm = new StatisticManager(info);\r
- assertNotNull(sm, "Statictic manager is null");\r
- try {\r
+ assertNotNull(runner, "Runner is NULL");\r
+ runner.executeJob();\r
+ // assertNotNull("JobId is null", jobId1);\r
+ JobStatus status = runner.getJobStatus();\r
+ assertTrue(status == JobStatus.PENDING\r
+ || status == JobStatus.RUNNING,\r
+ "Status of the process is wrong!");\r
+ JobInfo info = runner.getJobInfo();\r
+ assertNotNull(info, "JobInfo is null");\r
+ StatisticManager sm = new StatisticManager(info);\r
+ assertNotNull(sm, "Statictic manager is null");\r
+ try {\r
\r
- String exits = sm.getExitStatus();\r
- assertNotNull("Exit status is null", exits);\r
- // cut 4 trailing zeros from the number\r
- int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits)\r
- .intValue();\r
- assertEquals(0, exitsInt);\r
- System.out.println(sm.getAllStats());\r
+ String exits = sm.getExitStatus();\r
+ assertNotNull("Exit status is null", exits);\r
+ // cut 4 trailing zeros from the number\r
+ int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits)\r
+ .intValue();\r
+ assertEquals(0, exitsInt);\r
+ System.out.println(sm.getAllStats());\r
\r
- } catch (ParseException e) {\r
- e.printStackTrace();\r
- fail("Parse Exception: " + e.getMessage());\r
- }\r
- //assertFalse(runner.cleanup());\r
- assertTrue(sm.hasExited());\r
- assertFalse(sm.wasAborted());\r
- assertFalse(sm.hasDump());\r
- assertFalse(sm.hasSignaled());\r
+ } catch (ParseException e) {\r
+ e.printStackTrace();\r
+ fail("Parse Exception: " + e.getMessage());\r
+ }\r
+ //assertFalse(runner.cleanup());\r
+ assertTrue(sm.hasExited());\r
+ assertFalse(sm.wasAborted());\r
+ assertFalse(sm.hasDump());\r
+ assertFalse(sm.hasSignaled());\r
\r
- } catch (JobSubmissionException e) {\r
- e.printStackTrace();\r
- fail("DrmaaException caught:" + e.getMessage());\r
- } catch (JobExecutionException e) {\r
- e.printStackTrace();\r
- fail("DrmaaException caught:" + e.getMessage());\r
- } catch (DrmaaException e) {\r
- e.printStackTrace();\r
- fail("DrmaaException caught:" + e.getMessage());\r
- }\r
+ } catch (JobSubmissionException e) {\r
+ e.printStackTrace();\r
+ fail("DrmaaException caught:" + e.getMessage());\r
+ } catch (JobExecutionException e) {\r
+ e.printStackTrace();\r
+ fail("DrmaaException caught:" + e.getMessage());\r
+ } catch (DrmaaException e) {\r
+ e.printStackTrace();\r
+ fail("DrmaaException caught:" + e.getMessage());\r
}\r
+ }\r
\r
- /**\r
- * This tests fails from time to time depending on the cluster load or some\r
- * other factors. Any client code has to adjust for this issue\r
- */\r
- @Test(groups = { AllTestSuit.test_group_cluster,\r
- AllTestSuit.test_group_runner })\r
- public void testRunOnClusterAsync() {\r
- assertFalse(SysPrefs.isWindows,\r
+ /**\r
+ * This tests fails from time to time depending on the cluster load or some\r
+ * other factors. Any client code has to adjust for this issue\r
+ */\r
+ @Test(groups = { AllTestSuit.test_group_cluster,\r
+ AllTestSuit.test_group_runner })\r
+ public void testRunOnClusterAsync() {\r
+ assertFalse(SysPrefs.isWindows,\r
"Cluster execution can only be in unix environment");\r
- try {\r
- ConfiguredExecutable<Jronn> confJronn = Configurator\r
- .configureExecutable(jronn, Executable.ExecProvider.Cluster);\r
- AsyncExecutor aengine = Configurator.getAsyncEngine(confJronn);\r
- String jobId = aengine.submitJob(confJronn);\r
- assertNotNull(jobId, "Runner is NULL");\r
- // let drmaa to start\r
- Thread.sleep(500);\r
- JobStatus status = aengine.getJobStatus(jobId);\r
- while (status != JobStatus.FINISHED) {\r
- System.out.println("Job Status: " + status);\r
- Thread.sleep(1000);\r
- status = aengine.getJobStatus(jobId);\r
- ConfiguredExecutable<Jronn> result = (ConfiguredExecutable<Jronn>) aengine.getResults(jobId);\r
- assertNotNull(result);\r
- System.out.println("RES:" + result);\r
- // Some times the job could be removed from the cluster accounting \r
- // before it has been reported to finish. Make sure \r
- // to stop waiting in such case\r
- if(status == JobStatus.UNDEFINED) {\r
- break;\r
- }\r
- }\r
- } catch (JobSubmissionException e) {\r
- e.printStackTrace();\r
- fail("DrmaaException caught:" + e.getMessage());\r
- } catch (InterruptedException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (ResultNotAvailableException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
+ try {\r
+ ConfiguredExecutable<Jronn> confJronn = Configurator\r
+ .configureExecutable(jronn, Executable.ExecProvider.Cluster);\r
+ AsyncExecutor aengine = Configurator.getAsyncEngine(confJronn);\r
+ String jobId = aengine.submitJob(confJronn);\r
+ assertNotNull(jobId, "Runner is NULL");\r
+ // let drmaa to start\r
+ Thread.sleep(500);\r
+ JobStatus status = aengine.getJobStatus(jobId);\r
+ while (status != JobStatus.FINISHED) {\r
+ System.out.println("Job Status: " + status);\r
+ Thread.sleep(1000);\r
+ status = aengine.getJobStatus(jobId);\r
+ ConfiguredExecutable<Jronn> result = (ConfiguredExecutable<Jronn>) aengine\r
+ .getResults(jobId);\r
+ assertNotNull(result);\r
+ System.out.println("RES:" + result);\r
+ // Some times the job could be removed from the cluster accounting \r
+ // before it has been reported to finish. Make sure \r
+ // to stop waiting in such case\r
+ if (status == JobStatus.UNDEFINED) {\r
+ break;\r
}\r
+ }\r
+ } catch (JobSubmissionException e) {\r
+ e.printStackTrace();\r
+ fail("DrmaaException caught:" + e.getMessage());\r
+ } catch (InterruptedException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\r
+ } catch (ResultNotAvailableException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\r
}\r
+ }\r
\r
- @Test(groups = { AllTestSuit.test_group_runner })\r
- public void testRunLocally() {\r
- try {\r
- ConfiguredExecutable<Jronn> confJronn = Configurator\r
- .configureExecutable(jronn, Executable.ExecProvider.Local);\r
+ @Test(groups = { AllTestSuit.test_group_runner })\r
+ public void testRunLocally() {\r
+ try {\r
+ ConfiguredExecutable<Jronn> confJronn = Configurator\r
+ .configureExecutable(jronn, Executable.ExecProvider.Local);\r
\r
- // For local execution use relative\r
- LocalRunner lr = new LocalRunner(confJronn);\r
- lr.executeJob();\r
- ConfiguredExecutable<?> al1 = lr.waitForResult();\r
- assertNotNull(al1.getResults());\r
- List<AnnotatedSequence> al2 = confJronn.getResults();\r
- assertNotNull(al2);\r
- assertEquals(al2.size(), 3);\r
- assertEquals(al1.getResults(), al2);\r
- } catch (JobSubmissionException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (ResultNotAvailableException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (JobExecutionException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- }\r
+ // For local execution use relative\r
+ LocalRunner lr = new LocalRunner(confJronn);\r
+ lr.executeJob();\r
+ ConfiguredExecutable<?> al1 = lr.waitForResult();\r
+ assertNotNull(al1.getResults());\r
+ List<AnnotatedSequence> al2 = confJronn.getResults();\r
+ assertNotNull(al2);\r
+ assertEquals(al2.size(), 3);\r
+ assertEquals(al1.getResults(), al2);\r
+ } catch (JobSubmissionException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (ResultNotAvailableException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (JobExecutionException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
}\r
+ }\r
\r
- @Test( groups = { AllTestSuit.test_group_runner })\r
- public void readStatistics() {\r
- try {\r
- ConfiguredExecutable<Jronn> confJronn = Configurator\r
- .configureExecutable(jronn, Executable.ExecProvider.Local);\r
- // For local execution use relavive\r
+ @Test(groups = { AllTestSuit.test_group_runner })\r
+ public void readStatistics() {\r
+ try {\r
+ ConfiguredExecutable<Jronn> confJronn = Configurator\r
+ .configureExecutable(jronn, Executable.ExecProvider.Local);\r
+ // For local execution use relavive\r
\r
- AsyncExecutor sexec = Configurator.getAsyncEngine(confJronn);\r
- String jobId = sexec.submitJob(confJronn);\r
- FilePuller fw = FilePuller.newFilePuller(confJronn\r
- .getWorkDirectory()\r
- + File.separator + Jronn.getStatFile(),\r
- FileWatcher.MIN_CHUNK_SIZE_BYTES);\r
- int count = 0;\r
- long position = 0;\r
- fw.waitForFile(4);\r
- JobStatus status = sexec.getJobStatus(jobId);\r
- while (status != JobStatus.FINISHED\r
- || fw.hasMoreData()) {\r
- ChunkHolder ch = fw.pull(position);\r
- String chunk = ch.getChunk();\r
- position = ch.getNextPosition();\r
- System.out.print("C: "+chunk);\r
- count++;\r
- // Make sure the loop is terminated if the job fails\r
- if((status == JobStatus.UNDEFINED || status== JobStatus.FAILED)) {\r
- break;\r
- }\r
- status = sexec.getJobStatus(jobId);\r
- }\r
- System.out.println("\nOut of the LOOP!! ");\r
- assertTrue(count > 1);\r
- ConfiguredExecutable<?> al = sexec.getResults(jobId);\r
- assertNotNull(al.getResults());\r
- } catch (JobSubmissionException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (ResultNotAvailableException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
+ AsyncExecutor sexec = Configurator.getAsyncEngine(confJronn);\r
+ String jobId = sexec.submitJob(confJronn);\r
+ FilePuller fw = FilePuller.newFilePuller(confJronn\r
+ .getWorkDirectory()\r
+ + File.separator + Jronn.getStatFile(),\r
+ FileWatcher.MIN_CHUNK_SIZE_BYTES);\r
+ int count = 0;\r
+ long position = 0;\r
+ fw.waitForFile(4);\r
+ JobStatus status = sexec.getJobStatus(jobId);\r
+ while (status != JobStatus.FINISHED) {\r
+ System.out.println((status != JobStatus.FINISHED) + " d: "\r
+ + fw.hasMoreData());\r
+ if (fw.hasMoreData()) {\r
+ ChunkHolder ch = fw.pull(position);\r
+ System.out.println("p:" + position);\r
+ String chunk = ch.getChunk();\r
+ position = ch.getNextPosition();\r
+ System.out.println("np " + position + " c: " + chunk);\r
}\r
+ count++;\r
+ // Make sure the loop is terminated if the job fails\r
+ if ((status == JobStatus.UNDEFINED || status == JobStatus.FAILED)) {\r
+ break;\r
+ }\r
+ Thread.sleep(300);\r
+ status = sexec.getJobStatus(jobId);\r
+ }\r
+ System.out.println("\nOut of the LOOP!! ");\r
+ assertTrue(count > 1);\r
+ ConfiguredExecutable<?> al = sexec.getResults(jobId);\r
+ assertNotNull(al.getResults());\r
+ } catch (JobSubmissionException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\r
+ } catch (ResultNotAvailableException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\r
+ } catch (InterruptedException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\r
}\r
+ }\r
\r
- @Test(groups = { AllTestSuit.test_group_runner })\r
- public void testPersistance() {\r
- try {\r
- Jronn jronn = new Jronn();\r
- jronn.setError("errrr.txt").setInput(AllTestSuit.test_input)\r
- .setOutput("outtt.txt");\r
- assertEquals(jronn.getInput(), AllTestSuit.test_input);\r
- assertEquals(jronn.getError(), "errrr.txt");\r
- assertEquals(jronn.getOutput(), "outtt.txt");\r
- ConfiguredExecutable<Jronn> cJronn = Configurator\r
- .configureExecutable(jronn, Executable.ExecProvider.Local);\r
+ @Test(groups = { AllTestSuit.test_group_runner })\r
+ public void testPersistance() {\r
+ try {\r
+ Jronn jronn = new Jronn();\r
+ jronn.setError("errrr.txt").setInput(AllTestSuit.test_input)\r
+ .setOutput("outtt.txt");\r
+ assertEquals(jronn.getInput(), AllTestSuit.test_input);\r
+ assertEquals(jronn.getError(), "errrr.txt");\r
+ assertEquals(jronn.getOutput(), "outtt.txt");\r
+ ConfiguredExecutable<Jronn> cJronn = Configurator\r
+ .configureExecutable(jronn, Executable.ExecProvider.Local);\r
\r
- SyncExecutor sexec = Configurator.getSyncEngine(cJronn);\r
- sexec.executeJob();\r
- ConfiguredExecutable<?> al = sexec.waitForResult();\r
- assertNotNull(al.getResults());\r
- // Save run configuration\r
- assertTrue(cJronn.saveRunConfiguration());\r
+ SyncExecutor sexec = Configurator.getSyncEngine(cJronn);\r
+ sexec.executeJob();\r
+ ConfiguredExecutable<?> al = sexec.waitForResult();\r
+ assertNotNull(al.getResults());\r
+ // Save run configuration\r
+ assertTrue(cJronn.saveRunConfiguration());\r
\r
- // See if loaded configuration is the same as saved\r
- RunConfiguration loadedRun = RunConfiguration\r
- .load(new FileInputStream(new File(cJronn\r
- .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
- assertEquals(\r
- ((ConfExecutable<Jronn>) cJronn).getRunConfiguration(),\r
- loadedRun);\r
- // Load run configuration as ConfExecutable\r
- ConfiguredExecutable<Jronn> resurrectedCMuscle = (ConfiguredExecutable<Jronn>) cJronn\r
- .loadRunConfiguration(new FileInputStream(new File(cJronn\r
- .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
- assertNotNull(resurrectedCMuscle);\r
- assertEquals(resurrectedCMuscle.getExecutable().getInput(),\r
- AllTestSuit.test_input);\r
- assertEquals(resurrectedCMuscle.getExecutable().getError(),\r
- "errrr.txt");\r
- assertEquals(resurrectedCMuscle.getExecutable().getOutput(),\r
- "outtt.txt");\r
- // See in details whether executables are the same\r
- assertEquals(resurrectedCMuscle.getExecutable(), jronn);\r
+ // See if loaded configuration is the same as saved\r
+ RunConfiguration loadedRun = RunConfiguration\r
+ .load(new FileInputStream(new File(cJronn\r
+ .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
+ assertEquals(\r
+ ((ConfExecutable<Jronn>) cJronn).getRunConfiguration(),\r
+ loadedRun);\r
+ // Load run configuration as ConfExecutable\r
+ ConfiguredExecutable<Jronn> resurrectedCMuscle = (ConfiguredExecutable<Jronn>) cJronn\r
+ .loadRunConfiguration(new FileInputStream(new File(cJronn\r
+ .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
+ assertNotNull(resurrectedCMuscle);\r
+ assertEquals(resurrectedCMuscle.getExecutable().getInput(),\r
+ AllTestSuit.test_input);\r
+ assertEquals(resurrectedCMuscle.getExecutable().getError(),\r
+ "errrr.txt");\r
+ assertEquals(resurrectedCMuscle.getExecutable().getOutput(),\r
+ "outtt.txt");\r
+ // See in details whether executables are the same\r
+ assertEquals(resurrectedCMuscle.getExecutable(), jronn);\r
\r
- ConfiguredExecutable<Jronn> resJronn = Configurator\r
- .configureExecutable(resurrectedCMuscle.getExecutable(),\r
- Executable.ExecProvider.Local);\r
+ ConfiguredExecutable<Jronn> resJronn = Configurator\r
+ .configureExecutable(resurrectedCMuscle.getExecutable(),\r
+ Executable.ExecProvider.Local);\r
\r
- sexec = Configurator.getSyncEngine(resJronn,\r
- Executable.ExecProvider.Local);\r
- sexec.executeJob();\r
- al = sexec.waitForResult();\r
- assertNotNull(al);\r
+ sexec = Configurator.getSyncEngine(resJronn,\r
+ Executable.ExecProvider.Local);\r
+ sexec.executeJob();\r
+ al = sexec.waitForResult();\r
+ assertNotNull(al);\r
\r
- } catch (JobSubmissionException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (JobExecutionException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (FileNotFoundException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- } catch (ResultNotAvailableException e) {\r
- e.printStackTrace();\r
- fail(e.getMessage());\r
- }\r
+ } catch (JobSubmissionException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\r
+ } catch (JobExecutionException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\r
+ } catch (ResultNotAvailableException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\r
}\r
+ }\r
\r
- @Test(groups = { AllTestSuit.test_group_runner })\r
- public void testConfigurationLoading() {\r
- try {\r
- RunnerConfig<Jronn> jronnConfig = ConfExecutable\r
- .getRunnerOptions(Jronn.class);\r
- assertNotNull(jronnConfig);\r
- assertTrue(jronnConfig.getArguments().size() > 0);\r
+ @Test(groups = { AllTestSuit.test_group_runner })\r
+ public void testConfigurationLoading() {\r
+ try {\r
+ RunnerConfig<Jronn> jronnConfig = ConfExecutable\r
+ .getRunnerOptions(Jronn.class);\r
+ assertNotNull(jronnConfig);\r
+ assertTrue(jronnConfig.getArguments().size() > 0);\r
\r
- PresetManager<Jronn> jronnPresets = ConfExecutable\r
- .getRunnerPresets(Jronn.class);\r
- assertNull(jronnPresets); // there is no presets\r
+ PresetManager<Jronn> jronnPresets = ConfExecutable\r
+ .getRunnerPresets(Jronn.class);\r
+ assertNull(jronnPresets); // there is no presets\r
\r
- LimitsManager<Jronn> jronnLimits = ConfExecutable\r
- .getRunnerLimits(Jronn.class);\r
- assertNotNull(jronnLimits);\r
- assertTrue(jronnLimits.getLimits().size() > 0);\r
- jronnLimits.validate(jronnPresets);\r
+ LimitsManager<Jronn> jronnLimits = ConfExecutable\r
+ .getRunnerLimits(Jronn.class);\r
+ assertNotNull(jronnLimits);\r
+ assertTrue(jronnLimits.getLimits().size() > 0);\r
+ jronnLimits.validate(jronnPresets);\r
\r
- } catch (FileNotFoundException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (IOException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- } catch (ValidationException e) {\r
- e.printStackTrace();\r
- fail(e.getLocalizedMessage());\r
- }\r
+ } catch (FileNotFoundException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (IOException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
+ } catch (ValidationException e) {\r
+ e.printStackTrace();\r
+ fail(e.getLocalizedMessage());\r
}\r
+ }\r
\r
}\r