|
27 | 27 | import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
|
28 | 28 | import org.elasticsearch.common.settings.ImmutableSettings;
|
29 | 29 | import org.elasticsearch.common.settings.Settings;
|
| 30 | +import org.elasticsearch.common.xcontent.ToXContent; |
| 31 | +import org.elasticsearch.common.xcontent.XContentHelper; |
30 | 32 | import org.elasticsearch.indices.recovery.RecoveryState;
|
31 | 33 | import org.elasticsearch.test.ElasticsearchBackwardsCompatIntegrationTest;
|
32 | 34 | import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
33 | 35 | import org.junit.Test;
|
34 | 36 |
|
| 37 | +import java.util.HashMap; |
| 38 | + |
35 | 39 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
36 | 40 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
37 | 41 | import static org.hamcrest.Matchers.equalTo;
|
@@ -96,19 +100,23 @@ public void testReusePeerRecovery() throws Exception {
|
96 | 100 | assertHitCount(countResponse, numDocs);
|
97 | 101 |
|
98 | 102 | RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries("test").setDetailed(true).get();
|
| 103 | + HashMap<String, String> map = new HashMap<>(); |
| 104 | + map.put("details", "true"); |
| 105 | + final ToXContent.Params params = new ToXContent.MapParams(map); |
99 | 106 | for (ShardRecoveryResponse response : recoveryResponse.shardResponses().get("test")) {
|
100 | 107 | RecoveryState recoveryState = response.recoveryState();
|
| 108 | + final String recoverStateAsJSON = XContentHelper.toString(recoveryState, params); |
101 | 109 | if (!recoveryState.getPrimary()) {
|
102 | 110 | RecoveryState.Index index = recoveryState.getIndex();
|
103 |
| - assertThat(index.toString(), index.recoveredBytes(), equalTo(0l)); |
104 |
| - assertThat(index.toString(), index.reusedBytes(), greaterThan(0l)); |
105 |
| - assertThat(index.toString(), index.reusedBytes(), equalTo(index.totalBytes())); |
106 |
| - assertThat(index.toString(), index.recoveredFileCount(), equalTo(0)); |
107 |
| - assertThat(index.toString(), index.reusedFileCount(), equalTo(index.totalFileCount())); |
108 |
| - assertThat(index.toString(), index.reusedFileCount(), greaterThan(0)); |
109 |
| - assertThat(index.toString(), index.recoveredBytesPercent(), equalTo(100.f)); |
110 |
| - assertThat(index.toString(), index.recoveredFilesPercent(), equalTo(100.f)); |
111 |
| - assertThat(index.toString(), index.reusedBytes(), greaterThan(index.recoveredBytes())); |
| 111 | + assertThat(recoverStateAsJSON, index.recoveredBytes(), equalTo(0l)); |
| 112 | + assertThat(recoverStateAsJSON, index.reusedBytes(), greaterThan(0l)); |
| 113 | + assertThat(recoverStateAsJSON, index.reusedBytes(), equalTo(index.totalBytes())); |
| 114 | + assertThat(recoverStateAsJSON, index.recoveredFileCount(), equalTo(0)); |
| 115 | + assertThat(recoverStateAsJSON, index.reusedFileCount(), equalTo(index.totalFileCount())); |
| 116 | + assertThat(recoverStateAsJSON, index.reusedFileCount(), greaterThan(0)); |
| 117 | + assertThat(recoverStateAsJSON, index.recoveredBytesPercent(), equalTo(100.f)); |
| 118 | + assertThat(recoverStateAsJSON, index.recoveredFilesPercent(), equalTo(100.f)); |
| 119 | + assertThat(recoverStateAsJSON, index.reusedBytes(), greaterThan(index.recoveredBytes())); |
112 | 120 | // TODO upgrade via optimize?
|
113 | 121 | }
|
114 | 122 | }
|
|
0 commit comments