Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,19 @@ public void setJavaHome(File javaHome) {

@Override
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) {
if (Version.fromString(node.getVersion()).getMajor() >= 7) {
node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]");
node.defaultConfig.put("discovery.seed_providers", "file");
if (nodeNames != null) {
// Can only configure master nodes if we have node names defined
if (Version.fromString(node.getVersion()).getMajor() >= 7) {
node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]");
node.defaultConfig.put("discovery.seed_providers", "file");
}
}
node.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,10 @@ private void syncWithLinks(Path sourceRoot, Path destinationRoot) {
}

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.data", confPathData.toAbsolutePath().toString());
defaultConfig.put("path.logs", confPathLogs.toAbsolutePath().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void testGetLicense() throws Exception {
//end::get-license-response

assertThat(currentLicense, containsString("trial"));
assertThat(currentLicense, containsString("client_rest-high-level_integTestCluster"));
assertThat(currentLicense, containsString("integTest"));
}
{
GetLicenseRequest request = new GetLicenseRequest();
Expand Down Expand Up @@ -233,7 +233,7 @@ public void onFailure(Exception e) {
String currentLicense = response.getLicenseDefinition();
assertThat(currentLicense, startsWith("{"));
assertThat(currentLicense, containsString("trial"));
assertThat(currentLicense, containsString("client_rest-high-level_integTestCluster"));
assertThat(currentLicense, containsString("integTest"));
assertThat(currentLicense, endsWith("}"));
}
}
Expand Down
29 changes: 12 additions & 17 deletions qa/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@

import org.elasticsearch.gradle.test.RestIntegTestTask
import org.elasticsearch.gradle.testclusters.TestClustersPlugin

subprojects { Project subproj ->
subproj.tasks.withType(RestIntegTestTask) {
subproj.extensions.configure("${it.name}Cluster") { cluster ->
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"
}
}
if (subproj.extensions.findByName("${it.name}Cluster")) {
subproj.extensions.configure("${it.name}Cluster") { cluster ->
cluster.distribution = System.getProperty('tests.distribution', 'oss')
}
}
}
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()
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions qa/logging-config/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
* under the License.
*/


apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-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
* can successfully startup.
*/
extraConfigFile 'log4j2.properties', 'custom-log4j2.properties'
extraConfigFile 'log4j2.properties', file('custom-log4j2.properties')
}

integTestRunner {
integTest.runner {
nonInputProperties.systemProperty 'tests.logfile',
"${ -> integTest.nodes[0].homeDir}/logs/${ -> integTest.nodes[0].clusterName }_server.log"
"${ -> testClusters.integTest.singleNode().getServerLog().absolutePath.replaceAll(".json", ".log")}"
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* The intention is to confirm that users can still run their Elasticsearch instances with previous configurations.
*/
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 {
assertBusy(() -> {
Expand Down
3 changes: 2 additions & 1 deletion qa/smoke-test-ingest-disabled/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
* under the License.
*/

apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test'

dependencies {
testCompile project(path: ':modules:ingest-common', configuration: 'runtime')
}

integTestCluster {
testClusters.integTest {
setting 'node.ingest', 'false'
}
15 changes: 11 additions & 4 deletions qa/smoke-test-multinode/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,26 @@
* under the License.
*/

apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test'

integTest {
includePackaged = true
}

integTestCluster {
numNodes = 2
File repo = file("$buildDir/testclusters/repo")
testClusters.integTest {
numberOfNodes = 2
setting 'path.repo', repo.absolutePath
}

integTestRunner {
if ('default'.equals(integTestCluster.distribution)) {
integTest.runner {
doFirst {
project.delete(repo)
repo.mkdirs()
}
if ('default'.equalsIgnoreCase(System.getProperty('tests.distribution', 'oss'))) {
systemProperty 'tests.rest.blacklist', [
'cat.templates/10_basic/No templates',
'cat.templates/10_basic/Sort templates',
Expand Down
13 changes: 8 additions & 5 deletions qa/smoke-test-plugins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@

import org.elasticsearch.gradle.MavenFilteringHack

apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test'

ext.pluginsCount = 0
project(':plugins').getChildProjects().each { pluginName, pluginProject ->
integTestCluster {
plugin pluginProject.path
int pluginsCount = 0

testClusters.integTest {
project(':plugins').getChildProjects().each { pluginName, pluginProject ->
plugin file(pluginProject.tasks.bundlePlugin.archiveFile)
tasks.integTest.dependsOn pluginProject.tasks.bundlePlugin
pluginsCount += 1
}
pluginsCount += 1
}
assert pluginsCount > 0

Expand Down
13 changes: 5 additions & 8 deletions qa/unconfigured-node-name/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@
* under the License.
*/

apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test'

integTestCluster {
setting 'node.name', 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
testClusters.integTest {
nameCustomization = { null }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to do this in a more first-class way instead of using a null node name? The node name actually isn't relevant here. We just want to disable discovery. Perhaps we should make that a formal option on TestClusterConfiguration? We can then remove all the handling for null node names which is confusing IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do also care about not configuring a node name for the test. We are also testing that we can start up without it. I taught about having a more formal way to do this, but this is the only test that would use it and it's a bit of an edge case.
Would definitely consider extending this if we were to have other users.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. I assumed the empty node name was just an implementation detail.

}

integTestRunner {
integTest.runner {
nonInputProperties.systemProperty 'tests.logfile',
"${ -> integTest.nodes[0].homeDir}/logs/${ -> integTest.nodes[0].clusterName }_server.json"
"${ -> testClusters.integTest.singleNode().getServerLog() }"
}
6 changes: 4 additions & 2 deletions qa/wildfly/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import java.util.stream.Stream
*/

apply plugin: 'war'
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.rest-test'

Expand Down Expand Up @@ -88,12 +89,13 @@ task deploy(type: Copy) {

task writeElasticsearchProperties {
onlyIf { !Os.isFamily(Os.FAMILY_WINDOWS) }
dependsOn 'integTestCluster#wait', deploy
useCluster testClusters.integTest
dependsOn deploy
doLast {
final File elasticsearchProperties = file("${wildflyInstall}/standalone/configuration/elasticsearch.properties")
elasticsearchProperties.write(
[
"http.uri=${-> integTest.getNodes().get(0).httpUri()}"
"http.uri=${-> testClusters.integTest.getAllHttpSocketURI().get(0)}"
].join("\n"))
}
}
Expand Down