Skip to content

Conversation

@javanna
Copy link
Member

@javanna javanna commented May 5, 2017

AggregationsTests#testFromXContent verifies that parsing of aggregations works by combining multiple aggs at the same level, and also adding sub-aggregations to multi bucket and single bucket aggs, up to a maximum depth of 5.

AggregationsTests#testFromXContent verifies that parsing of aggregations works by combining multiple aggs at the same level, and also adding sub-aggregations to multi bucket and single bucket aggs, up to a maximum depth of 5.
@javanna javanna added :Java High Level REST Client >test Issues or PRs that are addressing/adding tests labels May 5, 2017
@javanna javanna requested review from cbuescher and tlrx May 5, 2017 22:09
Copy link
Member

@tlrx tlrx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very nice and elegant, I like it a lot. I requested a change about a @after annotation but once it is fixed it will be good.


import static java.util.Collections.singletonMap;

public class AggregationsTests extends ESTestCase {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some doc about the purpose of this test?

aggsTests.add(new InternalGeoCentroidTests());
aggsTests.add(new InternalHistogramTests());
aggsTests.add(new InternalDateHistogramTests());
return aggsTests;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can it be an unmodifiable list?

return createTestInstance(0, 5);
}

private static InternalAggregations createTestInstance(int currentDepth, int maxDepth) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maxDepth can be final

subAggregationsSupplier = () -> {
final int numAggregations = randomIntBetween(1, 3);
List<InternalAggregation> aggs = new ArrayList<>();
for (int i = 0; i <numAggregations; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after ̀<`


@Before
public void setup() {
@After //we force @After to have it run before ESTestCase#after otherwise it fails
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why it is @after and not @before anymore... This is going to break the test.

Copy link
Member Author

@javanna javanna May 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not make any sense. let me dig why tests run though... I thought after needed to be forced on tearDown, let me verify that!

Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left two comment regarding setUp/tearDown. I generally find that part a bit hard to follow, but I see why it is done this way.

public void setup() {
@After //we force @After to have it run before ESTestCase#after otherwise it fails
@Override
public void setUp() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to call super.setUp() as well as it overrides LuceneTestCase#setUp()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it does. I have messed these two up for some reason. Probably ran only AggregationsTests and not the cardinality tests...fixing

}

@Override
public void tearDown() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to call super.tearDown() as well as it overrides LuceneTestCase#tearDown()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

@javanna
Copy link
Member Author

javanna commented May 9, 2017

I generally find that part a bit hard to follow, but I see why it is done this way.

I agree, and that is because there are multiple ways to do the same thing, but each one works slightly differently :) I wanted to have one single way to set things up in the base test class. THen I hooked into the lucene setup and teardown methods. That also makes sure that we don't forget to call super which is nice. Yet given that the annotations are in the base class LuceneTestCase, the after in ESTestCase runs first, and that is why in one case we have to force the After annotation in a subclass, so that tearDown is called before we check that we did clean things up.

@javanna
Copy link
Member Author

javanna commented May 9, 2017

@tlrx @cbuescher I have addressed your comments, can you have another look please?

@javanna javanna merged commit c5bdbec into elastic:feature/client_aggs_parsing May 9, 2017
javanna added a commit to javanna/elasticsearch that referenced this pull request May 23, 2017
AggregationsTests#testFromXContent verifies that parsing of aggregations works by combining multiple aggs at the same level, and also adding sub-aggregations to multi bucket and single bucket aggs, up to a maximum depth of 5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>test Issues or PRs that are addressing/adding tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants