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

Deprecate types in update requests. #36181

Merged
merged 5 commits into from
Dec 14, 2018

Conversation

jtibshirani
Copy link
Contributor

@jtibshirani jtibshirani commented Dec 3, 2018

The following updates were made:

  • Add deprecation warnings to RestUpdateAction, plus a test in RestUpdateActionTests.
  • Deprecate relevant methods on the Java HLRC requests/ responses.
  • Update documentation (for both the REST API and Java HLRC).

Because of an earlier PR, the REST yml tests were already updated (one version without types, and another legacy version that retains types).

@jtibshirani jtibshirani added :Search Foundations/Mapping Index mappings, including merging and defining field types >deprecation v7.0.0 labels Dec 3, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

Copy link
Contributor

@mayya-sharipova mayya-sharipova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Julie! Just a couple of small comments

import org.elasticsearch.search.fetch.subphase.FetchSourceContext;

import java.io.IOException;

import static org.elasticsearch.rest.RestRequest.Method.POST;

public class RestUpdateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestSearchAction.class));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be here RestUpdateAction instead of RestSearchAction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks! I have been doing a lot of copy-paste.

request.param("id"));
UpdateRequest updateRequest;
if (request.hasParam("type")) {
deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to use deprecatedAndMaybeLog instead of deprecated not to log same deprecation warnings many times?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, I hadn't seen this method. I think we should use it more generally for types deprecation -- I will go over and update some of our other logging statements as well.

@@ -17,7 +17,6 @@ An +{request}+ requires the following arguments:
include-tagged::{doc-tests-file}[{api}-request]
--------------------------------------------------
<1> Index
<2> Type
<3> Document id

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<2> Document id instead of <3> Document id>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -507,14 +507,14 @@ public void testUpdate() throws IOException {
IndexResponse indexResponse = highLevelClient().index(indexRequest, RequestOptions.DEFAULT);
assertEquals(RestStatus.CREATED, indexResponse.status());

UpdateRequest updateRequest = new UpdateRequest("index", "_doc", "id");
UpdateRequest updateRequest = new UpdateRequest("index", "id");
Copy link
Contributor

@markharwood markharwood Dec 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth keeping a deprecated example usage in this test?
I think there's some work to be done to make ESRestTestCase support assertWarnings checks first (currently have to use getStrictDeprecationMode=false to avoid test failures when making deprecated calls)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, this shouldn't be hard now that we are able to check warnings in REST integration tests.

@@ -358,7 +357,7 @@ public void testUpdate() throws Exception {
}
{
//tag::update-request-with-doc-as-string
UpdateRequest request = new UpdateRequest("posts", "_doc", "1");
UpdateRequest request = new UpdateRequest("posts", "1");
String jsonString = "{" +
"\"updated\":\"2017-01-01\"," +
"\"reason\":\"daily update\"" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also remove String type = updateResponse.getType(); example from line 377?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -46,7 +46,7 @@ public void testIndexWithoutId() throws IOException {
}
Copy link
Contributor

@markharwood markharwood Dec 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^ methods testCreate, testIndexWithId and testIndexWithoutId above still going with "test" doc type. Is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't intentional. I switched them to _doc when deprecating get requests, so this should be fixed.

// use the deprecated path and disable strict deprecation checks.
return false;
}

Copy link
Contributor

@markharwood markharwood Dec 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found I had to do this too and didn't like it. EsRestTestCase has a "fail or nothing" approach to testing responses.

Either the whole test fails (strictDeprecationMode is too strict) or in the alternative lax mode we blindly accept any warnings as ok - we can't check we got the expected warnings because ESRestTestCase does not work with the assertWarnings feature declared in base class ESTestCase. I'm going to look into adding that support to ESRestTestCase. Opened #36251

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks for this work, I'll avoid using getStrictDeprecationMode.

.build();
performRequest(deprecatedRequest);
assertWarnings(RestUpdateAction.TYPES_DEPRECATION_MESSAGE);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test the undeprecated form too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jtibshirani
Copy link
Contributor Author

Thanks @mayya-sharipova and @markharwood for the detailed reviews, and sorry I took so long to respond. I was juggling quite a few of these at once and decided it was best to focus on one at a time. I'm working on bringing the PR up to date and will try to address your comments.

@jtibshirani
Copy link
Contributor Author

This should now be ready for another look.

@mayya-sharipova
Copy link
Contributor

@jtibshirani thanks Julie, I had another look. Everything looks good to me. testUpdateWithTypes() and similar are very good, adopted them for my PR.

@jtibshirani jtibshirani merged commit ccd1beb into elastic:master Dec 14, 2018
@jtibshirani jtibshirani deleted the deprecate-types-in-update branch December 14, 2018 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>deprecation :Search Foundations/Mapping Index mappings, including merging and defining field types v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants