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

top_metrics needs a test for flattened fields #70108

Closed
nik9000 opened this issue Mar 8, 2021 · 16 comments
Closed

top_metrics needs a test for flattened fields #70108

nik9000 opened this issue Mar 8, 2021 · 16 comments
Labels
:Analytics/Aggregations Aggregations good first issue low hanging fruit Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@nik9000
Copy link
Member

nik9000 commented Mar 8, 2021

I believe top_metrics can fetch flattened fields but I never wrote a test for it because I didn't realize anyone would be interested in that. Folks seem to be. We should probably have a test to make sure it continues to work.

@nik9000 nik9000 added good first issue low hanging fruit :Analytics/Aggregations Aggregations labels Mar 8, 2021
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Mar 8, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

@fighting-dreamer
Copy link

Newbie to open-source coding. Like to pick this Issue.

@nik9000
Copy link
Member Author

nik9000 commented Mar 10, 2021

Go ahead! I imagine we'd add the test to x-pack/plugin/src/test/resources/rest-api-spec/test/analytics/top_metrics.yml and I'd run the test with something like ./gradlew :x-pack:plugin:check -Dtests.method='*top_metrics*.

@fighting-dreamer
Copy link

trying to understand how test work.
I understand that the test/queries are to be written in the above file(x-pack/plugin/src/test/resources/rest-api-spec/test/analytics/top_metrics.yml).

@nik9000
Copy link
Member Author

nik9000 commented Mar 22, 2021

Sorry, yeah. Those yml files are the integration tests we share with our client libraries. In this case I'm looking for a test that creates a flattened field, indexes some documents, and lists the flattened field as a metric in a top_metrics agg. Then asserts that it got the values it expects back.

@fighting-dreamer
Copy link

Have figured out the test case, was quite busy at work this last month. hoping to raise the PR soon.

@GrayFox1
Copy link
Contributor

I am interested to pick this Issue, are you still working on it? @fighting-dreamer

@nik9000
Copy link
Member Author

nik9000 commented Jun 11, 2021

@GrayFox1 I imagine @fighting-dreamer is not going to finish this one so if you'd like to have a look go for it.

Since we've had a whole bunch of similar comments to yours in the past few days I'll mention that we don't want contributions made as part of a class. I'm not sure if that applies to you. Folks contributing as part of a class tend to open PRs but not take the time to go through the actual code review portion of the process. And when a whole class piles on trying to contribute to the project it puts a bunch of load on the maintainers. Sorry for the big paragraph. Its become a thing.... Anyway, if you aren't from a class then welcome!

Honestly the rule isn't hard and fast - if you are from a class but swear to go through with the code review, even if we finish it after your class then I'm willing to work with you. Sorry for all this.

Go ahead! I imagine we'd add the test to x-pack/plugin/src/test/resources/rest-api-spec/test/analytics/top_metrics.yml and I'd run the test with something like ./gradlew :x-pack:plugin:check -Dtests.method='*top_metrics*.

I think these are still the correct instructions! As of today you'll need JAVA_HOME to be set to a Java 16 installation to build Elasticsearch.

@nilanshu96
Copy link
Contributor

Hi @nik9000 ,
I have created a very simple test case for a flattened type field called "with flattened". You can check it here
top_metrics.yml

The test can be run using the following command:

./gradlew ':x-pack:plugin:yamlRestTest' --tests "org.elasticsearch.xpack.test.rest.XPackRestIT" -Dtests.method="test {p0=analytics/top_metrics/with flattened}"

I've confirmed that the test is passing. Currently the test is very simple. Please do tell me if there are any improvements that can be made else I'll raise a PR if this is sufficient.

@nilanshu96
Copy link
Contributor

@nik9000 Can you please provide an update on this issue or is it already resolved? If not can you check my solution in previous comment?

@imotov
Copy link
Contributor

imotov commented Oct 11, 2021

Could you open a PR for it?

@nilanshu96
Copy link
Contributor

Hi @imotov I've added the PR, The test in question can be found here. Currently I've created a very simple test to see if flattened fields can be tested. Can you please check it and suggest any improvements?

@nilanshu96
Copy link
Contributor

Hi @imotov @nik9000 , can you please provide an update regarding this issue?

@nik9000
Copy link
Member Author

nik9000 commented Oct 18, 2021 via email

@nilanshu96
Copy link
Contributor

@nik9000 don't worry, it wasn't a big deal. Also I'm happy to contribute. I got to learn a lot from this task.

@nik9000
Copy link
Member Author

nik9000 commented Oct 20, 2021

Closed by #78960.

@nik9000 nik9000 closed this as completed Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations good first issue low hanging fruit Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

No branches or pull requests

6 participants