thorough plugin integration tests
Original commit: elastic/x-pack-elasticsearch@ff361ee49c
This commit is contained in:
parent
c2c1eeeb97
commit
d431c8b532
|
@ -17,6 +17,8 @@ import org.elasticsearch.license.plugin.action.put.PutLicenseRequestBuilder;
|
||||||
import org.elasticsearch.license.plugin.action.put.PutLicenseResponse;
|
import org.elasticsearch.license.plugin.action.put.PutLicenseResponse;
|
||||||
import org.elasticsearch.license.plugin.core.LicensesStatus;
|
import org.elasticsearch.license.plugin.core.LicensesStatus;
|
||||||
import org.elasticsearch.test.InternalTestCluster;
|
import org.elasticsearch.test.InternalTestCluster;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -31,7 +33,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
@ClusterScope(scope = TEST, numDataNodes = 10, numClientNodes = 0)
|
@ClusterScope(scope = TEST, numDataNodes = 10, numClientNodes = 0)
|
||||||
public class LicensesPluginIntegrationTests extends AbstractLicensesIntegrationTests {
|
public class LicensesPluginIntegrationTests extends AbstractLicensesIntegrationTests {
|
||||||
|
|
||||||
private final int trialLicenseDurationInSeconds = 5;
|
private final int trialLicenseDurationInSeconds = 2;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Settings nodeSettings(int nodeOrdinal) {
|
protected Settings nodeSettings(int nodeOrdinal) {
|
||||||
|
@ -42,13 +44,18 @@ public class LicensesPluginIntegrationTests extends AbstractLicensesIntegrationT
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void beforeTest() throws Exception {
|
||||||
|
wipeAllLicenses();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test1() throws Exception {
|
public void testTrialLicenseAndSignedLicenseNotification() throws Exception {
|
||||||
logger.info(" --> trial license generated");
|
logger.info(" --> trial license generated");
|
||||||
// managerService should report feature to be enabled on all data nodes
|
// managerService should report feature to be enabled on all data nodes
|
||||||
assertLicenseManagerEnabledFeatureFor(TestPluginService.FEATURE_NAME);
|
assertLicenseManagerEnabledFeatureFor(TestPluginService.FEATURE_NAME);
|
||||||
// consumer plugin service should return enabled on all data nodes
|
// consumer plugin service should return enabled on all data nodes
|
||||||
assertConsumerPluginEnableNotification(2);
|
assertConsumerPluginEnableNotification(1);
|
||||||
|
|
||||||
logger.info(" --> check trial license expiry notification");
|
logger.info(" --> check trial license expiry notification");
|
||||||
// consumer plugin should notify onDisabled on all data nodes (expired trial license)
|
// consumer plugin should notify onDisabled on all data nodes (expired trial license)
|
||||||
|
@ -56,19 +63,69 @@ public class LicensesPluginIntegrationTests extends AbstractLicensesIntegrationT
|
||||||
assertLicenseManagerDisabledFeatureFor(TestPluginService.FEATURE_NAME);
|
assertLicenseManagerDisabledFeatureFor(TestPluginService.FEATURE_NAME);
|
||||||
|
|
||||||
logger.info(" --> put signed license");
|
logger.info(" --> put signed license");
|
||||||
ESLicense license = generateSignedLicense(TestPluginService.FEATURE_NAME, TimeValue.timeValueSeconds(5));
|
ESLicense license = generateSignedLicense(TestPluginService.FEATURE_NAME, TimeValue.timeValueSeconds(trialLicenseDurationInSeconds));
|
||||||
final PutLicenseResponse putLicenseResponse = new PutLicenseRequestBuilder(client().admin().cluster()).setLicense(Lists.newArrayList(license)).get();
|
final PutLicenseResponse putLicenseResponse = new PutLicenseRequestBuilder(client().admin().cluster()).setLicense(Lists.newArrayList(license)).get();
|
||||||
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
||||||
|
|
||||||
logger.info(" --> check signed license enabled notification");
|
logger.info(" --> check signed license enabled notification");
|
||||||
// consumer plugin should notify onEnabled on all data nodes (signed license)
|
// consumer plugin should notify onEnabled on all data nodes (signed license)
|
||||||
assertConsumerPluginEnableNotification(2);
|
assertConsumerPluginEnableNotification(1);
|
||||||
assertLicenseManagerEnabledFeatureFor(TestPluginService.FEATURE_NAME);
|
assertLicenseManagerEnabledFeatureFor(TestPluginService.FEATURE_NAME);
|
||||||
|
|
||||||
logger.info(" --> check signed license expiry notification");
|
logger.info(" --> check signed license expiry notification");
|
||||||
// consumer plugin should notify onDisabled on all data nodes (expired signed license)
|
// consumer plugin should notify onDisabled on all data nodes (expired signed license)
|
||||||
assertConsumerPluginDisableNotification(5 * 2);
|
assertConsumerPluginDisableNotification(trialLicenseDurationInSeconds * 2);
|
||||||
|
assertLicenseManagerDisabledFeatureFor(TestPluginService.FEATURE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTrialLicenseNotification() throws Exception {
|
||||||
|
logger.info(" --> check onEnabled for trial license");
|
||||||
|
// managerService should report feature to be enabled on all data nodes
|
||||||
|
assertLicenseManagerEnabledFeatureFor(TestPluginService.FEATURE_NAME);
|
||||||
|
// consumer plugin service should return enabled on all data nodes
|
||||||
|
assertConsumerPluginEnableNotification(1);
|
||||||
|
|
||||||
|
logger.info(" --> sleep for rest of trailLicense duration");
|
||||||
|
Thread.sleep(trialLicenseDurationInSeconds * 1000l);
|
||||||
|
|
||||||
|
logger.info(" --> check trial license expiry notification");
|
||||||
|
// consumer plugin should notify onDisabled on all data nodes (expired signed license)
|
||||||
|
assertConsumerPluginDisableNotification(trialLicenseDurationInSeconds);
|
||||||
|
assertLicenseManagerDisabledFeatureFor(TestPluginService.FEATURE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOverlappingTrialAndSignedLicenseNotification() throws Exception {
|
||||||
|
logger.info(" --> check onEnabled for trial license");
|
||||||
|
// managerService should report feature to be enabled on all data nodes
|
||||||
|
assertLicenseManagerEnabledFeatureFor(TestPluginService.FEATURE_NAME);
|
||||||
|
// consumer plugin service should return enabled on all data nodes
|
||||||
|
assertConsumerPluginEnableNotification(1);
|
||||||
|
|
||||||
|
logger.info(" --> put signed license while trial license is in effect");
|
||||||
|
ESLicense license = generateSignedLicense(TestPluginService.FEATURE_NAME, TimeValue.timeValueSeconds(trialLicenseDurationInSeconds * 2));
|
||||||
|
final PutLicenseResponse putLicenseResponse = new PutLicenseRequestBuilder(client().admin().cluster()).setLicense(Lists.newArrayList(license)).get();
|
||||||
|
assertThat(putLicenseResponse.isAcknowledged(), equalTo(true));
|
||||||
|
assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID));
|
||||||
|
|
||||||
|
logger.info(" --> check signed license enabled notification");
|
||||||
|
// consumer plugin should notify onEnabled on all data nodes (signed license)
|
||||||
|
assertConsumerPluginEnableNotification(1);
|
||||||
|
assertLicenseManagerEnabledFeatureFor(TestPluginService.FEATURE_NAME);
|
||||||
|
|
||||||
|
logger.info(" --> sleep for rest of trailLicense duration");
|
||||||
|
Thread.sleep(trialLicenseDurationInSeconds * 1000l);
|
||||||
|
|
||||||
|
logger.info(" --> check consumer is still enabled [signed license]");
|
||||||
|
// consumer plugin should notify onEnabled on all data nodes (signed license)
|
||||||
|
assertConsumerPluginEnableNotification(1);
|
||||||
|
assertLicenseManagerEnabledFeatureFor(TestPluginService.FEATURE_NAME);
|
||||||
|
|
||||||
|
logger.info(" --> check signed license expiry notification");
|
||||||
|
// consumer plugin should notify onDisabled on all data nodes (expired signed license)
|
||||||
|
assertConsumerPluginDisableNotification(trialLicenseDurationInSeconds * 2 * 2);
|
||||||
assertLicenseManagerDisabledFeatureFor(TestPluginService.FEATURE_NAME);
|
assertLicenseManagerDisabledFeatureFor(TestPluginService.FEATURE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue