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

Adding mutation testing to build gradle with PiTest #1204

Merged

Conversation

MitchellGale
Copy link
Contributor

@MitchellGale MitchellGale commented Dec 21, 2022

Description

Adds PiTest Gradle to build.gradle in core. This adds support for Mutation testng/Analysis to our testing ability. It should help us make more effective tests for past/future features.

Why does this help?

Mutation testing is used to find missing parts of your project not covered by existing tests. It modifies (mutates) one part of code and checks if a test is killed (fails) because of the mutation. Sometimes it will make return statements return null, other times it will switch == to !=, or < with >, or || with && and lots more mutations. More mutations can be found in the default mutations column here https://pitest.org/quickstart/mutators/. Often mutation testing provides a more clear picture of the quality of tests compared to line/branch coverage alone.

If you notice mutations that "survive" your test suite, consider adding additional tests to kill the mutations.
Short presentation PDF on mutation testing MutationTesting_Presentation.pdf.

Docs for Gradle plugin for PiTest.

Currently to be manually run, but could be added to GitHub actions later. It generates an html page indicating mutations that survived and were killed by our test suite.

Only adding support for running mutation testing in core & OpenSearch modules (for now).

Steps to run

./gradlew pitest

Report will be placed in core/build/reports/pitest/index.html.
Reports can be found in artifacts under core and opensearch respectively.

Sample Report

PiTest_Results.zip

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

CVE

hcoles/pitest#1084

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

MitchellGale and others added 15 commits November 18, 2022 10:50
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Adding mutation testing to build gradle with PiTest
@MitchellGale MitchellGale requested a review from a team as a code owner December 21, 2022 18:59
@MitchellGale MitchellGale changed the base branch from 2.x to main December 21, 2022 18:59
@codecov-commenter
Copy link

codecov-commenter commented Dec 22, 2022

Codecov Report

Merging #1204 (5623c1f) into main (d03c176) will decrease coverage by 2.47%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##               main    #1204      +/-   ##
============================================
- Coverage     98.31%   95.83%   -2.48%     
- Complexity     3535     3550      +15     
============================================
  Files           342      354      +12     
  Lines          8730     9420     +690     
  Branches        554      673     +119     
============================================
+ Hits           8583     9028     +445     
- Misses          142      334     +192     
- Partials          5       58      +53     
Flag Coverage Δ
query-workbench 62.76% <ø> (?)
sql-engine 98.32% <ø> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...rc/main/java/org/opensearch/sql/storage/Table.java 100.00% <0.00%> (ø)
...c/main/java/org/opensearch/sql/expression/DSL.java 100.00% <0.00%> (ø)
...java/org/opensearch/sql/sql/parser/AstBuilder.java 100.00% <0.00%> (ø)
...org/opensearch/sql/planner/DefaultImplementor.java 100.00% <0.00%> (ø)
...opensearch/sql/planner/logical/LogicalPlanDSL.java 100.00% <0.00%> (ø)
...pensearch/sql/sql/parser/AstExpressionBuilder.java 100.00% <0.00%> (ø)
...search/sql/planner/optimizer/pattern/Patterns.java 100.00% <0.00%> (ø)
...arch/sql/expression/datetime/DateTimeFunction.java 100.00% <0.00%> (ø)
...ch/sql/planner/logical/LogicalPlanNodeVisitor.java 100.00% <0.00%> (ø)
...ch/sql/planner/optimizer/LogicalPlanOptimizer.java 100.00% <0.00%> (ø)
... and 18 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
@dai-chen dai-chen added the infrastructure Changes to infrastructure, testing, CI/CD, pipelines, etc. label Dec 23, 2022
@penghuo
Copy link
Collaborator

penghuo commented Jan 3, 2023

Thanks for adding this. Could you help updating https://github.com/opensearch-project/sql/blob/main/DEVELOPER_GUIDE.rst also.

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
@Yury-Fridlyand
Copy link
Collaborator

Thanks for adding this. Could you help updating https://github.com/opensearch-project/sql/blob/main/DEVELOPER_GUIDE.rst also.

Done

@Yury-Fridlyand Yury-Fridlyand merged commit c6a59f7 into opensearch-project:main Jan 11, 2023
@Yury-Fridlyand Yury-Fridlyand deleted the integ-AddPiTestMutationTesting branch January 11, 2023 19:55
@Yury-Fridlyand
Copy link
Collaborator

Do we need to backport?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Changes to infrastructure, testing, CI/CD, pipelines, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants