test: cleanup usages of node builder where we actually need Shield loaded

Some tests are still using a node builder for nodes that need to load Shield, which is not currently
supported by elasticsearch. This changes some to use a MockNode and awaits fix a tribe test
that was previously testing nothing.

Original commit: elastic/x-pack-elasticsearch@57d0c902b6
This commit is contained in:
jaymode 2015-09-23 13:34:23 -04:00
parent 22edda4044
commit 44cd14d5f1
3 changed files with 13 additions and 7 deletions

View File

@ -17,7 +17,6 @@ import org.elasticsearch.env.Environment;
import org.elasticsearch.license.plugin.LicensePlugin;
import org.elasticsearch.node.MockNode;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.shield.ShieldPlugin;
import org.elasticsearch.shield.authc.RealmConfig;
import org.elasticsearch.shield.authc.activedirectory.ActiveDirectorySessionFactoryTests;
@ -36,7 +35,6 @@ import java.nio.file.Path;
import java.text.MessageFormat;
import java.util.*;
import static org.elasticsearch.common.settings.Settings.builder;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.ShieldTestsUtils.assertAuthenticationException;
import static org.hamcrest.Matchers.*;

View File

@ -30,7 +30,6 @@ import java.nio.file.Path;
import java.util.Arrays;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
import static org.elasticsearch.shield.test.ShieldTestUtils.createFolder;
import static org.elasticsearch.shield.test.ShieldTestUtils.writeFile;
import static org.hamcrest.CoreMatchers.instanceOf;
@ -139,8 +138,9 @@ public class ServerTransportFilterIntegrationTests extends ShieldIntegTestCase {
.put(InternalCryptoService.FILE_SETTING, systemKeyFile)
.put("discovery.initial_state_timeout", "2s")
.put("path.home", createTempDir())
.put("node.client", true)
.build();
try (Node node = nodeBuilder().client(true).settings(nodeSettings).build()) {
try (Node node = new MockNode(nodeSettings, Version.CURRENT, Arrays.asList(ShieldPlugin.class, licensePluginClass()))) {
node.start();
// assert that node is not connected by waiting for the timeout

View File

@ -6,8 +6,10 @@
package org.elasticsearch.shield.tribe;
import org.apache.lucene.util.LuceneTestCase;
import org.elasticsearch.Version;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.plugin.LicensePlugin;
import org.elasticsearch.node.MockNode;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.plugins.PluginsService;
@ -15,6 +17,8 @@ import org.elasticsearch.shield.ShieldPlugin;
import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
import java.util.Arrays;
import static org.hamcrest.CoreMatchers.containsString;
/**
@ -25,11 +29,13 @@ import static org.hamcrest.CoreMatchers.containsString;
public class TribeShieldLoadedTests extends ESTestCase {
@Test
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/13212")
// we really need to support loading plugins at the node level this way which should flow the plugins down to the tribe service, right now it doesnt!
public void testShieldLoadedOnBothTribeNodeAndClients() {
//all good if the plugin is loaded on both tribe node and tribe clients, no matter how it gets loaded (manually or from classpath)
Settings.Builder builder = defaultSettings();
try (Node node = NodeBuilder.nodeBuilder().settings(builder.build()).build()) {
try (Node node = new MockNode(builder.build(), Version.CURRENT, Arrays.asList(ShieldPlugin.class, LicensePlugin.class))) {
node.start();
}
}
@ -66,13 +72,15 @@ public class TribeShieldLoadedTests extends ESTestCase {
private static Settings.Builder defaultSettings() {
return addTribeSettings(Settings.builder()
.put("node.name", "tribe_node")
.put("path.home", createTempDir()), "t1");
.put("path.home", createTempDir())
.putArray("plugin.mandatory", ShieldPlugin.NAME, LicensePlugin.NAME), "t1");
}
private static Settings.Builder addTribeSettings(Settings.Builder settingsBuilder, String tribe) {
String tribePrefix = "tribe." + tribe + ".";
return settingsBuilder.put(tribePrefix + "cluster.name", "non_existing_cluster")
.put(tribePrefix + "discovery.type", "local")
.put(tribePrefix + "discovery.initial_state_timeout", 0);
.put(tribePrefix + "discovery.initial_state_timeout", 0)
.putArray(tribePrefix + "plugin.mandatory", ShieldPlugin.NAME, LicensePlugin.NAME);
}
}