Tests: Use TestZenDiscovery instead of MockZenPing (elastic/elasticsearch#4052)

This is the xplugins side of elastic/elasticsearchelastic/elasticsearch#21488

Original commit: elastic/x-pack-elasticsearch@d3db54498a
This commit is contained in:
Ryan Ernst 2016-11-14 22:00:53 -08:00 committed by GitHub
parent 3a03ccf548
commit 96ba09436e
4 changed files with 17 additions and 13 deletions

View File

@ -29,7 +29,7 @@ import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.InternalTestCluster; import org.elasticsearch.test.InternalTestCluster;
import org.elasticsearch.test.NodeConfigurationSource; import org.elasticsearch.test.NodeConfigurationSource;
import org.elasticsearch.test.TestCluster; import org.elasticsearch.test.TestCluster;
import org.elasticsearch.test.discovery.MockZenPing; import org.elasticsearch.test.discovery.TestZenDiscovery;
import org.elasticsearch.transport.MockTcpTransportPlugin; import org.elasticsearch.transport.MockTcpTransportPlugin;
import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.XPackSettings; import org.elasticsearch.xpack.XPackSettings;
@ -141,7 +141,7 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase {
.put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME) .put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME)
.build(); .build();
final List<Class<? extends Plugin>> mockPlugins = Arrays.asList(MockZenPing.TestPlugin.class, MockTcpTransportPlugin.class); final List<Class<? extends Plugin>> mockPlugins = Arrays.asList(TestZenDiscovery.TestPlugin.class, MockTcpTransportPlugin.class);
final Node tribeNode = new MockNode(merged, mockPlugins).start(); final Node tribeNode = new MockNode(merged, mockPlugins).start();
Client tribeClient = tribeNode.client(); Client tribeClient = tribeNode.client();

View File

@ -9,10 +9,12 @@ import org.apache.lucene.util.IOUtils;
import org.elasticsearch.action.Action; import org.elasticsearch.action.Action;
import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.io.Streams; import org.elasticsearch.common.io.Streams;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.Licensing; import org.elasticsearch.license.Licensing;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.test.discovery.TestZenDiscovery;
import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.graph.Graph; import org.elasticsearch.xpack.graph.Graph;
import org.elasticsearch.xpack.security.action.SecurityActionModule; import org.elasticsearch.xpack.security.action.SecurityActionModule;
@ -58,8 +60,9 @@ public class KnownActionsTests extends SecurityIntegTestCase {
} }
@Override @Override
protected boolean addMockZenPings() { protected Settings nodeSettings(int nodeOrdinal) {
return false; // make sure unicasthost zen ping actions are loaded return Settings.builder().put(super.nodeSettings(nodeOrdinal))
.put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false).build();
} }
@BeforeClass @BeforeClass

View File

@ -5,6 +5,12 @@
*/ */
package org.elasticsearch.xpack.security.transport; package org.elasticsearch.xpack.security.transport;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import org.elasticsearch.common.network.NetworkAddress; import org.elasticsearch.common.network.NetworkAddress;
import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -15,7 +21,7 @@ import org.elasticsearch.node.MockNode;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeValidationException; import org.elasticsearch.node.NodeValidationException;
import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecurityIntegTestCase;
import org.elasticsearch.test.discovery.MockZenPing; import org.elasticsearch.test.discovery.TestZenDiscovery;
import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.Transport;
import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.XPackPlugin;
import org.elasticsearch.xpack.security.Security; import org.elasticsearch.xpack.security.Security;
@ -23,12 +29,6 @@ import org.elasticsearch.xpack.security.authc.file.FileRealm;
import org.elasticsearch.xpack.ssl.SSLClientAuth; import org.elasticsearch.xpack.ssl.SSLClientAuth;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import static java.util.Collections.singletonMap; import static java.util.Collections.singletonMap;
import static org.elasticsearch.test.SecuritySettingsSource.getSSLSettingsForStore; import static org.elasticsearch.test.SecuritySettingsSource.getSSLSettingsForStore;
import static org.elasticsearch.xpack.security.test.SecurityTestUtils.writeFile; import static org.elasticsearch.xpack.security.test.SecurityTestUtils.writeFile;
@ -100,7 +100,7 @@ public class ServerTransportFilterIntegrationTests extends SecurityIntegTestCase
.put(NetworkModule.HTTP_ENABLED.getKey(), false) .put(NetworkModule.HTTP_ENABLED.getKey(), false)
.put(Node.NODE_MASTER_SETTING.getKey(), false) .put(Node.NODE_MASTER_SETTING.getKey(), false)
.build(); .build();
try (Node node = new MockNode(nodeSettings, Arrays.asList(XPackPlugin.class, MockZenPing.TestPlugin.class))) { try (Node node = new MockNode(nodeSettings, Arrays.asList(XPackPlugin.class, TestZenDiscovery.TestPlugin.class))) {
node.start(); node.start();
assertGreenClusterState(node.client()); assertGreenClusterState(node.client());
} }

View File

@ -15,6 +15,7 @@ import org.elasticsearch.discovery.DiscoverySettings;
import org.elasticsearch.discovery.MasterNotDiscoveredException; import org.elasticsearch.discovery.MasterNotDiscoveredException;
import org.elasticsearch.discovery.zen.ElectMasterService; import org.elasticsearch.discovery.zen.ElectMasterService;
import org.elasticsearch.discovery.zen.UnicastZenPing; import org.elasticsearch.discovery.zen.UnicastZenPing;
import org.elasticsearch.discovery.zen.ZenDiscovery;
import org.elasticsearch.discovery.zen.ZenPing; import org.elasticsearch.discovery.zen.ZenPing;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration; import org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration;
@ -226,7 +227,7 @@ public class NoMasterNodeTests extends AbstractWatcherIntegrationTestCase {
// will elect itself as master. This is bad and should be fixed in core. What I think that should happen is that // will elect itself as master. This is bad and should be fixed in core. What I think that should happen is that
// if a node detects that is has lost a node, a node should clear its unicast temporal responses or at least // if a node detects that is has lost a node, a node should clear its unicast temporal responses or at least
// remove the node that has been removed. This is a workaround: // remove the node that has been removed. This is a workaround:
ZenPing zenPing = internalCluster().getInstance(ZenPing.class); ZenPing zenPing = internalCluster().getInstance(ZenDiscovery.class).getZenPing();
if (zenPing instanceof UnicastZenPing) { if (zenPing instanceof UnicastZenPing) {
((UnicastZenPing) zenPing).clearTemporalResponses(); ((UnicastZenPing) zenPing).clearTemporalResponses();
} }