Functional test setup with kbn-test package#18568
Functional test setup with kbn-test package#18568rhoboat merged 16 commits intoelastic:masterfrom rhoboat:improve-integ-test-xpack
Conversation
This comment has been minimized.
This comment has been minimized.
|
Tests themselves are passing but the x-pack job failed because of looking into this. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
I like how it looks, we can handle papercuts in the follow-ups, so LGTM for non-x-pack part.
I'm still keeping review request for x-pack portion: readme is outdated and I couldn't run saml api integration tests (destructuring of xPackAPITestsConfig.get('elasticsearchServerArgs') that isn't defined and permission error when ES tries to load idp_metadata.xml), likely it's still in progress.
There was a problem hiding this comment.
note: we agreed to handle or at least re-consider this in the follow-up, so just a reminder here: having such default configPaths looks weird to me, but if it's fine for everyone else then we should at least mention this in README.md (same for runServers).
There was a problem hiding this comment.
as a result of moving things to cli, this was resolved and config paths are no longer referenced here. take another look?
packages/kbn-test/package.json
Outdated
There was a problem hiding this comment.
question: is there any reason why you don't use the latest available versions of deps? And IIRC we're trying to use "caret" versions whenever possible.
There was a problem hiding this comment.
My reasoning was to use the same versions that are currently being used, without upgrading dependencies.
There was a problem hiding this comment.
Why does it matter what versions are currently used in Kibana if we introduce isolated (once we get rid of FTR dependency), test-only and brand new package with its own dependencies and have a chance to not rely on something that's outdated (both dependencies themselves and the way we define them in package.json since we commit yarn.lock)?
Just to be clear, it's not a big deal at all and we can discuss it after this PR is merged, I'm just trying to find common ground on this matter and not to raise this question again :)
There was a problem hiding this comment.
note: I believe we shouldn't process both "normal" arguments (configPaths) and argv in the same function, there should be a dedicated function/cli that parses command line arguments into string[] and passes it to runTests. Having said that, I'm totally fine if we discuss it in the follow-up. (same for runServers)
There was a problem hiding this comment.
Take another look? I made some cli functions using only getopts. Commander would be overkill at the moment because we also need special args to be passed to functional_test_runner. I think this should be resolved in a followup.
There was a problem hiding this comment.
optional nit: what if we:
- remove
awaitin front ofresolvesince it's sync function - mark
configPathasconstand not reuse it for both "resolved" and "non-resolved" path versions - limit scope of
try/catchonly to piece of code we expect errors to come from
for (const configPath of configs) {
try {
await runWithConfig(resolve(KIBANA_ROOT, configPath), runEs, runKbn);
} catch (err) {
fatalErrorHandler(err);
}
}But since runWithConfig already wraps its content into the same try/catch we don't need to duplicate error handling in this function and it feels like we can just inline content of runWithConfig here.
Changes are arguable, hence optional :)
There was a problem hiding this comment.
question: what if we use options: { runEs = runElasticseach, runKbn = runKibanaServer }? With this we'll be able to only override how we run Kibana if we want to. Or you think it's not a valid use case? (same for runServers)
There was a problem hiding this comment.
That's a valid use case. Let's do that!
test/common/config.js
Outdated
There was a problem hiding this comment.
optional nit: hmm, maybe let's just move esTestConfig.getUrlParts() to a variable (it's called 4 times in this function)?
There was a problem hiding this comment.
or rather, use the existing servers.elasticsearch definition in this file. ;)
test/multiple_config.js
Outdated
There was a problem hiding this comment.
question: this file isn't needed anymore, right (:tada:)?
There was a problem hiding this comment.
Ah, it is deleted from x-pack but not from kibana.
x-pack/README.md
Outdated
There was a problem hiding this comment.
question: should we start sentence for every list item from the capital letter?
There was a problem hiding this comment.
Fixed-- made them all lowercase.
x-pack/README.md
Outdated
There was a problem hiding this comment.
nit: no more x-pack-elasticsearch (and x-pack-kibana below), right?
x-pack/README.md
Outdated
There was a problem hiding this comment.
issue: it seems there is no functional_tests_single.
tylersmalley
left a comment
There was a problem hiding this comment.
Good direction so far. Added comments inline which should allow you to entirely get rid of runEsWithXpack.
There was a problem hiding this comment.
This should be replaced with using kbn/es, and doing so the following files can be removed:
- packages/kbn-test/src/functional_tests/lib/find_most_recently_changed.js
- packages/kbn-test/src/functional_tests/lib/tarball.js
- x-pack/dev-tools/functional_tests/lib/tarball.js
- x-pack/dev-tools/functional_tests/lib/find_most_recently_changed.js
And some paths in packages/kbn-test/src/functional_tests/lib/paths.js and x-pack/dev-tools/functional_tests/lib/paths.js can also be removed
There was a problem hiding this comment.
Added comments inline which should allow you to entirely get rid of runEsWithXpack.
This should be replaced with using kbn/es,
So, you're saying we get rid of runElasticsearch and runEsWithXpack, both?
There was a problem hiding this comment.
^ Nevermind, yes, that makes sense. Both would go away, or just be simple methods that use kbn/es
There was a problem hiding this comment.
Since running with or without x-pack is an option presented to kbn/es with license. We can probably get rid of this altogether and add as part of the configuration.
x-pack/scripts/functional_tests.js
Outdated
There was a problem hiding this comment.
The SAML tests need their own config since they require specific ES/Kibana configuration, correct?
There was a problem hiding this comment.
Yes, the idea was to move all that SAML-specific logic from the start/run methods and into config instead.
There was a problem hiding this comment.
Changing this to an object would allow us to directly pass options to kbn/es installSnapshot/installSource.
Thinking something shaped like this:
{
license: 'basic',
password: 'changeme',
esArgs: []
}
There was a problem hiding this comment.
Great, that's a good plan. But then they have a different appearance than the kibanaServerArgs. I guess that doesn't look too bad.
There was a problem hiding this comment.
Maybe the name should be something else, since esArgs: [] within is now the array.
There was a problem hiding this comment.
@tylersmalley Your thoughts on the changes here? Did some work last Thursday to use kbn/es here, but still using proc.
There was a problem hiding this comment.
(I named this myClusterStart just to try this out. Name needs to be better)
There was a problem hiding this comment.
@tylersmalley How does this work today? Originally we had this
fs.createReadStream(
resolve(XPACK_KIBANA_ROOT, 'test/saml_api_integration/fixtures/idp_metadata.xml')
).pipe(
fs.createWriteStream(resolve(esExtractPath, 'config', 'idp_metadata.xml'))
);
to copy the idp_metadata.xml file into the config dir of the elasticsearch install path. How is the current code able to reference this path without a permissions error? Locally (with my PR), I see
java.security.AccessControlException: access denied ("java.io.FilePermission"
"/Users/archana/Development/apps/elastic/versions/master/kibana/x-pack/
test/saml_api_integration/fixtures/idp_metadata.xml" "read")
There was a problem hiding this comment.
You just need to pass it as an absolute path, kbn/es will ensure any absolute path to a file is copied to the config directory before running.
https://github.com/elastic/kibana/blob/master/packages/kbn-es/src/utils/extract_config_files.js
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@tylersmalley ready for your review again, took care of all your concerns. (but there may be more) |
This comment has been minimized.
This comment has been minimized.
|
@archanid I'm confused about the description for running the x-pack functional tests. It looks like both Kibana and the x-pack tests are started with
and in the x-pack section it says What are How can the same functional_tests script have 2 different defaults? Lastly, can we call this issue I tend to think of all of these tests as Functional tests. And the name of the test script is |
💚 Build Succeeded |
Restructure testing with kbn-test package - Run with multiple configs, move cli options to config - Package-ify kbn-test - Eventually we'll have functional_test_runner live in a package of its own, and then this kbn-test will use that as a dependency, probably still as a devDependency. - Implement functional_tests_server - Collapse single and multiple config apis into one command Use kbn-es Replace es_test_cluster + es_test_config with kbn/test utils Implement new createEsTestCluster Improve scripts, jsdocs, cli top-level tools Lift error handling to the top level
Restructure testing with kbn-test package - Run with multiple configs, move cli options to config - Package-ify kbn-test - Eventually we'll have functional_test_runner live in a package of its own, and then this kbn-test will use that as a dependency, probably still as a devDependency. - Implement functional_tests_server - Collapse single and multiple config apis into one command Use kbn-es Replace es_test_cluster + es_test_config with kbn/test utils Implement new createEsTestCluster Improve scripts, jsdocs, cli top-level tools Lift error handling to the top level
Restructure testing with kbn-test package - Run with multiple configs, move cli options to config - Package-ify kbn-test - Eventually we'll have functional_test_runner live in a package of its own, and then this kbn-test will use that as a dependency, probably still as a devDependency. - Implement functional_tests_server - Collapse single and multiple config apis into one command Use kbn-es Replace es_test_cluster + es_test_config with kbn/test utils Implement new createEsTestCluster Improve scripts, jsdocs, cli top-level tools Lift error handling to the top level
Meta Issue: #12699
This PR improves functional test setup in Kibana and plugins. The idea is to group test files that need to run, along with the specific Elasticsearch server and Kibana server they need to run against. All of this information is now in a single config file. For each config file, we can start up servers, run tests, and tear them down. This means we can pass in multiple config files to do several iterations of this in one go.
Overview
Explanation:
Look at the READMEs (here and here).
Files:
Code that originally existed in
x-pack-kibana/dev-tools/functional_testshas been migrated to Kibana, just used as a starting point for how we can run functional tests for both Kibana and X-Pack Kibana. Many of the files are the same in the newpackages/kbn-test/src/functional_tests/lib.To run
node scripts/functional_tests--config test/functional/config.js --config test/api_integration/config.jstest/functional/config.jstest/api_integration/config.js.node scripts/functional_tests_server [--config test/functional/config.js]node scripts/functional_test_runnerLater PRs:
node scripts/functional_tests[Functional Tests] Use @kbn/test on Kibana CI #18593X-Pack
For x-pack, all functional, api, and saml api integration tests are run via methods exposed from Kibana.
To run
Change directory into
x-packfirst.node scripts/functional_tests [--config test/functional/config.js --config test/api_integration/config.js --config test/saml_api_integration/config.js]test/functional/config.jstest/api_integration/config.js, andtest/saml_api_integration/config.js.node scripts/functional_tests_server [--config test/functional/config.js]node scripts/functional_test_runner--bailoption still passed to ftr (don't use commander)