|
@@ -26,6 +26,7 @@ import org.apache.http.nio.entity.NStringEntity;
|
|
|
import org.elasticsearch.action.ActionListener;
|
|
|
import org.elasticsearch.action.delete.DeleteRequest;
|
|
|
import org.elasticsearch.action.delete.DeleteResponse;
|
|
|
+import org.elasticsearch.action.get.GetRequest;
|
|
|
import org.elasticsearch.action.index.IndexRequest;
|
|
|
import org.elasticsearch.action.index.IndexResponse;
|
|
|
import org.elasticsearch.client.ESRestHighLevelClientTestCase;
|
|
@@ -43,6 +44,7 @@ import java.io.InputStream;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import static java.util.Collections.emptyMap;
|
|
|
+import static java.util.Collections.singletonMap;
|
|
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
|
|
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
|
|
|
|
|
@@ -67,7 +69,7 @@ public class MigrationDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
public void testCreateIndex() throws IOException {
|
|
|
RestHighLevelClient client = highLevelClient();
|
|
|
{
|
|
|
- //tag::migration-create-inded
|
|
|
+ //tag::migration-create-index
|
|
|
Settings indexSettings = Settings.builder() // <1>
|
|
|
.put(SETTING_NUMBER_OF_SHARDS, 1)
|
|
|
.put(SETTING_NUMBER_OF_REPLICAS, 0)
|
|
@@ -95,7 +97,7 @@ public class MigrationDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
|
|
|
// <7>
|
|
|
}
|
|
|
- //end::migration-create-inded
|
|
|
+ //end::migration-create-index
|
|
|
assertEquals(200, response.getStatusLine().getStatusCode());
|
|
|
}
|
|
|
}
|
|
@@ -104,7 +106,8 @@ public class MigrationDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
RestHighLevelClient client = highLevelClient();
|
|
|
{
|
|
|
//tag::migration-cluster-health
|
|
|
- Response response = client.getLowLevelClient().performRequest("GET", "/_cluster/health"); // <1>
|
|
|
+ Map<String, String> parameters = singletonMap("wait_for_status", "green");
|
|
|
+ Response response = client.getLowLevelClient().performRequest("GET", "/_cluster/health", parameters); // <1>
|
|
|
|
|
|
ClusterHealthStatus healthStatus;
|
|
|
try (InputStream is = response.getEntity().getContent()) { // <2>
|
|
@@ -120,7 +123,7 @@ public class MigrationDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void testRequests() throws IOException {
|
|
|
+ public void testRequests() throws Exception {
|
|
|
RestHighLevelClient client = highLevelClient();
|
|
|
{
|
|
|
//tag::migration-request-ctor
|
|
@@ -133,13 +136,6 @@ public class MigrationDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
//end::migration-request-ctor-execution
|
|
|
assertEquals(RestStatus.CREATED, response.status());
|
|
|
}
|
|
|
- {
|
|
|
- //tag::migration-request-sync-execution
|
|
|
- DeleteRequest request = new DeleteRequest("index", "doc", "id");
|
|
|
- DeleteResponse response = client.delete(request); // <1>
|
|
|
- //end::migration-request-sync-execution
|
|
|
- assertEquals(RestStatus.OK, response.status());
|
|
|
- }
|
|
|
{
|
|
|
//tag::migration-request-async-execution
|
|
|
DeleteRequest request = new DeleteRequest("index", "doc", "id"); // <1>
|
|
@@ -155,6 +151,14 @@ public class MigrationDocumentationIT extends ESRestHighLevelClientTestCase {
|
|
|
}
|
|
|
});
|
|
|
//end::migration-request-async-execution
|
|
|
+ assertBusy(() -> assertFalse(client.exists(new GetRequest("index", "doc", "id"))));
|
|
|
+ }
|
|
|
+ {
|
|
|
+ //tag::migration-request-sync-execution
|
|
|
+ DeleteRequest request = new DeleteRequest("index", "doc", "id");
|
|
|
+ DeleteResponse response = client.delete(request); // <1>
|
|
|
+ //end::migration-request-sync-execution
|
|
|
+ assertEquals(RestStatus.NOT_FOUND, response.status());
|
|
|
}
|
|
|
}
|
|
|
}
|