From f2181d5cbfb6f8763b707e4647f719f81f6f5d0d Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Sun, 6 Apr 2014 09:28:11 +0200 Subject: [PATCH] [TEST] Be more verbose if ClusterStatsTests fails --- .../cluster/stats/ClusterStatsTests.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsTests.java b/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsTests.java index bb6c46bcaae..c82eef9db61 100644 --- a/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsTests.java +++ b/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsTests.java @@ -131,27 +131,28 @@ public class ClusterStatsTests extends ElasticsearchIntegrationTest { index("test1", "type", "1", "f", "f"); ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get(); - assertThat(response.getTimestamp(), Matchers.greaterThan(946681200000l)); // 1 Jan 2000 - assertThat(response.indicesStats.getStore().getSizeInBytes(), Matchers.greaterThan(0l)); + String msg = response.toString(); + assertThat(msg, response.getTimestamp(), Matchers.greaterThan(946681200000l)); // 1 Jan 2000 + assertThat(msg, response.indicesStats.getStore().getSizeInBytes(), Matchers.greaterThan(0l)); - assertThat(response.nodesStats.getFs().getTotal().bytes(), Matchers.greaterThan(0l)); - assertThat(response.nodesStats.getJvm().getVersions().size(), Matchers.greaterThan(0)); + assertThat(msg, response.nodesStats.getFs().getTotal().bytes(), Matchers.greaterThan(0l)); + assertThat(msg, response.nodesStats.getJvm().getVersions().size(), Matchers.greaterThan(0)); if (sigarService.sigarAvailable()) { // We only get those if we have sigar - assertThat(response.nodesStats.getOs().getAvailableProcessors(), Matchers.greaterThan(0)); - assertThat(response.nodesStats.getOs().getAvailableMemory().bytes(), Matchers.greaterThan(0l)); - assertThat(response.nodesStats.getOs().getCpus().size(), Matchers.greaterThan(0)); + assertThat(msg, response.nodesStats.getOs().getAvailableProcessors(), Matchers.greaterThan(0)); + assertThat(msg, response.nodesStats.getOs().getAvailableMemory().bytes(), Matchers.greaterThan(0l)); + assertThat(msg, response.nodesStats.getOs().getCpus().size(), Matchers.greaterThan(0)); } - assertThat(response.nodesStats.getVersions().size(), Matchers.greaterThan(0)); - assertThat(response.nodesStats.getVersions().contains(Version.CURRENT), Matchers.equalTo(true)); - assertThat(response.nodesStats.getPlugins().size(), Matchers.greaterThanOrEqualTo(0)); + assertThat(msg, response.nodesStats.getVersions().size(), Matchers.greaterThan(0)); + assertThat(msg, response.nodesStats.getVersions().contains(Version.CURRENT), Matchers.equalTo(true)); + assertThat(msg, response.nodesStats.getPlugins().size(), Matchers.greaterThanOrEqualTo(0)); - assertThat(response.nodesStats.getProcess().count, Matchers.greaterThan(0)); + assertThat(msg, response.nodesStats.getProcess().count, Matchers.greaterThan(0)); // 0 happens when not supported on platform - assertThat(response.nodesStats.getProcess().getAvgOpenFileDescriptors(), Matchers.greaterThanOrEqualTo(0L)); + assertThat(msg, response.nodesStats.getProcess().getAvgOpenFileDescriptors(), Matchers.greaterThanOrEqualTo(0L)); // these can be -1 if not supported on platform - assertThat(response.nodesStats.getProcess().getMinOpenFileDescriptors(), Matchers.greaterThanOrEqualTo(-1L)); - assertThat(response.nodesStats.getProcess().getMaxOpenFileDescriptors(), Matchers.greaterThanOrEqualTo(-1L)); + assertThat(msg, response.nodesStats.getProcess().getMinOpenFileDescriptors(), Matchers.greaterThanOrEqualTo(-1L)); + assertThat(msg, response.nodesStats.getProcess().getMaxOpenFileDescriptors(), Matchers.greaterThanOrEqualTo(-1L)); } }