Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove types from Monitoring plugin "backend" code #37745

Merged
merged 16 commits into from
Feb 4, 2019
Merged
Prev Previous commit
Next Next commit
Reverting change to monitoring bulk endpoint code and tests
  • Loading branch information
ycombinator committed Feb 1, 2019
commit ab9c7ae677c4fcc4b1bdf21a21ade444bd32749a
Original file line number Diff line number Diff line change
@@ -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]);
@@ -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();
@@ -203,6 +208,7 @@ public void testAddRequestContentWithUnrecognizedIndexName() throws IOException
builder.startObject("index");
{
builder.field("_index", indexName);
builder.field("_type", "doc");
}
builder.endObject();
}
@@ -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 {
Original file line number Diff line number Diff line change
@@ -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;
@@ -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 {
@@ -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 {
@@ -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);
}

/**
@@ -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");