Badoo Rajdeep Varma Feb 9, 2017

Dockerizing Calabash Android Testing on macOS

Article Summary

Rajdeep Varma from Badoo (now Bumble) tackled a problem that sounds impossible: running Android device tests inside Docker on macOS when Docker can't even see USB devices. The workaround? Brilliantly hacky.

Badoo's QA team wanted developers to run Calabash Android tests in one command without complex environment setup. Docker was faster than Vagrant, but macOS Docker doesn't support USB—a dealbreaker for ADB communication with Android devices. This article details the creative networking tricks that made it work.

Key Takeaways

Critical Insight

By combining an ADB proxy server and network interface forwarding, the team containerized their entire Android test suite while keeping just one small dependency on the host machine.

The article includes complete shell scripts and Docker configurations you can adapt for your own Android testing pipeline.

About This Article

Problem

Calabash-Android uses Ruby code that relies on ADB port forwarding to reach an HTTP server running inside Android devices. Docker containers can't access localhost:xxxx ports when they're only bound to the Mac host's 127.0.0.1 interface because of how Docker for Mac handles networking.

Solution

Rajdeep Varma's team set up pfctl packet filtering rules to redirect traffic from network interfaces like lo0, en0, and en1 to localhost port 34778. This allowed containers to communicate with devices through the host's forwarded ports.

Impact

Developers can now run the entire Calabash test suite with one command: ./started.sh path/to/your.apk features/my_feature/awesome.feature. They only need ADB as a local dependency, which means no more wrestling with JDK, Android SDK, and Ruby installation.