Posts Tagged ‘api’

Doing Continuous Integration Testing? Check Out Our CI API

November 4th, 2010 by Santiago Suarez OrdoƱez

Testing is a key ingredient in CI. And so in the constant effort to make our service insanely flexible and easy to use, we’ve released a brand new API that will help Continuous Integration servers such as Hudson, Bamboo, and TeamCity send Sauce OnDemand some interesting information about each test they run.

This includes the pass/fail final status of the test, the build number in which it was run, and even your own custom data.

Since some of this new job info is known only when the test finishes (e.g. whether the job passed or not), we’ve created not only one but two alternative methods for the info to be sent – the REST API and Selenium’s standard setContext command. Both are documented in our docs, and anyone interested can use them right now.

Once the info makes it to our end, it will be appropriately displayed with each job, helping our users find and group their jobs with less effort. (Notice that some of the work needed to display this in a cool way is still in our TODO – but the data is there). You can see some example jobs [1] with this data set or just create your own!

In the near future, we’ll be working with the authors of the Hudson and Bamboo plugins to add support for these CI APIs.

If you’re interested in hearing more, trying early versions of these plugins, or would like to see a plugin for another CI system, feel free to ping us here!

[1] https://saucelabs.com/jobs/4baf3ad0cd8b686ef554135c4addf621,
https://saucelabs.com/jobs/0d925d14c23888b8561215360b70a78d

Share

Library for Hudson Sauce OnDemand PlugIn

July 19th, 2010 by Ashley Wilson

By Kohsuke Kawaguchi

As promised in my earlier post, today I’ll talk about the library that does the heavy-lifting for the Hudson Sauce OnDemand plugin. This library is called Sauce REST API, and defines a Java API to access Sauce OnDemand REST API. It’s built by Maven, and deployed to java.net Maven2 repository.

The library is capable of basic CRUD (create, read, update, and delete) operations over SSH tunnels. To use this library, you create a SauceTunnelFactory instance, then use the CRUD methods defined on it.

For example, to set up a tunnel and tear it down, do as follows:

SauceTunnelFactory tunnelFactory = new SauceTunnelFactory();

// create a new tunnel for the intranet host foo.corp.infradna.com
// wait until the tunnel is ready
SauceTunnel t = tunnelFactory.create("foo.corp.infradna.com");
t.waitUntilRunning(30000);
assertTrue(t.isRunning());

// reverse port forwarding so that foo.corp.infradna.com:80
// will come to localhost:80
t.connect(80,"localhost",80);

// do something with the tunnel
...

// destroy the tunnel (and all port forwardings that go with it)
t.destroy();

You can also list the current active tunnels, if you’d like to.
This lists all the tunnels that belong to your account, not just the ones
created by the current process:

for (SauceTunnel t : tunnelFactory.list()) {
    System.out.println(t.getCreationTime()+" "+t.isRunning());
}

In these examples, you see I didn’t pass in the user name and API key explicitly. This is because the library reads the credential from a property file at ~/.sauce-ondemand, which should look like this:

username=kohsuke
key=12345678-abcd-cdef-1234-1234567890ab

This encourages all the applications that use this library to share the same credential source, which is more convenient for users. Of course, if your application wants to control the credential in its own way, you can use a different overloaded version of the SauceTunnelFactory constructor to pass it in explicitly.

The Maven-generated documentation and javadoc are also available.

Kohsuke Kawaguchi, the creator of Hudson, wrote the majority of Hudson’s core single-handedly. He is a founder of InfraDNA, which provides products, services, and support for Hudson.

Share