mirror of
https://github.com/apache/sqoop.git
synced 2025-05-02 17:40:39 +08:00
SQOOP-3408 Introduce a Gradle build parameter to set the default forkEvery value for the tests
(Szabolcs Vasas via Fero Szabo)
This commit is contained in:
parent
0a7407613b
commit
74252163f0
@ -149,6 +149,18 @@ This the same as running unitTest, integrationTest and kerberizedTest.
|
|||||||
* +allTest+: Runs all Sqoop tests.
|
* +allTest+: Runs all Sqoop tests.
|
||||||
|
|
||||||
|
|
||||||
|
The https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test:forkEvery[forkEvery]
|
||||||
|
parameter of most of the Gradle test tasks is set to +0+ which means that all of the tests run in a single JVM.
|
||||||
|
The only exception is the +kerberizedTest+ task which requires a new JVM for every test class.
|
||||||
|
The benefit of this setup is that the test tasks finish much faster since the JVM creation is a slow operation however
|
||||||
|
the Sqoop test framework seems to consume/leak too much memory which can lead to an +OutOfMemoryError+ during the build.
|
||||||
|
To prevent the JVM running out of memory you can use the +-DforkEvery.default+ property to set the forkEvery
|
||||||
|
parameter for all the test tasks except +kerberizedTest+:
|
||||||
|
|
||||||
|
----
|
||||||
|
./gradlew -DforkEvery.default=30 test
|
||||||
|
----
|
||||||
|
|
||||||
=== Third party tests
|
=== Third party tests
|
||||||
|
|
||||||
==== Installing the necessary databases
|
==== Installing the necessary databases
|
||||||
|
36
build.gradle
36
build.gradle
@ -87,6 +87,7 @@ configurations.all {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def sqoopThirdPartyLib = System.getProperty("sqoop.thirdparty.lib.dir")
|
def sqoopThirdPartyLib = System.getProperty("sqoop.thirdparty.lib.dir")
|
||||||
|
def forkEveryDefault = Integer.valueOf(System.getProperty("forkEvery.default", "0"))
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
if (sqoopThirdPartyLib != null) runtime fileTree(dir: sqoopThirdPartyLib, include: '*.jar')
|
if (sqoopThirdPartyLib != null) runtime fileTree(dir: sqoopThirdPartyLib, include: '*.jar')
|
||||||
@ -171,20 +172,6 @@ task integrationTest(type: Test) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task kerberizedTest (type: Test){
|
|
||||||
description 'Run Kerberized Test'
|
|
||||||
// A Gradle test task with forkEvery 1 and includeCategories performs poorly because it starts a new JVM even for the filtered tests.
|
|
||||||
// To work around this performance problem we need to add every kerberized test in a separate include field here.
|
|
||||||
include '**/TestKerberosAuthenticator*'
|
|
||||||
include '**/HBaseKerberizedConnectivityTest*'
|
|
||||||
include '**/TestHiveMiniCluster*'
|
|
||||||
include '**/TestHiveServer2TextImport*'
|
|
||||||
useJUnit {
|
|
||||||
includeCategories 'org.apache.sqoop.testcategories.KerberizedTest'
|
|
||||||
}
|
|
||||||
forkEvery 1
|
|
||||||
}
|
|
||||||
|
|
||||||
task thirdPartyTest (type: Test) {
|
task thirdPartyTest (type: Test) {
|
||||||
description 'Run Third-party Tests - you need to specify -Dsqoop.thirdparty.lib.dir where the Third party driver ' +
|
description 'Run Third-party Tests - you need to specify -Dsqoop.thirdparty.lib.dir where the Third party driver ' +
|
||||||
'jars reside (relative to the project directory)'
|
'jars reside (relative to the project directory)'
|
||||||
@ -210,7 +197,6 @@ test {
|
|||||||
excludeCategories 'org.apache.sqoop.testcategories.sqooptest.ManualTest'
|
excludeCategories 'org.apache.sqoop.testcategories.sqooptest.ManualTest'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
test.finalizedBy(kerberizedTest)
|
|
||||||
|
|
||||||
task s3Test(type: Test) {
|
task s3Test(type: Test) {
|
||||||
description 'Run S3 tests'
|
description 'Run S3 tests'
|
||||||
@ -229,7 +215,6 @@ task allTest (type: Test){
|
|||||||
excludeCategories 'org.apache.sqoop.testcategories.sqooptest.ManualTest'
|
excludeCategories 'org.apache.sqoop.testcategories.sqooptest.ManualTest'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
allTest.finalizedBy(kerberizedTest)
|
|
||||||
|
|
||||||
def testBuildDir = "$buildDir/test/"
|
def testBuildDir = "$buildDir/test/"
|
||||||
def testBuildDirData ="$testBuildDir/data/"
|
def testBuildDirData ="$testBuildDir/data/"
|
||||||
@ -265,8 +250,27 @@ tasks.withType(Test) {
|
|||||||
jacoco{
|
jacoco{
|
||||||
excludes = ["**/SqoopVersion*"]
|
excludes = ["**/SqoopVersion*"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
forkEvery forkEveryDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task kerberizedTest (type: Test){
|
||||||
|
description 'Run Kerberized Test'
|
||||||
|
// A Gradle test task with forkEvery 1 and includeCategories performs poorly because it starts a new JVM even for the filtered tests.
|
||||||
|
// To work around this performance problem we need to add every kerberized test in a separate include field here.
|
||||||
|
include '**/TestKerberosAuthenticator*'
|
||||||
|
include '**/HBaseKerberizedConnectivityTest*'
|
||||||
|
include '**/TestHiveMiniCluster*'
|
||||||
|
include '**/TestHiveServer2TextImport*'
|
||||||
|
useJUnit {
|
||||||
|
includeCategories 'org.apache.sqoop.testcategories.KerberizedTest'
|
||||||
|
}
|
||||||
|
forkEvery 1
|
||||||
|
}
|
||||||
|
|
||||||
|
test.finalizedBy(kerberizedTest)
|
||||||
|
allTest.finalizedBy(kerberizedTest)
|
||||||
|
|
||||||
tasks.withType(Checkstyle) {
|
tasks.withType(Checkstyle) {
|
||||||
reports {
|
reports {
|
||||||
xml.enabled false
|
xml.enabled false
|
||||||
|
Loading…
Reference in New Issue
Block a user