-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add support for switching distribution for all integration tests #30874
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
Conversation
|
Pinging @elastic/es-core-infra |
| // for unicast discovery | ||
| ClusterConfiguration config = new ClusterConfiguration(project) | ||
| config.distribution = 'integ-test-zip' | ||
| config.distribution = System.getProperty('tests.distribution', 'integ-test-zip') |
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'm not sure we need this line at all given your change to PluginBuildPlugin.
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 would take precedence and override that. So it would be set back to integ-test-zip regardless of the property.
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 am concerned this is fragile. I don't want to see this logic copied around to other projects. Can you please create an issue for making creating additional cluster fixtures easier, so that the default can be set by PluginBuildPlugin for this project and reused the we create this cluster?
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.
++ on this being fragile. Fixing it in a followup is fine with me though.
| testCompile project(path: ':modules:lang-mustache', configuration: 'runtime') | ||
| } | ||
|
|
||
| /* |
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 is closed. If you want to just push a commit that removes that comment to the repo without waiting on a PR that'd be awesome.
|
|
||
| integTestCluster { | ||
| distribution = 'zip' | ||
| if (System.getProperty('tests.distribution') == 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.
This seems a bit complicated to add to every project. I'm not 100% sure we need to support -Dtests.distribution=integ-test-zip. Maybe integ-test-zip is a thing we should only use when you don't override the property.
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.
It'd be fairly simple to fail the build if someone sets distribution to integ-test-zip. If we did that then this project could do distribution = System.getProperty('tests.distribution', 'zip).
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 might be cleaner to move the PluginBuildPlugin change to a gradle.projectsEvaluated and have it handle the logic all in one place.
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.
setting distro integ-test-zip would offer a way to run some integration tests in a build that would be much quicker as it would skip a lot of the heavier integration tests (probably most of QA). I'm not sure how useful that would be during development, so can't decide if it's worth doing.
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 don't think that is generally useful. Plugins and modules are the projects which use integ-test-zip, and you can already cd into the plugins or modules dir and run tests from there.
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.
Yeah. I don't think we should support setting -Dtests.distribution=integ-test-zip. It should be what you get when you run without setting it.
|
@nik9000 just want to make sure that you looked at the todo list as well and share your thoughts before I start implementing |
rjernst
left a comment
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 have some general comments
| } | ||
|
|
||
| static Task configureInstallModuleTask(String name, Project project, Task setup, NodeInfo node, Project module) { | ||
| if (node.config.distribution != 'integ-test-zip') { |
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.
If using a non integ-test-zip distribution, modules need to not be installed at all. This looks like it allows installing them over what the distribution installs, which could create craziness. I think we need to skip setting up install module tasks if the distribution is not integ-test-zip.
|
|
||
| integTestCluster { | ||
| distribution = 'zip' | ||
| if (System.getProperty('tests.distribution') == 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 don't think that is generally useful. Plugins and modules are the projects which use integ-test-zip, and you can already cd into the plugins or modules dir and run tests from there.
| // for unicast discovery | ||
| ClusterConfiguration config = new ClusterConfiguration(project) | ||
| config.distribution = 'integ-test-zip' | ||
| config.distribution = System.getProperty('tests.distribution', 'integ-test-zip') |
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 am concerned this is fragile. I don't want to see this logic copied around to other projects. Can you please create an issue for making creating additional cluster fixtures easier, so that the default can be set by PluginBuildPlugin for this project and reused the we create this cluster?
|
Some tests seem to be written specifically for the integ test distro |
Makes it possible to have a key that points to a list and assert that a
certain object is present in the list. All keys have to be present and
values have to match. The objects in the source list may have additional
fields.
example:
```
match: { 'nodes.$master.plugins': { name: ingest-attachment } }
```
Some of the tests expected that the integration tests will always be ran with the `integ-test-zip` distribution so that there will be no other plugins loaded. With this change, we check for the presence of the plugin without assuming exclusivity.
|
The following still fails: |
To match the behavior of tets.distributions
| if(expectedValue instanceof Map && actualValue instanceof List) { | ||
| Map<String, Object> expectedMap = (Map<String, Object>) expectedValue; | ||
| List<Object> actualList = (List<Object>) actualValue; | ||
| assertTrue( |
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'm not sure we want match to be contains in some cases. If we want this we should make a new construct.
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 semantics seemed to fit with me, but now that I think of it, match is in fact an exact match so it should be an exact match when dealing with lists as well. I'll add a new construct and call it contains.
Replaces the previus changes that caused `match` to do a partial match.
|
test this please |
|
@nik9000 can you take another look please. |
nik9000
left a comment
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 it this is still a good thing to do. I've left a few requests to change things. Thanks for pinging me again on it!
| @@ -1,4 +1,4 @@ | |||
| # Integration tests for Expression scripts | |||
| # Integration tests for Expression scriptsmatch | |||
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.
Did you mean to add this?
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.
no, I'll have to be more careful with my fat fingers :) thanks !
| // for unicast discovery | ||
| ClusterConfiguration config = new ClusterConfiguration(project) | ||
| config.distribution = 'integ-test-zip' | ||
| config.distribution = System.getProperty('tests.distribution', 'integ-test-zip') |
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.
++ on this being fragile. Fixing it in a followup is fine with me though.
| integTestCluster.distribution = 'oss-zip' | ||
| } | ||
|
|
||
| if (integTestCluster.distribution == 'integ-test-zip') { |
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 can remove this line because we don't support setting the setting to this.
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.
We can add something to cluster formation tasks to make sure we don't set the system property to integ-test-zip.
qa/build.gradle
Outdated
| subproj.tasks.withType(RestIntegTestTask) { | ||
| subproj.extensions.configure("${it.name}Cluster") { cluster -> | ||
| cluster.distribution = System.getProperty('tests.distribution', 'oss-zip') | ||
| if (cluster.distribution == 'integ-test-zip') { |
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're better off checking if the system property is integ-test-zip in the cluster formation tasks and failing there. Basically, the only way you can get integ-test-zip is to not set the property.
| Map<String, Object> expectedMap = (Map<String, Object>) expectedValue; | ||
| List<Object> actualList = (List<Object>) actualValue; | ||
| List<Map<String, Object>> actualValues = actualList.stream() | ||
| .filter(each -> each instanceof Map) |
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 fail the assertion if the thing we're testing isn't a map.
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.
As implemented now, we can check that a list has an object that has all the keys at the specific values. In theory we could have a list having a mix of lists and objects. The filter only rules out anything that's not a map at this point when looking for actualValues. The subsequent check on actual values not empty would fail the assertion in case of a list of lists for example.
The only case we don't fail if we have a list that has both a list and an object that has the keys we are interested in, but I don't think we should in this case, because we did find that the list contains what we are looking for.
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 see! Got it.
| import static org.hamcrest.Matchers.not; | ||
| import static org.junit.Assert.assertNotNull; | ||
| import static org.junit.Assert.assertThat; | ||
| import static org.junit.Assert.assertTrue; |
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.
These look like leftovers.
| @@ -1,4 +1,4 @@ | |||
| # Integration tests for monitoring | |||
| # Integration tests for monitoring.23. | |||
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.
Mistake?
| - match: { nodes.$master.modules.21.name: x-pack-sql } | ||
| - match: { nodes.$master.modules.22.name: x-pack-upgrade } | ||
| - match: { nodes.$master.modules.23.name: x-pack-watcher } | ||
| - contains: { nodes.$master.modules: { name: x-pack-core } } |
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 seems nice!
nik9000
left a comment
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.
Thanks for working with me on this one! LGTM.
| Map<String, Object> expectedMap = (Map<String, Object>) expectedValue; | ||
| List<Object> actualList = (List<Object>) actualValue; | ||
| List<Map<String, Object>> actualValues = actualList.stream() | ||
| .filter(each -> each instanceof Map) |
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 see! Got it.
* master: ingest: Add ignore_missing property to foreach filter (#22147) (#31578) Fix a formatting issue in the docvalue_fields documentation. (#31563) reduce log level at gradle configuration time [TEST] Close additional clients created while running yaml tests (#31575) Docs: Clarify sensitive fields watcher encryption (#31551) Watcher: Remove never executed code (#31135) Add support for switching distribution for all integration tests (#30874) Improve robustness of geo shape parser for malformed shapes (#31449) QA: Create xpack yaml features (#31403) Improve test times for tests using `RandomObjects::addFields` (#31556) [Test] Add full cluster restart test for Rollup (#31533) Enhance thread context uniqueness assertion [DOCS] Fix heading format errors (#31483) fix writeIndex evaluation for aliases (#31562) Add x-opaque-id to search slow logs (#31539) Watcher: Fix put watch action (#31524) Add package pre-install check for java binary (#31343) Reduce number of raw types warnings (#31523) Migrate scripted metric aggregation scripts to ScriptContext design (#30111) turn GetFieldMappingsResponse to ToXContentObject (#31544) Close xcontent parsers (partial) (#31513) Ingest Attachment: Upgrade Tika to 1.18 (#31252) TEST: Correct the assertion arguments order (#31540)
* elastic/master: (57 commits) HLRest: Fix test for explain API [TEST] Fix RemoteClusterConnectionTests Add Create Snapshot to High-Level Rest Client (elastic#31215) Remove legacy MetaDataStateFormat (elastic#31603) Add explain API to high-level REST client (elastic#31387) Preserve thread context when connecting to remote cluster (elastic#31574) Unify headers for full text queries Remove redundant 'minimum_should_match' JDBC driver prepared statement set* methods (elastic#31494) [TEST] call yaml client close method from test suite (elastic#31591) ingest: Add ignore_missing property to foreach filter (elastic#22147) (elastic#31578) Fix a formatting issue in the docvalue_fields documentation. (elastic#31563) reduce log level at gradle configuration time [TEST] Close additional clients created while running yaml tests (elastic#31575) Docs: Clarify sensitive fields watcher encryption (elastic#31551) Watcher: Remove never executed code (elastic#31135) Add support for switching distribution for all integration tests (elastic#30874) Improve robustness of geo shape parser for malformed shapes (elastic#31449) QA: Create xpack yaml features (elastic#31403) Improve test times for tests using `RandomObjects::addFields` (elastic#31556) ...
Makes it possible to have a key that points to a list and assert that a
certain object is present in the list. All keys have to be present and
values have to match. The objects in the source list may have additional
fields.
example:
```
contains: { 'nodes.$master.plugins': { name: ingest-attachment } }
```
Backported from elastic#30874 (e8b8d11)
Co-authored-by: Alpar Torok <[email protected]>
The contains syntax was added in elastic#30874 but the skips were not properly put in place. The java runner has the feature so the tests will run as part of the build, but language clients will be able to support it at their own pace.
The contains syntax was added in #30874 but the skips were not properly put in place. The java runner has the feature so the tests will run as part of the build, but language clients will be able to support it at their own pace.
The contains syntax was added in #30874 but the skips were not properly put in place. The java runner has the feature so the tests will run as part of the build, but language clients will be able to support it at their own pace.
Makes it possible to have a key that points to a list and assert that a
certain object is present in the list. All keys have to be present and
values have to match. The objects in the source list may have additional
fields.
example:
```
contains: { 'nodes.$master.plugins': { name: ingest-attachment } }
```
Backported from #30874 (e8b8d11)
Co-authored-by: Alpar Torok <[email protected]>
Allow using the
tests.distributionproperty for telling integration tests which distribution to use.If the property is not present, integration tests for plugins will use
integ-test-zip, qa integration tests will default tooss-zip, and x-pack qa tozip.When the property is present, integration tests will always honor it, meaning that integration tests will be skipped if they cannot run against the specific distribution. e.x. we won't run
x-pack/qawith-Dtests.distribution=oss-zipbecause we can't honor that, ignoring the property and running them withzipwould just duplicate the work.TODO:
tests.distributionfor plugins to switch distribution these run againstx-pack/plugins/build.gradle( top level ) integration tests if distribution is notzipxpack-qatests iftests.distributionand it's notzipinteg-test-zipto QA ? Tests should probably be skipped.tests.distributionand with each ofzip,oss-zip