disabled licensing tests until license refactoring is done

Original commit: elastic/x-pack-elasticsearch@e5673fedd9
This commit is contained in:
uboness 2015-09-24 02:37:24 +02:00
parent 075707e12c
commit 3162097ce8
11 changed files with 62 additions and 19 deletions

View File

@ -22,8 +22,11 @@ import org.elasticsearch.marvel.agent.settings.MarvelSetting;
import org.elasticsearch.marvel.agent.settings.MarvelSettings;
import org.elasticsearch.marvel.license.LicenseModule;
import org.elasticsearch.marvel.license.LicenseService;
import org.elasticsearch.marvel.shield.MarvelInternalUserHolder;
import org.elasticsearch.marvel.shield.MarvelShieldIntegration;
import org.elasticsearch.marvel.shield.MarvelShieldModule;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.shield.authz.AuthorizationModule;
import org.elasticsearch.tribe.TribeService;
import java.util.Arrays;
@ -95,6 +98,16 @@ public class MarvelPlugin extends Plugin {
return settings.getAsBoolean(ENABLED, true);
}
// NOTE: The fact this signature takes a module is a hack, and effectively like the previous
// processModule in the plugin api. The problem is tight coupling between marvel and shield.
// We need to avoid trying to load the AuthorizationModule class unless we know shield integration
// is enabled. This is a temporary solution until inter-plugin-communication can be worked out.
public void onModule(Module module) {
if (enabled && MarvelShieldIntegration.enabled(settings) && module instanceof AuthorizationModule) {
((AuthorizationModule)module).registerReservedRole(MarvelInternalUserHolder.ROLE);
}
}
public void onModule(ClusterModule module) {
Exporters.registerDynamicSettings(module);
// MarvelSettingsService

View File

@ -10,6 +10,7 @@ import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
import org.elasticsearch.common.joda.Joda;
import org.elasticsearch.common.logging.support.LoggerMessageFormat;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.license.core.License;
@ -31,6 +32,8 @@ public class LicenseService extends AbstractLifecycleComponent<LicenseService> {
private static final FormatDateTimeFormatter DATE_FORMATTER = Joda.forPattern("EEEE, MMMMM dd, yyyy", Locale.ROOT);
static final TimeValue GRACE_PERIOD = days(7);
private final LicensesManagerService managerService;
private final LicensesClientService clientService;
private final MarvelSettings marvelSettings;
@ -69,24 +72,37 @@ public class LicenseService extends AbstractLifecycleComponent<LicenseService> {
"#", DATE_FORMATTER.printer().print(license.expiryDate()));
}
},
new LicensesService.ExpirationCallback.Post(days(0), null, minutes(10)) {
new LicensesService.ExpirationCallback.Post(days(0), GRACE_PERIOD, minutes(10)) {
@Override
public void on(License license, LicensesService.ExpirationStatus status) {
long endOfGracePeriod = license.expiryDate() + GRACE_PERIOD.getMillis();
logger.error("\n" +
"#\n" +
"# MARVEL LICENSE WAS EXPIRED ON [{}].\n" +
"# MARVEL LICENSE HAS EXPIRED ON [{}].\n" +
"# MARVEL WILL STOP COLLECTING DATA ON [{}].\n" +
"# HAVE A NEW LICENSE? PLEASE UPDATE IT. OTHERWISE, PLEASE REACH OUT TO YOUR SUPPORT CONTACT.\n" +
"#", DATE_FORMATTER.printer().print(license.expiryDate()));
"#", DATE_FORMATTER.printer().print(endOfGracePeriod), DATE_FORMATTER.printer().print(license.expiryDate()));
}
}
);
this.acknowledgementCallback = new LicensesClientService.AcknowledgementCallback() {
@Override
public List<String> acknowledge(License currentLicense, License newLicense) {
// TODO: add messages to be acknowledged when installing newLicense from currentLicense
// NOTE: currentLicense can be null, as a license registration can happen before
// a trial license could be generated
return Collections.emptyList();
switch (newLicense.type()) {
case "trial":
case "gold":
case "platinum":
return Collections.emptyList();
default: // "basic" - we also fall back to basic for an unknown type
return Collections.singletonList(LoggerMessageFormat.format(
"Marvel: Multi-cluster support is disabled for clusters with [{}] licenses.\n" +
"If you are running multiple customers, users won't be able to access this\n" +
"all the clusters with [{}] licenses from a single Marvel instance. To access them\n" +
"a dedicated and separated marvel instance will be required for each cluster",
newLicense.type(), newLicense.type()));
}
}
};
}

View File

@ -7,10 +7,7 @@ package org.elasticsearch.marvel.shield;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.util.Providers;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.shield.authz.Privilege;
/**
*

View File

@ -44,7 +44,7 @@ public class ClusterInfoCollectorTests extends AbstractCollectorTestCase {
assertThat(clusterInfoMarvelDoc.getClusterStats().getNodesStats().getCounts().getTotal(), equalTo(internalCluster().getNodeNames().length));
}
@Test
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
public void testClusterInfoCollectorWithLicensing() {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {

View File

@ -116,7 +116,7 @@ public class ClusterStateCollectorTests extends AbstractCollectorTestCase {
}
}
@Test
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
public void testClusterStateCollectorWithLicensing() {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {

View File

@ -37,7 +37,7 @@ public class ClusterStatsCollectorTests extends AbstractCollectorTestCase {
assertThat(clusterStatsMarvelDoc.getClusterStats().getNodesStats().getCounts().getTotal(), equalTo(internalCluster().getNodeNames().length));
}
@Test
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
public void testClusterStatsCollectorWithLicensing() {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {

View File

@ -116,7 +116,7 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase {
}
}
@Test
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
public void testIndexRecoveryCollectorWithLicensing() {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {

View File

@ -171,7 +171,7 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase {
}
}
@Test
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
public void testIndexStatsCollectorWithLicensing() {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {

View File

@ -51,7 +51,7 @@ public class NodeStatsCollectorTests extends AbstractCollectorTestCase {
}
}
@Test
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
public void testNodeStatsCollectorWithLicensing() {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {

View File

@ -154,7 +154,7 @@ public class ShardsCollectorTests extends AbstractCollectorTestCase {
}
}
@Test
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
public void testShardsCollectorWithLicensing() {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {

View File

@ -29,6 +29,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
/**
*
@ -40,21 +41,37 @@ public class MarvelIntegTestCase extends ESIntegTestCase {
@Override
protected TestCluster buildTestCluster(Scope scope, long seed) throws IOException {
if (shieldEnabled == null) {
shieldEnabled = false; // enableShield();
shieldEnabled = true; // enableShield();
}
return super.buildTestCluster(scope, seed);
}
@Override
protected Settings nodeSettings(int nodeOrdinal) {
Map<String, String> originalSettings = super.nodeSettings(nodeOrdinal).getAsMap();
if (shieldEnabled) {
originalSettings.remove("index.queries.cache.type"); // setting not supported by shield
}
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(originalSettings)
// we do this by default in core, but for marvel this isn't needed and only adds noise.
.put("index.store.mock.check_index_on_close", false)
.put(ShieldSettings.settings(shieldEnabled))
.build();
}
@Override
protected Settings transportClientSettings() {
if (shieldEnabled) {
return Settings.builder()
.put(super.transportClientSettings())
.put("client.transport.sniff", false)
.put("shield.user", "test:changeme")
.build();
}
return super.transportClientSettings();
}
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
if (shieldEnabled) {