diff --git a/Dockerfile b/Dockerfile index ef0fda3..d507f81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,8 @@ WORKDIR /root # Java # libqt5webkit5 # Web content engine (Fix issue in Android) +# socat +# Port forwarder #------------------ # NoVNC Packages #------------------ @@ -57,6 +59,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ supervisor \ openjdk-8-jdk \ libqt5webkit5 \ + socat \ xvfb \ x11vnc \ openbox \ @@ -146,11 +149,15 @@ ENV DISPLAY=:0 \ # Expose Ports #--------------- # 4723 -# appium port +# Appium port # 6080 # noVNC port +# 5554 +# Emulator port +# 5555 +# ADB connection port #=============== -EXPOSE 4723 6080 +EXPOSE 4723 6080 5554 5555 #====================== # Add Emulator Devices @@ -162,4 +169,5 @@ COPY devices /root/devices #=================== COPY src /root/src COPY supervisord.conf /root/ +RUN chmod -R +x /root/src && chmod +x /root/supervisord.conf CMD /usr/bin/supervisord --configuration supervisord.conf diff --git a/README.md b/README.md index b8570b4..f57d310 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,10 @@ Docker is installed in your system. Purpose ------- -1. Build android project / application and run unit test inside docker-container +1. Build android project / application and run unit test 2. Run UI Test for mobile website with appium framework 3. Run UI Test for mobile application with different frameworks (appium, espresso, etc.) +4. Simulate Short Message Service (SMS) Features -------- @@ -34,13 +35,13 @@ List of Docker images |Linux|5.0.1|21|butomo1989/docker-android-x86-5.0.1|[![](https://images.microbadger.com/badges/version/butomo1989/docker-android-x86-5.0.1.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-5.0.1 "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-5.0.1.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-5.0.1 "Get your own image badge on microbadger.com")| |Linux|5.1.1|22|butomo1989/docker-android-x86-5.1.1|[![](https://images.microbadger.com/badges/version/butomo1989/docker-android-x86-5.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-5.1.1 "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-5.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-5.1.1 "Get your own image badge on microbadger.com")| |Linux|6.0|23|butomo1989/docker-android-x86-6.0|[![](https://images.microbadger.com/badges/version/butomo1989/docker-android-x86-6.0.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-6.0 "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-6.0.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-6.0 "Get your own image badge on microbadger.com")| -|Linux|7.0|24|butomo1989/docker-android-x86-7.0|[![](https://images.microbadger.com/badges/version/butomo1989/docker-android-x86-7.0.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-7.0 "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-7.0.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-7.0 "Get your own image badge on microbadger.com")| -|Linux|7.1.1|25|butomo1989/docker-android-x86-7.1.1|[![](https://images.microbadger.com/badges/version/butomo1989/docker-android-x86-7.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-7.1.1 "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-7.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-x86-7.1.1 "Get your own image badge on microbadger.com")| +|Linux|7.0|24|TODO because still have a Bug|| +|Linux|7.1.1|25|TODO because still have a Bug|| |OSX / Windows|5.0.1|21|butomo1989/docker-android-arm-5.0.1|[![](https://images.microbadger.com/badges/version/butomo1989/docker-android-arm-5.0.1.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-5.0.1 "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-5.0.1.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-5.0.1 "Get your own image badge on microbadger.com")| |OSX / Windows|5.1.1|22|butomo1989/docker-android-arm-5.1.1|[![](https://images.microbadger.com/badges/version/butomo1989/docker-android-arm-5.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-5.1.1 "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-5.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-5.1.1 "Get your own image badge on microbadger.com")| |OSX / Windows|6.0|23|butomo1989/docker-android-arm-6.0|[![](https://images.microbadger.com/badges/version/butomo1989/docker-android-arm-6.0.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-6.0 "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-6.0.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-6.0 "Get your own image badge on microbadger.com")| -|OSX / Windows|7.0|24|butomo1989/docker-android-arm-7.0|[![](https://images.microbadger.com/badges/version/butomo1989/docker-android-arm-7.0.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-7.0 "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-7.0.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-7.0 "Get your own image badge on microbadger.com")| -|OSX / Windows|7.1.1|25|butomo1989/docker-android-arm-7.1.1|[![](https://images.microbadger.com/badges/version/butomo1989/docker-android-arm-7.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-7.1.1 "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/butomo1989/docker-android-arm-7.1.1.svg)](https://microbadger.com/images/butomo1989/docker-android-arm-7.1.1 "Get your own image badge on microbadger.com")| +|OSX / Windows|7.0|24|TODO because still have a Bug|| +|OSX / Windows|7.1.1|25|TODO because still have a Bug|| Quick Start ----------- @@ -50,7 +51,7 @@ Quick Start 2. Run docker-android ```bash - docker run --privileged -d -p 6080:6080 -p 4723:4723 -e DEVICE="Samsung Galaxy S6" -e APPIUM=False --name appium-container butomo1989/docker-android-x86-5.0.1 + docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" -e APPIUM=False --name android-container butomo1989/docker-android-x86-5.0.1 ``` **Optional arguments** @@ -75,6 +76,7 @@ Quick Start Connect to Selenium Grid ------------------------ + This feature can be used only if you set **APPIUM=True** in environment variable. **Arguments** @@ -107,12 +109,61 @@ Tablet | Nexus 10 ![][galaxy s6] ![][nexus 5] +Control android emulator outside container +------------------------------------------ + +```bash +adb connect :5555 +``` + +![][adb_connection] + +**Note:** You need to have Android Debug Bridge (adb) installed in your host machine. + +SMS Simulation +-------------- + +1. Using telnet + - Find the auth_token and copy it. + + ```bash + docker exec -it android-container cat /root/.emulator_console_auth_token + ``` + + - Access emulator using telnet and login with auth_token + + ```bash + telnet 5554 + ``` + + - Login with given auth_token from 1.step + + ```bash + auth + ``` + + - Send the sms + + ```bash + sms send + ``` + +2. Using adb + + ```bash + docker exec -it android-container adb emu sms send + ``` + +3. You can also integrate it inside project using [adblib]. + +![][sms] + Troubleshooting --------------- All logs inside container are stored under folder **/var/log/supervisor**. you can print out log file by using **docker exec**. Example: ```bash -docker exec -it appium-container tail -f /var/log/supervisor/docker-appium.stdout.log +docker exec -it android-container tail -f /var/log/supervisor/docker-appium.stdout.log ``` [noVNC]: "login with noVNC to see what happen inside container" @@ -120,3 +171,6 @@ docker exec -it appium-container tail -f /var/log/supervisor/docker-appium.stdou [connect to grid 2]: [galaxy s6]: [nexus 5]: +[adb_connection]: +[sms]: +[adblib]: diff --git a/images/SMS.png b/images/SMS.png new file mode 100644 index 0000000..a3d14c8 Binary files /dev/null and b/images/SMS.png differ diff --git a/images/adb_connection.png b/images/adb_connection.png new file mode 100644 index 0000000..5634616 Binary files /dev/null and b/images/adb_connection.png differ diff --git a/src/port_forward.sh b/src/port_forward.sh new file mode 100644 index 0000000..2c5d8dd --- /dev/null +++ b/src/port_forward.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +ip=$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') +socat tcp-listen:5554,bind=$ip,fork tcp:127.0.0.1:5554 & +socat tcp-listen:5555,bind=$ip,fork tcp:127.0.0.1:5555 diff --git a/supervisord.conf b/supervisord.conf index 965cad4..9420c4c 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -23,6 +23,10 @@ command=./noVNC/utils/launch.sh --vnc localhost:%(ENV_LOCAL_PORT)s --listen %(EN stdout_logfile=%(ENV_LOG_PATH)s/novnc.stdout.log stderr_logfile=%(ENV_LOG_PATH)s/novnc.stderr.log +[program:port-forward] +command=./src/port_forward.sh +autorestart=false + [program:docker-appium] command=python3 -m src.app autorestart=false