fix compile errors

Original commit: elastic/x-pack-elasticsearch@38feef1376
This commit is contained in:
Martijn van Groningen 2015-08-31 10:47:49 +02:00
parent c09c5611b8
commit af4af34e2b
5 changed files with 37 additions and 19 deletions

View File

@ -144,9 +144,9 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
logger.info("--> remote indexing enabled. shield enabled: [{}], SSL enabled: [{}]", useShield, useSSL); logger.info("--> remote indexing enabled. shield enabled: [{}], SSL enabled: [{}]", useShield, useSSL);
ShieldSettingsSource cluster2SettingsSource = new ShieldSettingsSource(numNodes, useSSL, systemKey(), createTempDir(), Scope.SUITE) { ShieldSettingsSource cluster2SettingsSource = new ShieldSettingsSource(numNodes, useSSL, systemKey(), createTempDir(), Scope.SUITE) {
@Override @Override
public Settings node(int nodeOrdinal) { public Settings nodeSettings(int nodeOrdinal) {
Settings.Builder builder = Settings.builder() Settings.Builder builder = Settings.builder()
.put(super.node(nodeOrdinal)) .put(super.nodeSettings(nodeOrdinal))
.put(ShieldPlugin.ENABLED_SETTING_NAME, useShield); .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, // 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 // but if shield is disabled then we don't need to forcefully set the query cache

View File

@ -71,9 +71,9 @@ public class RemoteIndexAuditTrailStartingTests extends ShieldIntegTestCase {
final int numNodes = randomIntBetween(2, 3); final int numNodes = randomIntBetween(2, 3);
ShieldSettingsSource cluster2SettingsSource = new ShieldSettingsSource(numNodes, useSSL, systemKey(), createTempDir(), Scope.SUITE) { ShieldSettingsSource cluster2SettingsSource = new ShieldSettingsSource(numNodes, useSSL, systemKey(), createTempDir(), Scope.SUITE) {
@Override @Override
public Settings node(int nodeOrdinal) { public Settings nodeSettings(int nodeOrdinal) {
Settings.Builder builder = Settings.builder() Settings.Builder builder = Settings.builder()
.put(super.node(nodeOrdinal)) .put(super.nodeSettings(nodeOrdinal))
.put("shield.audit.enabled", true) .put("shield.audit.enabled", true)
.put("shield.audit.outputs", randomFrom("index", "index,logfile")) .put("shield.audit.outputs", randomFrom("index", "index,logfile"))
.putArray("shield.audit.index.client.hosts", addresses.toArray(new String[addresses.size()])) .putArray("shield.audit.index.client.hosts", addresses.toArray(new String[addresses.size()]))

View File

@ -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 //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) { tribeSettingsSource = new ShieldSettingsSource(1, sslTransportEnabled, systemKey(), createTempDir(), Scope.SUITE) {
@Override @Override
public Settings node(int nodeOrdinal) { public Settings nodeSettings(int nodeOrdinal) {
Settings shieldSettings = super.node(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 //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); Settings.Builder builder = Settings.builder().put(shieldSettings);
//the tribe node itself won't join any cluster, no need for unicast discovery configuration //the tribe node itself won't join any cluster, no need for unicast discovery configuration

View File

@ -29,10 +29,7 @@ import org.junit.rules.ExternalResource;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.*;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
@ -155,17 +152,27 @@ public abstract class ShieldIntegTestCase extends ESIntegTestCase {
@Override @Override
protected Settings nodeSettings(int nodeOrdinal) { protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder().put(super.nodeSettings(nodeOrdinal)) return Settings.builder().put(super.nodeSettings(nodeOrdinal))
.put(customShieldSettingsSource.node(nodeOrdinal)) .put(customShieldSettingsSource.nodeSettings(nodeOrdinal))
.build(); .build();
} }
@Override @Override
protected Settings transportClientSettings() { protected Settings transportClientSettings() {
return Settings.builder().put(super.transportClientSettings()) return Settings.builder().put(super.transportClientSettings())
.put(customShieldSettingsSource.transportClient()) .put(customShieldSettingsSource.transportClientSettings())
.build(); .build();
} }
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(ShieldPlugin.class, licensePluginClass());
}
@Override
protected Collection<Class<? extends Plugin>> transportClientPlugins() {
return nodePlugins();
}
@Override @Override
protected Settings externalClusterClientSettings() { protected Settings externalClusterClientSettings() {
return Settings.builder() return Settings.builder()

View File

@ -26,6 +26,8 @@ import org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collection;
import static com.carrotsearch.randomizedtesting.RandomizedTest.randomBoolean; import static com.carrotsearch.randomizedtesting.RandomizedTest.randomBoolean;
import static org.elasticsearch.common.settings.Settings.settingsBuilder; 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; 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}, * Unicast discovery is configured through {@link org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration.UnicastZen},
* also shield is installed with all the needed configuration and files. * 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. * 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; 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 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 * @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 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 * @param sslTransportEnabled whether ssl should be enabled on the transport layer or not
@ -110,9 +112,9 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ
} }
@Override @Override
public Settings node(int nodeOrdinal) { public Settings nodeSettings(int nodeOrdinal) {
Path folder = ShieldTestUtils.createFolder(parentFolder, subfolderPrefix + "-" + 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("plugin.types", ShieldPlugin.class.getName() + "," + licensePluginClass().getName())
.put("shield.audit.enabled", randomBoolean()) .put("shield.audit.enabled", randomBoolean())
.put(InternalCryptoService.FILE_SETTING, writeFile(folder, "system_key", systemKey)) .put(InternalCryptoService.FILE_SETTING, writeFile(folder, "system_key", systemKey))
@ -132,14 +134,23 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ
} }
@Override @Override
public Settings transportClient() { public Settings transportClientSettings() {
Settings.Builder builder = settingsBuilder().put(super.transportClient()) Settings.Builder builder = settingsBuilder().put(super.transportClientSettings())
.put("plugin.types", ShieldPlugin.class.getName()) .put("plugin.types", ShieldPlugin.class.getName())
.put(getClientSSLSettings()); .put(getClientSSLSettings());
setUser(builder, transportClientUsername(), transportClientPassword()); setUser(builder, transportClientUsername(), transportClientPassword());
return builder.build(); return builder.build();
} }
@Override
public Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(ShieldPlugin.class, licensePluginClass());
}
@Override
public Collection<Class<? extends Plugin>> transportClientPlugins() {
return nodePlugins();
}
protected String configUsers() { protected String configUsers() {
return CONFIG_STANDARD_USER; return CONFIG_STANDARD_USER;