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

Scout: run tests in parallel (with spaces) #207253

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

dmlemeshko
Copy link
Member

@dmlemeshko dmlemeshko commented Jan 20, 2025

Summary

This PR adds spaceTest interface to kbn-scout to run space aware tests, that can be executed in parallel. Most of Discover tests were converted to parallel run because we see runtime improvement with 2 parallel workers.

Experiment 1: ES data pre-ingested, running 9 Discover stateful tests in 5 files locally

Run setup Took time
1 worker 1.3 min
2 workers 58.7 sec
3 workers 48.3 sec
4 workers tests fail

Conclusion: using 2 workers is the optimal solution to continue

Experiment 2: Running Discover tests for stateful/serverless in Kibana CI (starting servers, ingesting ES data, running tests)

Run setup 1 worker 2 workers diff
stateful, 9 tests / 5 files 1.7 min 1.2 min -29.4%
svl ES, 8 tests / 4 files 1.7 min 1.3 min -23.5%
svl Oblt, 8 tests / 4 files 1.8 min 1.4 min -22.2%
svl Search, 5 tests / 2 files 59.9 sec 51.6 sec -13.8%

Conclusion: parallel run effectiveness benefits from tests being split in more test files.

Experiment 3: Clone existing tests to have 3 times more test files and re-run tests for stateful/serverless in Kibana CI (starting servers, ingesting ES data, running tests)

Run setup 1 worker 2 workers diff
stateful, 27 tests / 15 files 4.3 min 2.7 min -37.2%
svl ES, 24 tests / 12 files 4.3 min 2.7 min -37.2%

Conclusion: parallel run effectiveness is increasing with more test files in place, not linear but with good test design we can expect up to 40% or maybe a bit more.

How parallel run works:

  • scoutSpace fixture is loaded on Playwright worker setup (using auto: true config), creates a new Kibana Space, expose its id to other fixtures and deletes the space on teardown.
  • browserAuth fixture for parallel run caches Cookie per worker/space like role:spaceId. It is needed because Playwright doesn't spin up new browser for worker, but only new context.
  • kbnClient was updated to allow passing createNewCopies: true in query, it is needed to load the same Saved Objects in parallel workers/spaces and generate new ids to work with them. scoutSpace caches ids and allows to reach saved object by its name. This logic is different from single thread run, where we can use default ids from kbnArchives.

How to run parallel tests locally, e.g. for stateful:

node scripts/scout run-tests --stateful --config x-pack/platform/plugins/private/discover_enhanced/ui_tests/parallel.playwright.config.ts

@dmlemeshko dmlemeshko self-assigned this Jan 22, 2025
@dmlemeshko dmlemeshko added v9.0.0 backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) test:scout release_note:skip Skip the PR/issue when compiling release notes labels Jan 22, 2025
@dmlemeshko dmlemeshko marked this pull request as ready for review January 22, 2025 11:40
@dmlemeshko dmlemeshko requested review from a team as code owners January 22, 2025 11:40

return measurePerformance(log, '[scout setup]: ingestTestDataHook', async () => {
// TODO: This should be configurable local vs cloud
const configName = 'local';
Copy link
Member Author

@dmlemeshko dmlemeshko Jan 22, 2025

Choose a reason for hiding this comment

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

we have separate issue to enable cloud testing.

testDir: string;
workers?: 1 | 2;
workers?: 1 | 2 | 3; // to keep performance consistent within test suites
Copy link
Member Author

Choose a reason for hiding this comment

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

We can keep 3 as an option to experiment in the future. wdyt?

body: formData,
headers: formData.getHeaders(),
});

if (resp.data.success) {
this.log.success('import success');
return resp.data;
Copy link
Member Author

Choose a reason for hiding this comment

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

We need response to access re-generated ids

@elasticmachine
Copy link
Contributor

elasticmachine commented Jan 22, 2025

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #17 / Connector renders loading state correctly
  • [job] [logs] Jest Tests #17 / useGetActionLicense unhappy path

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/scout 86 104 +18
@kbn/test 306 307 +1
total +19

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/scout 8 10 +2
Unknown metric groups

API count

id before after diff
@kbn/scout 121 134 +13
@kbn/test 361 362 +1
total +14

ESLint disabled line counts

id before after diff
discoverEnhanced 1 3 +2

Total ESLint disabled count

id before after diff
discoverEnhanced 1 3 +2

History

cc @dmlemeshko

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes test:scout v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants