FTR - optimize service initialization#212421
Conversation
| private readonly browser = | ||
| // browser service is not normally available in common. | ||
| this.ctx.hasService('browser') ? (this.ctx.getService('browser' as any) as Browser) : undefined; | ||
| this.ctx.hasService('browser') ? this.ctx.getService('browser' as any) : undefined; |
There was a problem hiding this comment.
The construction here was not ideal: the service tries to determine if it's loaded for a UI suite and in that case adds steps in the UI after the test user role has been updated. Importing the types from the UI services would introduce a cyclic dependency. I've decided to remove the typing here as it's only a few lines of code making use of it. The alternative would probably be to move the browser and test subject services to yet another package so we can import from this common package as well as from the UI package, but to me that seemed too much effort for the gained benefit.
|
Pinging @elastic/fleet (Team:Fleet) |
machadoum
left a comment
There was a problem hiding this comment.
Entity Analytics team changes LGTM!
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Public APIs missing exports
Unknown metric groupsAPI count
History
cc @pheyos |
|
Starting backport for target branches: 8.x, 9.0 https://github.com/elastic/kibana/actions/runs/13564395702 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary This PR optimizes the FTR service initialization by not loading UI service for API tests and by removing retries during test user setup ## Changes - Remove loading of common UI services from common services (UI services should not be loaded for API tests) - Move `security` service from `@kbn/ftr-common-functional-ui-services` to `@kbn/ftr-common-functional-services` as it should be available to API tests as well - Only try once to delete `testUser` during init (this user usually does not exist on a fresh deployment - and if it does, a single delete request is enough to get rid of it) ## Benchmark results **These changes will reduce FTR CI runtime overall by ~100 minutes** :rocket: Due to parallel workers in CI, the effective runtime of the whole CI job will be less than that. - The removal of UI service loading (which includes starting a browser instance) for API tests reduces init time by ~0.5 seconds. With 313 API configs that are started on CI, this reduces the runtime overall by ~156 seconds / ~2.6 minutes. - The removal of test user delete retries reduces init time by ~10 seconds. With 589 FTR configs that are started on CI, this reduces the runtime overall by ~5890 seconds / ~98 minutes. - These numbers have been taken on a local machine and since CI workers are usually slower, we should see at least this amount of improvement if not more in CI. (cherry picked from commit 7a381af) # Conflicts: # src/platform/packages/shared/kbn-ftr-common-functional-services/index.ts
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
# Backport This will backport the following commits from `main` to `8.x`: - [FTR - optimize service initialization (#212421)](#212421) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Robert Oskamp","email":"robert.oskamp@elastic.co"},"sourceCommit":{"committedDate":"2025-02-27T10:35:47Z","message":"FTR - optimize service initialization (#212421)\n\n## Summary\n\nThis PR optimizes the FTR service initialization by not loading UI\nservice for API tests and by removing retries during test user setup\n\n## Changes\n\n- Remove loading of common UI services from common services (UI services\nshould not be loaded for API tests)\n- Move `security` service from `@kbn/ftr-common-functional-ui-services`\nto `@kbn/ftr-common-functional-services` as it should be available to\nAPI tests as well\n- Only try once to delete `testUser` during init (this user usually does\nnot exist on a fresh deployment - and if it does, a single delete\nrequest is enough to get rid of it)\n\n## Benchmark results\n\n**These changes will reduce FTR CI runtime overall by ~100 minutes**\n:rocket:\nDue to parallel workers in CI, the effective runtime of the whole CI job\nwill be less than that.\n\n- The removal of UI service loading (which includes starting a browser\ninstance) for API tests reduces init time by ~0.5 seconds. With 313 API\nconfigs that are started on CI, this reduces the runtime overall by ~156\nseconds / ~2.6 minutes.\n- The removal of test user delete retries reduces init time by ~10\nseconds. With 589 FTR configs that are started on CI, this reduces the\nruntime overall by ~5890 seconds / ~98 minutes.\n- These numbers have been taken on a local machine and since CI workers\nare usually slower, we should see at least this amount of improvement if\nnot more in CI.","sha":"7a381afb177c81ed4d0704cfcec49e6da7179376","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport missing","Team:Fleet","v9.0.0","backport:version","v9.1.0","v8.19.0"],"title":"FTR - optimize service initialization","number":212421,"url":"https://github.com/elastic/kibana/pull/212421","mergeCommit":{"message":"FTR - optimize service initialization (#212421)\n\n## Summary\n\nThis PR optimizes the FTR service initialization by not loading UI\nservice for API tests and by removing retries during test user setup\n\n## Changes\n\n- Remove loading of common UI services from common services (UI services\nshould not be loaded for API tests)\n- Move `security` service from `@kbn/ftr-common-functional-ui-services`\nto `@kbn/ftr-common-functional-services` as it should be available to\nAPI tests as well\n- Only try once to delete `testUser` during init (this user usually does\nnot exist on a fresh deployment - and if it does, a single delete\nrequest is enough to get rid of it)\n\n## Benchmark results\n\n**These changes will reduce FTR CI runtime overall by ~100 minutes**\n:rocket:\nDue to parallel workers in CI, the effective runtime of the whole CI job\nwill be less than that.\n\n- The removal of UI service loading (which includes starting a browser\ninstance) for API tests reduces init time by ~0.5 seconds. With 313 API\nconfigs that are started on CI, this reduces the runtime overall by ~156\nseconds / ~2.6 minutes.\n- The removal of test user delete retries reduces init time by ~10\nseconds. With 589 FTR configs that are started on CI, this reduces the\nruntime overall by ~5890 seconds / ~98 minutes.\n- These numbers have been taken on a local machine and since CI workers\nare usually slower, we should see at least this amount of improvement if\nnot more in CI.","sha":"7a381afb177c81ed4d0704cfcec49e6da7179376"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212421","number":212421,"mergeCommit":{"message":"FTR - optimize service initialization (#212421)\n\n## Summary\n\nThis PR optimizes the FTR service initialization by not loading UI\nservice for API tests and by removing retries during test user setup\n\n## Changes\n\n- Remove loading of common UI services from common services (UI services\nshould not be loaded for API tests)\n- Move `security` service from `@kbn/ftr-common-functional-ui-services`\nto `@kbn/ftr-common-functional-services` as it should be available to\nAPI tests as well\n- Only try once to delete `testUser` during init (this user usually does\nnot exist on a fresh deployment - and if it does, a single delete\nrequest is enough to get rid of it)\n\n## Benchmark results\n\n**These changes will reduce FTR CI runtime overall by ~100 minutes**\n:rocket:\nDue to parallel workers in CI, the effective runtime of the whole CI job\nwill be less than that.\n\n- The removal of UI service loading (which includes starting a browser\ninstance) for API tests reduces init time by ~0.5 seconds. With 313 API\nconfigs that are started on CI, this reduces the runtime overall by ~156\nseconds / ~2.6 minutes.\n- The removal of test user delete retries reduces init time by ~10\nseconds. With 589 FTR configs that are started on CI, this reduces the\nruntime overall by ~5890 seconds / ~98 minutes.\n- These numbers have been taken on a local machine and since CI workers\nare usually slower, we should see at least this amount of improvement if\nnot more in CI.","sha":"7a381afb177c81ed4d0704cfcec49e6da7179376"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
## Summary This PR optimizes the FTR service initialization by not loading UI service for API tests and by removing retries during test user setup ## Changes - Remove loading of common UI services from common services (UI services should not be loaded for API tests) - Move `security` service from `@kbn/ftr-common-functional-ui-services` to `@kbn/ftr-common-functional-services` as it should be available to API tests as well - Only try once to delete `testUser` during init (this user usually does not exist on a fresh deployment - and if it does, a single delete request is enough to get rid of it) ## Benchmark results **These changes will reduce FTR CI runtime overall by ~100 minutes** :rocket: Due to parallel workers in CI, the effective runtime of the whole CI job will be less than that. - The removal of UI service loading (which includes starting a browser instance) for API tests reduces init time by ~0.5 seconds. With 313 API configs that are started on CI, this reduces the runtime overall by ~156 seconds / ~2.6 minutes. - The removal of test user delete retries reduces init time by ~10 seconds. With 589 FTR configs that are started on CI, this reduces the runtime overall by ~5890 seconds / ~98 minutes. - These numbers have been taken on a local machine and since CI workers are usually slower, we should see at least this amount of improvement if not more in CI.
Summary
This PR optimizes the FTR service initialization by not loading UI service for API tests and by removing retries during test user setup
Changes
securityservice from@kbn/ftr-common-functional-ui-servicesto@kbn/ftr-common-functional-servicesas it should be available to API tests as welltestUserduring init (this user usually does not exist on a fresh deployment - and if it does, a single delete request is enough to get rid of it)Benchmark results
These changes will reduce FTR CI runtime overall by ~100 minutes 🚀
Due to parallel workers in CI, the effective runtime of the whole CI job will be less than that.