Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test clusters ( was clusterformation ) - part 3 #33264

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4b532c0
Implement Version in java
alpar-t Jul 12, 2018
506dfc8
Merge remote-tracking branch 'origin/master' into fix/30904-cluster-f…
alpar-t Jul 13, 2018
952af44
PR review comments
alpar-t Jul 13, 2018
cddb550
Cluster formation plugin with reference counting
alpar-t Jun 11, 2018
dfc38a1
Fix rebase
alpar-t Jul 13, 2018
b01ed0e
Merge remote-tracking branch 'origin/master' into fix/30904-cluster-f…
alpar-t Jul 16, 2018
7ac5b7c
Merge branch 'master' into fix/30904-cluster-formation-part2
alpar-t Aug 6, 2018
f2fb450
Change to `useCluster` method on task
alpar-t Aug 15, 2018
2d0e478
remove task extension
alpar-t Aug 16, 2018
938ef53
address PR
alpar-t Aug 17, 2018
a611747
Listener in anonymous class
alpar-t Aug 21, 2018
5483186
Merge remote-tracking branch 'origin/master' into fix/30904-cluster-f…
alpar-t Aug 22, 2018
121e025
Cluster formation plugin with reference counting
alpar-t Aug 23, 2018
9baed19
Stage cluster formation artifacts
alpar-t Jun 27, 2018
8a4d21f
Add an explicit dependency between tests of different versions
alpar-t May 23, 2018
da69766
Gradle orders all celanups up-fron with --parallel
alpar-t Jul 3, 2018
ba4f4a9
Configure depenedencies based on configuration
alpar-t Jul 3, 2018
de87e74
Don't configure repos in the plugin
alpar-t Jul 3, 2018
2df0545
Use a thread pool to start the cluster
alpar-t Jul 3, 2018
6574f82
Non working attempt to start ES with threads and Gradle exec
alpar-t Jul 3, 2018
4d44141
Properly shutdown clusters when tasks fail
alpar-t Jul 4, 2018
df6a529
Working ProcessBuilder based implementation to start cluster
alpar-t Jul 4, 2018
d2a7810
Implement cluster configuration and wait for it to start
alpar-t Jul 5, 2018
2f03501
Lazy wait for ES
alpar-t Jul 6, 2018
ea381b1
Move build integration tests out of :buildSrc project
alpar-t Jul 6, 2018
64afbd0
Clean up docs and naming
alpar-t Jul 6, 2018
5ecae33
Fix up naming of node vs cluster
alpar-t Jul 6, 2018
fc877d5
Imrooove documentation, various fixes
alpar-t Jul 9, 2018
af9c74f
Add cleanup hooks to make sure no processes survive the build
alpar-t Jul 9, 2018
1ecb42f
Support closures as system props for testing
alpar-t Jul 9, 2018
cc66d2f
Integrate the new clusterformation with plugin builds
alpar-t Jul 9, 2018
6f7d46e
Add support for windows
alpar-t Jul 10, 2018
feac1f8
frix rebase
alpar-t Jul 13, 2018
28059d8
Merge branch 'fix/30904-cluster-formation-part2' into fix/30904-clust…
alpar-t Aug 23, 2018
a39b678
Fix blugin build
alpar-t Aug 23, 2018
594a9de
Rename to testClusters
alpar-t Aug 23, 2018
b6ead15
Merge remote-tracking branch 'origin/master' into fix/30904-cluster-f…
alpar-t Aug 24, 2018
f11fb2f
refactor plugin for better readability
alpar-t Aug 24, 2018
9bcf35f
refactor node and improove logging
alpar-t Aug 24, 2018
9f7352e
Close all child processes on stop
alpar-t Aug 27, 2018
bc8def8
Merge commit '214652d4af8' into fix/30904-cluster-formation-part3
alpar-t Aug 30, 2018
de13f67
Merge remote-tracking branch 'origin/master' into fix/30904-cluster-f…
alpar-t Aug 30, 2018
656b155
Rename from clusterformation
alpar-t Aug 30, 2018
6c87326
self review
alpar-t Aug 30, 2018
9ea7d92
Change runtime to 10
alpar-t Sep 3, 2018
9a98434
Merge remote-tracking branch 'origin/master' into fix/30904-cluster-f…
alpar-t Sep 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .ci/java-versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
# are 'java' or 'openjdk' followed by the major release number.

ES_BUILD_JAVA=java10
ES_RUNTIME_JAVA=java8
# FIXME: revert once CI is updated
ES_RUNTIME_JAVA=java10
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if (properties.get("org.elasticsearch.acceptScanTOS", "false") == "true") {
}

// common maven publishing configuration
subprojects {
allprojects {
group = 'org.elasticsearch'
version = VersionProperties.elasticsearch.toString()
description = "Elasticsearch subproject ${project.path}"
Expand All @@ -52,6 +52,8 @@ if (VersionProperties.elasticsearch.toString().endsWith('-SNAPSHOT')) {
}
String elasticLicenseUrl = "https://raw.githubusercontent.com/elastic/elasticsearch/${licenseCommit}/licenses/ELASTIC-LICENSE.txt"

BuildPlugin.configureRepositories(project)

subprojects {
// Default to the apache license
project.ext.licenseName = 'The Apache Software License, Version 2.0'
Expand Down Expand Up @@ -199,7 +201,7 @@ task branchConsistency {
dependsOn verifyVersions, verifyBwcTestsEnabled
}

subprojects {
allprojects {
// ignore missing javadocs
tasks.withType(Javadoc) { Javadoc javadoc ->
// the -quiet here is because of a bug in gradle, in that adding a string option
Expand Down Expand Up @@ -370,7 +372,7 @@ gradle.projectsEvaluated {
return
}
dependencies.all { Dependency dep ->
Project upstreamProject = dependencyToProject(dep)
Project upstreamProject = project.ext.dependencyToProject(dep)
if (upstreamProject != null) {
if (project.path == upstreamProject.path) {
// TODO: distribution integ tests depend on themselves (!), fix that
Expand Down
13 changes: 10 additions & 3 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/

import java.nio.file.Files
import org.gradle.util.GradleVersion

plugins {
id 'java-gradle-plugin'
Expand All @@ -31,8 +31,10 @@ if (GradleVersion.current() < GradleVersion.version(minimumGradleVersion)) {
throw new GradleException("Gradle ${minimumGradleVersion}+ is required to build elasticsearch")
}

if (JavaVersion.current() < JavaVersion.VERSION_1_8) {
throw new GradleException('Java 1.8 is required to build elasticsearch gradle tools')
// TODO this will not work in CI as of this writing
// take advantage of the new Process API in 9
if (JavaVersion.current() < JavaVersion.VERSION_1_9) {
throw new GradleException('Java 1.9 is required to build elasticsearch gradle tools')
}

if (project == rootProject) {
Expand Down Expand Up @@ -130,6 +132,7 @@ if (project == rootProject) {
}
mavenCentral()
}

test {
include "**/*Tests.class"
exclude "**/*IT.class"
Expand Down Expand Up @@ -182,6 +185,10 @@ if (project != rootProject) {
}
check.dependsOn(integTest)

// TODO needs to be updated in CI, needs update in NamingConventions
targetCompatibility = "1.9"
sourceCompatibility = "1.9"

// TODO: re-enable once randomizedtesting gradle code is published and removed from here
licenseHeaders.enabled = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,22 @@ import com.carrotsearch.ant.tasks.junit4.ListenersList
import com.carrotsearch.ant.tasks.junit4.listeners.AggregatedEventListener
import groovy.xml.NamespaceBuilder
import groovy.xml.NamespaceBuilderSupport
import org.apache.tools.ant.BuildException
import org.apache.tools.ant.DefaultLogger
import org.apache.tools.ant.Project
import org.apache.tools.ant.RuntimeConfigurable
import org.apache.tools.ant.UnknownElement
import org.elasticsearch.gradle.BuildPlugin
import org.gradle.api.DefaultTask
import org.gradle.api.InvalidUserDataException
import org.gradle.api.file.FileCollection
import org.gradle.api.file.FileTreeElement
import org.gradle.api.specs.Spec
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.options.Option
import org.gradle.api.tasks.util.PatternFilterable
import org.gradle.api.tasks.util.PatternSet
import org.gradle.internal.logging.progress.ProgressLoggerFactory
import org.gradle.tooling.BuildException
import org.gradle.util.ConfigureUtil

import javax.inject.Inject
Expand Down Expand Up @@ -264,7 +261,11 @@ class RandomizedTestingTask extends DefaultTask {
throw new InvalidUserDataException('Seed should be ' +
'set on the project instead of a system property')
}
sysproperty key: prop.getKey(), value: prop.getValue().toString()
if (prop.getValue() instanceof Closure) {
sysproperty key: prop.getKey(), value: (prop.getValue() as Closure).call().toString()
} else {
sysproperty key: prop.getKey(), value: prop.getValue().toString()
}
}
systemProperty 'tests.seed', project.testSeed
for (Map.Entry<String, Object> envvar : environmentVariables) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@
*/
package org.elasticsearch.gradle.plugin

import com.carrotsearch.gradle.junit4.RandomizedTestingTask
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import nebula.plugin.publishing.maven.MavenScmPlugin
import org.elasticsearch.gradle.BuildPlugin
import org.elasticsearch.gradle.Distribution
import org.elasticsearch.gradle.NoticeTask
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.testclusters.ElasticsearchNode
import org.elasticsearch.gradle.test.RestIntegTestTask
import org.elasticsearch.gradle.test.RunTask
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.Project
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
Expand All @@ -42,12 +48,24 @@ public class PluginBuildPlugin extends BuildPlugin {
@Override
public void apply(Project project) {
super.apply(project)
project.pluginManager.apply(TestClustersPlugin.class)
NamedDomainObjectContainer<ElasticsearchNode> nodeExtension =
TestClustersPlugin.getNodeExtension(project)
ElasticsearchNode esNode = nodeExtension.create("${project.getPath()}##node") {
// TODO: change this to INTEG_TEST_ZIP when we add support to install plugins
it.distribution = Distribution.ZIP
it.version = VersionProperties.elasticsearch
}

configureDependencies(project)
// this afterEvaluate must happen before the afterEvaluate added by integTest creation,
// so that the file name resolution for installing the plugin will be setup
createIntegTestTask(project, esNode)
createBundleTask(project)
project.configurations.getByName('default').extendsFrom(project.configurations.getByName('runtime'))
project.tasks.create('run', RunTask) // allow running ES with this plugin in the foreground of a build
project.afterEvaluate {
boolean isXPackModule = project.path.startsWith(':x-pack:plugin')
boolean isModule = project.path.startsWith(':modules:') || isXPackModule
boolean isModule = project.path.startsWith(':modules:') || project.path.startsWith(':x-pack:plugin')
String name = project.pluginProperties.extension.name
project.archivesBaseName = name

Expand All @@ -56,20 +74,17 @@ public class PluginBuildPlugin extends BuildPlugin {

configurePublishing(project)

project.integTestCluster.dependsOn(project.bundlePlugin)
project.tasks.run.dependsOn(project.bundlePlugin)
if (isModule) {
project.integTestCluster.module(project)
project.tasks.run.clusterConfig.module(project)
project.tasks.run.clusterConfig.distribution = System.getProperty(
'run.distribution', 'integ-test-zip'
)
} else {
project.integTestCluster.plugin(project.path)
project.tasks.run.clusterConfig.plugin(project.path)
}

if (isModule == false || isXPackModule) {
if (isModule == false || project.path.startsWith(':x-pack:plugin')) {
addNoticeGeneration(project)
}

Expand All @@ -78,10 +93,6 @@ public class PluginBuildPlugin extends BuildPlugin {
skipIntegTestInDisguise = true
}
}
createIntegTestTask(project)
createBundleTask(project)
project.configurations.getByName('default').extendsFrom(project.configurations.getByName('runtime'))
project.tasks.create('run', RunTask) // allow running ES with this plugin in the foreground of a build
}

private void configurePublishing(Project project) {
Expand Down Expand Up @@ -125,10 +136,33 @@ public class PluginBuildPlugin extends BuildPlugin {
}

/** Adds an integTest task which runs rest tests */
private static void createIntegTestTask(Project project) {
RestIntegTestTask integTest = project.tasks.create('integTest', RestIntegTestTask.class)
private static void createIntegTestTask(Project project, ElasticsearchNode esNode) {
final RestIntegTestTask integTest
if (System.hasProperty('enableTestClusters')) {
// emulate external cluster
System.properties.put("tests.rest.cluster", "future")
System.properties.put("tests.cluster", "future")
integTest = project.tasks.create('integTest', RestIntegTestTask.class)
RandomizedTestingTask runner = project.tasks.getByName('integTestRunner')
runner.configure {
useCluster esNode
systemProperty('tests.rest.cluster', {-> esNode.getHttpSocketURI()})
systemProperty('tests.config.dir', {-> esNode.getCopyOfConfDir()})
systemProperty('tests.cluster', {-> esNode.getTransportPortURI()})
}
} else {
integTest = project.tasks.create('integTest', RestIntegTestTask.class)
project.integTestCluster.distribution = System.getProperty('tests.distribution', 'integ-test-zip')
project.afterEvaluate {
project.integTestCluster.dependsOn(project.bundlePlugin)
if (project.path.startsWith(':modules:') || project.path.startsWith(':x-pack:plugin')) {
project.integTestCluster.module(project)
} else {
project.integTestCluster.plugin(project.path)
}
}
}
integTest.mustRunAfter(project.precommit, project.test)
project.integTestCluster.distribution = System.getProperty('tests.distribution', 'integ-test-zip')
project.check.dependsOn(integTest)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,10 @@ class ClusterFormationTasks {
* snapshots survive failures / test runs and there is no simple way
* today to fix that. */
if (config.cleanShared) {
Task cleanup = project.tasks.create(
name: "${prefix}#prepareCluster.cleanShared",
type: Delete,
dependsOn: startDependencies) {
delete sharedDir
doLast {
sharedDir.mkdirs()
}
}
startDependencies = cleanup
runner.doFirst {
project.delete(sharedDir)
sharedDir.mkdirs()
}
}
List<Task> startTasks = []
List<NodeInfo> nodes = []
Expand Down
24 changes: 10 additions & 14 deletions buildSrc/src/main/java/org/elasticsearch/GradleServicesAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,23 @@
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.file.CopySpec;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.FileTree;
import org.gradle.api.tasks.WorkResult;
import org.gradle.process.ExecResult;
import org.gradle.process.JavaExecSpec;

import java.io.File;

/**
* Facilitate access to Gradle services without a direct dependency on Project.
*
* In a future release Gradle will offer service injection, this adapter plays that role until that time.
/*
* In a future release Gradle will offer service injection, this is a temporary measure until that that time.
* It exposes the service methods that are part of the public API as the classes implementing them are not.
* Today service injection is <a href="https://github.com/gradle/gradle/issues/2363">not available</a> for
* extensions.
* plugins.
*
* Everything exposed here must be thread safe. That is the very reason why project is not passed in directly.
*/
public class GradleServicesAdapter {
private final Project project;

public final Project project;

public GradleServicesAdapter(Project project) {
private GradleServicesAdapter(Project project) {
this.project = project;
}

Expand All @@ -58,11 +53,12 @@ public WorkResult sync(Action<? super CopySpec> action) {
return project.sync(action);
}

public ExecResult javaexec(Action<? super JavaExecSpec> action) {
return project.javaexec(action);
}

public FileTree zipTree(File zipPath) {
return project.zipTree(zipPath);
}

public FileCollection fileTree(File dir) {
return project.fileTree(dir);
}
}
22 changes: 14 additions & 8 deletions buildSrc/src/main/java/org/elasticsearch/gradle/Distribution.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,23 @@

public enum Distribution {

INTEG_TEST("integ-test-zip"),
ZIP("zip"),
ZIP_OSS("zip-oss");
INTEG_TEST_ZIP("integ-test", "zip"),
ZIP("elasticsearch", "zip"),
ZIP_OSS("elasticsearch-oss", "zip");

private final String name;
private final String fileName;
private final String extension;

Distribution(String name) {
this.name = name;
Distribution(String fileName, String extension) {
this.fileName = fileName;
this.extension = extension;
}

public String getName() {
return name;
public String getFileName() {
return fileName;
}

public String getExtension() {
return extension;
}
}
Loading