Archive for the ‘Programming’ Category

Setting Debug level in CouchDB

Monday, November 2nd, 2009

I have experimented with CouchDB in the last days and wanted to switch on the debug level. I thought this could be done when starting the couchdb server, but this wouldn’t work.

The solution was simply to set the level in the ini file (e.g. /usr/local/etc/couchdb/local.ini):

[log]
level = debug

This may be useful from time to time.

Haynes Catalog live

Friday, July 3rd, 2009

I’m glad to announce that the Haynes Catalog went live yesterday. The Haynes Catalog is an online project which “presents an interactive and continuously updated database containing music for and with oboe up to 1800“. A friend of mine, Peter Wuttke, continually collects information and uses the online catalog to make this available to the public.

The application is using Ruby on Rails with a Mysql database in the background. Apart of the public part of the application, there is an admin interface which allows Peter to update the data. Since I worked on this project only sporadically in my spare time, two challenges proved to be more complicated than expected:

  1. Versioning of changes:
    We tried to make changes of the data transparent to the user. It should be visible to the user, when information has been changed, for example when a composition has been published, or other data is corrected. Hence there is some change history.
    However, not all changes should be mentioned – simple corrections of typos etc. should be ignored.
    Finally, the versions must span several tables as there are a lot one-to-many or many-to-many relations.
  2. Synchronisation:
    Most of the research is done offline, for example in libraries or when travelling. Therefore there exist two installations, both being “productive”: the official homepage plus an offline installation which is used during the research.

Both problems can be solved, but there is no “out-of-the box” solution. There will be some detail about how to solve these two issues in a Rails application in following posts.

Using checkstyle with bitten

Tuesday, November 18th, 2008

Bitten is a trac plugin for continuous integration which I use for the antdiff project and it does a good job in getting the daily builds organized. One nice feature is the summary for unit tests and code coverage tools (I use corbertura). But what I was missing was a similar summary for my checkstyle reports.

But thanks to XSLT, there is a simple solution: Bitten is able to include test and coverage reports from xml files. And since checkstyle generates a xml file for the results, it was straight-forward to translate the checkstyle xml file to a xml file for bitten. The only problem is that bitten only knows the two mentioned types of reports, so I decided to use the test report. 

And this is the (extremely simple) stylesheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:template match="file">
    <xsl:choose>
      <xsl:when test="count(error) = 0">
        <test status="success" fixture="{@name}" name="No checkstyle errors" file="{@name}" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:for-each select="error">
          <test status="error" fixture="{../@name}" name="{@message}" file="{../@name}" />
        </xsl:for-each>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="checkstyle">
    <report category="test">
      <xsl:apply-templates/>
    </report>
  </xsl:template>   

</xsl:stylesheet>

Translating the checkstyle xml report using this stylesheet allows you to treat checkstyle results in the same way as unit test failures.

But there is one slight problem: the file names in the checkstyle xml are absolute file names. Hence also the file names in the bitten build summary are absolute. In my setup this means having something like “/tmp/bittenFpQXrh/build_Trunk_22″ in front of the name, which doesn’t look good and it also breaks the link to the source code. The simple solution was to remove the path name from the checkstyle report using the following ant task:

<replace file=“${dir.reports}/checkstyle_report.xml” token=“${basedir}” value=“”/>

Maybe it would be nice not to link the checkstyle results to the source code, but rather to the html reports which give more information about the details of the problem.

Please see on of the antdiff build status pages as an example (click on “Test results” in the checkstyle section).