| // 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. |
| |
| // This file contains common tasks and configuration for unit and integration tests. |
| |
| // Support parallel unit test execution. |
| test { |
| maxParallelForks = propertyWithDefault("maxParallelForks", "1").toInteger() |
| } |
| |
| 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" |
| // Hide the Java 9+ warnings about illegal reflective access |
| if (JavaVersion.current().isJava9Compatible()) { |
| jvmArgs += "--illegal-access=permit" |
| def reflectionModules = [ |
| "java.base/java.lang", // java.lang reflection is used by TestUtils |
| "java.base/java.net", // java.net reflection is used by FakeDNS |
| "java.base/java.nio", // java.nio reflection is used by Protobuf |
| "java.base/java.util", // java.util reflection is used by Spark |
| "java.base/java.util.concurrent", // java.util.concurrent reflection is used by Spark |
| "java.base/sun.nio.ch", // sun.nio.ch reflection is used by Netty |
| "java.security.jgss/sun.security.krb5" // sun.security.krb5 reflection is used by Hadoop's KerberosUtil |
| ] |
| reflectionModules.forEach { module -> |
| jvmArgs += "--add-opens=$module=ALL-UNNAMED" |
| } |
| } |
| |
| // 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. |
| |
| // Set rerunFailingTestsCount for use in BaseKuduTest.java to rerun failing tests. |
| systemProperty "rerunFailingTestsCount", propertyWithDefault("rerunFailingTestsCount", 0) |
| |
| // Set kuduBinDir to the binaries to use with the MiniKuduCluster. |
| systemProperty "kuduBinDir", "$project.rootDir/../build/latest/bin" |
| |
| // 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 |
| } |
| |
| // Force the tests to be rerun if the rerunTests property is set. |
| if (propertyExists("rerunTests")) { |
| outputs.upToDateWhen { false } |
| } |
| } |