Testclusters: convert left-overs from checkPart1 (#43370)

* Testclusters: convert left-overs from checkPart1
This commit is contained in:
Alpar Torok 2019-06-25 18:46:52 +03:00 committed by GitHub
parent 2a8cb74435
commit 05560c77bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 64 additions and 48 deletions

View file

@ -217,12 +217,20 @@ public class ElasticsearchCluster implements TestClusterConfiguration {
@Override @Override
public void start() { public void start() {
String nodeNames = nodes.stream().map(ElasticsearchNode::getName).collect(Collectors.joining(",")); final String nodeNames;
if (nodes.stream().map(ElasticsearchNode::getName).anyMatch( name -> name == null)) {
nodeNames = null;
} else {
nodeNames = nodes.stream().map(ElasticsearchNode::getName).collect(Collectors.joining(","));
};
for (ElasticsearchNode node : nodes) { for (ElasticsearchNode node : nodes) {
if (nodeNames != null) {
// Can only configure master nodes if we have node names defined
if (Version.fromString(node.getVersion()).getMajor() >= 7) { if (Version.fromString(node.getVersion()).getMajor() >= 7) {
node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]"); node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]");
node.defaultConfig.put("discovery.seed_providers", "file"); node.defaultConfig.put("discovery.seed_providers", "file");
} }
}
node.start(); node.start();
} }
} }

View file

@ -732,7 +732,10 @@ public class ElasticsearchNode implements TestClusterConfiguration {
} }
private void createConfiguration() { private void createConfiguration() {
defaultConfig.put("node.name", nameCustomization.apply(safeName(name))); String nodeName = nameCustomization.apply(safeName(name));
if (nodeName != null) {
defaultConfig.put("node.name", nodeName);
}
defaultConfig.put("path.repo", confPathRepo.toAbsolutePath().toString()); defaultConfig.put("path.repo", confPathRepo.toAbsolutePath().toString());
defaultConfig.put("path.data", confPathData.toAbsolutePath().toString()); defaultConfig.put("path.data", confPathData.toAbsolutePath().toString());
defaultConfig.put("path.logs", confPathLogs.toAbsolutePath().toString()); defaultConfig.put("path.logs", confPathLogs.toAbsolutePath().toString());

View file

@ -1,26 +1,21 @@
import org.elasticsearch.gradle.test.RestIntegTestTask import org.elasticsearch.gradle.test.RestIntegTestTask
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
subprojects { Project subproj -> subprojects { Project subproj ->
subproj.tasks.withType(RestIntegTestTask) { subproj.tasks.withType(RestIntegTestTask) {
if (subproj.extensions.findByName("${it.name}Cluster")) {
subproj.extensions.configure("${it.name}Cluster") { cluster -> subproj.extensions.configure("${it.name}Cluster") { cluster ->
cluster.distribution = System.getProperty('tests.distribution', 'oss') cluster.distribution = System.getProperty('tests.distribution', 'oss')
if (cluster.distribution == 'default') {
/*
* Add Elastic's repositories so we can resolve older versions of the
* default distribution. Those aren't in maven central.
*/
repositories {
maven {
name "elastic"
url "https://artifacts.elastic.co/maven"
}
maven {
name "elastic-snapshots"
url "https://snapshots.elastic.co/maven"
}
} }
} }
} }
plugins.withType(TestClustersPlugin).whenPluginAdded {
afterEvaluate {
// We need to delay this so it's not overwritten in RestIntegTestTask
testClusters.all {
distribution = System.getProperty('tests.distribution', 'oss').toUpperCase()
}
}
} }
} }

View file

@ -17,22 +17,22 @@
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
apply plugin: 'elasticsearch.standalone-test' apply plugin: 'elasticsearch.standalone-test'
integTestCluster { testClusters.integTest {
/** /**
* Provide a custom log4j configuration where layout is an old style pattern and confirm that Elasticsearch * Provide a custom log4j configuration where layout is an old style pattern and confirm that Elasticsearch
* can successfully startup. * can successfully startup.
*/ */
extraConfigFile 'log4j2.properties', 'custom-log4j2.properties' extraConfigFile 'log4j2.properties', file('custom-log4j2.properties')
} }
integTestRunner { integTest.runner {
nonInputProperties.systemProperty 'tests.logfile', nonInputProperties.systemProperty 'tests.logfile',
"${ -> integTest.nodes[0].homeDir}/logs/${ -> integTest.nodes[0].clusterName }_server.log" "${ -> testClusters.integTest.singleNode().getServerLog().absolutePath.replaceAll(".json", ".log")}"
} }
test { test {

View file

@ -40,7 +40,7 @@ import java.util.List;
* The intention is to confirm that users can still run their Elasticsearch instances with previous configurations. * The intention is to confirm that users can still run their Elasticsearch instances with previous configurations.
*/ */
public class CustomLoggingConfigIT extends ESRestTestCase { public class CustomLoggingConfigIT extends ESRestTestCase {
private static final String NODE_STARTED = ".*node-0.*cluster.uuid.*node.id.*recovered.*cluster_state.*"; private static final String NODE_STARTED = ".*integTest-0.*cluster.uuid.*node.id.*recovered.*cluster_state.*";
public void testSuccessfulStartupWithCustomConfig() throws Exception { public void testSuccessfulStartupWithCustomConfig() throws Exception {
assertBusy(() -> { assertBusy(() -> {

View file

@ -17,6 +17,7 @@
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
@ -24,6 +25,6 @@ dependencies {
testCompile project(path: ':modules:ingest-common', configuration: 'runtime') testCompile project(path: ':modules:ingest-common', configuration: 'runtime')
} }
integTestCluster { testClusters.integTest {
setting 'node.ingest', 'false' setting 'node.ingest', 'false'
} }

View file

@ -17,6 +17,7 @@
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
@ -24,12 +25,18 @@ integTest {
includePackaged = true includePackaged = true
} }
integTestCluster { File repo = file("$buildDir/testclusters/repo")
numNodes = 2 testClusters.integTest {
numberOfNodes = 2
setting 'path.repo', repo.absolutePath
} }
integTestRunner { integTest.runner {
if ('default'.equals(integTestCluster.distribution)) { doFirst {
project.delete(repo)
repo.mkdirs()
}
if ('default'.equalsIgnoreCase(System.getProperty('tests.distribution', 'oss'))) {
systemProperty 'tests.rest.blacklist', [ systemProperty 'tests.rest.blacklist', [
'cat.templates/10_basic/No templates', 'cat.templates/10_basic/No templates',
'cat.templates/10_basic/Sort templates', 'cat.templates/10_basic/Sort templates',

View file

@ -19,16 +19,19 @@
import org.elasticsearch.gradle.MavenFilteringHack import org.elasticsearch.gradle.MavenFilteringHack
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
ext.pluginsCount = 0 int pluginsCount = 0
testClusters.integTest {
project(':plugins').getChildProjects().each { pluginName, pluginProject -> project(':plugins').getChildProjects().each { pluginName, pluginProject ->
integTestCluster { plugin file(pluginProject.tasks.bundlePlugin.archiveFile)
plugin pluginProject.path tasks.integTest.dependsOn pluginProject.tasks.bundlePlugin
}
pluginsCount += 1 pluginsCount += 1
} }
}
assert pluginsCount > 0 assert pluginsCount > 0
ext.expansions = [ ext.expansions = [

View file

@ -17,18 +17,15 @@
* under the License. * under the License.
*/ */
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test' apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
integTestCluster { testClusters.integTest {
setting 'node.name', null nameCustomization = { null }
// Run with no discovery configuration at all, demonstrating that a node in its
// "out-of-the-box" configuration can automatically bootstrap a cluster
autoSetInitialMasterNodes = false
autoSetHostsProvider = false
} }
integTestRunner { integTest.runner {
nonInputProperties.systemProperty 'tests.logfile', nonInputProperties.systemProperty 'tests.logfile',
"${ -> integTest.nodes[0].homeDir}/logs/${ -> integTest.nodes[0].clusterName }_server.json" "${ -> testClusters.integTest.singleNode().getServerLog() }"
} }

View file

@ -26,6 +26,7 @@ import java.util.stream.Stream
*/ */
apply plugin: 'war' apply plugin: 'war'
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.build' apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.rest-test' apply plugin: 'elasticsearch.rest-test'
@ -88,12 +89,13 @@ task deploy(type: Copy) {
task writeElasticsearchProperties { task writeElasticsearchProperties {
onlyIf { !Os.isFamily(Os.FAMILY_WINDOWS) } onlyIf { !Os.isFamily(Os.FAMILY_WINDOWS) }
dependsOn 'integTestCluster#wait', deploy useCluster testClusters.integTest
dependsOn deploy
doLast { doLast {
final File elasticsearchProperties = file("${wildflyInstall}/standalone/configuration/elasticsearch.properties") final File elasticsearchProperties = file("${wildflyInstall}/standalone/configuration/elasticsearch.properties")
elasticsearchProperties.write( elasticsearchProperties.write(
[ [
"http.uri=${-> integTest.getNodes().get(0).httpUri()}" "http.uri=${-> testClusters.integTest.getAllHttpSocketURI().get(0)}"
].join("\n")) ].join("\n"))
} }
} }