Commit e687d703 authored by Peter van 't Hof's avatar Peter van 't Hof

Testing the complete graph itself

parent 85c9703c
......@@ -6,6 +6,8 @@ import com.google.common.io.Files
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
import PipelineStatusTest.Status
import nl.lumc.sasc.biopet.utils.IoUtils._
/**
* Created by pjvan_thof on 10-1-17.
......@@ -18,6 +20,7 @@ class PipelineStatusTest extends TestNGSuite with Matchers {
PipelineStatusTest.writeDeps(outputDir)
PipelineStatus.main(Array("-o", outputDir.toString, "-d", outputDir.toString))
checkOutput(outputDir)
}
@Test
......@@ -27,12 +30,52 @@ class PipelineStatusTest extends TestNGSuite with Matchers {
val depsfile = PipelineStatusTest.writeDeps(outputDir)
PipelineStatus.main(Array("-o", outputDir.toString, "-d", outputDir.toString, "--depsFile", depsfile.toString))
checkOutput(outputDir)
}
def checkOutput(outputDir: File,
cat: Status.Value = Status.Pending,
gzip: Status.Value = Status.Pending,
zcat: Status.Value = Status.Pending): Unit = {
val jobsGvFile = new File(outputDir, "jobs.gv")
val mainJobsGvFile = new File(outputDir, "main_jobs.gv")
val compressJobsGvFile = new File(outputDir, "compress.jobs.gv")
val compressMainJobsGvFile = new File(outputDir, "compress.main_jobs.gv")
jobsGvFile should exist
mainJobsGvFile should exist
compressJobsGvFile should exist
compressMainJobsGvFile should exist
val jobsGvLines = getLinesFromFile(jobsGvFile)
require(jobsGvLines.exists(_.contains("cat_1 -> gzip_1")))
require(jobsGvLines.exists(_.contains("gzip_1 -> zcat_1")))
require(jobsGvLines.forall(!_.contains("cat_1 -> zcat_1")))
val mainJobsGvLines = getLinesFromFile(mainJobsGvFile)
require(mainJobsGvLines.exists(_.contains("cat_1 -> zcat_1")))
require(mainJobsGvLines.forall(!_.contains("cat_1 -> gzip_1")))
require(mainJobsGvLines.forall(!_.contains("gzip_1 -> zcat_1")))
val compressJobsGvLines = getLinesFromFile(compressJobsGvFile)
require(compressJobsGvLines.exists(_.contains("cat -> gzip")))
require(compressJobsGvLines.exists(_.contains("gzip -> zcat")))
require(compressJobsGvLines.forall(!_.contains("cat -> zcat")))
val compressMainJobsGvLines = getLinesFromFile(compressMainJobsGvFile)
require(compressMainJobsGvLines.exists(_.contains("cat -> zcat")))
require(compressMainJobsGvLines.forall(!_.contains("cat -> gzip")))
require(compressMainJobsGvLines.forall(!_.contains("gzip -> zcat")))
}
}
object PipelineStatusTest {
object Status extends Enumeration {
val Failed, Done, Pending = Value
}
def writeDeps(outputDir: File): File = {
require(outputDir.exists())
val depsFile = new File(outputDir, ".log/test.1234567890/graph/deps.json")
......@@ -47,6 +90,36 @@ object PipelineStatusTest {
s"""
|{
| "jobs" : {
| "zcat_1" : {
| "fail_files" : [
| "$outputDir/.file.out.zcat.fail",
| "$outputDir/..file.out.zcat.Zcat.out.fail"
| ],
| "done_at_start" : false,
| "output_used_by_jobs" : [
|
| ],
| "outputs" : [
| "$outputDir/file.out.zcat",
| "$outputDir/.file.out.zcat.Zcat.out"
| ],
| "command" : "'/bin/zcat' '$outputDir/file.out.gz' > '$outputDir/file.out.zcat' ",
| "stdout_file" : "$outputDir/.file.out.zcat.Zcat.out",
| "depends_on_intermediate" : false,
| "fail_at_start" : false,
| "inputs" : [
| "$outputDir/file.out.gz"
| ],
| "depends_on_jobs" : [
| "gzip_1"
| ],
| "intermediate" : false,
| "done_files" : [
| "$outputDir/.file.out.zcat.done",
| "$outputDir/..file.out.zcat.Zcat.out.done"
| ],
| "main_job" : true
| },
| "gzip_1" : {
| "fail_files" : [
| "$outputDir/.file.out.gz.fail",
......@@ -54,13 +127,13 @@ object PipelineStatusTest {
| ],
| "done_at_start" : false,
| "output_used_by_jobs" : [
|
| "zcat_1"
| ],
| "outputs" : [
| "$outputDir/file.out.gz",
| "$outputDir/.file.out.gz.Gzip.out"
| ],
| "command" : "\n\n '/bin/gzip' -c '$outputDir/file.out' > '$outputDir/file.out.gz' ",
| "command" : "'/bin/gzip' -c '$outputDir/file.out' > '$outputDir/file.out.gz' ",
| "stdout_file" : "$outputDir/.file.out.gz.Gzip.out",
| "depends_on_intermediate" : false,
| "fail_at_start" : false,
......@@ -70,12 +143,12 @@ object PipelineStatusTest {
| "depends_on_jobs" : [
| "cat_1"
| ],
| "intermediate" : false,
| "intermediate" : true,
| "done_files" : [
| "$outputDir/.file.out.gz.done",
| "$outputDir/..file.out.gz.Gzip.out.done"
| ],
| "main_job" : true
| "main_job" : false
| },
| "cat_1" : {
| "fail_files" : [
......@@ -90,7 +163,7 @@ object PipelineStatusTest {
| "$outputDir/file.out",
| "$outputDir/.file.out.Cat.out"
| ],
| "command" : "\n\n '/bin/cat' 'test.deps' > '$outputDir/file.out' ",
| "command" : "'/bin/cat' 'test.deps' > '$outputDir/file.out' ",
| "stdout_file" : "$outputDir/.file.out.Cat.out",
| "depends_on_intermediate" : false,
| "fail_at_start" : false,
......
......@@ -14,7 +14,9 @@
*/
package nl.lumc.sasc.biopet.utils
import java.io.{ File, FileInputStream, FileOutputStream, InputStream }
import java.io.{File, FileInputStream, FileOutputStream, InputStream}
import scala.io.Source
/**
* This object contains generic io methods
......@@ -68,4 +70,17 @@ object IoUtils {
if (fname.toLowerCase.endsWith(ext)) fname.dropRight(ext.length)
else fname
}
/**
* This return the contends of a file as a List[String]
*
* @param file
* @return
*/
def getLinesFromFile(file: File): List[String] = {
val reader = Source.fromFile(file)
val lines = reader.getLines().toList
reader.close()
lines
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment