TestConsumerPlugin shouldn't register its service on transport clients

Original commit: elastic/x-pack-elasticsearch@c9baa72a4b
This commit is contained in:
Igor Motov 2014-10-30 18:20:02 -04:00
parent 34679d3e47
commit a107b5d70a
2 changed files with 14 additions and 6 deletions

View File

@ -43,7 +43,7 @@ public class LicensesServiceClusterRestartTest extends AbstractLicensesIntegrati
private ImmutableSettings.Builder nodeSettingsBuilder(int nodeOrdinal) { private ImmutableSettings.Builder nodeSettingsBuilder(int nodeOrdinal) {
return ImmutableSettings.settingsBuilder() return ImmutableSettings.settingsBuilder()
//.put(super.nodeSettings(nodeOrdinal)) .put(super.nodeSettings(nodeOrdinal))
.put("gateway.type", "local") .put("gateway.type", "local")
.put("plugins.load_classpath_plugins", false) .put("plugins.load_classpath_plugins", false)
.put("node.data", true) .put("node.data", true)
@ -58,10 +58,10 @@ public class LicensesServiceClusterRestartTest extends AbstractLicensesIntegrati
wipeAllLicenses(); wipeAllLicenses();
} }
@Test @Ignore @Test
public void testClusterRestart() throws Exception { public void testClusterRestart() throws Exception {
logger.info("--> starting 1 node"); logger.info("--> starting 1 node");
internalCluster().startNode(nodeSettingsBuilder(0)); internalCluster().startNode();
ensureGreen(); ensureGreen();
final List<ESLicense> esLicenses = generateAndPutLicense(); final List<ESLicense> esLicenses = generateAndPutLicense();

View File

@ -5,7 +5,8 @@
*/ */
package org.elasticsearch.license.plugin; package org.elasticsearch.license.plugin;
import org.elasticsearch.common.collect.ImmutableSet; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -15,11 +16,14 @@ import java.util.Collection;
public class TestConsumerPlugin extends AbstractPlugin { public class TestConsumerPlugin extends AbstractPlugin {
private final boolean isClient;
private final Settings settings; private final Settings settings;
@Inject @Inject
public TestConsumerPlugin(Settings settings) { public TestConsumerPlugin(Settings settings) {
this.settings = settings; this.settings = settings;
this.isClient = DiscoveryNode.clientNode(settings);
} }
@Override @Override
@ -35,6 +39,10 @@ public class TestConsumerPlugin extends AbstractPlugin {
@Override @Override
public Collection<Class<? extends LifecycleComponent>> services() { public Collection<Class<? extends LifecycleComponent>> services() {
return ImmutableSet.<Class<? extends LifecycleComponent>>of(TestPluginService.class); Collection<Class<? extends LifecycleComponent>> services = Lists.newArrayList();
if (!isClient) {
services.add(TestPluginService.class);
}
return services;
} }
} }