You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/06/06 04:34:06 UTC

[GitHub] [druid] maytasm opened a new pull request #9995: Add instruction for code coverage checks

maytasm opened a new pull request #9995:
URL: https://github.com/apache/druid/pull/9995


   Add instruction for code coverage checks
   
   ### Description
   
   Add instruction for code coverage checks to make Druid more user friendly for Devs.
   
   This PR has:
   - [x] been self-reviewed.
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/licenses.yaml)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] ccaominh commented on a change in pull request #9995: Add instruction for code coverage checks

Posted by GitBox <gi...@apache.org>.
ccaominh commented on a change in pull request #9995:
URL: https://github.com/apache/druid/pull/9995#discussion_r438459412



##########
File path: dev/code-review/code-coverage.md
##########
@@ -0,0 +1,33 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+# Druid's Code Coverage Enforcement
+
+Druid has an automated way of checking if new code has adequate unit tests. 
+Druid CI checks are configured to enforce code coverage using JaCoCo. The CI checks will prevent PR from being merged 
+if test coverage of new added code is below the set threshold. The CI checks filters test coverage based on a diff from
+your PR and make sure that the thresholds are met. Druid currently enforce branch and line code coverage.
+
+## Running code coverage locally
+Code coverage should be run locally to make sure the PR will pass Druid CI checks. 
+1. Code coverage on the codebase can be generated directly in [Intellij](../intellij-setup.md#Set-Code-Coverage-Runner). 
+2. Code coverage on just the diff of your PR can be generated in your terminal. First, you will have to install
+diff-test-coverage by running `npm install @connectis/diff-test-coverage`. Next, run the unit tests
+for the module you are working on `mvn -pl <MODULE_TO_CHECK> test jacoco:report`. Finally, run 

Review comment:
       We can also mention that this creates an HTML report in `target/site/jacoco/index.html`.

##########
File path: dev/intellij-setup.md
##########
@@ -34,6 +34,14 @@ an alias name. You can do this in Using `File` -> `Project Structure...` -> `Pla
 ## Code Style
 The Code Style is available in XML format at [druid_intellij_formatting.xml](druid_intellij_formatting.xml) and can be [imported into IntelliJ](https://www.jetbrains.com/help/idea/2017.1/copying-code-style-settings.html).
 
+## Set Code Coverage Runner
+Druid CI checks are configured to enforce code coverage using JaCoCo. The checks will prevent PR from being merged 

Review comment:
       typo: prevent RR -> prevent a PR




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm commented on a change in pull request #9995: Add instruction for code coverage checks

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #9995:
URL: https://github.com/apache/druid/pull/9995#discussion_r438498546



##########
File path: dev/intellij-setup.md
##########
@@ -34,6 +34,14 @@ an alias name. You can do this in Using `File` -> `Project Structure...` -> `Pla
 ## Code Style
 The Code Style is available in XML format at [druid_intellij_formatting.xml](druid_intellij_formatting.xml) and can be [imported into IntelliJ](https://www.jetbrains.com/help/idea/2017.1/copying-code-style-settings.html).
 
+## Set Code Coverage Runner
+Druid CI checks are configured to enforce code coverage using JaCoCo. The checks will prevent PR from being merged 

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm merged pull request #9995: Add instruction for code coverage checks

Posted by GitBox <gi...@apache.org>.
maytasm merged pull request #9995:
URL: https://github.com/apache/druid/pull/9995


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm commented on a change in pull request #9995: Add instruction for code coverage checks

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #9995:
URL: https://github.com/apache/druid/pull/9995#discussion_r438498150



##########
File path: dev/code-review/code-coverage.md
##########
@@ -0,0 +1,33 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+# Druid's Code Coverage Enforcement
+
+Druid has an automated way of checking if new code has adequate unit tests. 
+Druid CI checks are configured to enforce code coverage using JaCoCo. The CI checks will prevent PR from being merged 
+if test coverage of new added code is below the set threshold. The CI checks filters test coverage based on a diff from
+your PR and make sure that the thresholds are met. Druid currently enforce branch and line code coverage.
+
+## Running code coverage locally
+Code coverage should be run locally to make sure the PR will pass Druid CI checks. 
+1. Code coverage on the codebase can be generated directly in [Intellij](../intellij-setup.md#Set-Code-Coverage-Runner). 
+2. Code coverage on just the diff of your PR can be generated in your terminal. First, you will have to install
+diff-test-coverage by running `npm install @connectis/diff-test-coverage`. Next, run the unit tests
+for the module you are working on `mvn -pl <MODULE_TO_CHECK> test jacoco:report`. Finally, run 

Review comment:
       Done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm commented on a change in pull request #9995: Add instruction for code coverage checks

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #9995:
URL: https://github.com/apache/druid/pull/9995#discussion_r438497590



##########
File path: dev/intellij-setup.md
##########
@@ -34,6 +34,14 @@ an alias name. You can do this in Using `File` -> `Project Structure...` -> `Pla
 ## Code Style
 The Code Style is available in XML format at [druid_intellij_formatting.xml](druid_intellij_formatting.xml) and can be [imported into IntelliJ](https://www.jetbrains.com/help/idea/2017.1/copying-code-style-settings.html).
 
+## Set Code Coverage Runner
+Druid CI checks are configured to enforce code coverage using JaCoCo. The checks will prevent PR from being merged 
+if test coverage of new added code is below the set threshold. You should run the tests locally to make sure that
+your code pass the coverage threshold. In IntelliJ, edit the template of JUnit tests in "Run Configurations..." 
+to use Jacoco for code coverage (this provides branch coverage instead of the default which is only line coverage).
+You can then right click src/test/java folder of the modules you are modifying and click run with coverage. This
+will generate a report to show the current code coverage on the code (not just your change).
+

Review comment:
       Done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] suneet-s commented on a change in pull request #9995: Add instruction for code coverage checks

Posted by GitBox <gi...@apache.org>.
suneet-s commented on a change in pull request #9995:
URL: https://github.com/apache/druid/pull/9995#discussion_r436797510



##########
File path: dev/code-review/code-coverage.md
##########
@@ -0,0 +1,33 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+# Druid's Code Coverage Enforcement
+
+Druid has an automated way of checking if new code has adequate unit tests. 

Review comment:
       I think we should call out that our current code coverage checks are merely smoke tests.
   
   They only verify that a line/ branch of code has been called during the test, but not that the functionality has been tested sufficiently. Reviewers should still verify that all the different branches are sufficiently tested by reviewing the tests.

##########
File path: dev/intellij-setup.md
##########
@@ -34,6 +34,14 @@ an alias name. You can do this in Using `File` -> `Project Structure...` -> `Pla
 ## Code Style
 The Code Style is available in XML format at [druid_intellij_formatting.xml](druid_intellij_formatting.xml) and can be [imported into IntelliJ](https://www.jetbrains.com/help/idea/2017.1/copying-code-style-settings.html).
 
+## Set Code Coverage Runner
+Druid CI checks are configured to enforce code coverage using JaCoCo. The checks will prevent PR from being merged 
+if test coverage of new added code is below the set threshold. You should run the tests locally to make sure that
+your code pass the coverage threshold. In IntelliJ, edit the template of JUnit tests in "Run Configurations..." 
+to use Jacoco for code coverage (this provides branch coverage instead of the default which is only line coverage).
+You can then right click src/test/java folder of the modules you are modifying and click run with coverage. This
+will generate a report to show the current code coverage on the code (not just your change).
+

Review comment:
       Can you add screenshots to this section to make it easier for devs to follow along




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


[GitHub] [druid] maytasm commented on a change in pull request #9995: Add instruction for code coverage checks

Posted by GitBox <gi...@apache.org>.
maytasm commented on a change in pull request #9995:
URL: https://github.com/apache/druid/pull/9995#discussion_r438494826



##########
File path: dev/code-review/code-coverage.md
##########
@@ -0,0 +1,33 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+# Druid's Code Coverage Enforcement
+
+Druid has an automated way of checking if new code has adequate unit tests. 

Review comment:
       Done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org