-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Replace strict parsing mode with response headers assertions #22130
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
Conversation
cb4c1fd
to
4d7ae2e
Compare
There was a problem hiding this 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.
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 ;) |
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! |
There was a problem hiding this 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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
method refs ftw
8d5c772
to
ddd8613
Compare
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.
ddd8613
to
26867c1
Compare
… directly Relates to elastic#19552 Relates to elastic#22130
…Field directly Relates to elastic#19552 Relates to elastic#22130
…Field directly Relates to elastic#19552 Relates to elastic#22130
… directly Relates to elastic#19552 Relates to elastic#22130
…Field directly Relates to elastic#19552 Relates to elastic#22130
…Field directly Relates to elastic#19552 Relates to elastic#22130
… directly Relates to elastic#19552 Relates to elastic#22130
… directly Relates to elastic#19552 Relates to elastic#22130
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 theParseField
checks toParseFieldMatcher
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 forParseFieldMatcher
, by rather leveraging our current infrastructure based onThreadContext
andDeprecationLogger
. Another disadvantage ofParseFieldMatcher
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 ofParseFieldMatcher
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 fromAbstractQueryTestCase
toESTestCase
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