Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/geoshape-doc-values' into tl-d…
Browse files Browse the repository at this point in the history
…v-geoshape
  • Loading branch information
talevy committed May 1, 2019
2 parents e615a1c + fc02668 commit cf57f71
Show file tree
Hide file tree
Showing 1,701 changed files with 37,147 additions and 20,278 deletions.
2 changes: 1 addition & 1 deletion TESTING.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ password: `elastic-password`.
==== Other useful arguments

In order to start a node with a different max heap space add: `-Dtests.heap.size=4G`
In order to disable annotations add: `-Dtests.asserts=false`
In order to disable assertions add: `-Dtests.asserts=false`
In order to set an Elasticsearch setting, provide a setting with the following prefix: `-Dtests.es.`

=== Test case filtering.
Expand Down
14 changes: 8 additions & 6 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ Vagrant.configure(2) do |config|
SHELL
end
end
# Wheezy's backports don't contain Openjdk 8 and the backflips
# required to get the sun jdk on there just aren't worth it. We have
# jessie and stretch for testing debian and it works fine.
'debian-8'.tap do |box|
config.vm.define box, define_opts do |config|
config.vm.box = 'elastic/debian-8-x86_64'
Expand Down Expand Up @@ -247,7 +244,7 @@ def linux_common(config,
SHELL

config.vm.provision 'jdk-11', type: 'shell', inline: <<-SHELL
curl -sSL https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz | tar xz -C /opt/
curl -sSL https://download.oracle.com/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz | tar xz -C /opt/
SHELL

# This prevents leftovers from previous tests using the
Expand Down Expand Up @@ -406,11 +403,16 @@ def windows_common(config, name)
$ps_prompt | Out-File $PsHome/Microsoft.PowerShell_profile.ps1
SHELL

config.vm.provision 'windows-jdk-11', type: 'shell', inline: <<-SHELL
New-Item -ItemType Directory -Force -Path "C:/java"
Invoke-WebRequest "https://download.oracle.com/java/GA/jdk11/9/GPL/openjdk-11.0.2_windows-x64_bin.zip" -OutFile "C:/java/jdk-11.zip"
Expand-Archive -Path "C:/java/jdk-11.zip" -DestinationPath "C:/java/"
SHELL

config.vm.provision 'set env variables', type: 'shell', inline: <<-SHELL
$ErrorActionPreference = "Stop"
[Environment]::SetEnvironmentVariable("PACKAGING_ARCHIVES", "C:/project/build/packaging/archives", "Machine")
$javaHome = [Environment]::GetEnvironmentVariable("JAVA_HOME", "Machine")
[Environment]::SetEnvironmentVariable("SYSTEM_JAVA_HOME", $javaHome, "Machine")
[Environment]::SetEnvironmentVariable("SYSTEM_JAVA_HOME", "C:\java\jdk-11.0.2", "Machine")
[Environment]::SetEnvironmentVariable("PACKAGING_TESTS", "C:/project/build/packaging/tests", "Machine")
[Environment]::SetEnvironmentVariable("JAVA_HOME", $null, "Machine")
SHELL
Expand Down
40 changes: 38 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,30 @@ allprojects {
configurations.findAll { it.isCanBeResolved() }.each { it.resolve() }
}
}
}

allprojects {
// helper task to print direct dependencies of a single task
project.tasks.addRule("Pattern: <taskName>Dependencies") { String taskName ->
if (taskName.endsWith("Dependencies") == false) {
return
}
if (project.tasks.findByName(taskName) != null) {
return
}
String realTaskName = taskName.substring(0, taskName.length() - "Dependencies".length())
Task realTask = project.tasks.findByName(realTaskName)
if (realTask == null) {
return
}
project.tasks.create(taskName) {
doLast {
println("${realTask.path} dependencies:")
for (Task dep : realTask.getTaskDependencies().getDependencies(realTask)) {
println(" - ${dep.path}")
}
}
}
}

task checkPart1
task checkPart2
tasks.matching { it.name == "check" }.all { check ->
Expand All @@ -598,6 +619,21 @@ allprojects {
}
}

subprojects {
// Common config when running with a FIPS-140 runtime JVM
if (project.ext.has("inFipsJvm") && project.ext.inFipsJvm) {
tasks.withType(Test) {
systemProperty 'javax.net.ssl.trustStorePassword', 'password'
systemProperty 'javax.net.ssl.keyStorePassword', 'password'
}
project.pluginManager.withPlugin("elasticsearch.testclusters") {
project.testClusters.all {
systemProperty 'javax.net.ssl.trustStorePassword', 'password'
systemProperty 'javax.net.ssl.keyStorePassword', 'password'
}
}
}
}



19 changes: 3 additions & 16 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ sourceSets {
}
}
compileMinimumRuntimeGroovy {
// We can't use BuildPlugin here, so read from file
String minimumRuntimeVersion = file('src/main/resources/minimumRuntimeVersion').text.trim()
targetCompatibility = minimumRuntimeVersion
sourceCompatibility = minimumRuntimeVersion
targetCompatibility = 8
sourceCompatibility = 8
}
dependencies {
if (project.ext.has("isEclipse") == false || project.ext.isEclipse == false) {
Expand All @@ -113,8 +111,6 @@ repositories {

dependencies {
compile localGroovy()
compile "com.carrotsearch.randomizedtesting:junit4-ant:${props.getProperty('randomizedrunner')}"
compile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"

compile 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
compile 'com.netflix.nebula:nebula-publishing-plugin:4.4.4'
Expand All @@ -127,16 +123,7 @@ dependencies {
compile 'de.thetaphi:forbiddenapis:2.6'
compile 'com.avast.gradle:gradle-docker-compose-plugin:0.8.12'
testCompile "junit:junit:${props.getProperty('junit')}"
}


// Gradle 2.14+ removed ProgressLogger(-Factory) classes from the public APIs
// Use logging dependency instead
// Gradle 4.3.1 stopped releasing the logging jars to jcenter, just use the last available one
GradleVersion logVersion = GradleVersion.current() > GradleVersion.version('4.3') ? GradleVersion.version('4.3') : GradleVersion.current()

dependencies {
compileOnly "org.gradle:gradle-logging:${logVersion.getVersion()}"
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${props.getProperty('randomizedrunner')}"
}

/*****************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ import org.gradle.util.GradleVersion
import java.nio.charset.StandardCharsets
import java.time.ZoneOffset
import java.time.ZonedDateTime
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.Future
import java.util.regex.Matcher

/**
Expand Down Expand Up @@ -127,13 +130,6 @@ class BuildPlugin implements Plugin<Project> {
String runtimeJavaHome = findRuntimeJavaHome(compilerJavaHome)
File gradleJavaHome = Jvm.current().javaHome

final Map<Integer, String> javaVersions = [:]
for (int version = 8; version <= Integer.parseInt(minimumCompilerVersion.majorVersion); version++) {
if(System.getenv(getJavaHomeEnvVarName(version.toString())) != null) {
javaVersions.put(version, findJavaHome(version.toString()));
}
}

String javaVendor = System.getProperty('java.vendor')
String gradleJavaVersion = System.getProperty('java.version')
String gradleJavaVersionDetails = "${javaVendor} ${gradleJavaVersion}" +
Expand All @@ -153,8 +149,12 @@ class BuildPlugin implements Plugin<Project> {
runtimeJavaVersionEnum = JavaVersion.toVersion(findJavaSpecificationVersion(project, runtimeJavaHome))
}

String inFipsJvmScript = 'print(java.security.Security.getProviders()[0].name.toLowerCase().contains("fips"));'
boolean inFipsJvm = Boolean.parseBoolean(runJavaAsScript(project, runtimeJavaHome, inFipsJvmScript))
boolean inFipsJvm = false
if (new File(runtimeJavaHome).canonicalPath != gradleJavaHome.canonicalPath) {
// We don't expect Gradle to be running in a FIPS JVM
String inFipsJvmScript = 'print(java.security.Security.getProviders()[0].name.toLowerCase().contains("fips"));'
inFipsJvm = Boolean.parseBoolean(runJavaAsScript(project, runtimeJavaHome, inFipsJvmScript))
}

// Build debugging info
println '======================================='
Expand Down Expand Up @@ -190,24 +190,49 @@ class BuildPlugin implements Plugin<Project> {
throw new GradleException(message)
}

for (final Map.Entry<Integer, String> javaVersionEntry : javaVersions.entrySet()) {
final String javaHome = javaVersionEntry.getValue()
if (javaHome == null) {
continue
final Map<Integer, String> javaVersions = [:]
for (int version = 8; version <= Integer.parseInt(minimumCompilerVersion.majorVersion); version++) {
if(System.getenv(getJavaHomeEnvVarName(version.toString())) != null) {
javaVersions.put(version, findJavaHome(version.toString()));
}
JavaVersion javaVersionEnum = JavaVersion.toVersion(findJavaSpecificationVersion(project, javaHome))
final JavaVersion expectedJavaVersionEnum
final int version = javaVersionEntry.getKey()
if (version < 9) {
expectedJavaVersionEnum = JavaVersion.toVersion("1." + version)
} else {
expectedJavaVersionEnum = JavaVersion.toVersion(Integer.toString(version))
}

final int numberOfPhysicalCores = numberOfPhysicalCores(project.rootProject)
if (javaVersions.isEmpty() == false) {

ExecutorService exec = Executors.newFixedThreadPool(numberOfPhysicalCores)
Set<Future<Void>> results = new HashSet<>()

javaVersions.entrySet().stream()
.filter { it.getValue() != null }
.forEach { javaVersionEntry ->
results.add(exec.submit {
final String javaHome = javaVersionEntry.getValue()
final int version = javaVersionEntry.getKey()
if (project.file(javaHome).exists() == false) {
throw new GradleException("Invalid JAVA${version}_HOME=${javaHome} location does not exist")
}

JavaVersion javaVersionEnum = JavaVersion.toVersion(findJavaSpecificationVersion(project, javaHome))
final JavaVersion expectedJavaVersionEnum = version < 9 ?
JavaVersion.toVersion("1." + version) :
JavaVersion.toVersion(Integer.toString(version))

if (javaVersionEnum != expectedJavaVersionEnum) {
final String message =
"the environment variable JAVA" + version + "_HOME must be set to a JDK installation directory for Java" +
" ${expectedJavaVersionEnum} but is [${javaHome}] corresponding to [${javaVersionEnum}]"
throw new GradleException(message)
}
})
}
if (javaVersionEnum != expectedJavaVersionEnum) {
final String message =
"the environment variable JAVA" + version + "_HOME must be set to a JDK installation directory for Java" +
" ${expectedJavaVersionEnum} but is [${javaHome}] corresponding to [${javaVersionEnum}]"
throw new GradleException(message)

project.gradle.taskGraph.whenReady {
try {
results.forEach { it.get() }
} finally {
exec.shutdown();
}
}
}

Expand All @@ -223,7 +248,7 @@ class BuildPlugin implements Plugin<Project> {
project.rootProject.ext.inFipsJvm = inFipsJvm
project.rootProject.ext.gradleJavaVersion = JavaVersion.toVersion(gradleJavaVersion)
project.rootProject.ext.java9Home = "${-> findJavaHome("9")}"
project.rootProject.ext.defaultParallel = findDefaultParallel(project.rootProject)
project.rootProject.ext.defaultParallel = numberOfPhysicalCores
}

project.targetCompatibility = project.rootProject.ext.minimumRuntimeVersion
Expand Down Expand Up @@ -972,12 +997,6 @@ class BuildPlugin implements Plugin<Project> {
// TODO: remove this once ctx isn't added to update script params in 7.0
systemProperty 'es.scripting.update.ctx_in_params', 'false'

// Set the system keystore/truststore password if we're running tests in a FIPS-140 JVM
if (project.inFipsJvm) {
systemProperty 'javax.net.ssl.trustStorePassword', 'password'
systemProperty 'javax.net.ssl.keyStorePassword', 'password'
}

testLogging {
showExceptions = true
showCauses = true
Expand All @@ -995,7 +1014,7 @@ class BuildPlugin implements Plugin<Project> {
}
}

private static int findDefaultParallel(Project project) {
private static int numberOfPhysicalCores(Project project) {
if (project.file("/proc/cpuinfo").exists()) {
// Count physical cores on any Linux distro ( don't count hyper-threading )
Map<String, Integer> socketToCore = [:]
Expand All @@ -1008,7 +1027,7 @@ class BuildPlugin implements Plugin<Project> {
if (name == "physical id") {
currentID = value
}
// Number of cores not including hyper-threading
// number of cores not including hyper-threading
if (name == "cpu cores") {
assert currentID.isEmpty() == false
socketToCore[currentID] = Integer.valueOf(value)
Expand All @@ -1026,8 +1045,11 @@ class BuildPlugin implements Plugin<Project> {
standardOutput = stdout
}
return Integer.parseInt(stdout.toString('UTF-8').trim())
} else {
// guess that it is half the number of processors (which is wrong on systems that do not have simultaneous multi-threading)
// TODO: implement this on Windows
return Runtime.getRuntime().availableProcessors() / 2
}
return Runtime.getRuntime().availableProcessors() / 2
}

private static configurePrecommit(Project project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class PluginBuildPlugin extends BuildPlugin {
project.extensions.getByType(PluginPropertiesExtension).extendedPlugins.each { pluginName ->
// Auto add dependent modules to the test cluster
if (project.findProject(":modules:${pluginName}") != null) {
project.integTest.dependsOn(project.project(":modules:${pluginName}").tasks.bundlePlugin)
project.testClusters.integTest.module(
project.file(project.project(":modules:${pluginName}").tasks.bundlePlugin.archiveFile)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ class RestIntegTestTask extends DefaultTask {
if (usesTestclusters == true) {
ElasticsearchCluster cluster = project.testClusters."${name}"
nonInputProperties.systemProperty('tests.rest.cluster', "${-> cluster.allHttpSocketURI.join(",") }")
nonInputProperties.systemProperty('tests.config.dir', "${-> cluster.singleNode().getConfigDir() }")
nonInputProperties.systemProperty('tests.cluster', "${-> cluster.transportPortURI }")
} else {
// we pass all nodes to the rest cluster to allow the clients to round-robin between them
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,15 @@ class VagrantTestPlugin implements Plugin<Project> {
} else {
UPGRADE_FROM_ARCHIVES.each {
// The version of elasticsearch that we upgrade *from*
dependencies.add("downloads.${it}:elasticsearch:${upgradeFromVersion}@${it}")
if (upgradeFromVersion.onOrAfter('6.3.0')) {
dependencies.add("downloads.${it}:elasticsearch-oss:${upgradeFromVersion}@${it}")
if (upgradeFromVersion.onOrAfter('7.0.0')) {
String arch = it == "rpm" ? "x86_64" : "amd64"
dependencies.add("downloads.${it}:elasticsearch:${upgradeFromVersion}-${arch}@${it}")
dependencies.add("downloads.${it}:elasticsearch-oss:${upgradeFromVersion}-${arch}@${it}")
} else {
dependencies.add("downloads.${it}:elasticsearch:${upgradeFromVersion}@${it}")
if (upgradeFromVersion.onOrAfter('6.3.0')) {
dependencies.add("downloads.${it}:elasticsearch-oss:${upgradeFromVersion}@${it}")
}
}
}
}
Expand Down Expand Up @@ -294,7 +300,7 @@ class VagrantTestPlugin implements Plugin<Project> {
} else {
\$testArgs = \$args
}
"\$Env:SYSTEM_JAVA_HOME"/bin/java -cp "\$Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
& "\$Env:SYSTEM_JAVA_HOME"/bin/java -cp "\$Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
exit \$LASTEXITCODE
"""
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.elasticsearch.gradle;

import java.io.File;
import java.util.function.Supplier;

public interface FileSupplier extends Supplier<File> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class ForbiddenPatternsTask extends DefaultTask {
.exclude("**/*.zip")
.exclude("**/*.jks")
.exclude("**/*.crt")
.exclude("**/*.keystore")
.exclude("**/*.png");

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class TestingConventionsTasks extends DefaultTask {
public TestingConventionsTasks() {
setDescription("Tests various testing conventions");
// Run only after everything is compiled
Boilerplate.getJavaSourceSets(getProject()).all(sourceSet -> dependsOn(sourceSet.getClassesTaskName()));
Boilerplate.getJavaSourceSets(getProject()).all(sourceSet -> dependsOn(sourceSet.getOutput().getClassesDirs()));
naming = getProject().container(TestingConventionRule.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.elasticsearch.GradleServicesAdapter;
import org.elasticsearch.gradle.Distribution;
import org.elasticsearch.gradle.FileSupplier;
import org.elasticsearch.gradle.Version;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.Project;
Expand Down Expand Up @@ -143,6 +144,16 @@ public void keystore(String key, Supplier<CharSequence> valueSupplier) {
nodes.all(each -> each.keystore(key, valueSupplier));
}

@Override
public void keystore(String key, File value) {
nodes.all(each -> each.keystore(key, value));
}

@Override
public void keystore(String key, FileSupplier valueSupplier) {
nodes.all(each -> each.keystore(key, valueSupplier));
}

@Override
public void setting(String key, String value) {
nodes.all(each -> each.setting(key, value));
Expand Down
Loading

0 comments on commit cf57f71

Please sign in to comment.