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
HDDS-2195. Apply spotbugs check to test code #1806
Conversation
@adoroszlai Could you help to review the PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @symious for working on this.
Ozone already uses Spotbugs for non-test code:
Lines 1704 to 1712 in 3d70fab
<plugin> | |
<groupId>com.github.spotbugs</groupId> | |
<artifactId>spotbugs-maven-plugin</artifactId> | |
<version>${spotbugs.version}</version> | |
<configuration> | |
<maxHeap>1024</maxHeap> | |
<xmlOutput>true</xmlOutput> | |
</configuration> | |
</plugin> |
and most sub-projects have their own exclude file:
hadoop-hdds/common/dev-support/findbugsExcludeFile.xml
hadoop-hdds/container-service/dev-support/findbugsExcludeFile.xml
hadoop-hdds/interface-admin/dev-support/findbugsExcludeFile.xml
hadoop-hdds/interface-client/dev-support/findbugsExcludeFile.xml
hadoop-hdds/interface-server/dev-support/findbugsExcludeFile.xml
hadoop-ozone/common/dev-support/findbugsExcludeFile.xml
hadoop-ozone/csi/dev-support/findbugsExcludeFile.xml
hadoop-ozone/insight/dev-support/findbugsExcludeFile.xml
hadoop-ozone/interface-client/dev-support/findbugsExcludeFile.xml
hadoop-ozone/interface-storage/dev-support/findbugsExcludeFile.xml
hadoop-ozone/recon/dev-support/findbugsExcludeFile.xml
hadoop-ozone/tools/dev-support/findbugsExcludeFile.xml
Spotbugs has a configuration setting (<includeTests>
) for including tests, which defaults to false
. I think we only need to set it to true
, and fix or exclude any failures reported for test code.
There is a helper script to run Spotbugs (named findbugs.sh
for historical reasons), which is also run by the findbugs check in CI:
https://github.com/apache/ozone/blob/master/hadoop-ozone/dev-support/checks/findbugs.sh
@adoroszlai Thanks for the detailed comment, I will fix the patch later. |
@adoroszlai Please have a check on the commits, passed the findbugs check and tests locally. |
Still have some findbugs and checkstyle to fix. |
@adoroszlai Check green now, could you help to review the changes? |
Thanks a lot @symious for updating the patch and fixing a whole bunch of spotbugs issues. Currently I don't have time to check it in detail, but my previous change request is no longer valid.
Understand. @adoroszlai |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @symious for this huge patch. It mostly looks good to me, few minor items noted inline.
hadoop-hdds/config/src/test/java/org/apache/hadoop/hdds/conf/TestConfigFileGenerator.java
Outdated
Show resolved
Hide resolved
@@ -68,7 +68,7 @@ private void fail() { | |||
f.fail(cluster); | |||
} catch (Throwable t) { | |||
LOG.info("Caught exception while inducing failure:{}", f.getName(), t); | |||
System.exit(-2); | |||
throw new RuntimeException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mukul1987 will this keep existing behavior of chaos tests?
...tegration-test/src/test/java/org/apache/hadoop/fs/contract/AbstractContractUnbufferTest.java
Outdated
Show resolved
Hide resolved
...test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneClientRetriesOnException.java
Outdated
Show resolved
Hide resolved
...one/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/request/key/TestOMKeyRequest.java
Outdated
Show resolved
Hide resolved
...c/test/java/org/apache/hadoop/ozone/om/request/security/TestOMGetDelegationTokenRequest.java
Outdated
Show resolved
Hide resolved
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestEndpoints.java
Outdated
Show resolved
Hide resolved
...org/apache/hadoop/hdds/scm/container/placement/algorithms/TestContainerPlacementFactory.java
Outdated
Show resolved
Hide resolved
...s/server-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestSCMBlockProtocolServer.java
Outdated
Show resolved
Hide resolved
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
Outdated
Show resolved
Hide resolved
@adoroszlai Thanks for the detailed review. Will fix the issues later. |
Sure, take your time. I'll try to help with resolving any merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @symious for updating the patch.
@adoroszlai Thanks for the review. |
Thanks @symious for the contribution! |
What changes were proposed in this pull request?
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-2195
How was this patch tested?
Manually test passed. Spotbugs plugin works fine by running "mvn compile site".
The compile is needed according to spotbugs/spotbugs-maven-plugin#93.