[ 
https://issues.apache.org/jira/browse/GRIFFIN-276?focusedWorklogId=295053&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-295053
 ]

ASF GitHub Bot logged work on GRIFFIN-276:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/Aug/19 21:58
            Start Date: 14/Aug/19 21:58
    Worklog Time Spent: 10m 
      Work Description: guoyuepeng commented on 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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 295053)
    Time Spent: 40m  (was: 0.5h)

> Add batch type measure job test case
> ------------------------------------
>
>                 Key: GRIFFIN-276
>                 URL: https://issues.apache.org/jira/browse/GRIFFIN-276
>             Project: Griffin
>          Issue Type: Task
>            Reporter: wan kun
>            Priority: Major
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Add some test case for batch type measure job, which is helpful for checking 
> the correctness of the code and troublethooting.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to