Ensuring test isolation when jvm plugins are loaded
Instead of specifying 'path.plugins' configuration option, 'plugin.types' is used to load plugins in integration tests. This makes sure the JVM plugins are not loaded in all following tests from then. Also removed the now unneeded es-plugin.properties files from JVM test plugins.
This commit is contained in:
parent
2485c4890c
commit
bd857d6d2e
|
@ -60,7 +60,6 @@ public class SimpleNodesInfoTests extends AbstractNodesTests {
|
||||||
static final String SITE_PLUGIN = "dummy";
|
static final String SITE_PLUGIN = "dummy";
|
||||||
static final String SITE_PLUGIN_DESCRIPTION = "This is a description for a dummy test site plugin.";
|
static final String SITE_PLUGIN_DESCRIPTION = "This is a description for a dummy test site plugin.";
|
||||||
static final String SITE_PLUGIN_NO_DESCRIPTION = "No description found for dummy.";
|
static final String SITE_PLUGIN_NO_DESCRIPTION = "No description found for dummy.";
|
||||||
static final String JVM_PLUGIN_NO_DESCRIPTION = "No description found for test-no-version-plugin.";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterMethod
|
@AfterMethod
|
||||||
|
@ -126,9 +125,9 @@ public class SimpleNodesInfoTests extends AbstractNodesTests {
|
||||||
// The second has one site plugin with a es-plugin.properties file (description and version)
|
// The second has one site plugin with a es-plugin.properties file (description and version)
|
||||||
String server2NodeId = startNodeWithPlugins("node2");
|
String server2NodeId = startNodeWithPlugins("node2");
|
||||||
// The third has one java plugin
|
// The third has one java plugin
|
||||||
String server3NodeId = startNodeWithPlugins("node3");
|
String server3NodeId = startNodeWithPlugins("node3", TestPlugin.class.getName());
|
||||||
// The fourth has one java plugin and one site plugin
|
// The fourth has one java plugin and one site plugin
|
||||||
String server4NodeId = startNodeWithPlugins("node4");
|
String server4NodeId = startNodeWithPlugins("node4", TestNoVersionPlugin.class.getName());
|
||||||
|
|
||||||
ClusterHealthResponse clusterHealth = client("node4").admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
ClusterHealthResponse clusterHealth = client("node4").admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||||
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
|
||||||
|
@ -147,10 +146,9 @@ public class SimpleNodesInfoTests extends AbstractNodesTests {
|
||||||
Lists.newArrayList(TestPlugin.Fields.DESCRIPTION),
|
Lists.newArrayList(TestPlugin.Fields.DESCRIPTION),
|
||||||
Collections.EMPTY_LIST, Collections.EMPTY_LIST);
|
Collections.EMPTY_LIST, Collections.EMPTY_LIST);
|
||||||
|
|
||||||
// Note that we have now 2 JVM plugins as we have already loaded one with node3
|
|
||||||
assertNodeContainsPlugins(response, server4NodeId,
|
assertNodeContainsPlugins(response, server4NodeId,
|
||||||
Lists.newArrayList(TestPlugin.Fields.NAME, TestNoVersionPlugin.Fields.NAME),
|
Lists.newArrayList(TestNoVersionPlugin.Fields.NAME),
|
||||||
Lists.newArrayList(TestPlugin.Fields.DESCRIPTION, TestNoVersionPlugin.Fields.DESCRIPTION),
|
Lists.newArrayList(TestNoVersionPlugin.Fields.DESCRIPTION),
|
||||||
Lists.newArrayList(Fields.SITE_PLUGIN, TestNoVersionPlugin.Fields.NAME),
|
Lists.newArrayList(Fields.SITE_PLUGIN, TestNoVersionPlugin.Fields.NAME),
|
||||||
Lists.newArrayList(Fields.SITE_PLUGIN_NO_DESCRIPTION, TestNoVersionPlugin.Fields.DESCRIPTION));
|
Lists.newArrayList(Fields.SITE_PLUGIN_NO_DESCRIPTION, TestNoVersionPlugin.Fields.DESCRIPTION));
|
||||||
}
|
}
|
||||||
|
@ -196,13 +194,17 @@ public class SimpleNodesInfoTests extends AbstractNodesTests {
|
||||||
assertThat(sitePluginUrls, not(contains(nullValue())));
|
assertThat(sitePluginUrls, not(contains(nullValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String startNodeWithPlugins(String name) throws URISyntaxException {
|
private String startNodeWithPlugins(String name, String ... pluginClassNames) throws URISyntaxException {
|
||||||
URL resource = SimpleNodesInfoTests.class.getResource("/org/elasticsearch/test/integration/nodesinfo/" + name + "/");
|
URL resource = SimpleNodesInfoTests.class.getResource("/org/elasticsearch/test/integration/nodesinfo/" + name + "/");
|
||||||
ImmutableSettings.Builder settings = settingsBuilder();
|
ImmutableSettings.Builder settings = settingsBuilder();
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
settings.put("path.plugins", new File(resource.toURI()).getAbsolutePath());
|
settings.put("path.plugins", new File(resource.toURI()).getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pluginClassNames.length > 0) {
|
||||||
|
settings.putArray("plugin.types", pluginClassNames);
|
||||||
|
}
|
||||||
|
|
||||||
startNode(name, settings);
|
startNode(name, settings);
|
||||||
|
|
||||||
// We wait for a Green status
|
// We wait for a Green status
|
||||||
|
|
|
@ -30,14 +30,13 @@ import org.elasticsearch.http.HttpServerTransport;
|
||||||
import org.elasticsearch.node.internal.InternalNode;
|
import org.elasticsearch.node.internal.InternalNode;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.test.integration.AbstractNodesTests;
|
import org.elasticsearch.test.integration.AbstractNodesTests;
|
||||||
|
import org.elasticsearch.test.integration.plugin.responseheader.TestResponseHeaderPlugin;
|
||||||
import org.elasticsearch.test.integration.rest.helper.HttpClient;
|
import org.elasticsearch.test.integration.rest.helper.HttpClient;
|
||||||
import org.elasticsearch.test.integration.rest.helper.HttpClientResponse;
|
import org.elasticsearch.test.integration.rest.helper.HttpClientResponse;
|
||||||
import org.testng.annotations.AfterMethod;
|
import org.testng.annotations.AfterMethod;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,12 +48,7 @@ public class ResponseHeaderPluginTests extends AbstractNodesTests {
|
||||||
|
|
||||||
@BeforeMethod
|
@BeforeMethod
|
||||||
public void startNode() throws Exception {
|
public void startNode() throws Exception {
|
||||||
URL resource = ResponseHeaderPluginTests.class.getResource("/org/elasticsearch/test/integration/responseheader/");
|
ImmutableSettings.Builder settings = settingsBuilder().put("plugin.types", TestResponseHeaderPlugin.class.getName());
|
||||||
ImmutableSettings.Builder settings = settingsBuilder();
|
|
||||||
if (resource != null) {
|
|
||||||
settings.put("path.plugins", new File(resource.toURI()).getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
startNode(NODE_ID, settings);
|
startNode(NODE_ID, settings);
|
||||||
client(NODE_ID).admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
client(NODE_ID).admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
################################################################
|
|
||||||
# Licensed to ElasticSearch and Shay Banon under one
|
|
||||||
# or more contributor license agreements. See the NOTICE file
|
|
||||||
# distributed with this work for additional information
|
|
||||||
# regarding copyright ownership. ElasticSearch 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.
|
|
||||||
################################################################
|
|
||||||
plugin=org.elasticsearch.test.integration.nodesinfo.plugin.dummy1.TestPlugin
|
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
################################################################
|
|
||||||
# Licensed to ElasticSearch and Shay Banon under one
|
|
||||||
# or more contributor license agreements. See the NOTICE file
|
|
||||||
# distributed with this work for additional information
|
|
||||||
# regarding copyright ownership. ElasticSearch 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.
|
|
||||||
################################################################
|
|
||||||
plugin=org.elasticsearch.test.integration.nodesinfo.plugin.dummy2.TestNoVersionPlugin
|
|
|
@ -1,20 +0,0 @@
|
||||||
################################################################
|
|
||||||
# Licensed to ElasticSearch and Shay Banon under one
|
|
||||||
# or more contributor license agreements. See the NOTICE file
|
|
||||||
# distributed with this work for additional information
|
|
||||||
# regarding copyright ownership. ElasticSearch 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.
|
|
||||||
################################################################
|
|
||||||
plugin=org.elasticsearch.test.integration.plugin.responseheader.TestResponseHeaderPlugin
|
|
||||||
|
|
Loading…
Reference in New Issue