Monitoring: Fix NodeStatsResolverTests on Windows platforms

Because load_average is not available on Windows, it must be excluded from test assertions.

Original commit: elastic/x-pack-elasticsearch@f67f9bb5e7
This commit is contained in:
Tanguy Leroux 2016-03-04 17:28:49 +01:00
parent 66e49a0546
commit 452e729a02
2 changed files with 16 additions and 2 deletions

View File

@ -151,8 +151,7 @@ public abstract class MonitoringIndexNameResolverTestCase<M extends MonitoringDo
if (fields != null) {
for (String field : fields) {
assertNotNull("source must contain field [" + field + "] with a non-null value",
XContentMapValues.extractValue(field, sourceFields));
assertSourceField(field, sourceFields);
}
// Checks that no extra fields are present
@ -173,6 +172,11 @@ public abstract class MonitoringIndexNameResolverTestCase<M extends MonitoringDo
}
}
protected void assertSourceField(String field, Map<String, Object> sourceFields) {
assertNotNull("source must contain field [" + field + "] with a non-null value",
XContentMapValues.extractValue(field, sourceFields));
}
protected static String randomMonitoringId() {
return randomFrom(MonitoringIds.values()).getId();
}

View File

@ -5,6 +5,7 @@
*/
package org.elasticsearch.marvel.agent.resolver.node;
import org.apache.lucene.util.Constants;
import org.elasticsearch.Version;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.indices.stats.CommonStats;
@ -77,6 +78,15 @@ public class NodeStatsResolverTests extends MonitoringIndexNameResolverTestCase<
return false;
}
@Override
protected void assertSourceField(String field, Map<String, Object> sourceFields) {
// Assertions on node stats fields that are not reported on Windows platforms
if (Constants.WINDOWS && field.startsWith("node_stats.os.cpu.load_average")) {
return;
}
super.assertSourceField(field, sourceFields);
}
public void testNodeStatsResolver() throws IOException {
NodeStatsMonitoringDoc doc = newMarvelDoc();
doc.setTimestamp(1437580442979L);