Your SlideShare is downloading. ×
0
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Iasi code camp 20 april 2013 implement-quality-java-massol-codecamp

239

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
239
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Implementing Qualityon Java projectsVincent MassolCommitter XWikiCTO XWiki SAS@vmassolSunday, April 21, 13
  • 2. Vincent Massol• Speaker Bio•CTO XWiki SAS• Your Projects•XWiki (community-driven open source project)•Past: Maven, Apache Cargo, Apache Cactus, PatternTesting• Other Credentials:•LesCastCodeurs podcast•Creator of OSSGTP open source group in ParisSunday, April 21, 13
  • 3. What is Quality?Sunday, April 21, 13
  • 4. The XWiki project in summary• 9 years old• 28 activecommitters• 7 committersdo 80% ofwork• 700KNCLOC• 11 commits/daySunday, April 21, 13
  • 5. Examples of Quality actions• Coding rules (Checkstyle, ...)• Test coverage• Track bugs• Don’t use Commons Lang 2.x• Use SLF4J and don’t drawLog4J/JCL in dependencies• Automated build• Automated unit tests• Stable automated functionaltests• Ensure API stability• Code reviews• License header checks• Release with Java 6• Ensure javadoc exist• Prevent JAR hell• Release often (every 2 weeks)• Collaborative design• Test on supportedenvironments (DB & Browsers)Sunday, April 21, 13
  • 6. Quality Tip #1API StabilitySunday, April 21, 13
  • 7. The ProblemClass Not Found or Method NotFoundSunday, April 21, 13
  • 8. API Stability - Deprecations/*** ...* @deprecated since 2.4M1 use {@link #transform(* Block, TransformationContext)}*/@Deprecatedvoid transform(XDOM dom, Syntax syntax)throws TransformationException;Sunday, April 21, 13
  • 9. API Stability - CLIRR (1/2)<plugin><groupId>org.codehaus.mojo</groupId><artifactId>clirr-maven-plugin</artifactId><configuration><ignored><difference><differenceType>7006</differenceType><className>org/xwiki/.../MetaDataBlock</className><method>org.xwiki....block.Block clone()</method><to>org.xwiki.rendering.block.MetaDataBlock</to><justification>XDOM#clone() doesnt clone the metadata</justification></difference>...Sunday, April 21, 13
  • 10. API Stability - CLIRR (2/2)Example from XWiki 5.0M1 Release notesSunday, April 21, 13
  • 11. API Stability - Internal PackageJavadocCLIRR<plugin><groupId>org.codehaus.mojo</groupId><artifactId>clirr-maven-plugin</artifactId><excludes><exclude>**/internal/**</exclude><exclude>**/test/**</exclude><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-javadoc-plugin<configuration><excludePackageNames>*.internal.*</excludePackageNames>Sunday, April 21, 13
  • 12. API Stability - Legacy ModuleAspect Weaving+ “Legacy” Profile<plugin><groupId>org.codehaus.mojo</groupId><artifactId>aspectj-maven-plugin</...>...<configuration><weaveDependencies><weaveDependency><groupId>org.xwiki.rendering</...><artifactId>xwiki-rendering-api</...>...Sunday, April 21, 13
  • 13. API Stability - Young APIs/*** ...* @since 5.0M1*/@Unstable(<optional explanation>)public EntityReference createEntityReference(String name,...){...}+ max duration for keeping the annotation!Sunday, April 21, 13
  • 14. API Stability - Next steps• Annotation or package for SPI?• Better define when to use the @Unstableannotation• Not possible to add a new method to an existingInterface without breaking compatibility•Java 8 and Virtual Extension/Defender methodsinterface TestInterface {  public void testMe();  public void newMethod() default {    System.out.println("Default from interface"); }Sunday, April 21, 13
  • 15. Quality Tip #2JAR HellSunday, April 21, 13
  • 16. The ProblemClass Not Found or Method NotFound or not working featureSunday, April 21, 13
  • 17. No duplicate classes @ runtime<plugin><groupId>com.ning.maven.plugins</groupId><artifactId>maven-duplicate-finder-plugin</artifactId><executions><execution><phase>verify</phase><goals><goal>check</goal></goals><configuration><failBuildInCaseOfConflict>true</...><exceptions>...Sunday, April 21, 13
  • 18. Surprising results...• Commons Beanutils bundles some classes from CommonsCollections, apparently to avoid drawing a dependency to it...• Xalan bundles a lot of other projects (org/apache/xml/**, org/apache/bcel/**, JLex/**, java_cup/**, org/apache/regexp/**). Inaddition, it even has these jars in its source tree without anyindication about their versions...• stax-api, geronimo-stax-api_1.0_spec and xml-apis all drawjavax.xml.stream.* classes• xmlbeans and xml-apis draw incompatible versions oforg.w3c.dom.* classes14 exceptions in total!Sunday, April 21, 13
  • 19. Maven: dependency version issue<dependencies><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>1.4.0</version></dependency><dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>0.9.9</version><!-- Depends on org.slf4j:slf4j-api:1.5.0 --></dependency></dependencies>Will run logback 0.9.9with slf4J-api 1.4.0instead of 1.5.0!Sunday, April 21, 13
  • 20. Maven: ensure correct version<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-enforcer-plugin</artifactId><executions><execution><id>enforce-version-compatibility</id><phase>verify</phase><goals><goal>enforce</goal></goals><configuration><rules><requireUpperBoundDeps/></rules>Sunday, April 21, 13
  • 21. Quality Tip #3Test CoverageSunday, April 21, 13
  • 22. The ProblemMore bugs reported, overallquality goes down and harder todebug softwareSunday, April 21, 13
  • 23. Use Jacoco to fail the build<plugin><groupId>org.jacoco</groupId><artifactId>jacoco-maven-plugin</artifactId><executions><execution><id>jacoco-prepare</id><goals><goal>prepare-agent</goal></goals></execution><execution><id>jacoco-check</id><goals><goal>check</goal></goals></execution></executions><configuration><check><instructionRatio>${xwiki.jacoco.instructionRatio}</...></check>}Sunday, April 21, 13
  • 24. Strategy• When devs add code (and thustests), increase the TPC percentage• Put the Jacoco check in “Quality”Maven Profile• Have a CI job to execute thatprofile regularly•About 15% overhead compared to buildwithout checks• “Cheat mode”: Add easier-to-writetestSunday, April 21, 13
  • 25. Quizz Time![INFO] --- jacoco-maven-plugin:0.6.2.201302030002:check (jacoco-check)[INFO] All coverage checks have been met.[INFO] --- jacoco-maven-plugin:0.6.2.201302030002:check (jacoco-check)[WARNING] Insufficient code coverage for INSTRUCTION: 75.52% < 75.53%Step 1: Building on my local machine gives the following:Step 2: Building on the CI machine gave:Non determinism! Why?Sunday, April 21, 13
  • 26. Quizz Answerprivate Map componentEntries = new ConcurrentHashMap();...for (Map.Entry entry : componentEntries.entrySet()){if (entry.getValue().instance == component) {  key = entry.getKey();    oldDescriptor = entry.getValue().descriptor;    break;  }}... because the JVM is non deterministic!Sunday, April 21, 13
  • 27. Quality Tip #4Functional TestingStabilitySunday, April 21, 13
  • 28. The ProblemToo many false positivesleading to developers notpaying attention to CI emailsanymore... leading to failingsoftwareSunday, April 21, 13
  • 29. False positives examples• The JVM has crashed• VNC is down (we run Selenium tests)• Browser crash (we run Selenium tests)• Git connection issue• Machine slowness (if XWiki cannot start under 2 minutesthen it means the machine has some problems)• Nexus is down (we deploy our artifacts to a Nexusrepository)• Connection issue (Read time out)Sunday, April 21, 13
  • 30. Step 1: Groovy PostBuild Plugin (1/2)def messages = [[".*A fatal error has been detected by the Java Runtime Environment.*","JVM Crash", "A JVM crash happened!"],[".*Error: cannot open display: :1.0.*","VNC not running", "VNC connection issue!"],...]def shouldSendEmail = truemessages.each { message ->if (manager.logContains(message.get(0))) {manager.addWarningBadge(message.get(1))manager.createSummary("warning.gif").appendText(...)manager.buildUnstable()shouldSendEmail = false}}Sunday, April 21, 13
  • 31. Step 1: Groovy PostBuild Plugin (2/2)... continued from previous slide...if (!shouldSendEmail) {def pa = new ParametersAction([new BooleanParameterValue("noEmail", true)])manager.build.addAction(pa)}Sunday, April 21, 13
  • 32. Step 2: Mail Ext Pluginimport hudson.model.*build.actions.each { action ->if (action instanceof ParametersAction) {if (action.getParameter("noEmail")) {cancel = true}}}Pre-send ScriptSunday, April 21, 13
  • 33. Results+ use the Scriptler plugin to automate configuration for all jobsSunday, April 21, 13
  • 34. Quality Tip #5Bug Fixing DaySunday, April 21, 13
  • 35. The ProblemBugs increasing, evensimple to fixones, devs focusing too much onnew features (i.e. scope creep)vs fixing what existsBugs created vs closedSunday, April 21, 13
  • 36. Bug Fixing Day• Every Thursday• Goal is to close the max number of bugs• Triaging: Can be closed with Won’t fix,Duplicate, Cannot Reproduce, etc• Close low hanging fruits in priority• Started with last 365 days then with last 547days and currently with last 730 days (weneed to catch up with 6 bugs!)Sunday, April 21, 13
  • 37. ResultsSunday, April 21, 13
  • 38. ConclusionSunday, April 21, 13
  • 39. Parting words• Slowly add new quality check over time• Everyone must be on board• Favor Active Quality (i.e. make the build fail) overPassive checks• Be ready to adapt/remove checks if found not usefulenough• Quality brings some risks:•Potentially less committers for your project (especially opensource)Sunday, April 21, 13
  • 40. Be proud of your Quality!“I have offended God andmankind because my workdidnt reach the quality it shouldhave.”Leonardo da Vinci, on his death bedSunday, April 21, 13

×