From 74252163f0455747ed2a99eb6c2c9d0e48f3dedc Mon Sep 17 00:00:00 2001 From: Fero Szabo Date: Thu, 22 Nov 2018 16:20:30 +0100 Subject: [PATCH] SQOOP-3408 Introduce a Gradle build parameter to set the default forkEvery value for the tests (Szabolcs Vasas via Fero Szabo) --- COMPILING.txt | 12 ++++++++++++ build.gradle | 36 ++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/COMPILING.txt b/COMPILING.txt index 0383707f..b399ba82 100644 --- a/COMPILING.txt +++ b/COMPILING.txt @@ -149,6 +149,18 @@ This the same as running unitTest, integrationTest and kerberizedTest. * +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 ==== Installing the necessary databases diff --git a/build.gradle b/build.gradle index 954935da..efe980d6 100644 --- a/build.gradle +++ b/build.gradle @@ -87,6 +87,7 @@ configurations.all { } def sqoopThirdPartyLib = System.getProperty("sqoop.thirdparty.lib.dir") +def forkEveryDefault = Integer.valueOf(System.getProperty("forkEvery.default", "0")) dependencies { 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) { 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)' @@ -210,7 +197,6 @@ test { excludeCategories 'org.apache.sqoop.testcategories.sqooptest.ManualTest' } } -test.finalizedBy(kerberizedTest) task s3Test(type: Test) { description 'Run S3 tests' @@ -229,7 +215,6 @@ task allTest (type: Test){ excludeCategories 'org.apache.sqoop.testcategories.sqooptest.ManualTest' } } -allTest.finalizedBy(kerberizedTest) def testBuildDir = "$buildDir/test/" def testBuildDirData ="$testBuildDir/data/" @@ -265,8 +250,27 @@ tasks.withType(Test) { jacoco{ 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) { reports { xml.enabled false