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

[APM] Optimize API test order #88654

Merged
merged 17 commits into from
Jan 27, 2021
Merged

Conversation

dgieselaar
Copy link
Member

@dgieselaar dgieselaar commented Jan 19, 2021

Conditionally run API tests (depending on which configuration is active), and run them in the most efficient order to minimize time spent loading/unloading archives.

For the trial tests, total time goes from 8m to 2m. Might yield even better returns for basic tests (as there are more). Basic suite goes down to 2m (from 13m).

Obviously somewhat gross but might be worth it.

Here's the general outline:

  • Expose a runner service (needs a better name) to register tests (using runner.when())
  • runner.when() accepts a title (for the suite), a condition or more conditions, and the body of the suite (ie, it() and describe())
  • When all tests have been registered, call runner.run() which will select tests that should run and group tests that need the same archives
  • For each test group, load and unload the archives once

I also need to change the way decorate_snapshot_ui gets the file from the test, as Mocha incorrectly assumes its in the same file as the root suite. Done, using the stack trace now.

@dgieselaar dgieselaar changed the title [APM] POC: Matrix API testing [APM] POC: Optimize API test order Jan 19, 2021
@dgieselaar dgieselaar marked this pull request as ready for review January 20, 2021 20:20
@dgieselaar dgieselaar requested a review from a team as a code owner January 20, 2021 20:20
@dgieselaar dgieselaar requested a review from a team January 20, 2021 20:20
@dgieselaar dgieselaar changed the title [APM] POC: Optimize API test order [APM] Optimize API test order Jan 20, 2021
Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

Very excited to see this exploration, I've tried to do something similar many times but get caught up in the details and fear of defining a new interface around Mocha (and the inevitable cries about custom interfaces) but I hope this exploration will lead to some info we can apply to a solution provided by the FTR in the future.

PS: I wouldn't complain if you split the FTR changes out into a separate PR, but they look good to me.

Copy link
Contributor

@smith smith left a comment

Choose a reason for hiding this comment

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

This is great. Works as advertised.

Looks like the jest failures are related to your changes so ok to merge once we're green.

Thanks for doing this.

import archives_metadata from '../../../common/fixtures/es_archiver/archives_metadata';
import { FtrProviderContext } from '../../../../common/ftr_provider_context';
import archives_metadata from '../../common/fixtures/es_archiver/archives_metadata';
import { FtrProviderContext } from '../../common/ftr_provider_context';

export default function ApiTest({ getService }: FtrProviderContext) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Some of these are ApiTest, some are apiTest, and some are somethingApiTest. I prefer lowercase, but it doesn't actually make a difference. Looks like you mostly are preserving what is previously there.

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

This is great!

@dgieselaar
Copy link
Member Author

@spalger I think that's a good idea, created a separate PR for FTR changes: #88950

@dgieselaar dgieselaar added release_note:skip Skip the PR/issue when compiling release notes v7.12.0 labels Jan 22, 2021
@dgieselaar
Copy link
Member Author

@elasticmachine merge upstream

@dgieselaar
Copy link
Member Author

dgieselaar commented Jan 24, 2021

@spalger I had to make some changes unfortunately to make it work:

  • Instead of using a service I'm now using a module. Looks like services are never initialized when running scripts/ensure_all_tests_in_ci_group.js, so the tests using registry.when() never get registered
  • I initially changed decorate_snapshot_ui to use the stacktrace from expectSnapshot() to get the file for a test. But that means I can only find tests that are not skipped, which means that decorate_snapshot_ui will report false positives for obsolete snapshots. What I'm doing now is using eachTest() for the root suite to iterate over all the tests, and I'm setting test.file when registering a suite in registry.when().

Probably good if you have another look at the changes?

@dgieselaar dgieselaar requested a review from spalger January 24, 2021 13:33
@dgieselaar
Copy link
Member Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

Code looks good, double checked that all tests are running and I'm seeing everything where it should be, but it looks like we might be executing a lot more tests than expected.

Based on the numbers at https://kibana-ci.elastic.co/job/elastic+kibana+pipeline-pull-request/101001/testReport/ and compared to the test results from the master build of f5e869189b0bbf242637a2fb8f06c1e5e74633b7 (which was merged into this PR most recently) There are now 68 new tests in "APM API integration tests (basic)", and 158 new tests in "X-Pack APM API integration tests (trial)". If these numbers look right to you then LGTM!

@dgieselaar
Copy link
Member Author

@spalger I think that's correct, we're registering all tests now but skipping those that are not applicable. The new (skipped) tests in basic are the trial tests, and vice versa.

@spalger
Copy link
Contributor

spalger commented Jan 26, 2021

Ah, that makes sense. Would be ideal to skip registering them all together but I get the approach.

@dgieselaar dgieselaar merged commit 053628c into elastic:master Jan 27, 2021
@dgieselaar dgieselaar deleted the matrix-testing branch January 27, 2021 08:54
dgieselaar added a commit to dgieselaar/kibana that referenced this pull request Jan 27, 2021
dgieselaar added a commit that referenced this pull request Jan 27, 2021
Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Jan 27, 2021
…y-tests

* 'master' of github.com:elastic/kibana: (276 commits)
  [Telemetry] Settings Collector: redact sensitive reported values (elastic#88675)
  [CI] Combines Jest test jobs (elastic#85850)
  [Upgrade Assistant] Migrate server to new es-js client (elastic#89207)
  Migrate maps_legacy, maps_oss, region_map, and tile_map plugions to TS projects (elastic#89351)
  [Vega Docs] Add experimental flag on the vega maps title (elastic#89402)
  Increase the time needed to locate the save viz toast (elastic#89301)
  [Enterprise Search] Add links to doc links service (elastic#89260)
  Fixed regex bug in Safari (elastic#89399)
  [Lens] Fix indexpattern checks for missing references (elastic#88840)
  [Lens] Clean up usage collector (elastic#89109)
  update apm index pattern (elastic#89395)
  [APM] Upgrade ES client (elastic#86594)
  Enable v2 so migrations, disable in FTR tests (elastic#89297)
  [Search Sessions] Make search session indicator UI opt-in, refactor per-app capabilities (elastic#88699)
  Cleanup OSS code from visualizations wizard (elastic#89092)
  [APM] Optimize API test order (elastic#88654)
  Rename conversion function, extract to module scope and add tests. (elastic#89018)
  [core.logging] Add ops logs to the KP logging system (elastic#88070)
  chore(NA): improve ts build refs performance on kbn bootstrap (elastic#89333)
  skip flaky suite (elastic#89379)
  ...

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx
#	x-pack/test/accessibility/config.ts
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 27, 2021
…ana into task-manager/shift-on-trend

* 'task-manager/shift-on-trend' of github.com:gmmorris/kibana: (74 commits)
  [Metrics UI] Fix Host Overview boxes in Host Detail page (elastic#89299)
  [Telemetry] Settings Collector: redact sensitive reported values (elastic#88675)
  [CI] Combines Jest test jobs (elastic#85850)
  [Upgrade Assistant] Migrate server to new es-js client (elastic#89207)
  Migrate maps_legacy, maps_oss, region_map, and tile_map plugions to TS projects (elastic#89351)
  [Vega Docs] Add experimental flag on the vega maps title (elastic#89402)
  Increase the time needed to locate the save viz toast (elastic#89301)
  [Enterprise Search] Add links to doc links service (elastic#89260)
  Fixed regex bug in Safari (elastic#89399)
  [Lens] Fix indexpattern checks for missing references (elastic#88840)
  [Lens] Clean up usage collector (elastic#89109)
  update apm index pattern (elastic#89395)
  [APM] Upgrade ES client (elastic#86594)
  Enable v2 so migrations, disable in FTR tests (elastic#89297)
  [Search Sessions] Make search session indicator UI opt-in, refactor per-app capabilities (elastic#88699)
  Cleanup OSS code from visualizations wizard (elastic#89092)
  [APM] Optimize API test order (elastic#88654)
  Rename conversion function, extract to module scope and add tests. (elastic#89018)
  [core.logging] Add ops logs to the KP logging system (elastic#88070)
  chore(NA): improve ts build refs performance on kbn bootstrap (elastic#89333)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants