Marvel: Disable indexing for nodes attribute in cluster state documents

Closes elastic/elasticsearch#658

Original commit: elastic/x-pack-elasticsearch@bb501aa5b8
This commit is contained in:
Tanguy Leroux 2015-09-17 17:19:07 +02:00
parent db13d99cdf
commit 4d829951b4
2 changed files with 39 additions and 0 deletions

View File

@ -176,6 +176,9 @@
"index": "not_analyzed"
},
"nodes": {
"enabled": false
},
"shards": {
"type": "object"
}
}

View File

@ -6,8 +6,12 @@
package org.elasticsearch.marvel.agent.renderer.cluster;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.marvel.agent.collector.cluster.ClusterStateCollector;
import org.elasticsearch.marvel.agent.exporter.HttpESExporterUtils;
import org.elasticsearch.marvel.agent.renderer.AbstractRendererTestCase;
import org.elasticsearch.marvel.agent.settings.MarvelSettings;
import org.elasticsearch.search.SearchHit;
import org.junit.Test;
@ -15,6 +19,8 @@ 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 {
@ -44,4 +50,34 @@ public class ClusterStateIT extends AbstractRendererTestCase {
logger.debug("--> cluster state successfully collected");
}
/**
* This test should fail if the mapping for the 'nodes' attribute
* in the 'marvel_cluster_state' document is NOT set to 'enable: false'
*
* See
*/
@Test
public void testNoNodesIndexing() throws Exception {
logger.debug("--> forcing marvel's index template update");
assertAcked(client().admin().indices().preparePutTemplate("marvel").setSource(HttpESExporterUtils.loadDefaultTemplate()).execute().actionGet());
logger.debug("--> deleting all marvel indices");
cluster().wipeIndices(MarvelSettings.MARVEL_INDICES_PREFIX + "*");
logger.debug("--> checking for template existence");
assertMarvelTemplateExists();
waitForMarvelDocs(ClusterStateCollector.TYPE);
logger.debug("--> searching for marvel documents of type [{}]", ClusterStateCollector.TYPE);
SearchResponse response = client().prepareSearch().setTypes(ClusterStateCollector.TYPE).get();
assertThat(response.getHits().getTotalHits(), greaterThan(0L));
DiscoveryNodes nodes = client().admin().cluster().prepareState().clear().setNodes(true).get().getState().nodes();
logger.debug("--> ensure that the 'nodes' attributes of the cluster state document is not indexed");
assertHitCount(client().prepareCount()
.setTypes(ClusterStateCollector.TYPE)
.setQuery(QueryBuilders.matchQuery("cluster_state.nodes." + nodes.masterNodeId() + ".name", nodes.masterNode().name())).get(), 0L);
}
}