Skip to content

Commit

Permalink
Reverting change to monitoring bulk endpoint code and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ycombinator committed Feb 1, 2019
1 parent b7eaeb8 commit ab9c7ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public void testAddRequestContent() throws IOException {
if (rarely()) {
builder.field("_index", "");
}
if (defaultType == null || randomBoolean()) {
types[i] = randomAlphaOfLength(5);
builder.field("_type", types[i]);
}
if (randomBoolean()) {
ids[i] = randomAlphaOfLength(10);
builder.field("_id", ids[i]);
Expand Down Expand Up @@ -158,6 +162,7 @@ public void testAddRequestContentWithEmptySource() throws IOException {
builder.startObject("index");
{
builder.field("_index", "");
builder.field("_type", "doc");
builder.field("_id", String.valueOf(i));
}
builder.endObject();
Expand Down Expand Up @@ -203,6 +208,7 @@ public void testAddRequestContentWithUnrecognizedIndexName() throws IOException
builder.startObject("index");
{
builder.field("_index", indexName);
builder.field("_type", "doc");
}
builder.endObject();
}
Expand All @@ -226,7 +232,6 @@ public void testAddRequestContentWithUnrecognizedIndexName() throws IOException
assertThat(e.getMessage(), containsString("unrecognized index name [" + indexName + "]"));
//This test's JSON contains outdated references to types
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);

}

public void testSerialization() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.rest.action.RestBuilderListener;
import org.elasticsearch.rest.action.document.RestBulkAction;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.FakeRestRequest;
import org.elasticsearch.xpack.core.XPackClient;
Expand Down Expand Up @@ -121,6 +122,8 @@ public void testNoErrors() throws Exception {
assertThat(restResponse.status(), is(RestStatus.OK));
assertThat(restResponse.content().utf8ToString(),
is("{\"took\":" + response.getTookInMillis() + ",\"ignored\":false,\"errors\":false}"));
//This test's JSON contains outdated references to types
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
}

public void testNoErrorsButIgnored() throws Exception {
Expand All @@ -131,6 +134,8 @@ public void testNoErrorsButIgnored() throws Exception {
assertThat(restResponse.status(), is(RestStatus.OK));
assertThat(restResponse.content().utf8ToString(),
is("{\"took\":" + response.getTookInMillis() + ",\"ignored\":true,\"errors\":false}"));
//This test's JSON contains outdated references to types
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
}

public void testWithErrors() throws Exception {
Expand All @@ -150,6 +155,8 @@ public void testWithErrors() throws Exception {
assertThat(restResponse.status(), is(RestStatus.INTERNAL_SERVER_ERROR));
assertThat(restResponse.content().utf8ToString(),
is("{\"took\":" + response.getTookInMillis() + ",\"ignored\":false,\"errors\":true,\"error\":" + errorJson + "}"));
//This test's JSON contains outdated references to types
assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE);
}

/**
Expand Down Expand Up @@ -210,7 +217,7 @@ private static FakeRestRequest createRestRequest(final int nbDocs,
if (nbDocs > 0) {
final StringBuilder requestBody = new StringBuilder();
for (int n = 0; n < nbDocs; n++) {
requestBody.append("{\"index\":{}}\n");
requestBody.append("{\"index\":{\"_type\":\"_doc\"}}\n");
requestBody.append("{\"field\":").append(n).append("}\n");
}
requestBody.append("\n");
Expand Down

0 comments on commit ab9c7ae

Please sign in to comment.