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

Replace strict parsing mode with response headers assertions #22130

Merged

Conversation

javanna
Copy link
Member

@javanna javanna commented Dec 12, 2016

This is the first step towards removing ParseFieldMatcher. The only reason to have this class is strict parsing, which is only used in our test infra. Because it depends on a setting (although this setting was never settable by users), we were moved all of the ParseField checks to ParseFieldMatcher when it was introduced (see #11859), which was quite an intrusive change in our parsing code. We now have a deprecation logger, and we return warning headers whenever some deprecated feature is used throughout the execution of a request. The functionality of strict parsing can either be moved to clients, or re-implemented without the need for ParseFieldMatcher, by rather leveraging our current infrastructure based on ThreadContext and DeprecationLogger. Another disadvantage of ParseFieldMatcher is that it's completely decoupled from the deprecation logger, hence it became hard to keep the two in sync. Also, we ended up creating many copies of ParseFieldMatcher in our codebase that cause confusion.

This PR deprecates ParseFieldMatcher and makes it not useful as it removes support for strict parsing. All tests that used to rely on strict parsing are now moved to checking warning headers, introduced first with #20993 in query tests. Even more, we can now move the warnings check from AbstractQueryTestCase to ESTestCase and test more closely deprecation warnings, as well as easily catch which tests use deprecated features. This can only be leveraged in unit tests or single node test (where the only node runs in the same jvm as the test).

Once this change goes in, we can go and step by step remove all the usages of ParseFieldMatcher, which will be a mechanical change (a big one), and finally remove the class.

Relates to #19552

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

❤️

I'm fine with skipping warnings assertions on integ test cases. We should be testing those warnings using unit tests anyway. And we mostly do.

@javanna
Copy link
Member Author

javanna commented Dec 13, 2016

I'm fine with skipping warnings assertions on integ test cases. We should be testing those warnings using unit tests anyway. And we mostly do.

Agreed, I think we could check the responses through java api or REST client depending on the test, but that can come later, if we need it. At least now we check for warnings in all the unit tests, which is already much more than what we did until now. Thanks for your review ;)

@nik9000
Copy link
Member

nik9000 commented Dec 13, 2016

At least now we check for warnings in all the unit tests

Yeah! That is much nicer. And we check the wording. Which I see you fixed in a bunch of places because it was funky. Nice!

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

LGTM

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.hasToString;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you avoid reorganizinge the imports?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was reverting this bit, funnily enough this same import order change came in through another PR: b9600c7#diff-41da0c9cbefe797a78bab64005bf2b94 . :)

@@ -118,7 +112,7 @@ public void testToQuery() throws IOException {

public void testExceptionOnMissingTypes() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length == 0);
QueryShardException e = expectThrows(QueryShardException.class, () -> super.testToQuery());
QueryShardException e = expectThrows(QueryShardException.class, super::testToQuery);
Copy link
Contributor

Choose a reason for hiding this comment

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

method refs ftw

@javanna javanna force-pushed the enhancement/remove_strict_parsing_mode branch 4 times, most recently from 8d5c772 to ddd8613 Compare December 16, 2016 20:33
We return deprecation warnings as response headers, besides logging them. Strict parsing mode stayed around, but was only used in query tests, though we also introduced checks for deprecation warnings there that don't need strict parsing anymore (see elastic#20993).

 We can then safely remove support for strict parsing mode. The final goal is to remove the ParseFieldMatcher class, but there are many many users of it. This commit prepares the field for the removal, by deprecating ParseFieldMatcher and making it effectively not needed. Strict parsing is removed from ParseFieldMatcher, and strict parsing is replaced in tests where needed with deprecation warnings checks.

 Note that the setting to enable strict parsing was never ported to the new settings infra hance it cannot be set in production. It is really only used in our own tests.

 Relates to elastic#19552
We are currenlty checking that no deprecation warnings are emitted in our query tests. That can be moved to ESTestCase (disabled in ESIntegTestCase) as it allows us to easily catch where our tests use deprecated features and assert on the expected warnings.
@javanna javanna force-pushed the enhancement/remove_strict_parsing_mode branch from ddd8613 to 26867c1 Compare December 19, 2016 14:28
@javanna javanna merged commit 5dae10d into elastic:master Dec 19, 2016
javanna added a commit to javanna/elasticsearch that referenced this pull request Dec 30, 2016
javanna added a commit to javanna/elasticsearch that referenced this pull request Dec 30, 2016
javanna added a commit to javanna/elasticsearch that referenced this pull request Dec 30, 2016
javanna added a commit that referenced this pull request Dec 30, 2016
javanna added a commit that referenced this pull request Dec 30, 2016
javanna added a commit that referenced this pull request Dec 30, 2016
javanna added a commit to javanna/elasticsearch that referenced this pull request Dec 30, 2016
javanna added a commit to javanna/elasticsearch that referenced this pull request Dec 30, 2016
javanna added a commit to javanna/elasticsearch that referenced this pull request Dec 30, 2016
javanna added a commit to javanna/elasticsearch that referenced this pull request Dec 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants