From c6a59f76b3518c1b0e78428b33635e5ec91d2df9 Mon Sep 17 00:00:00 2001 From: MitchellGale-BitQuill <104795536+MitchellGale-BitQuill@users.noreply.github.com> Date: Wed, 11 Jan 2023 11:55:46 -0800 Subject: [PATCH] Adding mutation testing to build gradle with PiTest (#1204) Signed-off-by: MitchellGale-BitQuill Signed-off-by: Yury-Fridlyand Co-authored-by: Yury-Fridlyand --- .github/workflows/sql-test-and-build-workflow.yml | 6 ++++++ DEVELOPER_GUIDE.rst | 4 ++++ core/build.gradle | 10 ++++++++++ opensearch/build.gradle | 10 ++++++++++ 4 files changed, 30 insertions(+) diff --git a/.github/workflows/sql-test-and-build-workflow.yml b/.github/workflows/sql-test-and-build-workflow.yml index 14ce737bc3..a7159ea411 100644 --- a/.github/workflows/sql-test-and-build-workflow.yml +++ b/.github/workflows/sql-test-and-build-workflow.yml @@ -44,6 +44,12 @@ jobs: - name: Build with Gradle run: ./gradlew --continue build ${{ matrix.entry.os_build_args }} + - name: PiTest with Gradle + run: | + ./gradlew :core:pitest + ./gradlew :opensearch:pitest + + - name: Run backward compatibility tests if: ${{ matrix.entry.os == 'ubuntu-latest' }} run: ./scripts/bwctest.sh diff --git a/DEVELOPER_GUIDE.rst b/DEVELOPER_GUIDE.rst index bf9e603930..83e2c398c5 100644 --- a/DEVELOPER_GUIDE.rst +++ b/DEVELOPER_GUIDE.rst @@ -220,8 +220,12 @@ Most of the time you just need to run ./gradlew build which will make sure you p - Run all unit tests. * - ./gradlew :integ-test:integTest - Run all integration test (this takes time). + * - ./gradlew :doctest:doctest + - Run doctests * - ./gradlew build - Build plugin by run all tasks above (this takes time). + * - ./gradlew pitest + - Run PiTest mutation testing (see more info in `#1204 `_) For integration test, you can use ``-Dtests.class`` “UT full path” to run a task individually. For example ``./gradlew :integ-test:integTest -Dtests.class="*QueryIT"``. diff --git a/core/build.gradle b/core/build.gradle index 791d64df65..2438470518 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -26,6 +26,7 @@ plugins { id 'java-library' id "io.freefair.lombok" id 'jacoco' + id 'info.solidsoft.pitest' version '1.9.0' id 'java-test-fixtures' } @@ -33,6 +34,15 @@ repositories { mavenCentral() } +pitest { + targetClasses = ['org.opensearch.sql.*'] + pitestVersion = '1.9.0' + threads = 4 + outputFormats = ['HTML', 'XML'] + timestampedReports = false + junit5PluginVersion = '1.0.0' +} + dependencies { api group: 'com.google.guava', name: 'guava', version: '31.0.1-jre' api group: 'org.apache.commons', name: 'commons-lang3', version: '3.10' diff --git a/opensearch/build.gradle b/opensearch/build.gradle index 6eeab86fff..04fee22255 100644 --- a/opensearch/build.gradle +++ b/opensearch/build.gradle @@ -26,6 +26,7 @@ plugins { id 'java-library' id "io.freefair.lombok" id 'jacoco' + id 'info.solidsoft.pitest' version '1.9.0' } dependencies { @@ -47,6 +48,15 @@ dependencies { testImplementation group: 'org.opensearch.test', name: 'framework', version: "${opensearch_version}" } +pitest { + targetClasses = ['org.opensearch.sql.*'] + pitestVersion = '1.9.0' + threads = 4 + outputFormats = ['HTML', 'XML'] + timestampedReports = false + junit5PluginVersion = '1.0.0' +} + test { useJUnitPlatform() testLogging {