From 1d72eb2b617937f54e001e93b332cc168e49b1e1 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Fri, 1 Apr 2016 10:34:40 +0200 Subject: [PATCH] Monitoring: Check for source_node only for assigned shard in test Original commit: elastic/x-pack-elasticsearch@f0d5bccecd66f31b19acca1cfa3b22204c2877f5 --- .../agent/collector/shards/ShardsCollectorTests.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollectorTests.java index a333f0af184..8f2553296a0 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollectorTests.java @@ -26,6 +26,7 @@ import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; public class ShardsCollectorTests extends AbstractCollectorTestCase { @@ -132,11 +133,16 @@ public class ShardsCollectorTests extends AbstractCollectorTestCase { assertThat(shardDoc.getMonitoringVersion(), equalTo(Version.CURRENT.toString())); assertThat(shardDoc.getClusterUUID(), equalTo(clusterState.metaData().clusterUUID())); assertThat(shardDoc.getTimestamp(), greaterThan(0L)); - assertThat(shardDoc.getSourceNode(), notNullValue()); assertThat(shardDoc.getClusterStateUUID(), equalTo(clusterState.stateUUID())); ShardRouting shardRouting = shardDoc.getShardRouting(); assertNotNull(shardRouting); + + if (shardRouting.assignedToNode()) { + assertThat(shardDoc.getSourceNode(), notNullValue()); + } else { + assertThat(shardDoc.getSourceNode(), nullValue()); + } } // Checks that a correct number of ShardMarvelDoc documents has been created for each index