|
|
@@ -27,11 +27,15 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|
|
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
|
|
|
import org.elasticsearch.common.settings.ImmutableSettings;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
+import org.elasticsearch.common.xcontent.ToXContent;
|
|
|
+import org.elasticsearch.common.xcontent.XContentHelper;
|
|
|
import org.elasticsearch.indices.recovery.RecoveryState;
|
|
|
import org.elasticsearch.test.ElasticsearchBackwardsCompatIntegrationTest;
|
|
|
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
|
|
import org.junit.Test;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+
|
|
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
|
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
|
@@ -96,19 +100,23 @@ public class RecoveryBackwardsCompatibilityTests extends ElasticsearchBackwardsC
|
|
|
assertHitCount(countResponse, numDocs);
|
|
|
|
|
|
RecoveryResponse recoveryResponse = client().admin().indices().prepareRecoveries("test").setDetailed(true).get();
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("details", "true");
|
|
|
+ final ToXContent.Params params = new ToXContent.MapParams(map);
|
|
|
for (ShardRecoveryResponse response : recoveryResponse.shardResponses().get("test")) {
|
|
|
RecoveryState recoveryState = response.recoveryState();
|
|
|
+ final String recoverStateAsJSON = XContentHelper.toString(recoveryState, params);
|
|
|
if (!recoveryState.getPrimary()) {
|
|
|
RecoveryState.Index index = recoveryState.getIndex();
|
|
|
- assertThat(index.toString(), index.recoveredBytes(), equalTo(0l));
|
|
|
- assertThat(index.toString(), index.reusedBytes(), greaterThan(0l));
|
|
|
- assertThat(index.toString(), index.reusedBytes(), equalTo(index.totalBytes()));
|
|
|
- assertThat(index.toString(), index.recoveredFileCount(), equalTo(0));
|
|
|
- assertThat(index.toString(), index.reusedFileCount(), equalTo(index.totalFileCount()));
|
|
|
- assertThat(index.toString(), index.reusedFileCount(), greaterThan(0));
|
|
|
- assertThat(index.toString(), index.recoveredBytesPercent(), equalTo(100.f));
|
|
|
- assertThat(index.toString(), index.recoveredFilesPercent(), equalTo(100.f));
|
|
|
- assertThat(index.toString(), index.reusedBytes(), greaterThan(index.recoveredBytes()));
|
|
|
+ assertThat(recoverStateAsJSON, index.recoveredBytes(), equalTo(0l));
|
|
|
+ assertThat(recoverStateAsJSON, index.reusedBytes(), greaterThan(0l));
|
|
|
+ assertThat(recoverStateAsJSON, index.reusedBytes(), equalTo(index.totalBytes()));
|
|
|
+ assertThat(recoverStateAsJSON, index.recoveredFileCount(), equalTo(0));
|
|
|
+ assertThat(recoverStateAsJSON, index.reusedFileCount(), equalTo(index.totalFileCount()));
|
|
|
+ assertThat(recoverStateAsJSON, index.reusedFileCount(), greaterThan(0));
|
|
|
+ assertThat(recoverStateAsJSON, index.recoveredBytesPercent(), equalTo(100.f));
|
|
|
+ assertThat(recoverStateAsJSON, index.recoveredFilesPercent(), equalTo(100.f));
|
|
|
+ assertThat(recoverStateAsJSON, index.reusedBytes(), greaterThan(index.recoveredBytes()));
|
|
|
// TODO upgrade via optimize?
|
|
|
}
|
|
|
}
|