Bye Bye Charles, Welcome Odo, Android Meetup Berlin May 2014

Post on 27-May-2015

1,793 views 3 download

description

Introducing the next generation testing proxy we use at Groupon to the public: Odo an http proxy with a RESTful API for mocking or partial rewriting of responses and requests

transcript

Bye Bye Charles, Welcome Odo!Android Stammtisch 28.Mai 2014Danny Preussler

Leading the way in mobile commerce

Our mobile app is available in 43 countries

Groupon’s vibrant mobile marketplace connectsconsumers with their local economy

Sources: Internal Data; iTunes ranking for US stores available here - https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewFeature?id=500873243&mt=8&v0=www-itunes25Bcountdown-appstore

Nearly 70 million people worldwide have downloaded our mobile app to date; 9 million in Q4 2013.

One of the 25 most downloaded free apps of all time

Nearly 50% of our global transactions completed on a mobile device in December 2013

The Problem

Test data from WebService(s)

Mock data?

• Easy with DI frameworks

• Hard with black box test frameworks• Do not reflect server changes

+

-

Use real data?

• Real world

• Hard to setup all test cases(manipulate db with scripts …)

• Automation mostly breaks because of networking

+

-

Do both

• Return mocked data if needed

• Use real world real data

• Modify data on the fly if needed

We need:

• Someone who can change

depending on what is needed?

A Solution

Odo-ed

Response Override

• Return fixed response content

• Return fixed response code

• Add delays

Response Override cont.

• Add/remove request headers

• Change content

• Change response code

Response Override cont.

• Do sequences of all those

• Supports Plugins for custom responses

i.e. makeDealSoldOut

Request Override

• Add/remove request headers

• Custom request – add/change parameters

• Change the target

i.e. send production request to staging/test

Odo Demo

Build a plugin

public class MyPlugins {

@ResponseOverride( httpCode=302, description="Return HTTP302") public static String http302(String source) throws Exception { return „<html><body>You are being redirected.</body></html>“; }

Done

Configuration

• No installation needed, simple war file

• Webinterface

• API

API

• JSON REST API

• Java Client available

public class OdoTest extends ActivityInstrumentationTestCase2<LoginActivity> { Client odoClient = new Client("33", false);

public void testOdo() throws Exception {LoginActivity activity = getActivity();

// genymotion != localhost odoClient.setHostName("192.168.56.1"); odoClient.addMethodToResponseOverride(

"Countries", "com.groupon.odo.internal.Common.http503");

odoClient.toggleResponseOverride("Countries", true); }}

What do you have to change in your app?

Proxy proxy = new Proxy(

Proxy.Type.HTTP,

new InetSocketAddress(

"192.168.56.1", 9090));

new URL("http://api...").openConnection(proxy);

HttpUrlConnection

OkHttp

Proxy proxy = new Proxy(

Proxy.Type.HTTP,

new InetSocketAddress(

"192.168.56.1", 9090));

OkHttpClient client = new OkHttpClient();

client.setProxy(proxy);

DefaultHttpClient httpclient =

new DefaultHttpClient();

httpclient.getParams().setParameter(

ConnRoutePNames.DEFAULT_PROXY,

new HttpHost("192.168.56.1", 9090));

Old school apache

Configuration

• Supports multiple users through client id’s

• This way you can share proxy

• Apps send them as http-header

Configuration

• Forwarding proxy mode

• Man in the middle mode

• SSL certificate download page

Behind odo

• Utilizes forwarding proxy, Spring, Spring Boot, Java servlets, embedded database

• Packaged as a .war file

• No setup required

Advantages

• Test Automation

• Avoid stub data maintenance

• Create dynamic test automation

• Manual Test

• UI allows easy configuration changes

• No coding knowledge required

• Development

• Remove dependencies on server changes for

client development

Odo + vs Charles

• Is free• Is open source• Is “programmable”• Is extendable via plugins• Has API• Perfect for test automation

Where can I get Odo?

https://github.com/groupon

In a couple of d

ays…

Follow us…

Abgeschottete Realität

Android Apps kontrolliert im Emulator testen

Danny Preussler, Groupon

The Day After

Lars Röwekamp, open knowledge

Danny Preussler, Groupon

Follow us…

https://engineering.groupon.com/

Michael Burton, Roboguice

Carlos Sessa, 50 Android hacks

David van der Bokke, RoboRemote

David Willson, Odo

….

Thank you