-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Get data stream accepts single search parameter #54530
Conversation
Pinging @elastic/es-core-features (:Core/Features/Data streams) |
@elasticmachine update branch |
merge conflict between base and head |
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.
Looks good. I left some comments.
@@ -72,26 +73,26 @@ public ActionRequestValidationException validate() { | |||
|
|||
public Request(StreamInput in) throws IOException { | |||
super(in); | |||
this.names = in.readStringArray(); | |||
this.name = in.readString(); |
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.
This should be readOptionalString()
instead of readString()
, since the name maybe null.
This is also why I think the test fails.
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeStringArray(names); | ||
out.writeString(name); |
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.
This should be writeOptionalString()
instead of writeString()
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Request request = (Request) o; | ||
return Arrays.equals(names, request.names); | ||
return name.equals(request.name); |
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.
Objects.equals(...)
should be used here.
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Arrays.hashCode(names); | ||
return name.hashCode(); |
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.
Objects.hashCode(...)
should be used here.
GetDataStreamsAction.Request req = new GetDataStreamsAction.Request(new String[]{}); | ||
ActionRequestValidationException e = req.validate(); | ||
assertNull(e); | ||
return new Request(randomAlphaOfLength(8) + (randomBoolean() ? "*" : "")); |
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.
maybe also specify null
as a value here?
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.
maybe also randomly specify just "*" here?
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. I left a few comments to address, but no need for another round.
|
||
- do: | ||
indices.get_data_streams: | ||
name: null |
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 should think it works without this line too? I think I prefer to remove that line, we normally do not specify optional parameters as null in rest tests.
|
||
- do: | ||
indices.get_data_streams: | ||
name: get-data-stream1 |
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.
Would be nice to also test that GET _data_stream/get-data-stream*
works and returns both streams?
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeStringArray(names); | ||
out.writeString(name); |
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 think there is a BWC issue here since the original code is in the 7.7 branch? Probably easiest to just make it 7.7 compatible here (and in the read above) rather than other workarounds.
GetDataStreamsAction.Request req = new GetDataStreamsAction.Request(new String[]{}); | ||
ActionRequestValidationException e = req.validate(); | ||
assertNull(e); | ||
return new Request(randomAlphaOfLength(8) + (randomBoolean() ? "*" : "")); | ||
} | ||
|
||
public void testGetDataStreams() { |
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.
nit:
public void testGetDataStreams() { | |
public void testGetDataStream() { |
GetDataStreamsAction.Request req = new GetDataStreamsAction.Request(new String[]{}); | ||
ActionRequestValidationException e = req.validate(); | ||
assertNull(e); | ||
return new Request(randomAlphaOfLength(8) + (randomBoolean() ? "*" : "")); |
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.
maybe also randomly specify just "*" here?
@@ -65,8 +60,9 @@ public void testGetDataStreams() { | |||
public void testGetNonexistentDataStream() { |
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 think we should add a bit more tests:
- Get non existent data stream based on wildcard (which should return empty array).
- Get data stream based on wildcard, returning multiple.
@elasticmachine update branch |
@elasticmachine update branch |
@elasticmachine update branch |
Changes the
GET /_data_streams
endpoint to accept a single search parameter.If the search parameter contains wildcards, a list of matching data streams will be returned or the empty list if there are no matches. If the search parameter does not contain wildcards, the single matching data stream, if any, will be returned. If there are no matches, the response code of 404 will be returned.
The
GET /_data_streams
request without an explicit search parameter will be treated asGET /_data_streams/*
.Relates to #53100