Marvel: remove remaining @AwaitsFix and re enable licensing tests

Original commit: elastic/x-pack-elasticsearch@5e2eedae6d
This commit is contained in:
Tanguy Leroux 2015-10-12 17:31:38 +02:00
parent ef86ea87f6
commit 704f9b12bc
8 changed files with 258 additions and 201 deletions

View File

@ -5,6 +5,7 @@
*/
package org.elasticsearch.marvel.agent.collector.cluster;
import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.Version;
import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse;
import org.elasticsearch.client.Client;
@ -13,6 +14,7 @@ import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.core.License;
import org.elasticsearch.license.plugin.core.LicenseUtils;
import org.elasticsearch.marvel.agent.collector.AbstractCollector;
import org.elasticsearch.marvel.agent.exporter.MarvelDoc;
import org.elasticsearch.marvel.agent.settings.MarvelSettings;
@ -62,7 +64,16 @@ public class ClusterInfoCollector extends AbstractCollector<ClusterInfoMarvelDoc
License license = marvelLicensee.getLicense();
// Retrieves additional cluster stats
ClusterStatsResponse clusterStats = client.admin().cluster().prepareClusterStats().get(marvelSettings.clusterStatsTimeout());
ClusterStatsResponse clusterStats = null;
try {
clusterStats = client.admin().cluster().prepareClusterStats().get(marvelSettings.clusterStatsTimeout());
} catch (ElasticsearchSecurityException e) {
if (LicenseUtils.isLicenseExpiredException(e)) {
logger.trace("collector [{}] - unable to collect data because of expired license", e, name());
} else {
throw e;
}
}
String clusterUUID = clusterUUID();
results.add(new ClusterInfoMarvelDoc(MarvelSettings.MARVEL_DATA_INDEX_NAME, TYPE, clusterUUID, clusterUUID, System.currentTimeMillis(),

View File

@ -20,10 +20,7 @@ import static org.hamcrest.Matchers.*;
public class ClusterInfoCollectorTests extends AbstractCollectorTestCase {
// This test is muted for now until licensing stuff is updated.
// Right now AbstractCollectorTestCase only registers license for Marvel,
// so license count at line 56 will always be 1 even when Shield is enabled
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
@Test
public void testClusterInfoCollector() throws Exception {
Collection<MarvelDoc> results = newClusterInfoCollector().doCollect();
assertThat(results, hasSize(1));
@ -46,8 +43,9 @@ public class ClusterInfoCollectorTests extends AbstractCollectorTestCase {
assertThat(clusterInfoMarvelDoc.getClusterStats().getNodesStats().getCounts().getTotal(), equalTo(internalCluster().getNodeNames().length));
}
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
@Test
public void testClusterInfoCollectorWithLicensing() {
try {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {
logger.debug("--> creating a new instance of the collector");
@ -86,6 +84,10 @@ public class ClusterInfoCollectorTests extends AbstractCollectorTestCase {
assertCannotCollect(collector);
}
}
} finally {
// Ensure license is enabled before finishing the test
enableLicense();
}
}
private ClusterInfoCollector newClusterInfoCollector() {

View File

@ -119,8 +119,9 @@ public class ClusterStateCollectorTests extends AbstractCollectorTestCase {
}
}
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
@Test
public void testClusterStateCollectorWithLicensing() {
try {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {
logger.debug("--> creating a new instance of the collector");
@ -151,6 +152,10 @@ public class ClusterStateCollectorTests extends AbstractCollectorTestCase {
disableLicense();
assertCannotCollect(collector);
}
} finally {
// Ensure license is enabled before finishing the test
enableLicense();
}
}
private ClusterStateCollector newClusterStateCollector() {

View File

@ -37,8 +37,9 @@ public class ClusterStatsCollectorTests extends AbstractCollectorTestCase {
assertThat(clusterStatsMarvelDoc.getClusterStats().getNodesStats().getCounts().getTotal(), equalTo(internalCluster().getNodeNames().length));
}
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
@Test
public void testClusterStatsCollectorWithLicensing() {
try {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {
logger.debug("--> creating a new instance of the collector");
@ -69,6 +70,10 @@ public class ClusterStatsCollectorTests extends AbstractCollectorTestCase {
disableLicense();
assertCannotCollect(collector);
}
} finally {
// Ensure license is enabled before finishing the test
enableLicense();
}
}
private ClusterStatsCollector newClusterStatsCollector() {

View File

@ -116,8 +116,9 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase {
}
}
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
@Test
public void testIndexRecoveryCollectorWithLicensing() {
try {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {
logger.debug("--> creating a new instance of the collector");
@ -148,6 +149,10 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase {
disableLicense();
assertCannotCollect(collector);
}
} finally {
// Ensure license is enabled before finishing the test
enableLicense();
}
}
private IndexRecoveryCollector newIndexRecoveryCollector(String nodeId) {

View File

@ -133,8 +133,18 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase {
}
}
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
@Test
public void testIndexStatsCollectorWithLicensing() {
try {
final int nbDocs = randomIntBetween(1, 20);
for (int i = 0; i < nbDocs; i++) {
client().prepareIndex("test", "test").setSource("num", i).get();
}
securedFlush();
securedRefresh();
securedEnsureGreen("test");
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {
logger.debug("--> creating a new instance of the collector");
@ -165,6 +175,10 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase {
disableLicense();
assertCannotCollect(collector);
}
} finally {
// Ensure license is enabled before finishing the test
enableLicense();
}
}
private IndexStatsCollector newIndexStatsCollector() {

View File

@ -17,12 +17,17 @@ import org.elasticsearch.marvel.agent.exporter.MarvelDoc;
import org.elasticsearch.marvel.agent.settings.MarvelSettings;
import org.elasticsearch.marvel.license.MarvelLicensee;
import org.elasticsearch.node.service.NodeService;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.junit.Test;
import java.util.Collection;
import static org.hamcrest.Matchers.*;
// numClientNodes is set to 0 in this test because the NodeStatsCollector never collects data on client nodes:
// the NodeStatsCollector.shouldCollect() method checks if the node has node files and client nodes don't have
// such files.
@ClusterScope(numClientNodes = 0)
public class NodeStatsCollectorTests extends AbstractCollectorTestCase {
@Test
@ -52,8 +57,9 @@ public class NodeStatsCollectorTests extends AbstractCollectorTestCase {
}
}
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
@Test
public void testNodeStatsCollectorWithLicensing() {
try {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {
logger.debug("--> creating a new instance of the collector");
@ -76,6 +82,10 @@ public class NodeStatsCollectorTests extends AbstractCollectorTestCase {
disableLicense();
assertCannotCollect(collector);
}
} finally {
// Ensure license is enabled before finishing the test
enableLicense();
}
}
private NodeStatsCollector newNodeStatsCollector(final String nodeId) {

View File

@ -154,8 +154,9 @@ public class ShardsCollectorTests extends AbstractCollectorTestCase {
}
}
@Test @AwaitsFix(bugUrl = "https://github.com/elastic/x-plugins/issues/683")
@Test
public void testShardsCollectorWithLicensing() {
try {
String[] nodes = internalCluster().getNodeNames();
for (String node : nodes) {
logger.debug("--> creating a new instance of the collector");
@ -186,6 +187,10 @@ public class ShardsCollectorTests extends AbstractCollectorTestCase {
disableLicense();
assertCannotCollect(collector);
}
} finally {
// Ensure license is enabled before finishing the test
enableLicense();
}
}
private ShardsCollector newShardsCollector() {