mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-20 23:28:01 +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'
|
||||
}
|
||||
|
||||
task "playCoverage" (type: Exec) {
|
||||
commandLine playExec, 'jacoco:cover'
|
||||
}
|
||||
|
||||
sourceSets.main{
|
||||
java.srcDir 'app'
|
||||
compileClasspath += configurations.provided
|
||||
|
@ -23,3 +23,5 @@ libraryDependencies ++= Seq(
|
||||
"org.easytesting" % "fest-assert-core" % "2.0M8"
|
||||
).map(_.exclude("log4j", "log4j"))
|
||||
.map(_.exclude("org.slf4j", "slf4j-log4j12"))
|
||||
|
||||
jacoco.settings
|
||||
|
@ -5,4 +5,7 @@ logLevel := Level.Warn
|
||||
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
|
||||
|
||||
// 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.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import play.Logger;
|
||||
import play.libs.Json;
|
||||
@ -38,6 +39,7 @@ import static org.fest.assertions.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
||||
@Ignore("needs config")
|
||||
public class DatasetControllerTest {
|
||||
|
||||
public static FakeApplication app;
|
||||
|
10
build.gradle
10
build.gradle
@ -22,6 +22,7 @@ configurations.all {
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'jacoco'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'eclipse'
|
||||
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",
|
||||
"jython" : "org.python:jython-standalone:2.7.0",
|
||||
"testng" : "org.testng:testng:6.9.10",
|
||||
|
@ -51,7 +51,6 @@ task copyFiles(type: Copy, dependsOn: compileJava) {
|
||||
include 'schemaFetch.jar'
|
||||
}
|
||||
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
|
@ -24,6 +24,7 @@ import org.testng.annotations.Test;
|
||||
/**
|
||||
* Created by zsun on 9/21/15.
|
||||
*/
|
||||
@Test(groups = {"needConfig"})
|
||||
public class AzDbCommunicatorTest {
|
||||
AzDbCommunicator adc;
|
||||
|
||||
@ -34,7 +35,6 @@ public class AzDbCommunicatorTest {
|
||||
adc = new AzDbCommunicator(prop);
|
||||
}
|
||||
|
||||
@Test(groups = {"needConfig"})
|
||||
public void getExecLogTest()
|
||||
throws IOException, SQLException {
|
||||
int execId = 870536;
|
||||
|
@ -32,6 +32,7 @@ import wherehows.common.schemas.AzkabanJobExecRecord;
|
||||
/**
|
||||
* Created by zsun on 9/9/15.
|
||||
*/
|
||||
@Test(groups = {"needConfig"})
|
||||
public class AzJobCheckerTest {
|
||||
|
||||
AzJobChecker ajc;
|
||||
@ -44,7 +45,6 @@ public class AzJobCheckerTest {
|
||||
ajc = new AzJobChecker(prop);
|
||||
}
|
||||
|
||||
@Test(groups = {"needConfig"})
|
||||
public void getRecentFinishedJobFromFlowTest()
|
||||
throws SQLException, IOException {
|
||||
List<AzkabanJobExecRecord> results = ajc.getRecentFinishedJobFromFlow();
|
||||
@ -56,7 +56,6 @@ public class AzJobCheckerTest {
|
||||
Assert.assertNotNull(results);
|
||||
}
|
||||
|
||||
@Test(groups = {"needConfig"})
|
||||
public void getRecentFinishedJobFromFlowTest2()
|
||||
throws SQLException, IOException {
|
||||
List<AzkabanJobExecRecord> results = ajc.getRecentFinishedJobFromFlow(2, 1448916456L);
|
||||
@ -68,7 +67,6 @@ public class AzJobCheckerTest {
|
||||
Assert.assertNotNull(results);
|
||||
}
|
||||
|
||||
@Test(groups = {"needConfig"})
|
||||
public void parseNestedJsonTest()
|
||||
throws IOException, URISyntaxException {
|
||||
|
||||
|
@ -30,6 +30,7 @@ import wherehows.common.writers.DatabaseWriter;
|
||||
/**
|
||||
* Created by zsun on 9/10/15.
|
||||
*/
|
||||
@Test(groups = {"needConfig"})
|
||||
public class AzLineageExtractorTest {
|
||||
Properties prop;
|
||||
String connUrl;
|
||||
@ -52,7 +53,6 @@ public class AzLineageExtractorTest {
|
||||
* Test extract one job execution's lineage
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(groups = {"needConfig"})
|
||||
public void extractLineageTest()
|
||||
throws Exception {
|
||||
|
||||
|
@ -33,6 +33,7 @@ import wherehows.common.schemas.LineageRecord;
|
||||
/**
|
||||
* Created by zsun on 9/24/15.
|
||||
*/
|
||||
@Test(groups = {"needConfig"})
|
||||
public class AzLogParserTest {
|
||||
|
||||
private final int TEST_APP_ID = -1;
|
||||
@ -50,7 +51,6 @@ public class AzLogParserTest {
|
||||
AzLogParser.initialize(conn);
|
||||
}
|
||||
|
||||
@Test(groups = {"needConfig"})
|
||||
public void getHadoopJobIdFromLogTest() {
|
||||
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" +
|
||||
@ -78,7 +78,6 @@ public class AzLogParserTest {
|
||||
|
||||
}
|
||||
|
||||
@Test(groups = {"needConfig"})
|
||||
public void getLineageFromLogTest() {
|
||||
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");
|
||||
|
@ -26,6 +26,7 @@ import wherehows.common.Constant;
|
||||
/**
|
||||
* Created by zsun on 8/29/15.
|
||||
*/
|
||||
@Test(groups = {"needConfig"})
|
||||
public class AzServerCommunicatorTest {
|
||||
AzServiceCommunicator asc;
|
||||
Properties prop;
|
||||
@ -37,7 +38,6 @@ public class AzServerCommunicatorTest {
|
||||
asc = new AzServiceCommunicator(prop);
|
||||
}
|
||||
|
||||
@Test(groups = {"needConfig"})
|
||||
public void testGetExecLog()
|
||||
throws Exception {
|
||||
|
||||
@ -50,7 +50,6 @@ public class AzServerCommunicatorTest {
|
||||
Assert.assertEquals("27-08-2015", log);
|
||||
}
|
||||
|
||||
@Test(groups = {"needConfig"})
|
||||
public void testGetSessionId()
|
||||
throws Exception {
|
||||
|
||||
@ -61,7 +60,6 @@ public class AzServerCommunicatorTest {
|
||||
Assert.assertTrue(!response.equals(""));
|
||||
}
|
||||
|
||||
@Test(groups = {"needConfig"})
|
||||
public void getHadoopID()
|
||||
throws Exception {
|
||||
int execId = 843164;
|
||||
|
@ -58,6 +58,9 @@ task "playTest" (type: Exec, dependsOn: playCompile) {
|
||||
commandLine playExec, 'test'
|
||||
}
|
||||
|
||||
task "playCoverage" (type: Exec) {
|
||||
commandLine playExec, 'jacoco:cover'
|
||||
}
|
||||
|
||||
task "playClean" (type: Exec) {
|
||||
commandLine playExec, 'clean'
|
||||
|
@ -16,3 +16,5 @@ libraryDependencies ++= Seq(
|
||||
"org.mockito" % "mockito-core" % "1.10.19",
|
||||
"org.easytesting" % "fest-assert-core" % "2.0M8"
|
||||
)
|
||||
|
||||
jacoco.settings
|
||||
|
@ -6,4 +6,7 @@ resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/release
|
||||
|
||||
// Use the Play sbt plugin for Play projects
|
||||
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 org.fest.assertions.api.Assertions.*;
|
||||
|
||||
@Ignore
|
||||
public class IntegrationTest {
|
||||
|
||||
@Test
|
||||
|
@ -35,7 +35,7 @@ import wherehows.common.schemas.LineageRecord;
|
||||
/**
|
||||
* Created by zsun on 9/13/15.
|
||||
*/
|
||||
@Test(groups = {"wherehows.common"})
|
||||
@Test(groups = {"needConfig"})
|
||||
public class LineageCombinerTest {
|
||||
final static String TEST_PROP_FILE_NAME = "wherehows-common-test.properties";
|
||||
LineageCombiner lineageCombiner;
|
||||
@ -124,4 +124,4 @@ public class LineageCombinerTest {
|
||||
DatasetPath datasetPath = PathAnalyzer.analyze(fullPath);
|
||||
Assert.assertEquals(datasetPath.abstractPath, testProp.getProperty("analyzeTest.abstractPath"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user