guoyuepeng commented on a change in pull request #520: [GRIFFIN-276]Add batch 
type measure job test case
URL: https://github.com/apache/griffin/pull/520#discussion_r314102167
 
 

 ##########
 File path: 
measure/src/test/scala/org/apache/griffin/measure/job/BatchDQAppTest.scala
 ##########
 @@ -0,0 +1,155 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+package org.apache.griffin.measure.job
+
+import scala.util.{Failure, Success, Try}
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.SparkSession
+import org.scalatest.BeforeAndAfterAll
+
+import org.apache.griffin.measure.Application.readParamFile
+import org.apache.griffin.measure.configuration.dqdefinition.EnvConfig
+import org.apache.griffin.measure.launch.batch.BatchDQApp
+import org.apache.griffin.measure.step.builder.udf.GriffinUDFAgent
+
+class BatchDQAppTest extends DQAppTest with BeforeAndAfterAll {
+
+  override def beforeAll(): Unit = {
+    super.beforeAll()
+
+    envParam = readParamFile[EnvConfig](getConfigFilePath("/env-batch.json")) 
match {
+      case Success(p) => p
+      case Failure(ex) =>
+        error(ex.getMessage, ex)
+        sys.exit(-2)
+    }
+
+    sparkParam = envParam.getSparkParam
+
+    Try {
+      // build spark 2.0+ application context
+      var conf = new SparkConf().setAppName("BatchDQApp Test")
+      conf.setAll(sparkParam.getConfig)
+      conf.set("spark.sql.crossJoin.enabled", "true")
+
+      sparkSession = 
SparkSession.builder().config(conf).enableHiveSupport().getOrCreate()
+      val logLevel = getGriffinLogLevel()
+      sparkSession.sparkContext.setLogLevel(sparkParam.getLogLevel)
+      griffinLogger.setLevel(logLevel)
+      val sqlContext = sparkSession.sqlContext
+
+      // register udf
+      GriffinUDFAgent.register(sqlContext)
+    }
+  }
+
+  override def afterAll(): Unit = {
+    super.afterAll()
+    sparkSession.stop()
+  }
+
+  def runAndCheckResult(metrics: Map[String, Any]): Unit = {
+    val runResult = dqApp.run
+    assert(runResult.isSuccess)
+    assert(runResult.get)
+
+    // check Result Metrics
+    val dqContext = dqApp.asInstanceOf[BatchDQApp].dqContext
+    val timestamp = dqContext.contextId.timestamp
+    val expectedMetrics =
+      Map(timestamp -> metrics)
+
+    dqContext.metricWrapper.metrics should equal(expectedMetrics)
+  }
+
+  "accuracy batch job" should "work" in {
 
 Review comment:
   GOOD Test case for different data quality dimensions.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to