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

HDDS-2195. Apply spotbugs check to test code #1806

Merged
merged 16 commits into from Feb 4, 2021

Conversation

symious
Copy link
Contributor

@symious symious commented Jan 15, 2021

What changes were proposed in this pull request?

  • Add spotbugs plugin.
  • Fixed two bugs reported by spotbugs.
  • Add other bugs reported by spotbugs to spotbugs-exclude.xml.

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.

@symious
Copy link
Contributor Author

symious commented Jan 21, 2021

@adoroszlai Could you help to review the PR?

Copy link
Contributor

@adoroszlai adoroszlai left a 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:

ozone/pom.xml

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

@symious
Copy link
Contributor Author

symious commented Jan 21, 2021

@adoroszlai Thanks for the detailed comment, I will fix the patch later.

@symious
Copy link
Contributor Author

symious commented Jan 23, 2021

@adoroszlai Please have a check on the commits, passed the findbugs check and tests locally.

@symious
Copy link
Contributor Author

symious commented Jan 23, 2021

Still have some findbugs and checkstyle to fix.

@symious
Copy link
Contributor Author

symious commented Jan 23, 2021

@adoroszlai Check green now, could you help to review the changes?

@adoroszlai adoroszlai dismissed their stale review January 26, 2021 12:35

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.

@symious
Copy link
Contributor Author

symious commented Jan 28, 2021

Understand. @adoroszlai

Copy link
Contributor

@adoroszlai adoroszlai left a 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.

@@ -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();
Copy link
Contributor

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?

@symious
Copy link
Contributor Author

symious commented Feb 2, 2021

@adoroszlai Thanks for the detailed review. Will fix the issues later.

@adoroszlai
Copy link
Contributor

Will fix the issues later.

Sure, take your time. I'll try to help with resolving any merge conflicts.

Copy link
Contributor

@adoroszlai adoroszlai left a 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.

@symious
Copy link
Contributor Author

symious commented Feb 3, 2021

@adoroszlai Thanks for the review.

@adoroszlai adoroszlai merged commit 1e04c0e into apache:master Feb 4, 2021
@adoroszlai
Copy link
Contributor

Thanks @symious for the contribution!

@symious symious deleted the HDDS-2195 branch February 4, 2021 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants