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:
Alexander Reelsen 2013-05-17 13:21:26 +02:00
parent 2485c4890c
commit bd857d6d2e
5 changed files with 11 additions and 74 deletions

View File

@ -60,7 +60,6 @@ public class SimpleNodesInfoTests extends AbstractNodesTests {
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_NO_DESCRIPTION = "No description found for dummy.";
static final String JVM_PLUGIN_NO_DESCRIPTION = "No description found for test-no-version-plugin.";
}
@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)
String server2NodeId = startNodeWithPlugins("node2");
// 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
String server4NodeId = startNodeWithPlugins("node4");
String server4NodeId = startNodeWithPlugins("node4", TestNoVersionPlugin.class.getName());
ClusterHealthResponse clusterHealth = client("node4").admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
@ -147,10 +146,9 @@ public class SimpleNodesInfoTests extends AbstractNodesTests {
Lists.newArrayList(TestPlugin.Fields.DESCRIPTION),
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,
Lists.newArrayList(TestPlugin.Fields.NAME, TestNoVersionPlugin.Fields.NAME),
Lists.newArrayList(TestPlugin.Fields.DESCRIPTION, TestNoVersionPlugin.Fields.DESCRIPTION),
Lists.newArrayList(TestNoVersionPlugin.Fields.NAME),
Lists.newArrayList(TestNoVersionPlugin.Fields.DESCRIPTION),
Lists.newArrayList(Fields.SITE_PLUGIN, TestNoVersionPlugin.Fields.NAME),
Lists.newArrayList(Fields.SITE_PLUGIN_NO_DESCRIPTION, TestNoVersionPlugin.Fields.DESCRIPTION));
}
@ -196,13 +194,17 @@ public class SimpleNodesInfoTests extends AbstractNodesTests {
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 + "/");
ImmutableSettings.Builder settings = settingsBuilder();
if (resource != null) {
settings.put("path.plugins", new File(resource.toURI()).getAbsolutePath());
}
if (pluginClassNames.length > 0) {
settings.putArray("plugin.types", pluginClassNames);
}
startNode(name, settings);
// We wait for a Green status

View File

@ -30,14 +30,13 @@ import org.elasticsearch.http.HttpServerTransport;
import org.elasticsearch.node.internal.InternalNode;
import org.elasticsearch.rest.RestStatus;
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.HttpClientResponse;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.File;
import java.net.URL;
import java.util.Map;
/**
@ -49,12 +48,7 @@ public class ResponseHeaderPluginTests extends AbstractNodesTests {
@BeforeMethod
public void startNode() throws Exception {
URL resource = ResponseHeaderPluginTests.class.getResource("/org/elasticsearch/test/integration/responseheader/");
ImmutableSettings.Builder settings = settingsBuilder();
if (resource != null) {
settings.put("path.plugins", new File(resource.toURI()).getAbsolutePath());
}
ImmutableSettings.Builder settings = settingsBuilder().put("plugin.types", TestResponseHeaderPlugin.class.getName());
startNode(NODE_ID, settings);
client(NODE_ID).admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
}

View File

@ -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

View File

@ -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

View File

@ -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