Skip to content

Commit fb5afd6

Browse files
committed
Make integration test more verbose on failure
1 parent 5c04042 commit fb5afd6

File tree

2 files changed

+42
-21
lines changed

2 files changed

+42
-21
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/SequenceIntegrationTests.java

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import java.io.BufferedReader;
7575
import java.io.File;
7676
import java.io.IOException;
77+
import java.nio.charset.Charset;
7778
import java.text.SimpleDateFormat;
7879
import java.util.ArrayList;
7980
import java.util.Arrays;
@@ -592,20 +593,7 @@ private boolean isJobDone(PipelineJob job) throws Exception
592593
//on failure, append contents of pipeline job file to primary error log
593594
if (job.getLogFile() != null)
594595
{
595-
StringBuilder sb = new StringBuilder();
596-
try (BufferedReader reader = Readers.getReader(job.getLogFile()))
597-
{
598-
sb.append("*******************\n");
599-
sb.append("Error running sequence junit tests. Pipeline log:\n");
600-
String line;
601-
while ((line = reader.readLine()) != null) {
602-
sb.append(line).append('\n');
603-
}
604-
605-
sb.append("*******************\n");
606-
}
607-
608-
_log.error(sb.toString());
596+
writeJobLogToLog(job);
609597
}
610598
else
611599
{
@@ -618,9 +606,27 @@ private boolean isJobDone(PipelineJob job) throws Exception
618606
return false; //job != null && job.getActiveTaskId() != null;
619607
}
620608

609+
protected void writeJobLogToLog(PipelineJob job) throws IOException
610+
{
611+
StringBuilder sb = new StringBuilder();
612+
try (BufferedReader reader = Readers.getReader(job.getLogFile()))
613+
{
614+
sb.append("*******************\n");
615+
sb.append("Error running sequence junit tests. Pipeline log:\n");
616+
String line;
617+
while ((line = reader.readLine()) != null) {
618+
sb.append(line).append('\n');
619+
}
620+
621+
sb.append("*******************\n");
622+
}
623+
624+
_log.error(sb.toString());
625+
}
626+
621627
protected JSONObject substituteParams(File xml, String jobName) throws IOException
622628
{
623-
String content = FileUtils.readFileToString(xml);
629+
String content = FileUtils.readFileToString(xml, Charset.defaultCharset());
624630
content = content.replaceAll("@@BASEURL@@", AppProps.getInstance().getBaseServerUrl() + AppProps.getInstance().getContextPath());
625631
content = content.replaceAll("@@CONTAINERID@@", _project.getPath());
626632
content = content.replaceAll("@@CONTAINERPATH@@", _project.getPath());

SequenceAnalysis/src/org/labkey/sequenceanalysis/SequenceRemoteIntegrationTests.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,27 @@ public void RunBwaRemote() throws Exception
176176
executeJobRemote(outDir, jobFile);
177177

178178
//check outputs
179-
PipelineJob job2 = PipelineJob.readFromFile(jobFile);
180-
Assert.assertEquals("Incorrect status", PipelineJob.TaskStatus.complete, job2.getActiveTaskStatus());
181-
File workingFasta = job.getTargetGenome().getWorkingFastaFile();
182-
Assert.assertNotNull("Genome FASTA not set", workingFasta);
183-
File dict = new File(workingFasta.getParentFile(), FileUtil.getBaseName(workingFasta.getName()) + ".dict");
184-
Assert.assertTrue("Dictionary file not created, expected: " + dict.getPath(), dict.exists());
179+
try
180+
{
181+
PipelineJob job2 = PipelineJob.readFromFile(jobFile);
182+
Assert.assertEquals("Incorrect status", PipelineJob.TaskStatus.complete, job2.getActiveTaskStatus());
183+
File workingFasta = job.getTargetGenome().getWorkingFastaFile();
184+
Assert.assertNotNull("Genome FASTA not set", workingFasta);
185+
File idx = new File(workingFasta.getPath() + ".fai");
186+
Assert.assertTrue("FASTA index not created, expected: " + idx.getPath(), idx.exists());
187+
}
188+
catch (AssertionError e)
189+
{
190+
writeJobLogToLog(job);
191+
192+
_log.info("Files in job folder: " + job.getLogFile().getParentFile().getPath());
193+
for (File f : job.getLogFile().getParentFile().listFiles())
194+
{
195+
_log.info(f.getName());
196+
}
197+
198+
throw e;
199+
}
185200
}
186201

187202
protected void executeJobRemote(File workDir, @Nullable File jobJson) throws IOException

0 commit comments

Comments
 (0)