Packages

  • package root
    Definition Classes
    root
  • package cloudflow
    Definition Classes
    root
  • package spark
    Definition Classes
    cloudflow
  • package testkit
    Definition Classes
    spark
  • final case class SparkStreamletTestkit(session: SparkSession, config: Config = ConfigFactory.empty, maxDuration: Duration = 30.seconds) extends Product with Serializable

    Testkit for testing Spark streamlets.

    Testkit for testing Spark streamlets.

    The steps to write a test using the testkit are:

    1. Create the test class and extend it with SparkScalaTestSupport
    2. Create the Spark streamlet testkit instance
    3. Create the Spark streamlet
    4. Setup inlet tap on inlet port
    5. Setup outlet tap on outlet port
    6. Build input data and send to inlet tap
    7. Run the test
    8. Get data from outlet and assert
    // 1. Create the test class and extend it with `SparkScalaTestSupport`
    class MySparkStreamletSpec extends SparkScalaTestSupport {
    
     "SparkProcessor" should {
       "process streaming data" in {
    
         // 2. Create Spark streamlet testkit instance
         val testKit = SparkStreamletTestkit(session)
    
         // 3. Create spark streamlet
         val processor = new SparkProcessor[Data, Simple] {
           override def createLogic(): ProcessorLogic[Data, Simple] = new ProcessorLogic[Data, Simple](OutputMode.Append) {
             override def process(inDataset: Dataset[Data]): Dataset[Simple] =
               inDataset.select($"name").as[Simple]
           }
         }
    
         // 4. Setup inlet(s) tap on inlet port(s)
         val in: SparkInletTap[Data] = inletAsTap[Data](processor.shape.inlet)
    
         // 5. Setup outlet tap(s) on outlet port(s)
         val out: SparkOutletTap[Simple] = outletAsTap[Simple](processor.shape.outlet)
    
         // 6. Prepare input data and send it to the inlet tap(s)
         val data = (1 to 10).map(i => Data(i, s"name$i"))
         in.addData(data)
    
         // 7. Run the test
         run(processor, Seq(in), Seq(out))
    
         // 8. Get data from outlet tap(s) and assert
         val results = out.asCollection(session)
    
         results should contain(Simple("name1"))
       }
     }
    }

    Note: Every test is executed against a SparkSession which gets created and removed as part of the test lifecycle methods.

    Definition Classes
    testkit
  • InletTapOps
  • OutletTapOps

implicit class OutletTapOps[T] extends AnyRef

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. OutletTapOps
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new OutletTapOps(outlet: CodecOutlet[T])(implicit arg0: Encoder[T])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @HotSpotIntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  9. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. def outletAsTap: SparkOutletTap[T]
  15. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  16. def toString(): String
    Definition Classes
    AnyRef → Any
  17. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  18. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  19. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped