From 4ee4fd47e911897f92a49fad7acf4e227d389e92 Mon Sep 17 00:00:00 2001 From: kshakir Date: Sat, 29 Jan 2011 00:07:25 +0000 Subject: [PATCH] Moved the test name and the job queue into the spec. Defaulting to the hour queue for running pipeline tests. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5122 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/queue/pipeline/PipelineTest.scala | 20 ++++++++++++++----- .../queue/pipeline/PipelineTestSpec.scala | 9 ++++++--- .../ExampleCountLociPipelineTest.scala | 9 ++++----- .../examples/HelloWorldPipelineTest.scala | 6 +++--- .../playground/FullCallingPipelineTest.scala | 9 +++------ 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/scala/test/org/broadinstitute/sting/queue/pipeline/PipelineTest.scala b/scala/test/org/broadinstitute/sting/queue/pipeline/PipelineTest.scala index b4c210ccf..6c6d7a49f 100644 --- a/scala/test/org/broadinstitute/sting/queue/pipeline/PipelineTest.scala +++ b/scala/test/org/broadinstitute/sting/queue/pipeline/PipelineTest.scala @@ -3,12 +3,12 @@ package org.broadinstitute.sting.queue.pipeline import org.broadinstitute.sting.utils.Utils import org.testng.Assert import org.broadinstitute.sting.commandline.CommandLineProgram -import org.broadinstitute.sting.queue.QCommandLine import java.io.File import org.broadinstitute.sting.queue.util.{TextFormatUtils, ProcessController} import java.util.Date import java.text.SimpleDateFormat import org.broadinstitute.sting.{WalkerTest, BaseTest} +import org.broadinstitute.sting.queue.{QException, QCommandLine} object PipelineTest { @@ -54,11 +54,14 @@ object PipelineTest { val run = System.getProperty("pipeline.run") == "run" - def executeTest(name: String, pipelineTest: PipelineTestSpec) { + def executeTest(pipelineTest: PipelineTestSpec) { + val name = pipelineTest.name + if (name == null) + throw new QException("PipelineTestSpec.name is null.") println(Utils.dupString('-', 80)); - executeTest(name, pipelineTest.args, pipelineTest.expectedException) + executeTest(name, pipelineTest.args, pipelineTest.jobQueue, pipelineTest.expectedException) if (run) { - assertMatchingMD5s(name, pipelineTest.fileMD5s) + assertMatchingMD5s(name, pipelineTest.fileMD5s.map{case (file, md5) => new File(runDir(name), file) -> md5}) if (pipelineTest.evalSpec != null) validateEval(name, pipelineTest.evalSpec) println(" => %s PASSED".format(name)) @@ -109,14 +112,21 @@ object PipelineTest { * execute the test * @param name the name of the test * @param args the argument list + * @param jobQueue the queue to run the job on. Defaults to hour if jobQueue is null. * @param expectedException the expected exception or null if no exception is expected. */ - def executeTest(name: String, args: String, expectedException: Class[_]) { + def executeTest(name: String, args: String, jobQueue: String, expectedException: Class[_]) { var command = Utils.escapeExpressions(args) // add the logging level to each of the integration test commands command = Utils.appendArray(command, "-bsub", "-l", "WARN", "-startFromScratch", "-tempDir", tempDir(name), "-runDir", runDir(name)) + + if (jobQueue == null) + command = Utils.appendArray(command, "-jobQueue", "hour") + else + command = Utils.appendArray(command, "-jobQueue", jobQueue) + if (run) command = Utils.appendArray(command, "-run") diff --git a/scala/test/org/broadinstitute/sting/queue/pipeline/PipelineTestSpec.scala b/scala/test/org/broadinstitute/sting/queue/pipeline/PipelineTestSpec.scala index 5d1e0f4d7..22fe7c1f4 100644 --- a/scala/test/org/broadinstitute/sting/queue/pipeline/PipelineTestSpec.scala +++ b/scala/test/org/broadinstitute/sting/queue/pipeline/PipelineTestSpec.scala @@ -2,13 +2,16 @@ package org.broadinstitute.sting.queue.pipeline import java.io.File -class PipelineTestSpec { +class PipelineTestSpec(var name: String = null) { /** The arguments to pass to the Queue test, ex: "-S scala/qscript/examples/HelloWorld.scala" */ var args: String = _ + /** Job Queue to run the test. Default is null which means use hour. */ + var jobQueue: String = _ + /** Expected MD5 results for each file path. */ - var fileMD5s = Map.empty[File, String] + var fileMD5s = Map.empty[String, String] /** VariantEval validations to run on a VCF after the pipeline has completed. */ var evalSpec: PipelineTestEvalSpec = _ @@ -16,7 +19,7 @@ class PipelineTestSpec { /** Expected exception from the test. */ var expectedException: Class[_ <: Exception] = null - def this(args: String, fileMD5s: Traversable[(File, String)]) = { + def this(args: String, fileMD5s: Traversable[(String, String)]) = { this() this.args = args this.fileMD5s = fileMD5s.toMap diff --git a/scala/test/org/broadinstitute/sting/queue/pipeline/examples/ExampleCountLociPipelineTest.scala b/scala/test/org/broadinstitute/sting/queue/pipeline/examples/ExampleCountLociPipelineTest.scala index 59d4d5162..9c2f5186e 100644 --- a/scala/test/org/broadinstitute/sting/queue/pipeline/examples/ExampleCountLociPipelineTest.scala +++ b/scala/test/org/broadinstitute/sting/queue/pipeline/examples/ExampleCountLociPipelineTest.scala @@ -7,14 +7,13 @@ import org.broadinstitute.sting.BaseTest class ExampleCountLociPipelineTest { @Test def testCountLoci { - var testName = "countloci" var testOut = "count.out" val spec = new PipelineTestSpec - // TODO: Use a variable instead of "hour" - spec.args = "-S scala/qscript/examples/ExampleCountLoci.scala -gatk %s -R %s -I %s -o %s -jobQueue hour".format( + spec.name = "countloci" + spec.args = "-S scala/qscript/examples/ExampleCountLoci.scala -gatk %s -R %s -I %s -o %s".format( PipelineTest.currentGATK, BaseTest.hg18Reference, BaseTest.validationDataLocation + "small_bam_for_countloci.bam", testOut ) - spec.fileMD5s += PipelineTest.fileMD5(testName, testOut, "67823e4722495eb10a5e4c42c267b3a6") - PipelineTest.executeTest(testName, spec) + spec.fileMD5s += testOut -> "67823e4722495eb10a5e4c42c267b3a6" + PipelineTest.executeTest(spec) } } diff --git a/scala/test/org/broadinstitute/sting/queue/pipeline/examples/HelloWorldPipelineTest.scala b/scala/test/org/broadinstitute/sting/queue/pipeline/examples/HelloWorldPipelineTest.scala index 70b188c3a..a648838a7 100644 --- a/scala/test/org/broadinstitute/sting/queue/pipeline/examples/HelloWorldPipelineTest.scala +++ b/scala/test/org/broadinstitute/sting/queue/pipeline/examples/HelloWorldPipelineTest.scala @@ -6,9 +6,9 @@ import org.broadinstitute.sting.queue.pipeline.{PipelineTest, PipelineTestSpec} class HelloWorldPipelineTest { @Test def testHelloWorld { - var testName = "helloworld" val spec = new PipelineTestSpec - spec.args = "-S scala/qscript/examples/HelloWorld.scala -jobPrefix HelloWorld -jobQueue hour" - PipelineTest.executeTest(testName, spec) + spec.name = "helloworld" + spec.args = "-S scala/qscript/examples/HelloWorld.scala -jobPrefix HelloWorld" + PipelineTest.executeTest(spec) } } diff --git a/scala/test/org/broadinstitute/sting/queue/pipeline/playground/FullCallingPipelineTest.scala b/scala/test/org/broadinstitute/sting/queue/pipeline/playground/FullCallingPipelineTest.scala index 7e8335c42..0a4c4a32c 100644 --- a/scala/test/org/broadinstitute/sting/queue/pipeline/playground/FullCallingPipelineTest.scala +++ b/scala/test/org/broadinstitute/sting/queue/pipeline/playground/FullCallingPipelineTest.scala @@ -27,8 +27,6 @@ class FullCallingPipelineTest { dataset.validations :+= new DoubleValidation("eval.dbsnp.all.called.known.titv.tiTvRatio", 3.7426) dataset.validations :+= new DoubleValidation("eval.dbsnp.all.called.novel.titv.tiTvRatio", 3.3077) - dataset.jobQueue = "hour" - dataset } @@ -101,11 +99,10 @@ class FullCallingPipelineTest { cleanType = "uncleaned" } - if (dataset.jobQueue != null) - pipelineCommand += " -jobQueue " + dataset.jobQueue - val pipelineSpec = new PipelineTestSpec + pipelineSpec.name = testName pipelineSpec.args = pipelineCommand + pipelineSpec.jobQueue = dataset.jobQueue pipelineSpec.evalSpec = new PipelineTestEvalSpec pipelineSpec.evalSpec.vcf = new File(PipelineTest.runDir(testName) + "SnpCalls/%s.%s.annotated.handfiltered.vcf".format(projectName, cleanType)) @@ -115,7 +112,7 @@ class FullCallingPipelineTest { pipelineSpec.evalSpec.validations = dataset.validations // Run the test, at least checking if the command compiles - PipelineTest.executeTest(testName, pipelineSpec) + PipelineTest.executeTest(pipelineSpec) } class PipelineDataset(