“Q4E and Eclipse IAM, Maven integration for Eclipse” slides from ApacheCon

I have uploaded the slides from my talk Q4E and Eclipse IAM, Maven integration for Eclipse at ApacheCon in New Orleans. You can download them from the session page. It’s an introduction on the features, the roadmap, integration with other plugins,… Talk went well, few questions during the Q&A round but a lot more as I left the stage 😉

If you are interested in Maven, you can check too Brett Porter‘s talk More Apache Maven Best Practices.

The rest of ApacheCon is being great, a lot of networking as usual, attending a few talks to get introduced on some interesting technologies and drinks on the nearby, Bourbon street, walking distance (or crawling, depending on who are we talking about).

Amazon Web Services: habemus Windows

This is going to be a little bit out of order with my other posts about Amazon AWS, but it’s worth doing it. Amazon has launched finally the ability to run Windows images in EC2. Microsoft Windows Server 2003 actually, from 0.125$ per hour, compared to the 0.10$ for the unix/linux instances.

The instances are accessible through Windows Remote Desktop or the open source multiplatform rdesktop client. The first time you launch an image the password is generated, but you can change it for new images you make based on that one.

A nice feature that will save a lot of time is the ability of creating new Windows AMIs from the ElasticFox interface with a couple of clicks, without needing to mess with software installation in the image (more on image creation in next posts) which is way easier than the process for linux images.

You can also run Windows Server with SQL Server Standard, but watch out for the 1.10$ per hour, which makes 792$ per month that you can compare to the 6000$ processor license fee.

Previous entry: Amazon Web Services: an introduction

Next: Amazon Web Services: tools

Amazon Web Services: an introduction

This post is an introduction to Amazon Web Services, as I’ll be
writing a series of posts in the following weeks elaborating on the stuff I’ve been working on
this year.

Amazon Web Services, AWS, is a platform for infrastructure services in the cloud at very competitive prices. AWS is revolutionizing the IT services in all sorts of companies. No more
dealing with hardware, no need to have people available 24/7 to monitor
servers, no more trips to the data center, no need for the developers
to wait for days/weeks until IT can get you a specific server
platform,…

AWS is composed of

S3 is a  like a virtually infinite storage service. You can store files and pay per storage and data transfer ($0.15 per GB-month)

EC2 provides a way to have a virtual server running in a matter
of minutes. It takes an AMI (Amazon Image) stored in S3 and starts it,
giving you a public address where you can ssh to and you have your
server ready. There are many publicly available images from Amazon and
third parties, with several *nix flavors CentOS, Ubuntu, OpenSolaris… and Windows images
coming this fall. There are also images with stacks already installed, mysql, apache, ruby on rails,… If you need you can customize your running server and later capture an image to launch as many instances of it as you want, and
also considering that the image provided storage is not persistent, if
your image is stopped or dies, everything changed in the server since
you started it is lost. There are three types of servers, small, large, extra large,… with different amount of space, cpu, memory,… You pay per
type of instance, time running and data transfer, starting at $0.10 per hour.

EBS is an EC2 service that allows you to attach a virtual drive to EC2 instances, with high availability and high reliability, and size up to 1TB, providing persistent storage to the instance. The drive can be backed up to S3 too. You pay $0.15 per GB-month allocated.

SQS is a simple and scalable message queue, paying for the number of messages and data transfer (1$ gives you up to 500.000 messages)

SimpleDB is a web service for running queries on structured data in real time. Haven’t tried it at all but seems suitable if you have a huge structured database and need it to scale.

Now, why should you care about cloud computing and particularly about Amazon Web Services? well if you are in one of this cases you should definitely check it out:

  • I need a server for a few hours only: with AWS you pay per hour
  • I’m running a startup and dont have the cash up front to setup a huge infrastructure (and I don’t know if the company will go under in few months): you don’t have upfront costs, just pay for the time you use it
  • I need huge storage space requirements: you can allocate TB of space
  • I run a task that needs 24 hours to complete, but could be distributed in 24+ servers and take less than 1 hour: it will cost pretty much the same to have 1 server running 24 hours than having 24 servers running 1 hour
  • I need to scale fast: you can add servers in a matter of minutes, storage space,…
  • I need high availability and geographical distribution: Amazon provides availabilty zones, so far three for EC2 in the US East coast, and two for S3, US and Europe, most likely the possibilities will grow in the future

The next post will be about the tooling that can be used to easily manage all these services.

Next entry: Amazon Web Services: habemus Windows

Interview in JavaHispano

JavaHispano, the portal for the Spanish speaking Java community has published a podcast (in Spanish if you haven’t figured out yet 😉 ) where Abraham Otero interviews me, covering a little bit of my past, how I got involved with open source, the Apache Software Foundation, Eclipse, and other projects, how do they work, my personal view on the status of open source, the job market and a comparison of the USA vs Spain in many aspects for people working in the technology world.

Q4E and Eclipse IAM news and talks

Q4E, the Maven plugin for Eclipse, is in the process of moving to the Eclipse Foundation infrastructure as Eclipse IAM (Eclipse Integration for Apache Maven). We are going through the IP verification process, which is quite strict at Eclipse, so it takes some time to move the bits and pieces over. We are doing it slowly to prevent disruptions while the development still continues and to have a smooth transition. There will be some time while some things are still hosted at the Q4E site and some at IAM.

And in the next weeks the project will be present at two important conferences where Abel Muiño and myself will be talking about the project features, status, future direction,…

ApacheCon US, New Orleans, November 6th
Carlos Sanchez: Q4E and Eclipse IAM, Maven integration for Eclipse
“Q for Eclipse”, now Eclipse IAM (Eclipse Integration for Apache
Maven), is a new Open Source project that integrates Apache Maven and
the Eclipse IDE for faster, more agile, and more productive
development. The plugin allows you to run Maven from the IDE, import
existing Maven projects without intermediate steps, create new projects
using Maven archetypes, synchronize dependency management, search
artifact repositories for dependencies that are automatically
downloaded, view a graph of dependencies and more! Join us to discover
how to take advantage of all these features, as well as how they can
help you to improve your development process.

Eclipse Summit Europe, Ludwigsburg, Germany, November 20th
Abel Mui�o: IAM new & noteworthy
Eclipse IAM (Integration for Apache Maven) is a new eclipse technology
project in the eclipse incubator providing integration of maven in
eclipse.
In this talk we will review what features are already present on
Eclipse IAM, what is on the roadmap and how users and adopters can
configure and extend it.
Abel Muino is the project lead for Eclipse IAM (Integration of Apache
Maven) and principal architect for Berggi Inc.
For the past 5 years, he has worked as java developer and architect in
Data Integration, Security and Services for Mobile Devices.

Geotagged live video from cell phone with Ipoki and Qik

What about streaming live video from your cell phone while you track your route (and not just a point) with the phone GPS? Now you can do it with Ipoki, a GPS based social network, and their new integration with Qik, live video streaming service from cell phones.

Ipoki lets you share your current location with
others in real-time. Also, you can see where your friends are and track
them on Google Maps and Google Earth. Ipoki lets you keep track of your
routes and use it to geolocate photos in flickr automatically. Invite
your friends to see where you are and find and follow them across the
world. Feel free to sign up. It’s free.

In this video you can see the Ipoki web page with the moving real time location in a map (meters and seconds precision!) and the live video feed from an user driving around recording the wonderful views of my city 😉

You can also tag online your Flickr pictures using you cell phone location recorded and the picture timestamp, avoiding carrying (and buying!) an extra GPS logger, and without installing extra software. Seems that I just need to upgrade my phone!

http://www.youtube.com/v/F9lE_M6qvrY&hl=en&fs=1

Upgrading Struts 2.0.x to 2.1.x

Now that Struts 2.1.2 is officially out you may want to upgrade. I’ve found the upgrading instructions at the Struts wiki to be extremely useful, and pretty much you’ll need to read the whole thing.

Two things that I’ve contributed to the wiki:

Ensure no dependencies in the freemarker groupId are used as the latest version used by Struts is now under the org.freeemarker groupId and you’ll get classpath conflicts if you added a freemarker dependency.

In the unit tests you may get a NullPointerException as ActionContext.getContext() does not create a context on demand, I think there are better alternatives to avoid the direct use of getContext, but this snippet will fix the problem.


ConfigurationManager configurationManager = new ConfigurationManager();
configurationManager.addContainerProvider(new XWorkConfigurationProvider());
Configuration config = configurationManager.getConfiguration();
Container container = config.getContainer();

ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
stack.getContext().put(ActionContext.CONTAINER, container);
ActionContext.setContext(new ActionContext(stack.getContext()));

assertNotNull(ActionContext.getContext());

Functional testing with Maven, Cargo and Selenium

Setting up automated functional integration tests is not too hard if you have the right tools. It can take you a bit of time to setup but in the long run you’ll benefit from reduced QA times, reduced risks, a more confident development team, the ability to do safe refactorings, and many more advantages.

I’m going to explain how Maven, Selenium, Cargo and JBoss 4.2 can be setup to run automatically in a continuous integration server such as Continuum customizing the server configuration as needed and deploying any webapp automatically. Every time the webapp is changed the CI server will execute the tests against the latest version ensuring you are always in a safe state.

The biggest difference with other tutorials I’ve found is that most of them cover just Jetty and are not updated to the latest versions of libraries and tools, so here it is my contribution.

Architecture

  • A new project is setup with dependencies to the war project to be tested. Also required a dependency to selenium java client.
  • Cargo will download and install the application server (JBoss)
  • We will copy any required configuration and libraries (ie. jdbc driver)
  • Cargo will start the application server
  • The Selenium server is started
  • Surefire executes the junit tests that interact with the selenium server and test the running app
  • Cargo will stop the app server

We use profiles to enable different combination of browser/application server. By default cargo uses jetty.

Config Profiles
JBoss 4.2 and Firefox (default) -Pjboss42x,firefox
JBoss 4.2 and Internet Explorer -Pjboss42x,iexplore
Jetty and Firefox -Pfirefox
Jetty and Internet Explorer -Piexplore

The POM

Dependencies

<dependencies>
    <dependency>
      <groupId>com.acme</groupId>
      <artifactId>mywebapp</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
    <!-- the jdbc driver we need to copy to the appserver -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
      <groupId>org.openqa.selenium.client-drivers</groupId>
      <artifactId>selenium-java-client-driver</artifactId>
      <version>1.0-SNAPSHOT</version> <!-- required for firefox 3 else use 1.0-beta-1 -->
      <scope>test</scope>
    </dependency>
  </dependencies>

Properties used in several places

Ports, where to uncompress the application server,…

<properties>
    <cargo.install.directory>${project.build.directory}/installs</cargo.install.directory>
    <selenium.port>14444</selenium.port>
    <servlet.port>18880</servlet.port>
    <selenium.background>true</selenium.background>
  </properties>

Plugin configuration

JDBC driver

Copy mysql jdbc driver to the app server lib folder

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-jdbc-lib</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <includeGroupIds>mysql</includeGroupIds>
              <outputDirectory>${lib.target}</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

Cargo

Install the application server in an early phase so we can customize it with our configuration files (see profiles). Then start before integration tests and stop afterwards. Parameters are used so different profiles can use different application servers.

      <plugin>
        <groupId>org.codehaus.cargo</groupId>
        <artifactId>cargo-maven2-plugin</artifactId>
        <executions>
          <execution>
            <id>install</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>install</goal>
            </goals>
          </execution>
          <execution>
            <id>start-container</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>start</goal>
            </goals>
            <configuration>
              <wait>false</wait>
            </configuration>
          </execution>
          <execution>
            <id>stop-container</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <container>
            <containerId>${container.name}</containerId>
            <zipUrlInstaller>
              <url>${container.url}</url>
              <installDir>${cargo.install.directory}/${container.name}</installDir>
            </zipUrlInstaller>
            <log>${project.build.directory}/logs/${container.name}.log</log>
            <output>${project.build.directory}/logs/${container.name}.out</output>
            <timeout>600000</timeout>
          </container>
          <configuration>
            <!--
            <home>${project.build.directory}/${container.name}conf</home>
            <type>existing</type>
            -->
            <properties>
              <cargo.servlet.port>${servlet.port}</cargo.servlet.port>
              <cargo.jboss.configuration>default</cargo.jboss.configuration>
              <cargo.rmi.port>1099</cargo.rmi.port>
            </properties>

            <deployables>
              <!-- application to deploy -->
              <deployable>
                <groupId>com.acme</groupId>
                <artifactId>mywebapp</artifactId>
                <type>war</type>
                <properties>
                  <context>acontext</context>
                </properties>
              </deployable>
            </deployables>
          </configuration>
        </configuration>
      </plugin>

Selenium

Make surefire skip tests during test phase and run them in the integration-test phase. Pass some properties as system properties so they are accessible from the junit test case.

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <!-- Skip the normal tests, we'll run them in the integration-test phase -->
          <skip>true</skip>
          <systemProperties>
            <property>
              <name>browser</name>
              <value>${browser}</value>
            </property>
            <property>
              <name>servlet.port</name>
              <value>${servlet.port}</value>
            </property>
            <property>
              <name>selenium.port</name>
              <value>${selenium.port}</value>
            </property>
          </systemProperties>
        </configuration>
        <executions>
          <execution>
            <phase>integration-test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <skip>false</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>selenium-maven-plugin</artifactId>
        <!-- to run headless in a Unix server with a virtual framebuffer X server Xvfb
             you need to call first the goal selenium:xvfb ie. "mvn clean selenium:xvfb install"
             see http://mojo.codehaus.org/selenium-maven-plugin/examples/headless-with-xvfb.html -->
        <executions>
          <execution>
            <id>start-selenium</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>start-server</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <background>${selenium.background}</background>
          <port>${selenium.port}</port>
          <logOutput>true</logOutput>
        </configuration>
      </plugin>

Application server profiles

We can configure a different profile for each application server and set some specific application server configuration.

<profiles>
    <profile>
      <id>jboss42x</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <container.name>jboss42x</container.name>
        <container.url>http://internap.dl.sourceforge.net/sourceforge/jboss/jboss-4.2.1.GA.zip</container.url>
        <jboss.version>4.2.1.GA</jboss.version>
        <jboss.conf.directory>${cargo.install.directory}/${container.name}/jboss-${jboss.version}/jboss-${jboss.version}/server/default</jboss.conf.directory>
        <lib.target>${jboss.conf.directory}/deploy/lib</lib.target>
        <war.target>${jboss.conf.directory}/deploy</war.target>
      </properties>

      <dependencies>
        <dependency>
          <groupId>org.jboss</groupId>
          <artifactId>jboss</artifactId>
          <version>${jboss.version}</version>
          <type>zip</type>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <!-- copy to the application server directory any customized configuration files that we need -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <phase>process-resources</phase>
                <configuration>
                  <tasks>
                    <copy todir="${jboss.conf.directory}" overwrite="true">
                      <fileset dir="${basedir}/src/test/${container.name}"/>
                    </copy>
                  </tasks>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

Browser profiles

As with the application servers we have a profile for each browser

<profile>
      <id>firefox</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <browser>*firefox</browser>
      </properties>
    </profile>
    <profile>
      <id>iexplore</id>
      <properties>
        <browser>*iexplore</browser>
      </properties>
    </profile>
    <profile>
      <id>otherbrowser</id>
      <properties>
        <browser>*custom ${browserPath}</browser>
      </properties>
    </profile>

Enabling testing during development

Make selenium not to run in the background so we can execute tests from the IDE

    <profile>
      <id>dev</id>
      <properties>
        <selenium.background>false</selenium.background>
      </properties>
    </profile>

Repositories

Required for Selenium dependencies

<repositories>
    <repository>
      <id>openqa.org</id>
      <name>OpenQA Repository</name>
      <url>http://archiva.openqa.org/repository/releases</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <enabled>true</enabled>
      </releases>
    </repository>
    <!-- for selenium 1.0-SNAPSHOT -->
    <repository>
      <id>snapshots.openqa.org</id>
      <name>OpenQA Sanpshots Repository</name>
      <url>http://archiva.openqa.org/repository/snapshots</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>false</enabled>
      </releases>
    </repository>
  </repositories>

Running in the build server

In an Unix server without X running you can still run Selenium tests using Xvfb (virtual framebuffer X server) by calling selenium:xvfb provided it’s properly configured.

Also you can pass the path to the browser binary if not in the PATH

mvn clean selenium:xvfb install -Dbrowser="*firefox /usr/lib64/firefox-1.5.0.12/firefox-bin"

The JUnit test

public class SeleniumHelloWorldTest
    extends TestCase
{
    private DefaultSelenium selenium;

    private String baseUrl;

    @Override
    public void setUp()
        throws Exception
    {
        super.setUp();
        String port = System.getProperty( "servlet.port" );
        baseUrl = "http://localhost:" + port;
        selenium = createSeleniumClient( baseUrl );
        selenium.start();
    }

    @Override
    public void tearDown()
        throws Exception
    {
        selenium.stop();
        super.tearDown();
    }

    protected DefaultSelenium createSeleniumClient( String url )
        throws Exception
    {
        String browser = System.getProperty( "browser" );
        String port = System.getProperty( "selenium.port" );
        return new DefaultSelenium( "localhost", Integer.parseInt( port ), browser, url );
    }

    public void testHelloWorld()
        throws Exception
    {
        selenium.open( baseUrl + "/mycontext/" );
        assertTrue( selenium.isTextPresent( "acme" ) );
    }
}

Debugging and troubleshooting (update)

You can check JBoss logs in target/logs/jboss42x.out and Selenium server logs in target/selenium/server.log

References

Other wiki entries and blogs

Eclipse IAM passes creation review, Maven support at Eclipse Foundation soon

This week we have gone through the creation review for Eclipse IAM (Eclipse Integration for Apache Maven), and so we are starting with the paperwork at the Eclipse Foundation to create the project in the incubator and start moving the code from Q4E, the codebase will be donated to IAM as start point.

Development won’t stop in the meantime and we don’t expect any interruption for Q4E users.

Speaking at CommunityOne on Monday

Seems that I have been volunteered to do a lightening talk at CommunityOne on Monday at the Moscone as part of the Atlassian session.

Thanks to Cenqua’ Pete for offering free drinks in exchange (he hasn’t realized yet the mistake he has made) and entertainment like last year (hopefully with some differences in critical parts).

See you there.