From 9242f63a4d1185ef0a146b7fb354d2450752390b Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Wed, 25 Jul 2012 22:11:10 -0400 Subject: [PATCH] On the way to really sorting out HMS error handling -- Better error message when a traveral error occurs (a real bug) -- EngineFeaturesIntegrationTest runs the multi-threaded error testing routines 50x times -- A bit of cleanup in WalkerTest --- .../executive/HierarchicalMicroScheduler.java | 2 +- .../org/broadinstitute/sting/WalkerTest.java | 18 ++++++++++-------- .../gatk/EngineFeaturesIntegrationTest.java | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java b/public/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java index 1fe2b840f..3dc36dda2 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java +++ b/public/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java @@ -358,7 +358,7 @@ public class HierarchicalMicroScheduler extends MicroScheduler implements Hierar if (error instanceof RuntimeException) this.error = (RuntimeException)error; else - this.error = new ReviewedStingException("An error occurred during the traversal.", error); + this.error = new ReviewedStingException("An error occurred during the traversal. Message=" + error.getMessage(), error); } diff --git a/public/java/test/org/broadinstitute/sting/WalkerTest.java b/public/java/test/org/broadinstitute/sting/WalkerTest.java index a997385d6..7e38c00f3 100755 --- a/public/java/test/org/broadinstitute/sting/WalkerTest.java +++ b/public/java/test/org/broadinstitute/sting/WalkerTest.java @@ -169,7 +169,6 @@ public class WalkerTest extends BaseTest { Class expectedException = null; boolean includeImplicitArgs = true; boolean includeShadowBCF = true; - boolean repairHeader = false; // the default output path for the integration test private File outputFileLocation = null; @@ -211,8 +210,6 @@ public class WalkerTest extends BaseTest { String.format(" -et %s -K %s ", GATKRunReport.PhoneHomeOption.NO_ET, gatkKeyFile)); if ( includeShadowBCF && GENERATE_SHADOW_BCF ) args = args + " --generateShadowBCF "; - if ( repairHeader ) - args = args + " --repairVCFHeader public/data/vcfHeaderForRepairs.vcf "; } return args; @@ -224,7 +221,6 @@ public class WalkerTest extends BaseTest { * which will ultimately blow up... */ public void disableShadowBCF() { this.includeShadowBCF = false; } - public void repairHeaders() { this.repairHeader = true; } public void setOutputFileLocation(File outputFileLocation) { this.outputFileLocation = outputFileLocation; } @@ -367,10 +363,16 @@ public class WalkerTest extends BaseTest { // it's the type we expected //System.out.println(String.format(" => %s PASSED", name)); } else { - if ( e.getCause() != null ) - e.getCause().printStackTrace(System.out); // must print to stdout to see the message - Assert.fail(String.format("Test %s expected exception %s but instead got %s with error message %s", - name, expectedException, e.getClass(), e.getMessage())); + final String message = String.format("Test %s expected exception %s but instead got %s with error message %s", + name, expectedException, e.getClass(), e.getMessage()); + if ( e.getCause() != null ) { + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final PrintStream ps = new PrintStream(baos); + e.getCause().printStackTrace(ps); + BaseTest.log(message); + BaseTest.log(baos.toString()); + } + Assert.fail(message); } } else { // we didn't expect an exception but we got one :-( diff --git a/public/java/test/org/broadinstitute/sting/gatk/EngineFeaturesIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/EngineFeaturesIntegrationTest.java index 01af55ca3..f1acfda20 100644 --- a/public/java/test/org/broadinstitute/sting/gatk/EngineFeaturesIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/EngineFeaturesIntegrationTest.java @@ -90,7 +90,7 @@ public class EngineFeaturesIntegrationTest extends WalkerTest { super(EngineErrorHandlingTestProvider.class); this.expectedException = exceptedException; this.multiThreaded = multiThreaded; - this.iterationsToTest = multiThreaded ? 10 : 1; + this.iterationsToTest = multiThreaded ? 50 : 1; setName(String.format("Engine error handling: expected %s, is-multithreaded %b", exceptedException, multiThreaded)); } } @@ -110,7 +110,7 @@ public class EngineFeaturesIntegrationTest extends WalkerTest { // Loop over errors to throw, make sure they are the errors we get back from the engine, regardless of NT type // @Test(dataProvider = "EngineErrorHandlingTestProvider") - public void testEngineErrorHandlingTestProvider(EngineErrorHandlingTestProvider cfg) { + public void testEngineErrorHandlingTestProvider(final EngineErrorHandlingTestProvider cfg) { for ( int i = 0; i < cfg.iterationsToTest; i++ ) { final String root = "-T ErrorThrowing -R " + b37KGReference; final String args = root + (cfg.multiThreaded ? " -nt 2" : "") + " -E " + cfg.expectedException.getSimpleName();