diff --git a/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollector.java b/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollector.java index cc8fe3dbf79..01f456d9f69 100644 --- a/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollector.java +++ b/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollector.java @@ -16,6 +16,7 @@ import org.elasticsearch.common.inject.Provider; import org.elasticsearch.common.inject.ProvisionException; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.discovery.DiscoveryService; +import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.marvel.agent.collector.AbstractCollector; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; import org.elasticsearch.marvel.agent.settings.MarvelSettings; @@ -40,6 +41,7 @@ public class NodeStatsCollector extends AbstractCollector { private final NodeService nodeService; private final DiscoveryService discoveryService; + private final NodeEnvironment nodeEnvironment; // Use a provider in order to avoid Guice circular injection // issues because AllocationDecider is not an interface and cannot be proxied @@ -47,14 +49,20 @@ public class NodeStatsCollector extends AbstractCollector { @Inject public NodeStatsCollector(Settings settings, ClusterService clusterService, MarvelSettings marvelSettings, LicenseService licenseService, - NodeService nodeService, DiscoveryService discoveryService, + NodeService nodeService, DiscoveryService discoveryService, NodeEnvironment nodeEnvironment, Provider diskThresholdDeciderProvider) { super(settings, NAME, clusterService, marvelSettings, licenseService); this.nodeService = nodeService; this.discoveryService = discoveryService; + this.nodeEnvironment = nodeEnvironment; this.diskThresholdDeciderProvider = diskThresholdDeciderProvider; } + @Override + protected boolean canCollect() { + return super.canCollect() && nodeEnvironment.hasNodeFile(); + } + @Override protected Collection doCollect() throws Exception { List results = new ArrayList<>(1); diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/AbstractCollectorTestCase.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/AbstractCollectorTestCase.java index b00b7a18c25..8fc03e80d33 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/AbstractCollectorTestCase.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/AbstractCollectorTestCase.java @@ -48,13 +48,12 @@ public class AbstractCollectorTestCase extends MarvelIntegTestCase { return Arrays.asList(LicensePluginForCollectors.class, MarvelPlugin.class); } - @Override protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) .put(Node.HTTP_ENABLED, false) - .put(MarvelSettings.INTERVAL, "60m") + .put(MarvelSettings.INTERVAL, "-1") .build(); } diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollectorTests.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollectorTests.java index c33dcfb7e9d..0bade284ef2 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollectorTests.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollectorTests.java @@ -54,7 +54,9 @@ public class ClusterStateCollectorTests extends AbstractCollectorTestCase { for (int i = 0; i < nbDocs; i++) { client().prepareIndex("test", "test").setSource("num", i).get(); } - client().admin().indices().prepareRefresh().get(); + + securedFlush(); + securedRefresh(); assertHitCount(client().prepareCount().get(), nbDocs); Collection results = newClusterStateCollector().doCollect(); diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexRecoveryCollectorTests.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexRecoveryCollectorTests.java index 6d3a9bed919..1a31daa8354 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexRecoveryCollectorTests.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexRecoveryCollectorTests.java @@ -14,7 +14,7 @@ import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; import org.elasticsearch.marvel.agent.settings.MarvelSettings; import org.elasticsearch.marvel.license.LicenseService; -import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.junit.Test; import java.util.Collection; @@ -28,7 +28,7 @@ import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcke import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.hamcrest.Matchers.*; -@ESIntegTestCase.ClusterScope(numDataNodes = 0) +@ClusterScope(numDataNodes = 0, numClientNodes = 0, transportClientRatio = 0.0) public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase { private final boolean activeOnly = false; diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java index e6ba1589ec3..19def3556a2 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java @@ -11,6 +11,7 @@ import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider import org.elasticsearch.common.inject.Provider; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.discovery.DiscoveryService; +import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MarvelDoc; import org.elasticsearch.marvel.agent.settings.MarvelSettings; @@ -84,6 +85,7 @@ public class NodeStatsCollectorTests extends AbstractCollectorTestCase { internalCluster().getInstance(LicenseService.class, nodeId), internalCluster().getInstance(NodeService.class, nodeId), internalCluster().getInstance(DiscoveryService.class, nodeId), + internalCluster().getInstance(NodeEnvironment.class, nodeId), new Provider() { @Override public DiskThresholdDecider get() { diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/AbstractRendererTestCase.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/AbstractRendererTestCase.java deleted file mode 100644 index 338ff46c157..00000000000 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/AbstractRendererTestCase.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.marvel.agent.renderer; - -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.marvel.agent.settings.MarvelSettings; -import org.elasticsearch.marvel.test.MarvelIntegTestCase; -import org.elasticsearch.node.Node; -import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.test.ESIntegTestCase.ClusterScope; -import org.junit.After; -import org.junit.Before; - -import java.util.Collection; -import java.util.Map; - -import static org.hamcrest.Matchers.*; - - -@ClusterScope(scope = ESIntegTestCase.Scope.TEST, randomDynamicTemplates = false, transportClientRatio = 0.0) -public abstract class AbstractRendererTestCase extends MarvelIntegTestCase { - - @Override - protected Settings nodeSettings(int nodeOrdinal) { - return Settings.builder() - .put(super.nodeSettings(nodeOrdinal)) - .put(Node.HTTP_ENABLED, true) - .put(MarvelSettings.STARTUP_DELAY, "3s") - .put(MarvelSettings.INTERVAL, "1s") - .put(MarvelSettings.COLLECTORS, Strings.collectionToCommaDelimitedString(collectors())) - .build(); - } - - @Before - public void init() throws Exception { - startCollection(); - } - - @After - public void cleanup() throws Exception { - stopCollection(); - } - - protected abstract Collection collectors (); - - /** - * Checks if a field exist in a map of values. If the field contains a dot like 'foo.bar' - * it checks that 'foo' exists in the map of values and that it points to a sub-map. Then - * it recurses to check if 'bar' exists in the sub-map. - */ - protected void assertContains(String field, Map values) { - assertNotNull("field name should not be null", field); - assertNotNull("values map should not be null", values); - - int point = field.indexOf('.'); - if (point > -1) { - assertThat(point, allOf(greaterThan(0), lessThan(field.length()))); - - String segment = field.substring(0, point); - assertTrue(Strings.hasText(segment)); - - boolean fieldExists = values.containsKey(segment); - assertTrue("expecting field [" + segment + "] to be present in marvel document", fieldExists); - - Object value = values.get(segment); - String next = field.substring(point + 1); - if (next.length() > 0) { - assertTrue(value instanceof Map); - assertContains(next, (Map) value); - } else { - assertFalse(value instanceof Map); - } - } else { - assertTrue("expecting field [" + field + "] to be present in marvel document", values.containsKey(field)); - } - } -} diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterInfoIT.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterInfoIT.java index bb2f6a57d52..fbb44ec612c 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterInfoIT.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterInfoIT.java @@ -8,15 +8,14 @@ package org.elasticsearch.marvel.agent.renderer.cluster; import org.elasticsearch.Version; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.license.core.License; import org.elasticsearch.marvel.agent.collector.cluster.ClusterInfoCollector; -import org.elasticsearch.marvel.agent.renderer.AbstractRendererTestCase; import org.elasticsearch.marvel.agent.settings.MarvelSettings; +import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.junit.Test; -import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; @@ -25,15 +24,21 @@ import java.util.concurrent.TimeUnit; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.hamcrest.Matchers.*; -public class ClusterInfoIT extends AbstractRendererTestCase { +public class ClusterInfoIT extends MarvelIntegTestCase { @Override - protected Collection collectors() { - return Collections.singletonList(ClusterInfoCollector.NAME); + protected Settings nodeSettings(int nodeOrdinal) { + return Settings.builder() + .put(super.nodeSettings(nodeOrdinal)) + .put(MarvelSettings.INTERVAL, "3s") + .put(MarvelSettings.COLLECTORS, ClusterInfoCollector.NAME) + .build(); } @Test public void testClusterInfo() throws Exception { + ensureGreen(); + final String clusterUUID = client().admin().cluster().prepareState().setMetaData(true).get().getState().metaData().clusterUUID(); assertTrue(Strings.hasText(clusterUUID)); @@ -64,8 +69,9 @@ public class ClusterInfoIT extends AbstractRendererTestCase { Object licensesList = source.get(ClusterInfoRenderer.Fields.LICENSES.underscore().toString()); assertThat(licensesList, instanceOf(List.class)); + logger.warn("--> checking number of licenses [internal cluster:{}, shield enabled:{}]", isInternalCluster(), shieldEnabled); List licenses = (List) licensesList; - assertThat(licenses.size(), equalTo(shieldEnabled ? 2 : 1)); + assertThat(licenses.size(), equalTo(isInternalCluster() && shieldEnabled ? 2 : 1)); Map license = (Map) licenses.iterator().next(); assertThat(license, instanceOf(Map.class)); diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterStateIT.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterStateIT.java index 4aa708dfcc6..2d6f561b6b0 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterStateIT.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterStateIT.java @@ -7,30 +7,36 @@ package org.elasticsearch.marvel.agent.renderer.cluster; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.cluster.node.DiscoveryNodes; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.marvel.agent.collector.cluster.ClusterStateCollector; import org.elasticsearch.marvel.agent.exporter.http.HttpExporterUtils; -import org.elasticsearch.marvel.agent.renderer.AbstractRendererTestCase; +import org.elasticsearch.marvel.agent.settings.MarvelSettings; +import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.search.SearchHit; import org.junit.Test; -import java.util.Collection; -import java.util.Collections; import java.util.Map; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.hamcrest.Matchers.greaterThan; -public class ClusterStateIT extends AbstractRendererTestCase { +public class ClusterStateIT extends MarvelIntegTestCase { @Override - protected Collection collectors() { - return Collections.singletonList(ClusterStateCollector.NAME); + protected Settings nodeSettings(int nodeOrdinal) { + return Settings.builder() + .put(super.nodeSettings(nodeOrdinal)) + .put(MarvelSettings.INTERVAL, "3s") + .put(MarvelSettings.COLLECTORS, ClusterStateCollector.NAME) + .build(); } @Test public void testClusterState() throws Exception { + ensureGreen(); + awaitMarvelDocsCount(greaterThan(0L), ClusterStateCollector.TYPE); logger.debug("--> searching for marvel documents of type [{}]", ClusterStateCollector.TYPE); @@ -59,6 +65,8 @@ public class ClusterStateIT extends AbstractRendererTestCase { */ @Test public void testNoNodesIndexing() throws Exception { + ensureGreen(); + logger.debug("--> forcing marvel's index template update"); assertAcked(client().admin().indices().preparePutTemplate("marvel").setSource(HttpExporterUtils.loadDefaultTemplate()).execute().actionGet()); @@ -66,8 +74,8 @@ public class ClusterStateIT extends AbstractRendererTestCase { deleteMarvelIndices(); logger.debug("--> checking for template existence"); - assertMarvelTemplateInstalled(); awaitMarvelDocsCount(greaterThan(0L), ClusterStateCollector.TYPE); + assertMarvelTemplateInstalled(); logger.debug("--> searching for marvel documents of type [{}]", ClusterStateCollector.TYPE); SearchResponse response = client().prepareSearch().setTypes(ClusterStateCollector.TYPE).get(); diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterStatsIT.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterStatsIT.java index 36e9a724180..bdcfc4d23b9 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterStatsIT.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/cluster/ClusterStatsIT.java @@ -5,41 +5,74 @@ */ package org.elasticsearch.marvel.agent.renderer.cluster; +import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; +import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; +import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; +import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; +import org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodes; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse; import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.marvel.agent.collector.cluster.ClusterStatsCollector; -import org.elasticsearch.marvel.agent.renderer.AbstractRendererTestCase; +import org.elasticsearch.marvel.agent.settings.MarvelSettings; +import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.search.SearchHit; import org.junit.Test; -import java.util.Collection; -import java.util.Collections; import java.util.Map; import java.util.concurrent.TimeUnit; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.greaterThan; -public class ClusterStatsIT extends AbstractRendererTestCase { +public class ClusterStatsIT extends MarvelIntegTestCase { @Override - protected Collection collectors() { - return Collections.singletonList(ClusterStatsCollector.NAME); + protected Settings nodeSettings(int nodeOrdinal) { + return Settings.builder() + .put(super.nodeSettings(nodeOrdinal)) + .put(MarvelSettings.INTERVAL, "3s") + .put(MarvelSettings.COLLECTORS, ClusterStatsCollector.NAME) + .build(); } @Test public void testClusterStats() throws Exception { - logger.debug("--> creating some indices so that cluster stats reports data about shards"); + ensureGreen(); + + logger.debug("--> creating some indices so that every data nodes will at leats a shard"); + ClusterStatsNodes.Counts counts = client().admin().cluster().prepareClusterStats().get().getNodesStats().getCounts(); + assertThat(counts.getTotal(), greaterThan(0)); + for (int i = 0; i < randomIntBetween(1, 5); i++) { - createIndex("test-" + i); + assertAcked(prepareCreate("test-" + i).setSettings(Settings.settingsBuilder() + .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, counts.getDataOnly() + counts.getMasterData()) + .build())); + index("test-" + i, "foo", "1", jsonBuilder().startObject().field("dummy_field", 1).endObject()); } - logger.debug("--> wait for cluster stats to report data about shards"); + securedFlush(); + securedRefresh(); + + logger.debug("--> waiting for cluster stats to report data for each node"); assertBusy(new Runnable() { @Override public void run() { - ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get(); - assertNotNull(response.getIndicesStats().getShards()); - assertThat(response.getIndicesStats().getShards().getTotal(), greaterThan(0)); + NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().get(); + for (Map.Entry node : nodesInfoResponse.getNodesMap().entrySet()) { + // Checks that node has shards + ClusterStatsResponse clusterStatsResponse = client().admin().cluster().prepareClusterStats().setNodesIds(node.getKey()).get(); + assertNotNull(clusterStatsResponse.getIndicesStats().getShards()); + assertNotNull(clusterStatsResponse.getIndicesStats().getShards()); + assertThat(clusterStatsResponse.getIndicesStats().getShards().getTotal(), greaterThan(0)); + + NodesStatsResponse nodeStatsResponse = client().admin().cluster().prepareNodesStats(node.getKey()).setFs(true).get(); + for (NodeStats nodeStats : nodeStatsResponse) { + assertThat(nodeStats.getFs().total().getAvailable().bytes(), greaterThan(-1L)); + } + } } }, 30L, TimeUnit.SECONDS); diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/indices/IndexRecoveryIT.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/indices/IndexRecoveryIT.java index ef1091d53c0..4573e5151f3 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/indices/IndexRecoveryIT.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/indices/IndexRecoveryIT.java @@ -6,22 +6,26 @@ package org.elasticsearch.marvel.agent.renderer.indices; import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.marvel.agent.collector.indices.IndexRecoveryCollector; -import org.elasticsearch.marvel.agent.renderer.AbstractRendererTestCase; +import org.elasticsearch.marvel.agent.settings.MarvelSettings; +import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.search.SearchHit; import org.junit.Test; -import java.util.Collection; -import java.util.Collections; import java.util.Map; import static org.hamcrest.Matchers.greaterThan; -public class IndexRecoveryIT extends AbstractRendererTestCase { +public class IndexRecoveryIT extends MarvelIntegTestCase { @Override - protected Collection collectors() { - return Collections.singletonList(IndexRecoveryCollector.NAME); + protected Settings nodeSettings(int nodeOrdinal) { + return Settings.builder() + .put(super.nodeSettings(nodeOrdinal)) + .put(MarvelSettings.INTERVAL, "3s") + .put(MarvelSettings.COLLECTORS, IndexRecoveryCollector.NAME) + .build(); } @Test diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/indices/IndexStatsIT.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/indices/IndexStatsIT.java index b5df0997e9a..d58ca02f315 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/indices/IndexStatsIT.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/indices/IndexStatsIT.java @@ -7,23 +7,27 @@ package org.elasticsearch.marvel.agent.renderer.indices; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.marvel.agent.collector.indices.IndexStatsCollector; -import org.elasticsearch.marvel.agent.renderer.AbstractRendererTestCase; +import org.elasticsearch.marvel.agent.settings.MarvelSettings; +import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.search.SearchHit; import org.junit.Test; -import java.util.Collection; -import java.util.Collections; import java.util.Map; import static org.hamcrest.Matchers.greaterThan; -public class IndexStatsIT extends AbstractRendererTestCase { +public class IndexStatsIT extends MarvelIntegTestCase { @Override - protected Collection collectors() { - return Collections.singletonList(IndexStatsCollector.NAME); + protected Settings nodeSettings(int nodeOrdinal) { + return Settings.builder() + .put(super.nodeSettings(nodeOrdinal)) + .put(MarvelSettings.INTERVAL, "3s") + .put(MarvelSettings.COLLECTORS, IndexStatsCollector.NAME) + .build(); } @Test @@ -44,6 +48,8 @@ public class IndexStatsIT extends AbstractRendererTestCase { } } + ensureGreen(); + awaitMarvelDocsCount(greaterThan(0L), IndexStatsCollector.TYPE); logger.debug("--> wait for index stats collector to collect stat for each index"); diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/indices/IndicesStatsIT.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/indices/IndicesStatsIT.java index f666ab09aa3..e48c5d1aa84 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/indices/IndicesStatsIT.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/indices/IndicesStatsIT.java @@ -7,22 +7,26 @@ package org.elasticsearch.marvel.agent.renderer.indices; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.marvel.agent.collector.indices.IndicesStatsCollector; -import org.elasticsearch.marvel.agent.renderer.AbstractRendererTestCase; +import org.elasticsearch.marvel.agent.settings.MarvelSettings; +import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.search.SearchHit; import org.junit.Test; -import java.util.Collection; -import java.util.Collections; import java.util.Map; import static org.hamcrest.Matchers.greaterThan; -public class IndicesStatsIT extends AbstractRendererTestCase { +public class IndicesStatsIT extends MarvelIntegTestCase { @Override - protected Collection collectors() { - return Collections.singletonList(IndicesStatsCollector.NAME); + protected Settings nodeSettings(int nodeOrdinal) { + return Settings.builder() + .put(super.nodeSettings(nodeOrdinal)) + .put(MarvelSettings.INTERVAL, "3s") + .put(MarvelSettings.COLLECTORS, IndicesStatsCollector.NAME) + .build(); } @Test diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/node/NodeStatsIT.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/node/NodeStatsIT.java index e0f00a1f169..fcb887d2ca9 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/node/NodeStatsIT.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/node/NodeStatsIT.java @@ -6,22 +6,26 @@ package org.elasticsearch.marvel.agent.renderer.node; import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.marvel.agent.collector.node.NodeStatsCollector; -import org.elasticsearch.marvel.agent.renderer.AbstractRendererTestCase; +import org.elasticsearch.marvel.agent.settings.MarvelSettings; +import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.search.SearchHit; import org.junit.Test; -import java.util.Collection; -import java.util.Collections; import java.util.Map; import static org.hamcrest.Matchers.greaterThan; -public class NodeStatsIT extends AbstractRendererTestCase { +public class NodeStatsIT extends MarvelIntegTestCase { @Override - protected Collection collectors() { - return Collections.singletonList(NodeStatsCollector.NAME); + protected Settings nodeSettings(int nodeOrdinal) { + return Settings.builder() + .put(super.nodeSettings(nodeOrdinal)) + .put(MarvelSettings.INTERVAL, "3s") + .put(MarvelSettings.COLLECTORS, NodeStatsCollector.NAME) + .build(); } @Test diff --git a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/shards/ShardsIT.java b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/shards/ShardsIT.java index de20621e081..4a7498d9c7f 100644 --- a/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/shards/ShardsIT.java +++ b/marvel/src/test/java/org/elasticsearch/marvel/agent/renderer/shards/ShardsIT.java @@ -6,22 +6,26 @@ package org.elasticsearch.marvel.agent.renderer.shards; import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.marvel.agent.collector.shards.ShardsCollector; -import org.elasticsearch.marvel.agent.renderer.AbstractRendererTestCase; +import org.elasticsearch.marvel.agent.settings.MarvelSettings; +import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.search.SearchHit; import org.junit.Test; -import java.util.Collection; -import java.util.Collections; import java.util.Map; import static org.hamcrest.Matchers.greaterThan; -public class ShardsIT extends AbstractRendererTestCase { +public class ShardsIT extends MarvelIntegTestCase { @Override - protected Collection collectors() { - return Collections.singletonList(ShardsCollector.NAME); + protected Settings nodeSettings(int nodeOrdinal) { + return Settings.builder() + .put(super.nodeSettings(nodeOrdinal)) + .put(MarvelSettings.INTERVAL, "3s") + .put(MarvelSettings.COLLECTORS, ShardsCollector.NAME) + .build(); } @Test