You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2017/08/24 01:05:34 UTC

[3/4] kudu git commit: [java] Gradle test task improvements

[java] Gradle test task improvements

Previously some tests would be extremely flaky when
running via Gradle. Especially secure tests with token
renewal. This fixes that issue by forking a new jvm for
each test class to isolate the tests.

I also add a few system properties to match the
Maven build and support filtering tests from the root
directory with the --tests argument.

Change-Id: Ifb660b15423b68c299518b7ba54a15135972a007
Reviewed-on: http://gerrit.cloudera.org:8080/7782
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Adar Dembo <ad...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/df2fa4f7
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/df2fa4f7
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/df2fa4f7

Branch: refs/heads/master
Commit: df2fa4f7cf88b44b1dbf07ba5e8859f73af0b617
Parents: b2f5837
Author: Grant Henke <gr...@gmail.com>
Authored: Wed Aug 23 12:54:34 2017 -0500
Committer: Adar Dembo <ad...@cloudera.com>
Committed: Thu Aug 24 00:48:31 2017 +0000

----------------------------------------------------------------------
 java/gradle/tests.gradle | 21 ++++++++++++++++++++-
 java/pom.xml             |  2 +-
 2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/df2fa4f7/java/gradle/tests.gradle
----------------------------------------------------------------------
diff --git a/java/gradle/tests.gradle b/java/gradle/tests.gradle
index 01e3c0d..6963d2e 100644
--- a/java/gradle/tests.gradle
+++ b/java/gradle/tests.gradle
@@ -22,12 +22,31 @@ test {
   maxParallelForks = propertyWithDefault("maxParallelForks", "1").toInteger()
 }
 
-// Log all test events.
 tasks.withType(Test) {
+  // Log all test events.
   testLogging {
     events "passed", "skipped", "failed"
     exceptionFormat = "full"
   }
+
+  // Fork the jvm for every test class.
+  // This takes more time and resources but ensures isolation.
+  forkEvery 1
+
+  // Enable assertions during tests.
+  jvmArgs "-enableassertions"
+
+  // Set a few system properties.
+  systemProperty "java.awt.headless", true
+  systemProperty "java.net.preferIPv4Stack", true
+  systemProperty "java.security.egd", "file:/dev/urandom" // Improve RNG generation speed.
+
+  // Don't fail the build if a --tests filter doesn't match any tests.
+  // This is useful for filtering tests from the top of the project where some
+  // subprojects won't match the filter. Without this, those subprojects would fail.
+  filter {
+    failOnNoMatchingTests = false
+  }
 }
 
 // Adds pattern based integration test support.

http://git-wip-us.apache.org/repos/asf/kudu/blob/df2fa4f7/java/pom.xml
----------------------------------------------------------------------
diff --git a/java/pom.xml b/java/pom.xml
index 20b9eff..6567883 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -98,7 +98,7 @@
         <!-- Misc variables -->
         <testdata.dir>target/testdata</testdata.dir>
         <testArgLine>-enableassertions -Xmx1900m
-            -Djava.security.egd=file:/dev/./urandom -Djava.net.preferIPv4Stack=true
+            -Djava.security.egd=file:/dev/urandom -Djava.net.preferIPv4Stack=true
             -Djava.awt.headless=true
         </testArgLine>
     </properties>