-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Add remaining BWC tests for the ent-search module #98016
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
Changes from all commits
93f13bd
4d14567
126140e
34fbb5f
aded2a0
850f3a3
44e1b2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,14 +11,20 @@ | |
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.common.io.stream.Writeable; | ||
| import org.elasticsearch.core.Nullable; | ||
| import org.elasticsearch.xcontent.ConstructingObjectParser; | ||
| import org.elasticsearch.xcontent.ParseField; | ||
| import org.elasticsearch.xcontent.ToXContentObject; | ||
| import org.elasticsearch.xcontent.XContentBuilder; | ||
| import org.elasticsearch.xcontent.XContentParser; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
|
|
||
| import static org.elasticsearch.xcontent.ConstructingObjectParser.constructorArg; | ||
| import static org.elasticsearch.xcontent.ConstructingObjectParser.optionalConstructorArg; | ||
|
|
||
| /** | ||
| * This class is used for returning information for lists of search applications, to avoid including all | ||
| * {@link SearchApplication} information which can be retrieved using subsequent Get Search Application requests. | ||
|
|
@@ -75,6 +81,30 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws | |
| return builder; | ||
| } | ||
|
|
||
| private static final ConstructingObjectParser<SearchApplicationListItem, String> PARSER = new ConstructingObjectParser<>( | ||
| "search_application_list_item`", | ||
| false, | ||
| (params) -> { | ||
| final String name = (String) params[0]; | ||
| @SuppressWarnings("unchecked") | ||
| final String[] indices = ((List<String>) params[1]).toArray(String[]::new); | ||
| final String analyticsCollectionName = (String) params[2]; | ||
| final Long updatedAtMillis = (Long) params[3]; | ||
| return new SearchApplicationListItem(name, indices, analyticsCollectionName, updatedAtMillis); | ||
| } | ||
| ); | ||
|
|
||
| static { | ||
| PARSER.declareStringOrNull(optionalConstructorArg(), NAME_FIELD); | ||
| PARSER.declareStringArray(constructorArg(), INDICES_FIELD); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just a note for both of us - this will not be compatible with #98036 since I removed the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a really good observation. I actually think it might be best to merge this one first, so we can ensure that BWC works after removing the indices. WDYT? |
||
| PARSER.declareStringOrNull(optionalConstructorArg(), ANALYTICS_COLLECTION_NAME_FIELD); | ||
| PARSER.declareLong(optionalConstructorArg(), UPDATED_AT_MILLIS_FIELD); | ||
| } | ||
|
|
||
| public SearchApplicationListItem fromXContent(XContentParser parser) { | ||
| return PARSER.apply(parser, null); | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| out.writeString(name); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -7,13 +7,14 @@ | |||
|
|
||||
| package org.elasticsearch.xpack.application.search.action; | ||||
|
|
||||
| import org.elasticsearch.TransportVersion; | ||||
| import org.elasticsearch.action.DocWriteResponse; | ||||
| import org.elasticsearch.common.io.stream.Writeable; | ||||
| import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||||
| import org.elasticsearch.xpack.core.ml.AbstractBWCWireSerializationTestCase; | ||||
|
|
||||
| import java.io.IOException; | ||||
|
|
||||
| public class PutSearchApplicationActionResponseSerializingTests extends AbstractWireSerializingTestCase< | ||||
| public class PutSearchApplicationActionResponseBWCSerializingTests extends AbstractBWCWireSerializationTestCase< | ||||
| PutSearchApplicationAction.Response> { | ||||
|
|
||||
| @Override | ||||
|
|
@@ -30,4 +31,12 @@ protected PutSearchApplicationAction.Response createTestInstance() { | |||
| protected PutSearchApplicationAction.Response mutateInstance(PutSearchApplicationAction.Response instance) throws IOException { | ||||
| return randomValueOtherThan(instance, this::createTestInstance); | ||||
| } | ||||
|
|
||||
| @Override | ||||
| protected PutSearchApplicationAction.Response mutateInstanceForVersion( | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have to implement this because we are now inheriting from this is not related to your PR, but looking at the other (~70) implementation of this method most of them are the same where we just do Is there a reason why this is an abstract method? Line 30 in a2d4799
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a really good question. My guess is that the assumption was, these tests wouldn't be written unless we had backwards compatibility changes to address. However, if we're going to be proactively including them (which I think is a good idea) then it would make sense to have a sane default to return the instance.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the intention is to make us think about that. If we're doing a BWC test, then something could have changed between version serializations. So probably it's let's not forget?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (@kderusso - sorry again, I know this is not related to your PR and it's not a change I propose doing here) @astefan - do you think it would make sense to provide a sane default here instead of having this be an abstract method and forcing an implementation in each subclass? |
||||
| PutSearchApplicationAction.Response instance, | ||||
| TransportVersion version | ||||
| ) { | ||||
| return instance; | ||||
| } | ||||
| } | ||||
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.
The
canonical()calls were added here to ensure that versioned XContentTypes still act as equivalent in BWC tests.