Skip to content

Introduce code coverage collection to Cypress runs #9084

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

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

Conversation

AMoo-Miki
Copy link
Collaborator

@AMoo-Miki AMoo-Miki commented Dec 20, 2024

Description

  • Introduce code coverage collection to Cypress runs
  • Add coverage reporting to Cypress CI
  • Enable Cypress tests to detect features of the OSD instance they are running against
  • Turn on test isolation when security is disabled
  • Add comprehensive testing based on features during CI
  • Add auto-login to Cypress tests when security is enabled

Changelog

  • test: Introduce code coverage collection to Cypress runs
  • test: Enable Cypress tests to detect features of the OSD instance they are running against
  • test: Turn on test isolation when security is disabled
  • infra: Add coverage reporting to Cypress CI
  • infra: Add comprehensive testing based on features during CI
  • test: Add auto-login to Cypress tests when security is enabled

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 57.62%. Comparing base (9b5ce68) to head (08bc81f).

Files with missing lines Patch % Lines
packages/osd-babel-preset/common_preset.js 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9084      +/-   ##
==========================================
- Coverage   61.02%   57.62%   -3.41%     
==========================================
  Files        3813     4187     +374     
  Lines       91401   114337   +22936     
  Branches    14443    24825   +10382     
==========================================
+ Hits        55782    65887   +10105     
- Misses      32056    45284   +13228     
+ Partials     3563     3166     -397     
Flag Coverage Δ
Linux_1 29.08% <50.00%> (+<0.01%) ⬆️
Linux_2 56.45% <50.00%> (-0.01%) ⬇️
Linux_3 38.02% <50.00%> (?)
Linux_4 29.02% <0.00%> (-0.01%) ⬇️
Windows_1 29.09% <50.00%> (-0.02%) ⬇️
Windows_2 56.40% <50.00%> (-0.01%) ⬇️
Windows_3 38.03% <50.00%> (+<0.01%) ⬆️
Windows_4 29.02% <0.00%> (-0.01%) ⬇️
cypress:core-opensearch-dashboards:1 20.97% <100.00%> (?)
cypress:root:1 28.93% <100.00%> (?)
cypress:root:2 31.97% <100.00%> (?)
cypress:root:3 25.25% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

LDrago27
LDrago27 previously approved these changes Dec 20, 2024
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Dec 20, 2024
ananzh
ananzh previously approved these changes Dec 27, 2024
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Jan 12, 2025
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Jan 12, 2025
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Jan 12, 2025
@AMoo-Miki
Copy link
Collaborator Author

Talking to @ananzh, cypress:core-opensearch-dashboards:3 is expected to fail due to some data already existing; the tests have to clean up before they start.

@angle943
Copy link
Collaborator

There's a lot of good stuff in this PR. Unfortunately due to the age of the PR and the tremendous changes we made to the testing files past month, it cannot be merged as is. I will pick the good things that are relevant from this PR and make a fresh PR

@@ -57,6 +57,8 @@
"test:ftr": "scripts/use_node scripts/functional_tests",
"test:ftr:server": "scripts/use_node scripts/functional_tests_server",
"test:ftr:runner": "scripts/use_node scripts/functional_test_runner",
"test:cypress": "env TZ=America/Los_Angeles NO_COLOR=1 yarn cypress run",
"test:cypress:open": "env TZ=America/Los_Angeles NO_COLOR=1 yarn cypress open",
Copy link
Collaborator

Choose a reason for hiding this comment

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

* @param {Partial<Cypress.RequestOptions>} requestOptions
*/

Cypress.Commands.add('sendOpenSearch', (requestOptions) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think requestOpenSearch is better to conform to cypress's naming of cy.request()

'osd-xsrf': true,
},
});
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets add this change once we have SECURITY_ENABLED tests


beforeEach(() => {
cy.login();
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

we've had discussions as a team about how we want to remove the usage of beforeEach whenever possible, due to the following:

  • The tests were taking too long
  • The crashes that were happening due to the duration of the tests

Would a future implementation where this is replaced with before work?

@angle943 angle943 mentioned this pull request Feb 22, 2025
7 tasks
cypress/screenshots
cypress/videos
coverage
retention-days: 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

can code coverage work with split test buckets? We currently got all of our query-enhancements test split into 5 buckets due to how long they take

@angle943
Copy link
Collaborator

angle943 commented Mar 3, 2025

We have recently broken up our tests into five separate buckets due to how long they take (i think total will be around 8 hours). Will cypress test coverage still work without having one test runner run the entire tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants