This GitLab instance reached the end of its service life. It won't be possible to create new users or projects.

Please read the deprecation notice for more information concerning the deprecation timeline

Visit migration.git.tu-berlin.de (internal network only) to import your old projects to the new GitLab platform 📥

CoupledSimulationFlinkSpec.scala 2.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
package de.bbisping.coupledsim.flink

import scala.io.Source

import org.apache.flink.api.scala.ExecutionEnvironment
import org.scalatest.FunSpec
import org.scalatest.Inspectors.forAll
import org.scalatest.Matchers.be
import org.scalatest.Matchers.convertToAnyShouldWrapper
import org.scalatest.Matchers.empty
import org.scalatest.concurrent.TimeLimits
import org.scalatest.time.SpanSugar._

import de.bbisping.coupledsim.algo.cs.FixedPointCoupledSimilarity
import de.bbisping.coupledsim.ts.DirectTSImporter
16

17 18
class CoupledSimulationFlinkSpec extends FunSpec with TimeLimits {
  
19
  val smallSamples: Seq[String] = CoupledSimulationFlinkBenchmark.smallSamples
20
  
21
  val vltsSamplesSmall: Seq[String] = CoupledSimulationFlinkBenchmark.vltsSamplesSmall
22
    
23
  val vltsSamplesMedium: Seq[String] = CoupledSimulationFlinkBenchmark.vltsSamplesMedium
24
    
25
  val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment
26 27 28 29 30 31 32 33
  
  describe("The computed CS relation") {
    forAll(smallSamples) { sample =>
      describe("for sample " + sample) {
        val src = Source.fromFile(sample).mkString
        println("\nTEST: " + Console.BLUE + sample + Console.RESET)
        val ts = new DirectTSImporter(src).result()
        val rel = new FixedPointCoupledSimilarity(ts).compute()
34

35
        val cs = CoupledSimulationFlink.executeAlgorithm(env, cfgPath = sample, cfgReturnRelation = true).relation.get
36

37 38 39
        it("should be sound") {
          (cs.tupleSet diff rel.tupleSet) should be (empty)
        }
40

41 42 43 44 45 46 47 48 49
        it("should be complete") {
          (rel.tupleSet diff cs.tupleSet) should be (empty)
        }
      }
    }
    
    forAll(vltsSamplesSmall) { sample =>
      describe("for sample " + sample) {
        println("\n" + Console.BLUE + sample + Console.RESET)
50

51 52 53 54 55 56 57 58
        it("should be computed in a reasonable amount of time and be sound (by self-check)") {
          failAfter(180 seconds) {
            val cs = CoupledSimulationFlink.executeAlgorithm(env, cfgPath = sample, cfgReturnRelation = true, cfgCheckSoundness = true)
            cs.sound.get shouldEqual true
          }
        }
      }
    }
59

60 61 62 63 64 65 66 67 68 69 70 71
    forAll(vltsSamplesMedium) { sample =>
      describe("for sample " + sample) {
        it("should be computed in a reasonable amount of time") {
          failAfter(360 seconds) {
            CoupledSimulationFlink.executeAlgorithm(env, cfgPath = sample)
          }
        }
      }
    }
  }
  
}