From af4af34e2b4ec07522f600eba043640c53bee812 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Mon, 31 Aug 2015 10:47:49 +0200 Subject: [PATCH] fix compile errors Original commit: elastic/x-pack-elasticsearch@38feef1376a8552849a47c7ab88e8d356b4861a6 --- .../audit/index/IndexAuditTrailTests.java | 4 +-- .../RemoteIndexAuditTrailStartingTests.java | 4 +-- .../shield/tribe/TribeTests.java | 4 +-- .../test/ShieldIntegTestCase.java | 19 +++++++++----- .../test/ShieldSettingsSource.java | 25 +++++++++++++------ 5 files changed, 37 insertions(+), 19 deletions(-) diff --git a/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java b/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java index 870ca7d0590..b307484bc1c 100644 --- a/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java +++ b/shield/src/test/java/org/elasticsearch/shield/audit/index/IndexAuditTrailTests.java @@ -144,9 +144,9 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase { logger.info("--> remote indexing enabled. shield enabled: [{}], SSL enabled: [{}]", useShield, useSSL); ShieldSettingsSource cluster2SettingsSource = new ShieldSettingsSource(numNodes, useSSL, systemKey(), createTempDir(), Scope.SUITE) { @Override - public Settings node(int nodeOrdinal) { + public Settings nodeSettings(int nodeOrdinal) { Settings.Builder builder = Settings.builder() - .put(super.node(nodeOrdinal)) + .put(super.nodeSettings(nodeOrdinal)) .put(ShieldPlugin.ENABLED_SETTING_NAME, useShield); // For tests we forcefully configure Shield's custom query cache because the test framework randomizes the query cache impl, // but if shield is disabled then we don't need to forcefully set the query cache diff --git a/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java b/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java index 047ccf4cbef..66decf9f741 100644 --- a/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java +++ b/shield/src/test/java/org/elasticsearch/shield/audit/index/RemoteIndexAuditTrailStartingTests.java @@ -71,9 +71,9 @@ public class RemoteIndexAuditTrailStartingTests extends ShieldIntegTestCase { final int numNodes = randomIntBetween(2, 3); ShieldSettingsSource cluster2SettingsSource = new ShieldSettingsSource(numNodes, useSSL, systemKey(), createTempDir(), Scope.SUITE) { @Override - public Settings node(int nodeOrdinal) { + public Settings nodeSettings(int nodeOrdinal) { Settings.Builder builder = Settings.builder() - .put(super.node(nodeOrdinal)) + .put(super.nodeSettings(nodeOrdinal)) .put("shield.audit.enabled", true) .put("shield.audit.outputs", randomFrom("index", "index,logfile")) .putArray("shield.audit.index.client.hosts", addresses.toArray(new String[addresses.size()])) diff --git a/shield/src/test/java/org/elasticsearch/shield/tribe/TribeTests.java b/shield/src/test/java/org/elasticsearch/shield/tribe/TribeTests.java index 9279035570f..4f6dd5508e4 100644 --- a/shield/src/test/java/org/elasticsearch/shield/tribe/TribeTests.java +++ b/shield/src/test/java/org/elasticsearch/shield/tribe/TribeTests.java @@ -68,8 +68,8 @@ public class TribeTests extends ShieldIntegTestCase { //given the low (2 and 1) number of nodes that the 2 SUITE clusters will have, we are not going to have port conflicts tribeSettingsSource = new ShieldSettingsSource(1, sslTransportEnabled, systemKey(), createTempDir(), Scope.SUITE) { @Override - public Settings node(int nodeOrdinal) { - Settings shieldSettings = super.node(nodeOrdinal); + public Settings nodeSettings(int nodeOrdinal) { + Settings shieldSettings = super.nodeSettings(nodeOrdinal); //all the settings are needed for the tribe node, some of them will also need to be copied to the tribe clients configuration Settings.Builder builder = Settings.builder().put(shieldSettings); //the tribe node itself won't join any cluster, no need for unicast discovery configuration diff --git a/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java b/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java index 366dfb01d5a..e3822e502a8 100644 --- a/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java +++ b/shield/src/test/java/org/elasticsearch/test/ShieldIntegTestCase.java @@ -29,10 +29,7 @@ import org.junit.rules.ExternalResource; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Random; +import java.util.*; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout; import static org.hamcrest.CoreMatchers.is; @@ -155,17 +152,27 @@ public abstract class ShieldIntegTestCase extends ESIntegTestCase { @Override protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder().put(super.nodeSettings(nodeOrdinal)) - .put(customShieldSettingsSource.node(nodeOrdinal)) + .put(customShieldSettingsSource.nodeSettings(nodeOrdinal)) .build(); } @Override protected Settings transportClientSettings() { return Settings.builder().put(super.transportClientSettings()) - .put(customShieldSettingsSource.transportClient()) + .put(customShieldSettingsSource.transportClientSettings()) .build(); } + @Override + protected Collection> nodePlugins() { + return Arrays.asList(ShieldPlugin.class, licensePluginClass()); + } + + @Override + protected Collection> transportClientPlugins() { + return nodePlugins(); + } + @Override protected Settings externalClusterClientSettings() { return Settings.builder() diff --git a/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java b/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java index 67307fffb59..5c73ed17102 100644 --- a/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java +++ b/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java @@ -26,6 +26,8 @@ import org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Arrays; +import java.util.Collection; import static com.carrotsearch.randomizedtesting.RandomizedTest.randomBoolean; import static org.elasticsearch.common.settings.Settings.settingsBuilder; @@ -33,7 +35,7 @@ import static org.elasticsearch.shield.authc.support.UsernamePasswordToken.basic import static org.elasticsearch.shield.test.ShieldTestUtils.writeFile; /** - * {@link org.elasticsearch.test.SettingsSource} subclass that allows to set all needed settings for shield. + * {@link org.elasticsearch.test.NodeConfigurationSource} subclass that allows to set all needed settings for shield. * Unicast discovery is configured through {@link org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration.UnicastZen}, * also shield is installed with all the needed configuration and files. * To avoid conflicts, every cluster should have its own instance of this class as some configuration files need to be created. @@ -79,7 +81,7 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ private final boolean hostnameVerificationResolveNameEnabled; /** - * Creates a new {@link org.elasticsearch.test.SettingsSource} for the shield configuration. + * Creates a new {@link org.elasticsearch.test.NodeConfigurationSource} for the shield configuration. * * @param numOfNodes the number of nodes for proper unicast configuration (can be more than actually available) * @param sslTransportEnabled whether ssl should be enabled on the transport layer or not @@ -91,7 +93,7 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ } /** - * Creates a new {@link org.elasticsearch.test.SettingsSource} for the shield configuration. + * Creates a new {@link org.elasticsearch.test.NodeConfigurationSource} for the shield configuration. * * @param numOfNodes the number of nodes for proper unicast configuration (can be more than actually available) * @param sslTransportEnabled whether ssl should be enabled on the transport layer or not @@ -110,9 +112,9 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ } @Override - public Settings node(int nodeOrdinal) { + public Settings nodeSettings(int nodeOrdinal) { Path folder = ShieldTestUtils.createFolder(parentFolder, subfolderPrefix + "-" + nodeOrdinal); - Settings.Builder builder = settingsBuilder().put(super.node(nodeOrdinal)) + Settings.Builder builder = settingsBuilder().put(super.nodeSettings(nodeOrdinal)) .put("plugin.types", ShieldPlugin.class.getName() + "," + licensePluginClass().getName()) .put("shield.audit.enabled", randomBoolean()) .put(InternalCryptoService.FILE_SETTING, writeFile(folder, "system_key", systemKey)) @@ -132,14 +134,23 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ } @Override - public Settings transportClient() { - Settings.Builder builder = settingsBuilder().put(super.transportClient()) + public Settings transportClientSettings() { + Settings.Builder builder = settingsBuilder().put(super.transportClientSettings()) .put("plugin.types", ShieldPlugin.class.getName()) .put(getClientSSLSettings()); setUser(builder, transportClientUsername(), transportClientPassword()); return builder.build(); } + @Override + public Collection> nodePlugins() { + return Arrays.asList(ShieldPlugin.class, licensePluginClass()); + } + + @Override + public Collection> transportClientPlugins() { + return nodePlugins(); + } protected String configUsers() { return CONFIG_STANDARD_USER;