-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Add support for assertWarnings() to ESRestTestCase #36260
Conversation
Pinging @elastic/es-core-features |
thanks @markharwood I see that the major changes are in the low-level REST client. Given that Response allows to retrieve warnings, I wonder if a WarningListener is needed in the client itself. For our purpose in ESRestTestCase could we instead wrap the RestClient and make sure that performRequest makes the additional call when warnings are returned? We may not even need the async variant given how the client is generally used in tests, not sure though. I would prefer not to add this feature directly to the client as it already exposes what's needed to implement it outside of it. Also, I find having to use a listener for blocking calls a bit weird. What do you think? |
@nik9000 - I've been back and forward with @javanna on this PR and whether we should subclass RestClient to add in the "WarningListener" behaviour that picks up messages from Response.getWarnings(). |
abbdb1c
to
0e5fb0e
Compare
…r warnings surfacing up to ThreadLocal variables via DeprecationLogger
0e5fb0e
to
0e39436
Compare
I'd prefer that we use #36126 and check the warnings that come back from the request explicitly. I think |
That works for LLRC calls but we have tests now that use HLRC and never see the LLRC Request/Response pairs generated under the covers.
So behind the scenes the base class has an IdentityHashMap keyed on HLRC response objects (which can be anything, hence This base class (ESRestTestCase?) could override assertWarnings(String...) and throw an unsupported exception (we'd have to remove the final marker in EsTestCase) - I lost a chunk of time writing REST tests that expected that to work. |
Closing - implemented using an alternative PR |
Added a "WarningsListener" to RestClient and ESRestTestCase provides such a listener so that it can use a DeprecationLogger to record warnings returned in HTTP responses.
Logging deprecation warnings causes the existing ThreadLocal storage of warning messages to take effect meaning
EStTestCase.assertWarnings()
calls have something to inspect.Added an example use of assertWarnings to SearchIT
Closes #36251