Skip to content

Commit bd857d6

Browse files
committed
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.
1 parent 2485c48 commit bd857d6

File tree

5 files changed

+11
-74
lines changed

5 files changed

+11
-74
lines changed

src/test/java/org/elasticsearch/test/integration/nodesinfo/SimpleNodesInfoTests.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ static final class Fields {
6060
static final String SITE_PLUGIN = "dummy";
6161
static final String SITE_PLUGIN_DESCRIPTION = "This is a description for a dummy test site plugin.";
6262
static final String SITE_PLUGIN_NO_DESCRIPTION = "No description found for dummy.";
63-
static final String JVM_PLUGIN_NO_DESCRIPTION = "No description found for test-no-version-plugin.";
6463
}
6564

6665
@AfterMethod
@@ -126,9 +125,9 @@ public void testNodeInfoPlugin() throws URISyntaxException {
126125
// The second has one site plugin with a es-plugin.properties file (description and version)
127126
String server2NodeId = startNodeWithPlugins("node2");
128127
// The third has one java plugin
129-
String server3NodeId = startNodeWithPlugins("node3");
128+
String server3NodeId = startNodeWithPlugins("node3", TestPlugin.class.getName());
130129
// The fourth has one java plugin and one site plugin
131-
String server4NodeId = startNodeWithPlugins("node4");
130+
String server4NodeId = startNodeWithPlugins("node4", TestNoVersionPlugin.class.getName());
132131

133132
ClusterHealthResponse clusterHealth = client("node4").admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
134133
logger.info("--> done cluster_health, status " + clusterHealth.getStatus());
@@ -147,10 +146,9 @@ public void testNodeInfoPlugin() throws URISyntaxException {
147146
Lists.newArrayList(TestPlugin.Fields.DESCRIPTION),
148147
Collections.EMPTY_LIST, Collections.EMPTY_LIST);
149148

150-
// Note that we have now 2 JVM plugins as we have already loaded one with node3
151149
assertNodeContainsPlugins(response, server4NodeId,
152-
Lists.newArrayList(TestPlugin.Fields.NAME, TestNoVersionPlugin.Fields.NAME),
153-
Lists.newArrayList(TestPlugin.Fields.DESCRIPTION, TestNoVersionPlugin.Fields.DESCRIPTION),
150+
Lists.newArrayList(TestNoVersionPlugin.Fields.NAME),
151+
Lists.newArrayList(TestNoVersionPlugin.Fields.DESCRIPTION),
154152
Lists.newArrayList(Fields.SITE_PLUGIN, TestNoVersionPlugin.Fields.NAME),
155153
Lists.newArrayList(Fields.SITE_PLUGIN_NO_DESCRIPTION, TestNoVersionPlugin.Fields.DESCRIPTION));
156154
}
@@ -196,13 +194,17 @@ private void assertNodeContainsPlugins(NodesInfoResponse response, String nodeId
196194
assertThat(sitePluginUrls, not(contains(nullValue())));
197195
}
198196

199-
private String startNodeWithPlugins(String name) throws URISyntaxException {
197+
private String startNodeWithPlugins(String name, String ... pluginClassNames) throws URISyntaxException {
200198
URL resource = SimpleNodesInfoTests.class.getResource("/org/elasticsearch/test/integration/nodesinfo/" + name + "/");
201199
ImmutableSettings.Builder settings = settingsBuilder();
202200
if (resource != null) {
203201
settings.put("path.plugins", new File(resource.toURI()).getAbsolutePath());
204202
}
205203

204+
if (pluginClassNames.length > 0) {
205+
settings.putArray("plugin.types", pluginClassNames);
206+
}
207+
206208
startNode(name, settings);
207209

208210
// We wait for a Green status

src/test/java/org/elasticsearch/test/integration/plugin/ResponseHeaderPluginTests.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@
3030
import org.elasticsearch.node.internal.InternalNode;
3131
import org.elasticsearch.rest.RestStatus;
3232
import org.elasticsearch.test.integration.AbstractNodesTests;
33+
import org.elasticsearch.test.integration.plugin.responseheader.TestResponseHeaderPlugin;
3334
import org.elasticsearch.test.integration.rest.helper.HttpClient;
3435
import org.elasticsearch.test.integration.rest.helper.HttpClientResponse;
3536
import org.testng.annotations.AfterMethod;
3637
import org.testng.annotations.BeforeMethod;
3738
import org.testng.annotations.Test;
3839

39-
import java.io.File;
40-
import java.net.URL;
4140
import java.util.Map;
4241

4342
/**
@@ -49,12 +48,7 @@ public class ResponseHeaderPluginTests extends AbstractNodesTests {
4948

5049
@BeforeMethod
5150
public void startNode() throws Exception {
52-
URL resource = ResponseHeaderPluginTests.class.getResource("/org/elasticsearch/test/integration/responseheader/");
53-
ImmutableSettings.Builder settings = settingsBuilder();
54-
if (resource != null) {
55-
settings.put("path.plugins", new File(resource.toURI()).getAbsolutePath());
56-
}
57-
51+
ImmutableSettings.Builder settings = settingsBuilder().put("plugin.types", TestResponseHeaderPlugin.class.getName());
5852
startNode(NODE_ID, settings);
5953
client(NODE_ID).admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
6054
}

src/test/resources/org/elasticsearch/test/integration/nodesinfo/node3/test-plugin/es-plugin.properties

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/test/resources/org/elasticsearch/test/integration/nodesinfo/node4/test-no-version-plugin/es-plugin.properties

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/test/resources/org/elasticsearch/test/integration/responseheader/responseheader-plugin/es-plugin.properties

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)