blob: 90144a22216c95d23c6bbca4001ac4d53f8e45ac [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Configuration for running multi-process tests in parallel. See the 'multiProcessTestTasks'
* variable for the list of multi-process test tasks.
*
* To run multi-process tests in Docker, set the Gradle property 'parallelDunit'.
* The container used must have JAVA_HOME set in its 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.
*
* Additional configuration properties for running multi-process tests in Docker are:
*
* dunitDockerImage - The docker image used for running parallel dunits. The default image is
* 'bellsoft/liberica-openjdk-debian:8'. The image is required to have
* 'JAVA_HOME' set as an environment variable.
* dunitDockerUser - The user used within the docker container to run tests.
* The default is 'root'.
* dunitDockerVolumes - Docker volumes to mount in the docker container in addition to the ones
* mounted by the plugin. The plugin always mounts the directory of the
* top-level Geode project and the current user's Gradle home directory.
* dunitDockerJVM - The JVM to use to launch test worker processes inside Docker. The default
* is the value of the testJVM property if that property is set.
*
* The following properties apply to multi-process tests, whether running in Docker or not:
*
* --max-workers The maximum number of workers processes for Gradle to run in parallel.
* (Note that Gradle applies this value to all tasks, not just test tasks.)
*
* testMaxParallelForks The maximum number of tests for each multi-process test task to process in
* parallel. If 'parallelDunit' us defined, `testMaxParallelForks` defaults to
* 1/4 of the machine's available processors. If 'parallelDunit' is not
* defined, the default 'testMaxParallelForks' is 1. (Note that test.gradle
* also applies this property to unit test tasks, with different defaults.)
*/
import org.apache.geode.gradle.testing.Executers
import org.apache.geode.gradle.testing.isolation.WorkingDirectoryIsolator
def multiProcessTestTasks = [acceptanceTest, repeatAcceptanceTest,
distributedTest, repeatDistributedTest,
integrationTest, repeatIntegrationTest,
upgradeTest, repeatUpgradeTest,
uiTest, repeatUnitTest]
if (project.hasProperty('parallelDunit')) {
def parallelForks = project.hasProperty('testMaxParallelForks')
? Integer.parseUnsignedInt(project.testMaxParallelForks)
: Runtime.runtime.availableProcessors().intdiv(4) ?: 1
for (task in multiProcessTestTasks) {
task.maxParallelForks = parallelForks
}
apply plugin: 'geode-dockerized-test'
} else {
for (task in multiProcessTestTasks) {
if (project.hasProperty('testMaxParallelForks')) {
task.maxParallelForks = Integer.parseUnsignedInt(project.testMaxParallelForks)
}
task.doFirst {
testExecuter = Executers.withAdjustment(it, new WorkingDirectoryIsolator())
}
}
}