[TEST] more consistent toString on cluster state, print with assertTimeout
This commit is contained in:
parent
feb81e228b
commit
6a4f61a7d2
|
@ -31,6 +31,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
import org.elasticsearch.common.xcontent.XContentBuilderString;
|
||||||
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -234,22 +235,15 @@ public class ClusterHealthResponse extends ActionResponse implements Iterable<Cl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder("ClusterHealthResponse - status [").append(status).append("]")
|
try {
|
||||||
.append("\ntimedOut [").append(timedOut).append("]")
|
XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
|
||||||
.append("\nclustername [").append(clusterName).append("]")
|
builder.startObject();
|
||||||
.append("\nnumberOfNodes [").append(numberOfNodes).append("]")
|
toXContent(builder, EMPTY_PARAMS);
|
||||||
.append("\nnumberOfDataNodes [").append(numberOfDataNodes).append("]")
|
builder.endObject();
|
||||||
.append("\nactiveShards [").append(activeShards).append("]")
|
return builder.string();
|
||||||
.append("\nrelocatingShards [").append(relocatingShards).append("]")
|
} catch (IOException e) {
|
||||||
.append("\nactivePrimaryShards [").append(activePrimaryShards).append("]")
|
return "{ \"error\" : \"" + e.getMessage() + "\"}";
|
||||||
.append("\ninitializingShards [").append(initializingShards).append("]")
|
|
||||||
.append("\nvalidationFailures ").append(validationFailures)
|
|
||||||
.append("\nindices:");
|
|
||||||
|
|
||||||
for (Map.Entry<String, ClusterIndexHealth> indexEntry : indices.entrySet()) {
|
|
||||||
builder.append(" [").append(indexEntry.getKey()).append("][").append(indexEntry.getValue().status).append("]");
|
|
||||||
}
|
}
|
||||||
return builder.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class Fields {
|
static final class Fields {
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class ElasticsearchAssertions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertNoTimeout(ClusterHealthResponse response) {
|
public static void assertNoTimeout(ClusterHealthResponse response) {
|
||||||
assertThat("ClusterHealthResponse has timed out - returned status: [" + response.getStatus() + "]", response.isTimedOut(), is(false));
|
assertThat("ClusterHealthResponse has timed out - returned: [" + response + "]", response.isTimedOut(), is(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertAcked(AcknowledgedResponse response) {
|
public static void assertAcked(AcknowledgedResponse response) {
|
||||||
|
|
Loading…
Reference in New Issue