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

Drop the number of default iterations in AbstractQueryTestCase to 1 #42429

Closed

Conversation

romseygeek
Copy link
Contributor

As discussed in #40362 (comment),
given the number of runs our randomized CI does there is very little point in having multiple
iterations within individual tests. This commit drops the default number of iterations in
AbstractQueryTestCase to 1, while leaving the loops in-place for development purposes.

@romseygeek romseygeek added >test Issues or PRs that are addressing/adding tests :Search/Search Search-related issues that do not fall into other categories v8.0.0 v7.2.0 labels May 23, 2019
@romseygeek romseygeek requested a review from martijnvg May 23, 2019 08:39
@romseygeek romseygeek self-assigned this May 23, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@romseygeek romseygeek changed the title Drop the number of default iterations iin AbstractQueryTestCase to 1 Drop the number of default iterations in AbstractQueryTestCase to 1 May 23, 2019
Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

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

LGTM

@jimczi
Copy link
Contributor

jimczi commented May 23, 2019

The tests that use this number are a bit hidden and this is easy to miss them if you change the behavior of a query. With a single run a lot of failures could be missed during development and I am not sure that all contributors will be aware that they should increase this value to ensure that tests are passing locally. We had a lot of CI failures due to some missing changes in this area and that was with 20 iterations so I guess that this will just increase the number of failures that we don't spot in pr checks. The number of iterations here should not impact the build time (I didn't check but I doubt that this makes a difference) so why is it needed ?

@martijnvg
Copy link
Member

With a single run a lot of failures could be missed during development and I am not sure that all contributors will be aware that they should increase this value to ensure that tests are passing locally.

I think -Dtests.iters=N should be used during development to discover erroneous scenarios in unit tests. Just running these tests 20 times forever is not needed. There are many query builder tests, so I think it does have some impact on the gradle test task (but I've not checked).

@cbuescher
Copy link
Member

With a single run a lot of failures could be missed during development and I am not sure that all contributors will be aware that they should increase this value to ensure that tests are passing locally.

That was the original motivation for adding this 20 repetitions. We randomize a lot of input arguments for the query builders in these tests so the space each test covers is quite large. While we run CI a lot and eventually run into the interesting edge cases, it might take a few days and then get buried in the noise. While we were doing the query refactoring these repeats helped a lot I think. Also I think (haven't measures exactly either) that this loop doesn't add much runtime to the tests compared to e.g. start/teardown of each test suite so I think its neglegible in the overall scheme of things. But thats just my 10c, don't want to hold this up if folks want to reduce it.

@cbuescher
Copy link
Member

I think -Dtests.iters=N should be used during development to discover erroneous scenarios

From my own experience I know that this gets forgotten quite often, even from us and even more so from external developers. When CI runs into these error scenarios its usually a few hours to days later and harder to pinpoint the code change triggering the edge case failures. Keeping the loop trades a little bit of runtime overhead for the amount of time to find and fix bugs later in the game. Again, I'm not saying this is optimal, just a tradeoff.

@jimczi
Copy link
Contributor

jimczi commented May 23, 2019

I think -Dtests.iters=N should be used during development to discover erroneous scenarios

Maybe but we also need a good coverage on single runs. The randomization in these tests is precisely about coverage because it is difficult to write an abstract test that ensures that all form of query builders are correctly handled. If we had to write a serialization/build check for every query I am sure we would add more than one case on the same test.

There are many query builder tests, so I think it does have some impact on the gradle test task (but I've not checked).

Running the tests in the org.elasticsearch.index.query package takes approx 25s on my laptop and switching NUMBER_OF_TESTQUERIES to 1 doesn't impact this timing:

:server | 25.182s
-- | --

@javanna
Copy link
Member

javanna commented May 24, 2019

I remember discussions with @cbuescher on this in the past where I was disagreeing with him on this. I have changed my mind over time, for a simple reason: if you remove those 20 iterations, some edge cases become simply much more rare. I generally still use tests.iters on top of these existing 20 iterations while developing and that gives me much more confidence that there won't be surprises. This applies only to high-level REST client serialization tests etc. where the objects that we test against can change a lot from a run to another.

@martijnvg
Copy link
Member

So I also notice no real difference with 1 or 20 iterations when running:

./gradlew -p server/ test --tests "org.elasticsearch.index.query*"

Even when setting maxParallelForks for test task to 1 (in BuildPlugin.groovy).
So I guess the savings are more theoretical than practical on laptops. Since people have raised concerns around this change, maybe we shouldn't do this, unless someone else really thinks that we should make this change

@romseygeek
Copy link
Contributor Author

We discussed this in FixitFriday, and agreed to close this without committing. Instead, we should try and factor out randomization into separate instance runs, both in AbstractQueryTestCase and AbstractRequest/ResponseTest in HLRC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss :Search/Search Search-related issues that do not fall into other categories >test Issues or PRs that are addressing/adding tests v7.2.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants