@@ -23,7 +23,7 @@ import collection.JavaConverters._
2323import com .dimafeng .testcontainers .{ForAllTestContainer , GenericContainer }
2424import com .google .protobuf .util .Timestamps
2525import feast .proto .types .ValueProto .ValueType
26- import org .apache .spark .SparkConf
26+ import org .apache .spark .{ SparkConf , SparkEnv }
2727import org .joda .time .{DateTime , Seconds }
2828import org .scalacheck ._
2929import org .scalatest ._
@@ -46,25 +46,28 @@ case class TestRow(
4646class BatchPipelineIT extends SparkSpec with ForAllTestContainer {
4747
4848 override val container = GenericContainer (" redis:6.0.8" , exposedPorts = Seq (6379 ))
49+ val statsDStub = new StatsDStub
4950
5051 override def withSparkConfOverrides (conf : SparkConf ): SparkConf = conf
5152 .set(" spark.redis.host" , container.host)
5253 .set(" spark.redis.port" , container.mappedPort(6379 ).toString)
54+ .set(" spark.metrics.conf.*.sink.statsd.port" , statsDStub.port.toString)
5355
5456 trait Scope {
5557 val jedis = new Jedis (" localhost" , container.mappedPort(6379 ))
5658 jedis.flushAll()
5759
60+ statsDStub.receivedMetrics // clean the buffer
61+
5862 implicit def testRowEncoder : Encoder [TestRow ] = ExpressionEncoder ()
59- val statsDStub = new StatsDStub
6063
6164 def rowGenerator (start : DateTime , end : DateTime , customerGen : Option [Gen [String ]] = None ) =
6265 for {
6366 customer <- customerGen.getOrElse(Gen .asciiPrintableStr)
6467 feature1 <- Gen .choose(0 , 100 )
6568 feature2 <- Gen .choose[Float ](0 , 1 )
6669 eventTimestamp <- Gen
67- .choose(0 , Seconds .secondsBetween(start, end).getSeconds)
70+ .choose(0 , Seconds .secondsBetween(start, end).getSeconds - 1 )
6871 .map(start.withMillisOfSecond(0 ).plusSeconds)
6972 } yield TestRow (
7073 customer,
@@ -98,7 +101,7 @@ class BatchPipelineIT extends SparkSpec with ForAllTestContainer {
98101 ),
99102 startTime = DateTime .parse(" 2020-08-01" ),
100103 endTime = DateTime .parse(" 2020-09-01" ),
101- metrics = Some (StatsDConfig (host= " localhost" , port= statsDStub.port))
104+ metrics = Some (StatsDConfig (host = " localhost" , port = statsDStub.port))
102105 )
103106 }
104107
@@ -129,6 +132,14 @@ class BatchPipelineIT extends SparkSpec with ForAllTestContainer {
129132 keyTTL shouldEqual - 1
130133
131134 })
135+
136+ SparkEnv .get.metricsSystem.report()
137+ statsDStub.receivedMetrics should contain.allElementsOf(
138+ Map (
139+ " driver.ingestion_pipeline.read_from_source_count" -> rows.length,
140+ " driver.redis_sink.feature_row_ingested_count" -> rows.length
141+ )
142+ )
132143 }
133144
134145 " Parquet source file" should " be ingested in redis with expiry time equal to the largest of (event_timestamp + max_age) for" +
@@ -466,6 +477,13 @@ class BatchPipelineIT extends SparkSpec with ForAllTestContainer {
466477 .toString
467478 )
468479 .count() should be(rows.length)
480+
481+ SparkEnv .get.metricsSystem.report()
482+ statsDStub.receivedMetrics should contain.allElementsOf(
483+ Map (
484+ " driver.ingestion_pipeline.deadletter_count" -> rows.length
485+ )
486+ )
469487 }
470488
471489 " Columns from source" should " be mapped according to configuration" in new Scope {
0 commit comments