Posts Tagged ‘continous integration’

Using Hudson in VirtualBox for multi OS testing

February 8th, 2010

For a small project I currently work on I wanted to run my unit test suites on different operating systems.

Since I work on a Mac and wanted to also run tests on Linux, Virtual Box was exactly what I needed.

Preparing the guest

Just create a new virtual machine, for my project I created a CentOS guest. Install CentOS and configure it like you want. Install the guest additions as well, you will have to install quite a few extra packages in order to get these additions working but the install script is verbose enough to tell you what to install.

Preparing the shared folder

In your VM configuration, just create a new shared folder which points to the project you work on, ideally in read-only mode.
You can now mount the shared folder on the guest, like this:

sudo mkdir /mnt/shared/folder

Add the following line in your /etc/fstab

shared-folder-name /mnt/shared/folder vboxsf defaults 0 0

You can now mount the shared folder by simply running:

sudo mount shared-folder-name

Installing Hudson

You should now have a working guest with CentOS. Just install hudson by using the native packages available.

Configuring Hudson

Create and configure a new job like you would normally do for any normal hudson job.

Below is the configuration for my project, please note that I use the mercurial plugin and the clover plugin.

  • Project name : my project
  • SCM : mercurial, repository : /mnt/shared/folder with @hourly build
  • Run the following ant targets : rununittests, runcodingstandardcheck, generatecodecoveragereportclover
  • Publish code coverage report : checked in path ci/codecoverage with file ‘clover’
  • Activate Chuck Norris : yes (what would be a hudson job without the Chuck Norris plugin ^_^)

Here is a screenshot of the result:

By using such a guest VM I am able to test on 2 different systems, Mac OS ( the host ) and Linux ( the guest ). Next step, test on an Open Solaris guest :)

‘Hope that helps :)

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Using Liquibase for database updates

January 12th, 2010

This is post-it for me so I get a resource on how to install and run liquibase in case I forget.

What is Liquibase ?

LiquiBase is an open source (LGPL), database-independent library for tracking, managing and applying database changes. It is built on a simple premise: All database changes are stored in a human readable yet trackable form and checked into source control.
Source :
http://www.liquibase.org

There are few introductory videos available here :

Installation

Do not use the RC version because it does not seem to work well yet. Using 1.9.5 version is fine and works out of the box.

Download Liquibase here : http://www.liquibase.org/download

Store it in :

/opt/jerome/local/liquibase-1.9.5

Install the Java connector for mysql and postgresql :

sudo port install mysql-connector-java postgresql-jdbc

Now use the following XML changelog file for testing. Do not expect any relevancy in this XML file it is just there to test that Liquibase works :

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.7"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.7 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.7.xsd">
 <changeSet id="1" author="me">
 <comment>bla bla bla bla</comment>
 <createTable tableName="person">
 <column name="id" type="int">
 <constraints primaryKey="true" nullable="false"/>
 </column>
 <column name="firstname" type="java.sql.Types.SMALLINT"/>
 <column name="lastname" type="java.sql.Types.REAL"/>
 <column name="username" type="java.sql.Types.LONGVARCHAR">
 <constraints unique="true" nullable="false"/>
 </column>
 <column name="testid" type="int"/>
 </createTable>
 </changeSet>
</databaseChangeLog>

http://java.sun.com/j2se/1.3/docs/api/java/sql/Types.html

Use also the following liquibase.properties file

classpath:/opt/local/share/java/mysql-connector-java-5.0.jar:/opt/local/share/java/postgresql.jar
changeLogFile=createtable.xml
# Mysql Settings
username=root
password=1234
url=jdbc:mysql://localhost/testsliquibase

# Postgres driver
#url=jdbc:postgresql://localhost/postgres
#username=postgres

logLevel=severe

Now try everything works fine:

liquibase updateSQL

Troubleshooting

In case Liquibase fails to connect to MySQL make sure the login credentials are correct and that it is possible to connect to mysql by using the mysql CLI client. If yes, but Liquibase still refuses to connect to MySQL then comment the following line in /etc/hosts :

::1             localhost

and retry the liquibase command. It should work now.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)