Skip to main content

OpenSTF + Jenkins = Scalable In-House Device Sharing

I first learned about OpenSTF from a tweet by Square's Jake Wharton. It's frickin' awesome. I believe I've posted about this before but seriously go check it out if you're an Android developer or tester who has a pool of shared test devices to work with. It's FOSS and boss. Go check it out.

At the time of Jake's tweet, there was no integration between the awesome little project and my cluster of devices configured to host test automation in Jenkins. Because of the open source natures of both OpenSTF and Jenkins, and the robust plugin system on Jenkins, it seemed inevitable to me that a plugin would be written eventually to marry the two. I even speculated that I might write one if I got the chance.

Luckily for everyone that wasn't going to be necessary.

It's actually really straightforward to set up and easy to use but here are a couple of issues with work-arounds you might want to consider:

  • Issue -The API key from OpenSTF for the plugin's global config is associated with the username on the OpenSTF service that created it.
    • Solution - Create your API key on OpenSTF for the Jenkins Plugin using a service account with the name "Jenkins" so it is obvious who is using the device when a job configured with the plugin checks one out on the OpenSTF service.
  • Issue - The OpenSTF Plugin uses the Android Emulator Plugin to manage device IO which means you can't run all your tests across all devices in a given pool in parallel with a normal job config.
    • Solution - The suggested solution by the plugin maintainer is to use a matrix job but I find the Jenkins implementation of a matrix job to be a suboptimal experience. Instead, I prefer to configure my jobs in the following way:
      • restrict it to the node hosting your OpenSTF service
      • use the OpenSTF plugin to configure the job to use a single, specific device and name it in a semantically unique way that identifies the device as it's desired target (i.e. "testMyApp_Nexus5X_SDK24")
      • use the "$ANDROID_SERIAL" environment variable in all shell script calls to adb (see my previous posts on how to set up Jenkins and devices to be scalable for examples of this).
      • Granted, if you're running a job across dozens of devices, a Matrix Job might be a better config but in our case, less than 10 devices means single jobs work better visually and for discoverability
I may present on this at a future Seattle Android Developers meetup depending on timing and opportunity but if there's enough call for it here, I can update this post with a more elaborate description including screenshots and step-by-step instructions to fully illustrate my approach.

Comments

Post a Comment

Popular posts from this blog

UiAutomator and Watchers: Adding Async Robustness to UI Automation

"I'm looking over your shoulder... only because I've got your back." ~ Stephen Colbert After my recent UiAutomator review a user brought up an important question about the use of UiWatcher. The watchers serve as async guardians of the test flow, making sure the odd dialog window doesn't completely frustrate your tests. Having a tool that automatically watches your back when you're focused on the functional flow of your tests is awesome. 100% pure awesomesauce. Since the API documentation on watchers is scant and the UI Testing tutorial on the Android dev guide doesn't cover their use in depth, I figured I should add a post here that goes over a simple scenario demonstrating how to use this fundamentally important UI automation tool. In my example code below, I'm using uiautomator to launch the API Demo app (meaning run this against an Emulator built in API level 17 - I used the Galaxy Nexus image included in the latest ADT and platform tools). ...

UiAutomator.jar: What happened when Android's JUnit and MonkeyRunner got drunk and hooked up

"Drunkenness does not create vice; it merely brings it into view" ~Seneca So Jelly Bean 4.2 landed with much fanfare and tucked in amongst the neat new OS and SDK features (hello, multi-user tablets!) was this little gem for testers: UiAutomator.jar. I have it on good authority that it snuck in amongst the updates in the preview tools and OS updates sometime around 4.1 with r3 of the platform. As a code-monkey of a tester, I was intrigued. One of the best ways Google can support developers struggling with platform fragmentation is to make their OS more testable so I hold high hopes with every release to see effort spent in that area. I have spent a couple days testing out the new UiAutomator API  and the best way I can think of describing it is that Android's JUnit and MonkeyRunner got drunk and had a code baby. Let me explain what I mean before that phrase sinks down into "mental image" territory. JUnit, for all its power and access to every interface, e...

Why Developers Shouldn't Perform Software Testing - A Rebuttal

Take a minute and read the following 2-pager entitled " Guest View: Why developers shouldn’t perform software testing ". Man, I tried to like this article because the author, Martin Mudge, clearly knows that businesses who undervalue quality by trying to eliminate testing through simply shuffling the traditional testing task to developers are making a huge mistake. Unfortunately he begins by making an assertion that testing overburdens a developer which at face value is complete nonsense. If you feel overburdened, it is a timeline issue and that is true no matter WHAT the nature of the tasking is.  So his assertion of “one the most important” contributing factors being overburdening the developers is massively flawed. It gets immediately worse from there because his second point is about time constraints.  Mr Mudge just gets so much wrong. What he really should be shooting down is the idea that testing, as a cost-center not as a task, can be eliminated by having your p...