mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-21 07:38:13 +00:00
Generate code coverage reports (#334)
* Add playCoverage task to run code coverage using JaCoco for backend and web. * Add jacocoTestReport task to run code coverage for testNG-based tests in wherehows-common & metadata-etl.
This commit is contained in:
parent
bcc3cd9f76
commit
e36a40cd65
@ -66,6 +66,10 @@ task "playClean" (type: Exec) {
|
|||||||
commandLine playExec, 'clean'
|
commandLine playExec, 'clean'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task "playCoverage" (type: Exec) {
|
||||||
|
commandLine playExec, 'jacoco:cover'
|
||||||
|
}
|
||||||
|
|
||||||
sourceSets.main{
|
sourceSets.main{
|
||||||
java.srcDir 'app'
|
java.srcDir 'app'
|
||||||
compileClasspath += configurations.provided
|
compileClasspath += configurations.provided
|
||||||
|
@ -23,3 +23,5 @@ libraryDependencies ++= Seq(
|
|||||||
"org.easytesting" % "fest-assert-core" % "2.0M8"
|
"org.easytesting" % "fest-assert-core" % "2.0M8"
|
||||||
).map(_.exclude("log4j", "log4j"))
|
).map(_.exclude("log4j", "log4j"))
|
||||||
.map(_.exclude("org.slf4j", "slf4j-log4j12"))
|
.map(_.exclude("org.slf4j", "slf4j-log4j12"))
|
||||||
|
|
||||||
|
jacoco.settings
|
||||||
|
@ -6,3 +6,6 @@ resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/release
|
|||||||
|
|
||||||
// Use the Play sbt plugin for Play projects
|
// Use the Play sbt plugin for Play projects
|
||||||
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.8")
|
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.8")
|
||||||
|
|
||||||
|
// Use JaCoCo for code coverage
|
||||||
|
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6")
|
||||||
|
@ -20,6 +20,7 @@ import models.daos.DatasetDao;
|
|||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import play.Logger;
|
import play.Logger;
|
||||||
import play.libs.Json;
|
import play.libs.Json;
|
||||||
@ -38,6 +39,7 @@ import static org.fest.assertions.api.Assertions.*;
|
|||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Ignore("needs config")
|
||||||
public class DatasetControllerTest {
|
public class DatasetControllerTest {
|
||||||
|
|
||||||
public static FakeApplication app;
|
public static FakeApplication app;
|
||||||
|
10
build.gradle
10
build.gradle
@ -22,6 +22,7 @@ configurations.all {
|
|||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
|
apply plugin: 'jacoco'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'com.github.hierynomus.license'
|
apply plugin: 'com.github.hierynomus.license'
|
||||||
@ -82,6 +83,15 @@ subprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jacocoTestReport {
|
||||||
|
dependsOn excludegroup
|
||||||
|
reports {
|
||||||
|
xml.enabled false
|
||||||
|
csv.enabled false
|
||||||
|
}
|
||||||
|
executionData = files("$buildDir/jacoco/excludegroup.exec")
|
||||||
|
}
|
||||||
|
|
||||||
ext.externalDependency = ["mysql" : "mysql:mysql-connector-java:5.1.40",
|
ext.externalDependency = ["mysql" : "mysql:mysql-connector-java:5.1.40",
|
||||||
"jython" : "org.python:jython-standalone:2.7.0",
|
"jython" : "org.python:jython-standalone:2.7.0",
|
||||||
"testng" : "org.testng:testng:6.9.10",
|
"testng" : "org.testng:testng:6.9.10",
|
||||||
|
@ -51,7 +51,6 @@ task copyFiles(type: Copy, dependsOn: compileJava) {
|
|||||||
include 'schemaFetch.jar'
|
include 'schemaFetch.jar'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
java {
|
java {
|
||||||
|
@ -24,6 +24,7 @@ import org.testng.annotations.Test;
|
|||||||
/**
|
/**
|
||||||
* Created by zsun on 9/21/15.
|
* Created by zsun on 9/21/15.
|
||||||
*/
|
*/
|
||||||
|
@Test(groups = {"needConfig"})
|
||||||
public class AzDbCommunicatorTest {
|
public class AzDbCommunicatorTest {
|
||||||
AzDbCommunicator adc;
|
AzDbCommunicator adc;
|
||||||
|
|
||||||
@ -34,7 +35,6 @@ public class AzDbCommunicatorTest {
|
|||||||
adc = new AzDbCommunicator(prop);
|
adc = new AzDbCommunicator(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = {"needConfig"})
|
|
||||||
public void getExecLogTest()
|
public void getExecLogTest()
|
||||||
throws IOException, SQLException {
|
throws IOException, SQLException {
|
||||||
int execId = 870536;
|
int execId = 870536;
|
||||||
|
@ -32,6 +32,7 @@ import wherehows.common.schemas.AzkabanJobExecRecord;
|
|||||||
/**
|
/**
|
||||||
* Created by zsun on 9/9/15.
|
* Created by zsun on 9/9/15.
|
||||||
*/
|
*/
|
||||||
|
@Test(groups = {"needConfig"})
|
||||||
public class AzJobCheckerTest {
|
public class AzJobCheckerTest {
|
||||||
|
|
||||||
AzJobChecker ajc;
|
AzJobChecker ajc;
|
||||||
@ -44,7 +45,6 @@ public class AzJobCheckerTest {
|
|||||||
ajc = new AzJobChecker(prop);
|
ajc = new AzJobChecker(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = {"needConfig"})
|
|
||||||
public void getRecentFinishedJobFromFlowTest()
|
public void getRecentFinishedJobFromFlowTest()
|
||||||
throws SQLException, IOException {
|
throws SQLException, IOException {
|
||||||
List<AzkabanJobExecRecord> results = ajc.getRecentFinishedJobFromFlow();
|
List<AzkabanJobExecRecord> results = ajc.getRecentFinishedJobFromFlow();
|
||||||
@ -56,7 +56,6 @@ public class AzJobCheckerTest {
|
|||||||
Assert.assertNotNull(results);
|
Assert.assertNotNull(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = {"needConfig"})
|
|
||||||
public void getRecentFinishedJobFromFlowTest2()
|
public void getRecentFinishedJobFromFlowTest2()
|
||||||
throws SQLException, IOException {
|
throws SQLException, IOException {
|
||||||
List<AzkabanJobExecRecord> results = ajc.getRecentFinishedJobFromFlow(2, 1448916456L);
|
List<AzkabanJobExecRecord> results = ajc.getRecentFinishedJobFromFlow(2, 1448916456L);
|
||||||
@ -68,7 +67,6 @@ public class AzJobCheckerTest {
|
|||||||
Assert.assertNotNull(results);
|
Assert.assertNotNull(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = {"needConfig"})
|
|
||||||
public void parseNestedJsonTest()
|
public void parseNestedJsonTest()
|
||||||
throws IOException, URISyntaxException {
|
throws IOException, URISyntaxException {
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import wherehows.common.writers.DatabaseWriter;
|
|||||||
/**
|
/**
|
||||||
* Created by zsun on 9/10/15.
|
* Created by zsun on 9/10/15.
|
||||||
*/
|
*/
|
||||||
|
@Test(groups = {"needConfig"})
|
||||||
public class AzLineageExtractorTest {
|
public class AzLineageExtractorTest {
|
||||||
Properties prop;
|
Properties prop;
|
||||||
String connUrl;
|
String connUrl;
|
||||||
@ -52,7 +53,6 @@ public class AzLineageExtractorTest {
|
|||||||
* Test extract one job execution's lineage
|
* Test extract one job execution's lineage
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Test(groups = {"needConfig"})
|
|
||||||
public void extractLineageTest()
|
public void extractLineageTest()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import wherehows.common.schemas.LineageRecord;
|
|||||||
/**
|
/**
|
||||||
* Created by zsun on 9/24/15.
|
* Created by zsun on 9/24/15.
|
||||||
*/
|
*/
|
||||||
|
@Test(groups = {"needConfig"})
|
||||||
public class AzLogParserTest {
|
public class AzLogParserTest {
|
||||||
|
|
||||||
private final int TEST_APP_ID = -1;
|
private final int TEST_APP_ID = -1;
|
||||||
@ -50,7 +51,6 @@ public class AzLogParserTest {
|
|||||||
AzLogParser.initialize(conn);
|
AzLogParser.initialize(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = {"needConfig"})
|
|
||||||
public void getHadoopJobIdFromLogTest() {
|
public void getHadoopJobIdFromLogTest() {
|
||||||
String logSample = "9-08-2015 03:02:16 PDT hadoop-datasets-stats_sizeAggr INFO - INFO map 26% reduce 0%\n" +
|
String logSample = "9-08-2015 03:02:16 PDT hadoop-datasets-stats_sizeAggr INFO - INFO map 26% reduce 0%\n" +
|
||||||
"29-08-2015 03:02:16 PDT hadoop-datasets-stats_sizeAggr INFO - INFO map 30% reduce 0%\n" +
|
"29-08-2015 03:02:16 PDT hadoop-datasets-stats_sizeAggr INFO - INFO map 30% reduce 0%\n" +
|
||||||
@ -78,7 +78,6 @@ public class AzLogParserTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = {"needConfig"})
|
|
||||||
public void getLineageFromLogTest() {
|
public void getLineageFromLogTest() {
|
||||||
String logSample = "asfdasdfsadf Moving from staged path[asdf] to final resting place[/tm/b/c] sdaf dsfasdfasdf";
|
String logSample = "asfdasdfsadf Moving from staged path[asdf] to final resting place[/tm/b/c] sdaf dsfasdfasdf";
|
||||||
AzkabanJobExecRecord sampleExecution = new AzkabanJobExecRecord(TEST_APP_ID, "someJobName", (long) 0, 0, 0, "S", "path");
|
AzkabanJobExecRecord sampleExecution = new AzkabanJobExecRecord(TEST_APP_ID, "someJobName", (long) 0, 0, 0, "S", "path");
|
||||||
|
@ -26,6 +26,7 @@ import wherehows.common.Constant;
|
|||||||
/**
|
/**
|
||||||
* Created by zsun on 8/29/15.
|
* Created by zsun on 8/29/15.
|
||||||
*/
|
*/
|
||||||
|
@Test(groups = {"needConfig"})
|
||||||
public class AzServerCommunicatorTest {
|
public class AzServerCommunicatorTest {
|
||||||
AzServiceCommunicator asc;
|
AzServiceCommunicator asc;
|
||||||
Properties prop;
|
Properties prop;
|
||||||
@ -37,7 +38,6 @@ public class AzServerCommunicatorTest {
|
|||||||
asc = new AzServiceCommunicator(prop);
|
asc = new AzServiceCommunicator(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = {"needConfig"})
|
|
||||||
public void testGetExecLog()
|
public void testGetExecLog()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
@ -50,7 +50,6 @@ public class AzServerCommunicatorTest {
|
|||||||
Assert.assertEquals("27-08-2015", log);
|
Assert.assertEquals("27-08-2015", log);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = {"needConfig"})
|
|
||||||
public void testGetSessionId()
|
public void testGetSessionId()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
@ -61,7 +60,6 @@ public class AzServerCommunicatorTest {
|
|||||||
Assert.assertTrue(!response.equals(""));
|
Assert.assertTrue(!response.equals(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = {"needConfig"})
|
|
||||||
public void getHadoopID()
|
public void getHadoopID()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
int execId = 843164;
|
int execId = 843164;
|
||||||
|
@ -58,6 +58,9 @@ task "playTest" (type: Exec, dependsOn: playCompile) {
|
|||||||
commandLine playExec, 'test'
|
commandLine playExec, 'test'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task "playCoverage" (type: Exec) {
|
||||||
|
commandLine playExec, 'jacoco:cover'
|
||||||
|
}
|
||||||
|
|
||||||
task "playClean" (type: Exec) {
|
task "playClean" (type: Exec) {
|
||||||
commandLine playExec, 'clean'
|
commandLine playExec, 'clean'
|
||||||
|
@ -16,3 +16,5 @@ libraryDependencies ++= Seq(
|
|||||||
"org.mockito" % "mockito-core" % "1.10.19",
|
"org.mockito" % "mockito-core" % "1.10.19",
|
||||||
"org.easytesting" % "fest-assert-core" % "2.0M8"
|
"org.easytesting" % "fest-assert-core" % "2.0M8"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
jacoco.settings
|
||||||
|
@ -7,3 +7,6 @@ resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/release
|
|||||||
// Use the Play sbt plugin for Play projects
|
// Use the Play sbt plugin for Play projects
|
||||||
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.8")
|
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.8")
|
||||||
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.1.1")
|
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.1.1")
|
||||||
|
|
||||||
|
// Use JaCoCo for code coverage
|
||||||
|
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6")
|
||||||
|
@ -5,6 +5,7 @@ import play.libs.ws.WS;
|
|||||||
import static play.test.Helpers.*;
|
import static play.test.Helpers.*;
|
||||||
import static org.fest.assertions.api.Assertions.*;
|
import static org.fest.assertions.api.Assertions.*;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
public class IntegrationTest {
|
public class IntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -35,7 +35,7 @@ import wherehows.common.schemas.LineageRecord;
|
|||||||
/**
|
/**
|
||||||
* Created by zsun on 9/13/15.
|
* Created by zsun on 9/13/15.
|
||||||
*/
|
*/
|
||||||
@Test(groups = {"wherehows.common"})
|
@Test(groups = {"needConfig"})
|
||||||
public class LineageCombinerTest {
|
public class LineageCombinerTest {
|
||||||
final static String TEST_PROP_FILE_NAME = "wherehows-common-test.properties";
|
final static String TEST_PROP_FILE_NAME = "wherehows-common-test.properties";
|
||||||
LineageCombiner lineageCombiner;
|
LineageCombiner lineageCombiner;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user