geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [1/6] geode git commit: GEODE-3071: Provide capability to parallelize distributedTests
Date Mon, 19 Jun 2017 21:22:54 GMT
Repository: geode
Updated Branches:
  refs/heads/develop 8db786275 -> 80667f30e


GEODE-3071: Provide capability to parallelize distributedTests

Herewith the ability to leverage Gradle's parallel test execution
capability to run dunits in parallel. This is combined with launching
tests in Docker containers to provide process, network and filesystem
isolation. Depending on the size of your system, this can speed up
running the distributedTest task 2-5 times.

The capability is enabled by launching gradle with '-PparallelDunit'

Tunables, enabled as gradle parametrs (-P option) are:

- dunitDockerImage: The docker image which will be used to launch
  tests. The image must have the JAVA_HOME environment variable set. The
  image must be pulled locally before starting the tests.
- dunitParallelForks: The number of parallel docker containers to be
  launched.
- dunitDockerUser: The docker user which will run the tests. Because of
  the way that the containers map the build directory into them, the
  test artifacts, will be written with this user id. By default this is
  'root'.


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

Branch: refs/heads/develop
Commit: 588c3ed8af4b9a1b46737c2faebafa589a396e12
Parents: a4d790c
Author: Jens Deppe <jdeppe@pivotal.io>
Authored: Wed Jun 14 08:03:22 2017 -0700
Committer: Jens Deppe <jdeppe@pivotal.io>
Committed: Wed Jun 14 08:03:22 2017 -0700

----------------------------------------------------------------------
 build.gradle         |  2 ++
 gradle.properties    |  7 ++++
 gradle/docker.gradle | 83 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/588c3ed8/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index ec6b920..57372b3 100755
--- a/build.gradle
+++ b/build.gradle
@@ -26,6 +26,7 @@ buildscript {
     classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.0.1'
     classpath "com.diffplug.gradle.spotless:spotless:2.2.0"
     classpath "me.champeau.gradle:jmh-gradle-plugin:0.3.1"
+    classpath "com.pedjak.gradle.plugins:dockerized-test:0.4.2"
   }
 }
 
@@ -82,6 +83,7 @@ apply from: "${scriptDir}/code-analysis.gradle"
 apply from: "${scriptDir}/sonar.gradle"
 apply from: "${scriptDir}/ide.gradle"
 apply from: "${scriptDir}/rat.gradle"
+apply from: "${scriptDir}/docker.gradle"
 
 subprojects {
   // Make sure clean task for rootProject runs last

http://git-wip-us.apache.org/repos/asf/geode/blob/588c3ed8/gradle.properties
----------------------------------------------------------------------
diff --git a/gradle.properties b/gradle.properties
index ca79a38..9462295 100755
--- a/gradle.properties
+++ b/gradle.properties
@@ -49,3 +49,10 @@ buildRoot=
 
 # We want signing to be on by default. Signing requires GPG to be set up.
 nexusSignArchives = true
+
+# Control how many concurrent dunit (using docker) tests will be run
+dunitParallelForks = 8
+# This is the name of the Docker image for running parallel dunits
+dunitDockerImage = openjdk:8
+# Docker user for parallel dunit tests
+dunitDockerUser = root

http://git-wip-us.apache.org/repos/asf/geode/blob/588c3ed8/gradle/docker.gradle
----------------------------------------------------------------------
diff --git a/gradle/docker.gradle b/gradle/docker.gradle
new file mode 100644
index 0000000..7a74c5d
--- /dev/null
+++ b/gradle/docker.gradle
@@ -0,0 +1,83 @@
+/*
+ * Configuration for running (dunit) tests in parallel in Docker containers.
+ * The container used must hava JAVA_HOME set in it's environment and must
+ * have 'java' defined on the path. For example, the relevant Dockerfile
+ * content could be:
+ * 
+ *   ENV JAVA_HOME=/opt/jdk1.8.0_u101
+ *   ENV PATH=$PATH:$JAVA_HOME/bin
+ *
+ * In addition, the container must have docker installed.
+ *
+ * The plugin can be activated with the Gradle property 'parallelDunit'.
+ * Additional properties that can be set are:
+ *
+ *  dunitDockerImage   - The docker image used for running parallel dunits. The
+ *                       default image is 'openjdk:8'. The image is required to
+ *                       have 'JAVA_HOME' set as an environment variable.
+ *  dunitParallelForks - The number of parallel containers that will be
+ *                       launched. The default is 8.
+ *  dunitDockerUser    - The user used within the docker container to run tests.
+ *                       The default is 'root'.
+ */
+
+def dockerConfig = {
+  maxParallelForks = dunitParallelForks.toInteger()
+
+  docker {
+    // base image for creating docker containers that execute the tests
+    image = dunitDockerImage
+
+    // volumes mounted to the containers
+    // in a form: host_dir : container_dir
+    def pwd = System.getenv('PWD')
+    def gradleHome = System.getenv('GRADLE_USER_HOME') ?: "${System.getenv('HOME')}/.gradle"
+    volumes = ["${gradleHome}":gradleHome]
+
+    volumes << ["${pwd}":pwd]
+
+    // specify the user for starting Gradle test worker within the container.
+    user = dunitDockerUser
+
+    argsInspect = { List args ->
+      def javaHomeIdx = 0
+      def i = args.iterator()
+      def j = 0
+      while (i.hasNext()) {
+        if (i.next() == '-e') {
+          def x = i.next()
+          j++
+          if (x.startsWith('JAVA_HOME')) {
+            javaHomeIdx = j
+          }
+        }
+        j++
+      }
+
+      // Remove JAVA_HOME env variable - it might not be the same as the container needs
+      if (javaHomeIdx > 0) {
+        args.removeAt(javaHomeIdx-1)
+        args.removeAt(javaHomeIdx-1)
+      }
+
+      // Infer the index of this invocation
+      def matcher = (args[args.size - 1] =~ /.*Executor (\d*).*/)
+
+      args[3] = args[3] + matcher[0][1]
+      def workdir = new File(args[3])
+      println "dockerize: making ${workdir}"
+      workdir.mkdirs()
+      // println args
+
+      args
+    }
+  }
+}
+
+subprojects {
+  apply plugin: 'com.github.pedjak.dockerized-test'
+
+  if (project.hasProperty('parallelDunit')) {
+    distributedTest.configure(dockerConfig)
+  }
+}


Mime
View raw message