Maven, Amazon EC2 and SpringSource Cloud Foundry

You may have heard about the just announced SpringSource Cloud Foundry and how it is based on the CloudTools project, that includes a Maven plugin to deploy Java EE applications to Amazon EC2, starting the images as part of the build process.

Some time ago I started another Maven plugin, the Amazon EC2 Maven plugin, which allows you to start and stop EC2 AMIs as part of your build process. Unlike CloudTools, it’s a lower level plugin that can start any AMI, a very different goal.

My use case? starting Selenium Grid Remote Control images for different environments and browsers before the integration tests start, wait for the images to be online, run the integration tests, and shutdown the images. Check my previous Enterprise Build and Test in the Cloud entry for more details.

You could also have your AMIs with your webserver, db,… pre-installed, start it, deploy using the Maven Cargo plugin to any container of your choice, and shutdown the image at the end of the tests.

The plugin allows all the configuration options than the EC2 API does, because it’s based on the Typica EC2 library. Start any number of images, associate elastic IPs, choose availability zones,…

Hope you find it useful.

Using Subversion Ruby bindings

I tried to do some subversion hacking from Ruby, very simple things like add/remove files,
commits and so, and realized that there’s no documentation at all out there, just blog posts
here and there.

I finally got something working, including user authentication (that is not as easy as you would
expect) and ignoring https certificates not signed by a trusted CA. Something like committing a file is not as simple as it would seem.

You have to make sure you have the latest version installed. In linux it means installing the subversion-ruby package. In OS X is more complicated, you need to remove the preinstalled subversion, install the newer one from Collabnet, and move some files around.

mv /Library/Ruby/Site/1.8/svn /Library/Ruby/Site/1.8/svn.bak
mv /Library/Ruby/Site/1.8/universal-darwin9.0/svn /Library/Ruby/Site/1.8/universal-darwin9.0/svn.bak
ln -s /opt/subversion/lib/svn-ruby/svn /Library/Ruby/Site/1.8/svn
ln -s /opt/subversion/lib/svn-ruby/universal-darwin/svn /Library/Ruby/Site/1.8/universal-darwin9.0/svn

Once you have it installed then you can call the svn libraries

  require "svn/core"
  require "svn/client"
  require "svn/wc"
  require "svn/repos"

  make_context("") do |ctx|
    # checkout
    ctx.checkout SVN_URL, "/tmp"
  end

  # Add a file and commit with a message
  make_context("Adding a file") do |ctx|
    ctx.add f
    ctx.commit f
  end

  # from http://svn.collab.net/repos/svn/trunk/subversion/bindings/swig/ruby/test/util.rb
  def make_context(log)
    ctx = Svn::Client::Context.new

    # Function for commit messages
    ctx.set_log_msg_func do |items|
      [true, log]
    end

    # don't fail on non CA signed ssl server
    ctx.add_ssl_server_trust_file_provider

    # username and password
    ctx.add_simple_prompt_provider(0) do |cred, realm, username, may_save|
      cred.username = "myusername"
      cred.password = "mypassword"
      cred.may_save = false
    end
    # setup_auth_baton(ctx.auth_baton)
    return ctx unless block_given?
    begin
      yield ctx
    ensure
      ctx.destroy
    end
  end

Playing with Ruby and Rails

I have been playing with Ruby and Rails for a good number of months already and fond it quite interesting.
It’s fairly easy to start new projects and get going, although it’s also very easy to make
mistakes if you don’t know what’s going on behind the scenes. For instance, it’s very easy
to have the N+1 SQL problem, or dependency mismatches between machines.

What I like:

  • Migrations
  • Different environments (dev, test, production), and predefined configurations for each, like log level
  • Real time development, change a file and see the changes immediately.
  • AJAX support, very easy to create partial updates and requests

What I don’t like:

  • Dependency management, if you don’t define versions it will take whatever is installed in the system
    (but probably I’m just spoiled by using Maven for so long)
  • Debugging, it ends being puts statements, although there’s probably something helpful out there
  • The plugin ecosystem, it’s a big mess with plugins and forks of plugins, and forks of forks,… It’s too easy to fork, which makes users less likely to contribute the changes and just work on their version.
  • Scripting, mistakes like typos are very easy to do, and refactoring becomes a big PITA

 

JavaOne slides: Enterprise Build and Test in the Cloud

I have uploaded the slides from my talk Enterprise Build and Test in the Cloud at JavaOne in San Francisco.

You can check also the code, and an introduction in previous posts

Enterprise build and Test in the Cloud with Selenium I
and
Enterprise build and Test in the Cloud with Selenium II.

Follow me on twitter

Photos: The Standard Hotel

The Standard Hotel, Downtown Los Angeles

Standard Hotel rooftop bar
Standard Hotel rooftop bar

Swimming pool Standard Hotel rooftop bar in Downtown Los Angeles

Standard Hotel rooftop bar
Standard Hotel rooftop bar

Standard Hotel rooftop bar in Downtown Los Angeles

In front the water beds, behind the U.S. Bank Tower.
U.S. Bank Tower is the tallest building in the United States west of the Mississippi River. (1,018 ft/310 m)

JavaOne talk: Enterprise Build and Test in the Cloud

I’ll be presenting Enterprise Build and Test in the Cloud at JavaOne in San Francisco, Wednesday June 3rd 11:05am Esplanade 301 and will be around the whole week.

You can check the slides from the previous talk at ApacheCON, the code, and an introduction in previous posts

Enterprise build and Test in the Cloud with Selenium I
and
Enterprise build and Test in the Cloud with Selenium II.

Follow me on twitter

Enterprise Build and Test in the Cloud code available

The code accompanying the slides Enterprise Build and Test in the Cloud is available at the appfuse-selenium github page.

Provides a Selenium test environment for Maven projects, Appfuse as an example. Allows to run Selenium tests as part of the Maven build, either in an specific container and browser or launching the tests in parallel in several browsers at the same time.

For more information check my slides on Enterprise Build and Test in the Cloud and the blog entries Enterprise Build and Test in the Cloud with Selenium I and Enterprise Build and Test in the Cloud with Selenium II.

By default it’s configured to launch 3 browsers in parallel, Internet Explorer, Firefox 2 and 3

Check src/test/resources/testng.xml for the configuration.

In the single browser option you could do

  • Testing in Jetty 6 and Firefox

    • mvn install

  • Testing in Internet Explorer

    • mvn install -Pjetty6x,iexplore

  • Testing with any browser

    • mvn install
      -Pjetty6x,otherbrowser -DbrowserPath=path/to/browser/executable

  • Start the server (no tests
    running, good for recording tests)

    • mvn package cargo:start

ApacheCON slides: “Enterprise Build and Test in the Cloud” and “Eclipse IAM, Maven integration for Eclipse”

Here you have the slides from my talks at ApacheCON

Enterprise Build and Test in the Cloud

Building and testing software can be a time and resource consuming task. Cloud computing / on demand services like Amazon EC2 allow a cost-effective way to scale applications, and applied to building and testing software can reduce the time needed to find and correct problems, meaning a reduction also in time and costs. Properly configuring your build tools (Maven, Ant,…), continuous integration servers (Continuum, Cruise Control,…), and testing tools (TestNG, Selenium,…) can allow you to run all the build/testing process in a cloud environment, simulating high load environments, distributing long running tests to reduce their execution time, using different environments for client or server applications,… and in the case of on-demand services like Amazon EC2, pay only for the time you use it.
In this presentation we will introduce a development process and architecture using popular open source tools for the build and test process such as Apache Maven or Ant for building, Apache Continuum as continuous integration server, TestNG and Selenium for testing, and how to configure them to achieve the best results and performance in several typical use cases (long running testing processes, different client platforms,…) by using he Amazon Elastic Computing Cloud EC2, and therefore reducing time and costs compared to other solutions.

Download PDF

Eclipse IAM, Maven integration for Eclipse

Eclipse IAM (Eclipse Integration for Apache Maven), formerly “Q for Eclipse”, is an 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.

Download PDF

Amsterdam – Stockholm – Tallinn – Helsinki and back

ApacheCon was a great time, and I enjoyed so much the first visit to Amsterdam. Now I’m taking some time off, writing from a sunny Stockholm right now, tomorrow Wednesday I’ll be in Tallinn, Thursday in Helsinki, Friday and Saturday in Stockholm, and Sunday Amsterdam again before flying to Los Angeles.

Not so much blog writing lately, definitely easier just to twitter, follow me @csanchez. I will post the slides and more comments from ApacheCon soon.

Conference season: JavaOne

If last week I mentioned the two conferences I got talks accepted, ApacheCON and EclipseCON, now I just got the confirmation that my talk Enterprise build and test in the cloud was accepted for JavaOne, June 2-5 in San Francisco

You can read a little bit about what I’m going to talk about in my posts

Enterprise build and Test in the Cloud with Selenium I
and
Enterprise build and Test in the Cloud with Selenium II, probably a 3rd part coming after ApacheCON.