mirror of
https://github.com/budtmo/docker-android.git
synced 2026-07-31 04:07:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e5370b85b | ||
|
|
da177442ce | ||
|
|
e2800863e8 | ||
|
|
c4bd3dcf55 | ||
|
|
ac594d96e9 | ||
|
|
a49cc2950e | ||
|
|
6b657dd13e | ||
|
|
aa7a798f62 | ||
|
|
ccec2c5969 | ||
|
|
e45bc0010f | ||
|
|
efd1f07e58 | ||
|
|
73418a8b4f | ||
|
|
ad444fd738 | ||
|
|
12391277e6 | ||
|
|
c50f185c65 | ||
|
|
62090f73b4 | ||
|
|
7bce737447 | ||
|
|
f2c6ab79bb | ||
|
|
afcbd4a7e7 | ||
|
|
9a714e5fb3 | ||
|
|
a6394bcf74 | ||
|
|
43d0bb1292 | ||
|
|
e56352bf74 | ||
|
|
7746b0ce1a | ||
|
|
806443e956 | ||
|
|
a5d0e6eba2 | ||
|
|
ac9371a2ed | ||
|
|
f3abb0a828 | ||
|
|
c653efc7b1 | ||
|
|
bcd7d9a29b | ||
|
|
dd7ef41590 | ||
|
|
d7c9730712 | ||
|
|
735bc64a2d | ||
|
|
307d6502af | ||
|
|
91a4e270c6 | ||
|
|
d13e60a122 | ||
|
|
c4be3a1ac0 | ||
|
|
7c7eed4a3d | ||
|
|
d0271e0be0 | ||
|
|
9d71ecded7 | ||
|
|
81af88e7a4 | ||
|
|
a8f7fd2d02 | ||
|
|
de71e5156c | ||
|
|
bcf27f0489 | ||
|
|
972445a8bc | ||
|
|
460e0b8daf | ||
|
|
3673d195ea | ||
|
|
77c6ac8507 | ||
|
|
cd35f4a3ab | ||
|
|
217df7cd65 | ||
|
|
ccfdef4fe8 | ||
|
|
b40ec48136 | ||
|
|
064331de0e | ||
|
|
5ef52ca622 | ||
|
|
15c51a4ab1 | ||
|
|
7e2b364c08 | ||
|
|
0b18e4995c | ||
|
|
f0fb5ef009 | ||
|
|
ec0c381fb6 | ||
|
|
58f7693024 | ||
|
|
40f6e67d83 |
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
[](https://gitter.im/butomo1989/docker-android?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://gitter.im/butomo1989/docker-android?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
[](https://travis-ci.org/butomo1989/docker-android)
|
[](https://travis-ci.org/butomo1989/docker-android)
|
||||||
[](https://hub.docker.com/r/butomo1989/docker-android-x86-7.1.1/)
|
|
||||||
[](https://codecov.io/gh/butomo1989/docker-android)
|
[](https://codecov.io/gh/butomo1989/docker-android)
|
||||||
[](https://www.codacy.com/app/butomo1989/docker-appium?utm_source=github.com&utm_medium=referral&utm_content=butomo1989/docker-appium&utm_campaign=Badge_Grade)
|
[](https://www.codacy.com/app/butomo1989/docker-appium?utm_source=github.com&utm_medium=referral&utm_content=butomo1989/docker-appium&utm_campaign=Badge_Grade)
|
||||||
|
|
||||||
@@ -12,14 +11,14 @@ Docker-Android is a docker image built to be used for everything related to mobi
|
|||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://youtu.be/pQdpjuYwvp8"><img src="./images/appiumconf2018.png" alt="Appium Conference 2018" width="600"></a>
|
<a href="https://youtu.be/pQdpjuYwvp8"><img src="./images/appiumconf2018.png" alt="Appium Conference 2018" width="600"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Emulator - Samsung Device | Emulator - Nexus Device | Real Device
|
Emulator - Samsung Device | Emulator - Nexus Device | Real Device
|
||||||
:---------------------------:|:---------------------------:|:---------------------------:
|
:---------------------------:|:---------------------------:|:---------------------------:
|
||||||
![][emulator samsung] |![][emulator nexus] |![][real device]
|
![][emulator samsung] |![][emulator nexus] |![][real device]
|
||||||
|
|
||||||
Purpose
|
Purposes
|
||||||
-------
|
--------
|
||||||
|
|
||||||
1. Run UI tests for mobile websites with [appium]
|
1. Run UI tests for mobile websites with [appium]
|
||||||
2. Build Android project and run unit tests with the latest build-tools
|
2. Build Android project and run unit tests with the latest build-tools
|
||||||
@@ -36,22 +35,23 @@ Advantages compare with other docker-android projects
|
|||||||
4. Ability to control emulator from outside container by using adb connect
|
4. Ability to control emulator from outside container by using adb connect
|
||||||
5. Support real devices with screen mirroring
|
5. Support real devices with screen mirroring
|
||||||
6. Ability to record video during test execution for debugging
|
6. Ability to record video during test execution for debugging
|
||||||
7. Open source with more features coming
|
7. Integrated with other cloud solutions, e.g. [Genymotion Cloud](https://www.genymotion.com/cloud/)
|
||||||
|
8. Open source with more features coming
|
||||||
|
|
||||||
List of Docker images
|
List of Docker images
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
|Supported OS |Android version |API level |Image name |Image status |
|
|OS |Android |API |Browser |Browser version |Chromedriver |Image |Size |
|
||||||
|:---|:---|:---|:---|:---:|
|
|:---|:---|:---|:---|:---|:---|:---|:---|
|
||||||
|Linux|5.0.1|21|butomo1989/docker-android-x86-5.0.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-5.0.1 "Get your own image badge on microbadger.com")|
|
|Linux|5.0.1|21|browser|37.0|2.21|butomo1989/docker-android-x86-5.0.1|[](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://microbadger.com/images/butomo1989/docker-android-x86-5.1.1 "Get your own image badge on microbadger.com")|
|
|Linux|5.1.1|22|browser|39.0|2.13|butomo1989/docker-android-x86-5.1.1|[](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://microbadger.com/images/butomo1989/docker-android-x86-6.0 "Get your own image badge on microbadger.com")|
|
|Linux|6.0|23|browser|44.0|2.18|butomo1989/docker-android-x86-6.0|[](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://microbadger.com/images/butomo1989/docker-android-x86-7.0 "Get your own image badge on microbadger.com")|
|
|Linux|7.0|24|chrome|51.0|2.23|butomo1989/docker-android-x86-7.0|[](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://microbadger.com/images/butomo1989/docker-android-x86-7.1.1 "Get your own image badge on microbadger.com")|
|
|Linux|7.1.1|25|chrome|55.0|2.28|butomo1989/docker-android-x86-7.1.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-7.1.1 "Get your own image badge on microbadger.com")|
|
||||||
|Linux|8.0|26|butomo1989/docker-android-x86-8.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-8.0 "Get your own image badge on microbadger.com")|
|
|Linux|8.0|26|chrome|58.0|2.31|butomo1989/docker-android-x86-8.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-8.0 "Get your own image badge on microbadger.com")|
|
||||||
|Linux|8.1|27|butomo1989/docker-android-x86-8.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-8.1 "Get your own image badge on microbadger.com")|
|
|Linux|8.1|27|chrome|61.0|2.33|butomo1989/docker-android-x86-8.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-8.1 "Get your own image badge on microbadger.com")|
|
||||||
|All |-|-|butomo1989/docker-android-real-device|[](https://microbadger.com/images/butomo1989/docker-android-real-device "Get your own image badge on microbadger.com")|
|
|All |-|-|-|-|-|butomo1989/docker-android-real-device|[](https://microbadger.com/images/butomo1989/docker-android-real-device "Get your own image badge on microbadger.com")|
|
||||||
|Linux|All|All|butomo1989/docker-android-genymotion|[](https://microbadger.com/images/butomo1989/docker-android-genymotion "Get your own image badge on microbadger.com")|
|
|Linux|All|All|All|All|All|butomo1989/docker-android-genymotion|[](https://microbadger.com/images/butomo1989/docker-android-genymotion "Get your own image badge on microbadger.com")|
|
||||||
|
|
||||||
List of Devices
|
List of Devices
|
||||||
---------------
|
---------------
|
||||||
@@ -73,7 +73,7 @@ Docker is installed in your system.
|
|||||||
Quick Start
|
Quick Start
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
1. Run docker-android
|
1. Run Docker-Android
|
||||||
|
|
||||||
- For ***Linux OS***, please use image name that contains "x86"
|
- For ***Linux OS***, please use image name that contains "x86"
|
||||||
|
|
||||||
@@ -96,110 +96,32 @@ Quick Start
|
|||||||
|
|
||||||
3. Open ***http://docker-host-ip-address:6080*** from web browser.
|
3. Open ***http://docker-host-ip-address:6080*** from web browser.
|
||||||
|
|
||||||
Run Appium Server
|
Custom configurations
|
||||||
-----------------
|
---------------------
|
||||||
|
|
||||||
Appium is automation test framework to test mobile website and mobile application, including android. To be able to use appium, you need to run appium-server. You run appium server inside docker-android container by ***opening port 4723*** and ***passing an environment variable APPIUM=true***.
|
[This document](README_CUSTOM_CONFIG.md) contains custom configurations of Docker-Android that you might need, e.g. Proxy, Changing language on fly, etc.
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -p 4723:4723 -e DEVICE="Samsung Galaxy S6" -e APPIUM=true --name android-container butomo1989/docker-android-x86-8.1
|
|
||||||
```
|
|
||||||
|
|
||||||
### Connect to Selenium Grid
|
|
||||||
|
|
||||||
It is also possible to connect appium server that run inside docker-android with selenium grid by passing following environment variables:
|
|
||||||
|
|
||||||
- CONNECT\_TO\_GRID=true
|
|
||||||
- APPIUM_HOST="\<host\_ip\_address>"
|
|
||||||
- APPIUM_PORT=\<port\_number>
|
|
||||||
- SELENIUM_HOST="\<host\_ip\_address>"
|
|
||||||
- SELENIUM_PORT=\<port\_number>
|
|
||||||
|
|
||||||
To run tests for mobile browser, following parameter can be passed:
|
|
||||||
|
|
||||||
- MOBILE\_WEB\_TEST=true
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" -e APPIUM=true -e CONNECT_TO_GRID=true -e APPIUM_HOST="127.0.0.1" -e APPIUM_PORT=4723 -e SELENIUM_HOST="172.17.0.1" -e SELENIUM_PORT=4444 -e MOBILE_WEB_TEST=true --name android-container butomo1989/docker-android-x86-8.1
|
|
||||||
```
|
|
||||||
|
|
||||||
### Share Volume
|
|
||||||
|
|
||||||
If you want to use appium to test UI of your android application, you need to share volume where the APK is located to folder ***/root/tmp***.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -v $PWD/example/sample_apk:/root/tmp -e DEVICE="Nexus 5" -e APPIUM=true -e CONNECT_TO_GRID=true -e APPIUM_HOST="127.0.0.1" -e APPIUM_PORT=4723 -e SELENIUM_HOST="172.17.0.1" -e SELENIUM_PORT=4444 --name android-container butomo1989/docker-android-x86-8.1
|
|
||||||
```
|
|
||||||
|
|
||||||
### Video Recording
|
|
||||||
|
|
||||||
You can deactivate auto_record by changing the value to "False" in docker-compose file. e.g. change value to "False" in this [line].
|
|
||||||
|
|
||||||
### Docker-Compose
|
|
||||||
|
|
||||||
![][compose]
|
|
||||||
|
|
||||||
There is [example of compose file] to run complete selenium grid and docker-android container as nodes. [docker-compose] version [1.13.0] or higher is required to be able to execute that compose file.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker-compose up -d
|
|
||||||
```
|
|
||||||
|
|
||||||
Build Android project
|
Build Android project
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
docker-android can be used for building Android project and executing its unit test. This following steps will illustrate how to build Android project:
|
Docker-Android can be used for building Android project and executing its unit test. This following steps will illustrate how to build Android project:
|
||||||
|
|
||||||
1. Clone [this sample test project](https://github.com/googlesamples/android-testing).
|
1. Clone [this sample test project](https://github.com/googlesamples/android-testing).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone git@github.com:googlesamples/android-testing.git
|
git clone git@github.com:googlesamples/android-testing.git
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Build the project
|
2. Build the project
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -it --rm -v $PWD/android-testing/ui/espresso/BasicSample:/root/tmp butomo1989/docker-android-x86-8.1 tmp/gradlew build
|
docker run -it --rm -v $PWD/android-testing/ui/espresso/BasicSample:/root/tmp butomo1989/docker-android-x86-8.1 tmp/gradlew build
|
||||||
```
|
```
|
||||||
|
|
||||||
Proxy
|
Appium and Selenium Grid
|
||||||
-----
|
------------------------
|
||||||
|
|
||||||
You can enable proxy inside container by passing following environment variables:
|
|
||||||
|
|
||||||
- HTTP_PROXY="\<docker\_bridge\_ip\_address>"
|
|
||||||
- HTTPS_PROXY="\<docker\_bridge\_ip\_address>"
|
|
||||||
- NO_PROXY="localhost"
|
|
||||||
|
|
||||||
Relaxed Security
|
|
||||||
-----
|
|
||||||
|
|
||||||
Pass environment variable RELAXED_SECURITY=true to disable additional security check to use some advanced features.
|
|
||||||
|
|
||||||
Genymotion
|
|
||||||
----------
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Docker-Android supports [Genymotion Cloud].
|
|
||||||
|
|
||||||
You can easily scale your Appium tests on Genymotion Android virtual devices in the cloud.
|
|
||||||
Use [device.json] to define the device to start. You can specify the port on which the device will start so you don't need to change the device name in your tests every time you need to run those tests. Then run following command
|
|
||||||
|
|
||||||
```bash
|
|
||||||
export USER="xxx"
|
|
||||||
export PASS="xxx"
|
|
||||||
export LICENSE="xxx"
|
|
||||||
|
|
||||||
docker run -it --rm -p 4723:4723 -v $PWD/genymotion/example/sample_devices:/root/tmp -e USER=$USER -e PASS=$PASS -e LICENSE=$LICENSE butomo1989/docker-android-genymotion
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use [this docker-compose file].
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<a href="https://youtu.be/jXhUEyaVeMY"><img src="./images/Genymotion_cloud.png" alt="Docker-Android supports Genymotion Cloud" width="600"></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
If you want to use Appium and Selenium Grid, you can follow [this document](README_APPIUM_AND_SELENIUM.md). It also contains sample and use cases.
|
||||||
|
|
||||||
Control android emulator outside container
|
Control android emulator outside container
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
@@ -250,76 +172,27 @@ SMS Simulation
|
|||||||
|
|
||||||
![][sms]
|
![][sms]
|
||||||
|
|
||||||
How to use docker-android in VMWare or Parallels Desktop
|
Google Play Services and Google Play Store
|
||||||
---------------
|
------------------------------------------
|
||||||
The following instructions are used for OS X. You'll need [docker-machine-parallels](https://github.com/Parallels/docker-machine-parallels) to create a virtual machine (vm) with tiny core linux for running docker images. After that, you may start the vm you created for VMWare Fusion or Parallels Desktop and run a docker container inside this vm. If you're going to use the android docker of emulator with x86 processor, setup this vm for nested virtualization and kvm support before you run a docker container.
|
|
||||||
|
|
||||||
1. Install docker-machine-parallels via Homebrew:
|
Docker-Android contains Google Play Service (v12.8.74) and Google Play Store (v11.0.50). Both applications are downloaded from [apklinker](https://www.apklinker.com/), so please be aware of it in case you use private/company account to that applications.
|
||||||
```bash
|
|
||||||
$ brew install docker-machine-parallels
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Create a virtual machine for running docker images based on the virtual machine tool you use
|
VMWARE
|
||||||
|
------
|
||||||
|
|
||||||
2.1. Create a virtual machine of VMWare Fusion
|
This [document](README_VMWARE.md) shows you how to configure Virtual Machine on VMWARE to be able to run Docker-Android.
|
||||||
```bash
|
|
||||||
$ docker-machine create --driver=vmwarefusion vmware-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
2.2. Create a virtual machine of Parallels Desktop
|
Cloud
|
||||||
```bash
|
-----
|
||||||
$ docker-machine create --driver=parallels prl-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
This utility `docker-machine-parallels` will fetch boot2docker.iso to create a vm of VMWare fusion or Parallels Desktop. When the vm is created, you'll see it's booted with VMWare fusion or Parallels Desktop where the network of vm is set to NAT and one IP is assigned. You'll be able to connect to vnc service inside the docker image through that IP. Say it's `10.211.55.3` and we'll use it later.
|
|
||||||
|
|
||||||
3. Setup the virtual machine for nested virtualization support
|
This [document](README_CLOUD.md) contains information about deploying Docker-Android on cloud services.
|
||||||
|
|
||||||
3.1. Shutdown the vm by running the command below in the boot2docker vm before you setup it.
|
Genymotion
|
||||||
```bash
|
----------
|
||||||
# shutdown -h now
|
|
||||||
```
|
|
||||||
|
|
||||||
If you use VMWare Fusion, go to menu bar > Vitual Machine > Settings > Processors and Memory, expand Advanced options, and select `Enable hypervisor applications in this virtual machine`.
|

|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
If you use Parallels Desktop, open settings screen of that vm and go to `CPU & Memory` under `hardware` tab, expand Advanced settings and select `Enable nested virtualization`.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
4. Enable kvm inside virtual machine
|
For you who do not have ressources to maintain the simulator or to buy machines or need different device profiles, you need to give a try to [Genymotion Cloud](https://www.genymotion.com/cloud/). Docker-Android is integrated with Genymotion on different cloud services, e.g. Genymotion Cloud, AWS, GCP, Alibaba Cloud. Please follow [this document](README_GENYMOTION.md) for more detail.
|
||||||
4.1. Run as an account other than root to install kvm packages using tce-load.
|
|
||||||
```bash
|
|
||||||
# su docker
|
|
||||||
$ tce-load -wi kvm
|
|
||||||
```
|
|
||||||
|
|
||||||
4.2. Run as root to load kvm module after kvm packages install.
|
|
||||||
```bash
|
|
||||||
$ sudo modprobe kvm_intel
|
|
||||||
```
|
|
||||||
|
|
||||||
4.3. Check if the kvm device is loaded.
|
|
||||||
```bash
|
|
||||||
$ ls /dev/kvm
|
|
||||||
```
|
|
||||||
|
|
||||||
4.4. Check if your CPU supports hardware virtualization now
|
|
||||||
```bash
|
|
||||||
$ egrep -c '(vmx|svm)' /proc/cpuinfo
|
|
||||||
```
|
|
||||||
|
|
||||||
If **0** it means that your CPU doesn't support hardware virtualization.
|
|
||||||
If **1** or more it does - but you still need to make sure that virtualization is enabled in the BIOS.
|
|
||||||
|
|
||||||
5. You may now run a docker container
|
|
||||||
5.1. Let's run a docker image for an emulator with x86 processor.
|
|
||||||
```bash
|
|
||||||
docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container butomo1989/docker-android-x86-8.1
|
|
||||||
```
|
|
||||||
|
|
||||||
When the services inside this docker container are running, connect to http://10.211.55.3:6080/vnc.html (the IP we got when the docker machine was created) and login. The emulator with x86 processor should be running on screen.
|
|
||||||
|
|
||||||
Troubleshooting
|
Troubleshooting
|
||||||
---------------
|
---------------
|
||||||
@@ -339,14 +212,6 @@ Special Thanks
|
|||||||
[emulator samsung]: <images/emulator_samsung_galaxy_s6.png>
|
[emulator samsung]: <images/emulator_samsung_galaxy_s6.png>
|
||||||
[emulator nexus]: <images/emulator_nexus_5.png>
|
[emulator nexus]: <images/emulator_nexus_5.png>
|
||||||
[real device]: <images/real_device.png>
|
[real device]: <images/real_device.png>
|
||||||
[compose]: <images/compose.png>
|
|
||||||
[line]: <https://github.com/butomo1989/docker-android/blob/master/docker-compose.yml#L70>
|
|
||||||
[example of compose file]: <docker-compose.yml>
|
|
||||||
[docker-compose]: <https://docs.docker.com/compose/install/>
|
|
||||||
[1.13.0]: <https://github.com/docker/compose/releases/tag/1.13.0>
|
|
||||||
[Genymotion Cloud]: <https://www.genymotion.com/cloud/>
|
|
||||||
[device.json]: <genymotion/example/sample_devices/devices.json>
|
|
||||||
[this docker-compose file]: <genymotion/example/geny.yml>
|
|
||||||
[adb_connection]: <images/adb_connection.png>
|
[adb_connection]: <images/adb_connection.png>
|
||||||
[sms]: <images/SMS.png>
|
[sms]: <images/SMS.png>
|
||||||
[gian christanto]: <https://www.linkedin.com/in/gian-christanto-0b398b131/>
|
[gian christanto]: <https://www.linkedin.com/in/gian-christanto-0b398b131/>
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
Run Appium Server
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
Appium is automation test framework to test mobile website and mobile application, including Android. To be able to use Appium, you need to run appium-server. You run Appium-Server inside docker-android container by ***opening port 4723*** and ***passing an environment variable APPIUM=true***.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -p 4723:4723 -e DEVICE="Samsung Galaxy S6" -e APPIUM=true --name android-container butomo1989/docker-android-x86-8.1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Share Volume
|
||||||
|
|
||||||
|
If you want to use appium to test UI of your android application, you need to share volume where the APK is located to folder ***/root/tmp***.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -v $PWD/example/sample_apk:/root/tmp -e DEVICE="Nexus 5" -e APPIUM=true -e CONNECT_TO_GRID=true -e APPIUM_HOST="127.0.0.1" -e APPIUM_PORT=4723 -e SELENIUM_HOST="172.17.0.1" -e SELENIUM_PORT=4444 --name android-container butomo1989/docker-android-x86-8.1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Connect to Selenium Grid
|
||||||
|
|
||||||
|
It is also possible to connect appium server that run inside docker-android with selenium grid by passing following environment variables:
|
||||||
|
|
||||||
|
- CONNECT\_TO\_GRID=true
|
||||||
|
- APPIUM_HOST="\<host\_ip\_address>"
|
||||||
|
- APPIUM_PORT=\<port\_number>
|
||||||
|
- SELENIUM_HOST="\<host\_ip\_address>"
|
||||||
|
- SELENIUM_PORT=\<port\_number>
|
||||||
|
|
||||||
|
To run tests for mobile browser, following parameter can be passed:
|
||||||
|
|
||||||
|
- MOBILE\_WEB\_TEST=true
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" -e APPIUM=true -e CONNECT_TO_GRID=true -e APPIUM_HOST="127.0.0.1" -e APPIUM_PORT=4723 -e SELENIUM_HOST="172.17.0.1" -e SELENIUM_PORT=4444 -e MOBILE_WEB_TEST=true --name android-container butomo1989/docker-android-x86-8.1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Video Recording
|
||||||
|
|
||||||
|
You can deactivate auto_record by changing the value to "False" in docker-compose file. e.g. change value to "False" in this [line](docker-compose.yml#L70).
|
||||||
|
|
||||||
|
### Relaxed Security
|
||||||
|
|
||||||
|
Pass environment variable RELAXED_SECURITY=true to disable additional security check to use some advanced features.
|
||||||
|
|
||||||
|
### Docker-Compose
|
||||||
|
|
||||||
|
![][compose]
|
||||||
|
|
||||||
|
There is [example of compose file](docker-compose.yml) to run complete selenium grid and docker-android container as nodes. [docker-compose](https://docs.docker.com/compose/install/) version [1.13.0](https://github.com/docker/compose/releases/tag/1.13.0) or higher is required to be able to execute that compose file.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
[compose]: <images/compose.png>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Azure
|
||||||
|
-----
|
||||||
|
|
||||||
|
Make sure that the nodes, pods, containers for your emulators are generated within a **VM** of series **Dv3** or **Ev3**.
|
||||||
|
Reference: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/nested-virtualization
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
Proxy
|
||||||
|
-----
|
||||||
|
|
||||||
|
You can enable proxy inside container by passing following environment variables:
|
||||||
|
|
||||||
|
- HTTP_PROXY="\<language>docker\_bridge\_ip\_address>"
|
||||||
|
- HTTPS_PROXY="\<docker\_bridge\_ip\_address>"
|
||||||
|
- NO_PROXY="localhost"
|
||||||
|
|
||||||
|
Language
|
||||||
|
--------
|
||||||
|
|
||||||
|
You can change the language setting of Android Emulator on the fly by passing following environment variable:
|
||||||
|
|
||||||
|
- LANGUAGE="\<language>"
|
||||||
|
- COUNTRY="\<country>"
|
||||||
|
|
||||||
|
Custom Emulator Arguments
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
If you want to add more arguments for running emulator, you can ***pass an environment variable EMULATOR_ARGS*** while running docker command.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" -e EMULATOR_ARGS="-no-snapshot-load -partition-size 512" --name android-container butomo1989/docker-android-x86-8.1
|
||||||
|
```
|
||||||
|
|
||||||
|
Back & Restore
|
||||||
|
--------------
|
||||||
|
|
||||||
|
If you want to backup/reuse the avds created with furture upgrades or for replication, run the container with two extra mounts
|
||||||
|
|
||||||
|
- -v local_backup/.android:/root/.android
|
||||||
|
- -v local_backup/android_emulator:/root/android_emulator
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -v local_backup/.android:/root/.android -v local_backup/android_emulator:local_backup/android_emulator -e DEVICE="Nexus 5" --name android-container butomo1989/docker-android-x86-8.1
|
||||||
|
```
|
||||||
|
|
||||||
|
For the first run, this will create a new avd and all the changes will be accessible in the `local_backup` directory. Now for all future runs, it will reuse the avds. Even this should work with new releases of `docker-android`
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
Genymotion
|
||||||
|
----------
|
||||||
|
|
||||||
|
You can easily scale your Appium tests on Genymotion Android virtual devices in the cloud.
|
||||||
|
|
||||||
|
1. Using Genymotion Cloud
|
||||||
|
Use [device.json](genymotion/example/sample_devices/devices.json) to define the device to start. You can specify the port on which the device will start so you don't need to change the device name in your tests every time you need to run those tests. Then run following command
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export USER="xxx"
|
||||||
|
export PASS="xxx"
|
||||||
|
export LICENSE="xxx"
|
||||||
|
|
||||||
|
docker run -it --rm -p 4723:4723 -v $PWD/genymotion/example/sample_devices:/root/tmp -e TYPE=genycloud -e USER=$USER -e PASS=$PASS -e LICENSE=$LICENSE butomo1989/docker-android-genymotion
|
||||||
|
```
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://youtu.be/jXhUEyaVeMY"><img src="./images/Genymotion_cloud.png" alt="Docker-Android supports Genymotion Cloud" width="600"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
2. Using Genymotion on AWS
|
||||||
|
Use [aws.json](genymotion/example/sample_devices/aws.json) to define configuration of EC2 instance and run following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -it --rm -p 4723:4723 -v $PWD/genymotion/example/sample_devices:/root/tmp -v ~/.aws:/root/.aws -e TYPE=aws butomo1989/docker-android-genymotion
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also use [this docker-compose file](genymotion/example/geny.yml).
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
VMWare Fusion on OSX
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
The following instructions are used for OS X. You'll need [docker-machine-parallels](https://github.com/Parallels/docker-machine-parallels) to create a virtual machine (vm) with tiny core linux for running docker images. After that, you may start the vm you created for VMWare Fusion or Parallels Desktop and run a docker container inside this vm. If you're going to use the android docker of emulator with x86 processor, setup this vm for nested virtualization and kvm support before you run a docker container.
|
||||||
|
|
||||||
|
1. Install docker-machine-parallels via Homebrew:
|
||||||
|
```bash
|
||||||
|
$ brew install docker-machine-parallels
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Create a virtual machine for running docker images based on the virtual machine tool you use
|
||||||
|
|
||||||
|
2.1. Create a virtual machine of VMWare Fusion
|
||||||
|
```bash
|
||||||
|
$ docker-machine create --driver=vmwarefusion vmware-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
2.2. Create a virtual machine of Parallels Desktop
|
||||||
|
```bash
|
||||||
|
$ docker-machine create --driver=parallels prl-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
This utility `docker-machine-parallels` will fetch boot2docker.iso to create a vm of VMWare fusion or Parallels Desktop. When the vm is created, you'll see it's booted with VMWare fusion or Parallels Desktop where the network of vm is set to NAT and one IP is assigned. You'll be able to connect to vnc service inside the docker image through that IP. Say it's `10.211.55.3` and we'll use it later.
|
||||||
|
|
||||||
|
3. Setup the virtual machine for nested virtualization support
|
||||||
|
|
||||||
|
3.1. Shutdown the vm by running the command below in the boot2docker vm before you setup it.
|
||||||
|
```bash
|
||||||
|
# shutdown -h now
|
||||||
|
```
|
||||||
|
|
||||||
|
If you use VMWare Fusion, go to menu bar > Vitual Machine > Settings > Processors and Memory, expand Advanced options, and select `Enable hypervisor applications in this virtual machine`.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
If you use Parallels Desktop, open settings screen of that vm and go to `CPU & Memory` under `hardware` tab, expand Advanced settings and select `Enable nested virtualization`.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
4. Enable kvm inside virtual machine
|
||||||
|
4.1. Run as an account other than root to install kvm packages using tce-load.
|
||||||
|
```bash
|
||||||
|
# su docker
|
||||||
|
$ tce-load -wi kvm
|
||||||
|
```
|
||||||
|
|
||||||
|
4.2. Run as root to load kvm module after kvm packages install.
|
||||||
|
```bash
|
||||||
|
$ sudo modprobe kvm_intel
|
||||||
|
```
|
||||||
|
|
||||||
|
4.3. Check if the kvm device is loaded.
|
||||||
|
```bash
|
||||||
|
$ ls /dev/kvm
|
||||||
|
```
|
||||||
|
|
||||||
|
4.4. Check if your CPU supports hardware virtualization now
|
||||||
|
```bash
|
||||||
|
$ egrep -c '(vmx|svm)' /proc/cpuinfo
|
||||||
|
```
|
||||||
|
|
||||||
|
If **0** it means that your CPU doesn't support hardware virtualization.
|
||||||
|
If **1** or more it does - but you still need to make sure that virtualization is enabled in the BIOS.
|
||||||
|
|
||||||
|
5. You may now run a docker container
|
||||||
|
5.1. Let's run a docker image for an emulator with x86 processor.
|
||||||
|
```bash
|
||||||
|
docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container butomo1989/docker-android-x86-8.1
|
||||||
|
```
|
||||||
|
|
||||||
|
When the services inside this docker container are running, connect to http://10.211.55.3:6080/vnc.html (the IP we got when the docker machine was created) and login. The emulator with x86 processor should be running on screen.
|
||||||
+1
-1
@@ -6,7 +6,7 @@ version: "2.2"
|
|||||||
services:
|
services:
|
||||||
# Selenium hub
|
# Selenium hub
|
||||||
selenium_hub:
|
selenium_hub:
|
||||||
image: selenium/hub:3.12.0-americium
|
image: selenium/hub:3.14.0-curium
|
||||||
ports:
|
ports:
|
||||||
- 4444:4444
|
- 4444:4444
|
||||||
|
|
||||||
|
|||||||
+15
-4
@@ -1,4 +1,4 @@
|
|||||||
FROM appium/appium:1.8.1-p2
|
FROM appium/appium:1.9.0-p0
|
||||||
|
|
||||||
LABEL maintainer "Budi Utomo <budi.ut.1989@gmail.com>"
|
LABEL maintainer "Budi Utomo <budi.ut.1989@gmail.com>"
|
||||||
|
|
||||||
@@ -89,26 +89,37 @@ ARG PROCESSOR=x86
|
|||||||
ARG SYS_IMG=x86
|
ARG SYS_IMG=x86
|
||||||
ARG IMG_TYPE=google_apis
|
ARG IMG_TYPE=google_apis
|
||||||
ARG BROWSER=android
|
ARG BROWSER=android
|
||||||
ARG CHROME_DRIVER=24
|
ARG CHROME_DRIVER=2.40
|
||||||
|
ARG GOOGLE_PLAY_SERVICE=12.8.74
|
||||||
|
ARG GOOGLE_PLAY_STORE=11.0.50
|
||||||
ENV ANDROID_VERSION=$ANDROID_VERSION \
|
ENV ANDROID_VERSION=$ANDROID_VERSION \
|
||||||
API_LEVEL=$API_LEVEL \
|
API_LEVEL=$API_LEVEL \
|
||||||
PROCESSOR=$PROCESSOR \
|
PROCESSOR=$PROCESSOR \
|
||||||
SYS_IMG=$SYS_IMG \
|
SYS_IMG=$SYS_IMG \
|
||||||
IMG_TYPE=$IMG_TYPE \
|
IMG_TYPE=$IMG_TYPE \
|
||||||
BROWSER=$BROWSER \
|
BROWSER=$BROWSER \
|
||||||
CHROME_DRIVER=2.40
|
CHROME_DRIVER=$CHROME_DRIVER \
|
||||||
|
GOOGLE_PLAY_SERVICE=$GOOGLE_PLAY_SERVICE \
|
||||||
|
GOOGLE_PLAY_STORE=$GOOGLE_PLAY_STORE
|
||||||
ENV PATH ${PATH}:${ANDROID_HOME}/build-tools
|
ENV PATH ${PATH}:${ANDROID_HOME}/build-tools
|
||||||
|
|
||||||
RUN yes | sdkmanager --licenses && \
|
RUN yes | sdkmanager --licenses && \
|
||||||
sdkmanager "platforms;android-${API_LEVEL}" "system-images;android-${API_LEVEL};${IMG_TYPE};${SYS_IMG}" "emulator"
|
sdkmanager "platforms;android-${API_LEVEL}" "system-images;android-${API_LEVEL};${IMG_TYPE};${SYS_IMG}" "emulator"
|
||||||
|
|
||||||
#==============================================
|
#==============================================
|
||||||
# Download latest version of chromedriver
|
# Download proper version of chromedriver
|
||||||
# to be able to use Chrome browser in emulator
|
# to be able to use Chrome browser in emulator
|
||||||
#==============================================
|
#==============================================
|
||||||
RUN wget -nv -O chrome.zip "https://chromedriver.storage.googleapis.com/${CHROME_DRIVER}/chromedriver_linux64.zip" \
|
RUN wget -nv -O chrome.zip "https://chromedriver.storage.googleapis.com/${CHROME_DRIVER}/chromedriver_linux64.zip" \
|
||||||
&& unzip -x chrome.zip \
|
&& unzip -x chrome.zip \
|
||||||
&& rm chrome.zip
|
&& rm chrome.zip
|
||||||
|
|
||||||
|
#================================================================
|
||||||
|
# Download Google Play Services APK and Play Store from apklinker
|
||||||
|
#================================================================
|
||||||
|
Run wget -nv -O google_play_services.apk "https://www.apklinker.com/wp-content/uploads/uploaded_apk/5b5155e5ef4f8/com.google.android.gms_${GOOGLE_PLAY_SERVICE}-020700-204998136_12874013_MinAPI21_(x86)(nodpi)_apklinker.com.apk"
|
||||||
|
Run wget -nv -O google_play_store.apk "https://www.apklinker.com/wp-content/uploads/uploaded_apk/5b632b1164e31/com.android.vending_${GOOGLE_PLAY_STORE}-all-0-PR-206665793_81105000_MinAPI16_(armeabi,armeabi-v7a,mips,mips64,x86,x86_64)(240,320,480dpi)_apklinker.com.apk"
|
||||||
|
|
||||||
#================================================
|
#================================================
|
||||||
# noVNC Default Configurations
|
# noVNC Default Configurations
|
||||||
# These Configurations can be changed through -e
|
# These Configurations can be changed through -e
|
||||||
|
|||||||
+16
-3
@@ -1,4 +1,4 @@
|
|||||||
FROM appium/appium:1.8.1-p2
|
FROM appium/appium:1.9.0-p0
|
||||||
|
|
||||||
LABEL maintainer "Budi Utomo <budi.ut.1989@gmail.com>"
|
LABEL maintainer "Budi Utomo <budi.ut.1989@gmail.com>"
|
||||||
|
|
||||||
@@ -16,6 +16,8 @@ WORKDIR /root
|
|||||||
# Process manager
|
# Process manager
|
||||||
# socat
|
# socat
|
||||||
# Port forwarder
|
# Port forwarder
|
||||||
|
# keychain
|
||||||
|
# ssh-key creator
|
||||||
#------------------
|
#------------------
|
||||||
# Genymotion spec
|
# Genymotion spec
|
||||||
#------------------
|
#------------------
|
||||||
@@ -46,6 +48,7 @@ RUN apt-get -qqy update && apt-get -qqy install --no-install-recommends \
|
|||||||
xterm \
|
xterm \
|
||||||
supervisor \
|
supervisor \
|
||||||
socat \
|
socat \
|
||||||
|
keychain \
|
||||||
bzip2 \
|
bzip2 \
|
||||||
x11vnc \
|
x11vnc \
|
||||||
openbox \
|
openbox \
|
||||||
@@ -91,8 +94,8 @@ ENV DISPLAY=:0 \
|
|||||||
#====================
|
#====================
|
||||||
# Install genymotion
|
# Install genymotion
|
||||||
#====================
|
#====================
|
||||||
|
RUN echo | ssh-keygen -q
|
||||||
ARG GENYMOTION_VERSION=2.12.1
|
ARG GENYMOTION_VERSION=2.12.1
|
||||||
|
|
||||||
ENV GENYMOTION=true \
|
ENV GENYMOTION=true \
|
||||||
GENYMOTION_VERSION=$GENYMOTION_VERSION \
|
GENYMOTION_VERSION=$GENYMOTION_VERSION \
|
||||||
PATH="${PATH}:/opt/genymobile/genymotion/" \
|
PATH="${PATH}:/opt/genymobile/genymotion/" \
|
||||||
@@ -101,7 +104,17 @@ RUN wget -nv -O genymotion.bin "https://dl.genymotion.com/releases/genymotion-${
|
|||||||
&& chmod +x ./genymotion.bin \
|
&& chmod +x ./genymotion.bin \
|
||||||
&& yes | ./genymotion.bin \
|
&& yes | ./genymotion.bin \
|
||||||
&& rm genymotion.bin
|
&& rm genymotion.bin
|
||||||
COPY genymotion/generate_config.sh genymotion/geny_start.sh /root/
|
COPY genymotion/generate_config.sh genymotion/geny_start.sh genymotion/enable_adb.sh /root/
|
||||||
|
|
||||||
|
#===================
|
||||||
|
# Install Terraform
|
||||||
|
#===================
|
||||||
|
ARG TERRAFORM_VERSION=0.11.7
|
||||||
|
|
||||||
|
ENV TERRAFORM_VERSION=$TERRAFORM_VERSION
|
||||||
|
RUN wget -nv -O terraform.zip "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" \
|
||||||
|
&& unzip -x terraform.zip \
|
||||||
|
&& rm terraform.zip
|
||||||
|
|
||||||
#===============
|
#===============
|
||||||
# Expose Ports
|
# Expose Ports
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM appium/appium:1.8.1-p2
|
FROM appium/appium:1.9.0-p0
|
||||||
|
|
||||||
LABEL maintainer "Budi Utomo <budi.ut.1989@gmail.com>"
|
LABEL maintainer "Budi Utomo <budi.ut.1989@gmail.com>"
|
||||||
|
|
||||||
|
|||||||
Executable
+2
@@ -0,0 +1,2 @@
|
|||||||
|
#!/system/bin/sh
|
||||||
|
setprop persist.sys.usb.config adb
|
||||||
@@ -6,24 +6,38 @@ version: "2.2"
|
|||||||
services:
|
services:
|
||||||
# Selenium hub
|
# Selenium hub
|
||||||
selenium_hub:
|
selenium_hub:
|
||||||
image: selenium/hub:3.12.0-americium
|
image: selenium/hub:3.14.0-curium
|
||||||
ports:
|
ports:
|
||||||
- 4444:4444
|
- 4444:4444
|
||||||
|
|
||||||
# Please stop this container by using docker stop instead of docker-compose stop
|
# Please stop this container by using docker stop instead of docker-compose stop
|
||||||
genymotion:
|
cloud:
|
||||||
image: butomo1989/docker-android-genymotion
|
image: butomo1989/docker-android-genymotion
|
||||||
depends_on:
|
depends_on:
|
||||||
- selenium_hub
|
- selenium_hub
|
||||||
ports:
|
privileged: true
|
||||||
- 6080:6080
|
|
||||||
- 4723:4723
|
|
||||||
volumes:
|
volumes:
|
||||||
- $PWD/sample_apk:/root/tmp/sample_apk
|
- $PWD/sample_apk:/root/tmp/sample_apk
|
||||||
- $PWD/sample_devices:/root/tmp
|
- $PWD/sample_devices:/root/tmp
|
||||||
environment:
|
environment:
|
||||||
- GENY_TEMPLATE=/root/tmp/devices.json
|
- TYPE=genycloud
|
||||||
- USER=xxx
|
- TEMPLATE=/root/tmp/devices.json
|
||||||
- PASS=xxx
|
- USER=$USER
|
||||||
- LICENSE=xxx
|
- PASS=$PASS
|
||||||
|
- LICENSE=$LICENSE
|
||||||
|
- CONNECT_TO_GRID=true
|
||||||
|
|
||||||
|
# Please stop this container by using docker stop instead of docker-compose stop
|
||||||
|
aws:
|
||||||
|
image: butomo1989/docker-android-genymotion
|
||||||
|
depends_on:
|
||||||
|
- selenium_hub
|
||||||
|
privileged: true
|
||||||
|
volumes:
|
||||||
|
- ~/.aws:/root/.aws
|
||||||
|
- $PWD/sample_apk:/root/tmp/sample_apk
|
||||||
|
- $PWD/sample_devices:/root/tmp
|
||||||
|
environment:
|
||||||
|
- TYPE=aws
|
||||||
|
- TEMPLATE=/root/tmp/aws.json
|
||||||
- CONNECT_TO_GRID=true
|
- CONNECT_TO_GRID=true
|
||||||
|
|||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"region": "eu-west-1",
|
||||||
|
"android_version": "6.0",
|
||||||
|
"instance": "t2.small"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"region": "eu-west-1",
|
||||||
|
"android_version": "8.0",
|
||||||
|
"instance": "t2.small"
|
||||||
|
}
|
||||||
|
]
|
||||||
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
(export USER=$USER && export PASS=$PASS && export LICENSE=$LICENSE && docker-compose -f geny.yml up -d)
|
||||||
@@ -1,18 +1,44 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# This script is needed because of https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/
|
# This script is needed because of https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/
|
||||||
|
|
||||||
if [ -z "$GENY_TEMPLATE" ]; then
|
types=(genycloud aws)
|
||||||
GENY_TEMPLATE="/root/tmp/devices.json"
|
|
||||||
|
if [ -z "$TYPE" ]; then
|
||||||
|
echo "Please specify one of following types: ${types[@]}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
TYPE=$(echo "$TYPE" | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
if [ -z "$TEMPLATE" ]; then
|
||||||
|
case $TYPE in
|
||||||
|
"${types[0]}" )
|
||||||
|
TEMPLATE="/root/tmp/devices.json"
|
||||||
|
;;
|
||||||
|
"${types[1]}" )
|
||||||
|
TEMPLATE="/root/tmp/aws.json"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
"Type $TYPE is not supported! Valid types: ${types[@]}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$GENY_TEMPLATE" ]; then
|
if [ ! -f "$TEMPLATE" ]; then
|
||||||
echo "File not found! Nothing to do!"
|
echo "File not found! Nothing to do!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "[geny_start] Available types: ${types[@]}"
|
||||||
|
echo "[geny_start] Selected type of deployment: $TYPE, Template file: $TEMPLATE"
|
||||||
|
export TYPE=$TYPE
|
||||||
|
export TEMPLATE=$TEMPLATE
|
||||||
|
export TYPES=${types[@]}
|
||||||
|
|
||||||
getAbort() {
|
getAbort() {
|
||||||
if [ "$GENYMOTION" = true ]; then
|
case $TYPE in
|
||||||
contents=$(cat $GENY_TEMPLATE)
|
"${types[0]}" )
|
||||||
|
contents=$(cat $TEMPLATE)
|
||||||
echo "ABORT SIGNAL detected! Stopping all created emulators..."
|
echo "ABORT SIGNAL detected! Stopping all created emulators..."
|
||||||
for row in $(echo "${contents}" | jq -r '.[] | @base64'); do
|
for row in $(echo "${contents}" | jq -r '.[] | @base64'); do
|
||||||
get_value() {
|
get_value() {
|
||||||
@@ -22,7 +48,13 @@ getAbort() {
|
|||||||
gmtool --cloud admin stopdisposable $(get_value '.device')
|
gmtool --cloud admin stopdisposable $(get_value '.device')
|
||||||
done
|
done
|
||||||
echo "Done"
|
echo "Done"
|
||||||
fi
|
;;
|
||||||
|
"${types[1]}" )
|
||||||
|
contents=$(cat $TEMPLATE)
|
||||||
|
echo "ABORT SIGNAL detected! Detroy all EC2 instance(s)..."
|
||||||
|
./terraform destroy -auto-approve -lock=false
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
trap 'getAbort; exit' EXIT
|
trap 'getAbort; exit' EXIT
|
||||||
|
|
||||||
|
|||||||
+16
-4
@@ -31,6 +31,18 @@ declare -A list_of_levels=(
|
|||||||
[8.1]=27
|
[8.1]=27
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# The version of the Chrome browser installed on the Android emulator needs to be known beforehand
|
||||||
|
# in order to chose the proper version of chromedriver (see http://chromedriver.chromium.org/downloads)
|
||||||
|
declare -A chromedriver_versions=(
|
||||||
|
[5.0.1]="2.21"
|
||||||
|
[5.1.1]="2.13"
|
||||||
|
[6.0]="2.18"
|
||||||
|
[7.0]="2.23"
|
||||||
|
[7.1.1]="2.28"
|
||||||
|
[8.0]="2.31"
|
||||||
|
[8.1]="2.33"
|
||||||
|
)
|
||||||
|
|
||||||
function get_android_versions() {
|
function get_android_versions() {
|
||||||
versions=()
|
versions=()
|
||||||
|
|
||||||
@@ -57,9 +69,6 @@ function get_android_versions() {
|
|||||||
|
|
||||||
get_android_versions
|
get_android_versions
|
||||||
processor=x86
|
processor=x86
|
||||||
#chrome_driver=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
|
|
||||||
#Reason: https://sites.google.com/a/chromium.org/chromedriver/downloads
|
|
||||||
chrome_driver=2.33
|
|
||||||
|
|
||||||
function test() {
|
function test() {
|
||||||
# Prepare needed parameter to run tests
|
# Prepare needed parameter to run tests
|
||||||
@@ -135,7 +144,8 @@ function build() {
|
|||||||
IMG_TYPE=google_apis
|
IMG_TYPE=google_apis
|
||||||
BROWSER=browser
|
BROWSER=browser
|
||||||
else
|
else
|
||||||
IMG_TYPE=google_apis_playstore
|
#adb root cannot be run in IMG_TYPE=google_apis_playstore
|
||||||
|
IMG_TYPE=google_apis
|
||||||
BROWSER=chrome
|
BROWSER=chrome
|
||||||
fi
|
fi
|
||||||
echo "[BUILD] IMAGE TYPE: $IMG_TYPE"
|
echo "[BUILD] IMAGE TYPE: $IMG_TYPE"
|
||||||
@@ -143,6 +153,8 @@ function build() {
|
|||||||
echo "[BUILD] API Level: $level"
|
echo "[BUILD] API Level: $level"
|
||||||
sys_img=$processor
|
sys_img=$processor
|
||||||
echo "[BUILD] System Image: $sys_img"
|
echo "[BUILD] System Image: $sys_img"
|
||||||
|
chrome_driver="${chromedriver_versions[$v]}"
|
||||||
|
echo "[BUILD] chromedriver version: $chrome_driver"
|
||||||
image_version="$IMAGE-$processor-$v:$RELEASE"
|
image_version="$IMAGE-$processor-$v:$RELEASE"
|
||||||
image_latest="$IMAGE-$processor-$v:latest"
|
image_latest="$IMAGE-$processor-$v:latest"
|
||||||
echo "[BUILD] Image name: $image_version and $image_latest"
|
echo "[BUILD] Image name: $image_version and $image_latest"
|
||||||
|
|||||||
+10
-15
@@ -4,6 +4,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import uuid
|
||||||
|
|
||||||
from src import CHROME_DRIVER, CONFIG_FILE, ROOT
|
from src import CHROME_DRIVER, CONFIG_FILE, ROOT
|
||||||
from src import log
|
from src import log
|
||||||
@@ -50,13 +51,7 @@ def convert_str_to_bool(str: str) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def is_initialized() -> bool:
|
def is_initialized() -> bool:
|
||||||
return os.path.exists(INIT_FILE)
|
return os.path.exists(os.path.join(ROOT, '.android', 'devices.xml'))
|
||||||
|
|
||||||
|
|
||||||
def finish_initialization():
|
|
||||||
file = open(INIT_FILE, 'w+')
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
|
|
||||||
ANDROID_HOME = get_or_raise('ANDROID_HOME')
|
ANDROID_HOME = get_or_raise('ANDROID_HOME')
|
||||||
ANDROID_VERSION = get_or_raise('ANDROID_VERSION')
|
ANDROID_VERSION = get_or_raise('ANDROID_VERSION')
|
||||||
@@ -64,7 +59,6 @@ API_LEVEL = get_or_raise('API_LEVEL')
|
|||||||
PROCESSOR = get_or_raise('PROCESSOR')
|
PROCESSOR = get_or_raise('PROCESSOR')
|
||||||
SYS_IMG = get_or_raise('SYS_IMG')
|
SYS_IMG = get_or_raise('SYS_IMG')
|
||||||
IMG_TYPE = get_or_raise('IMG_TYPE')
|
IMG_TYPE = get_or_raise('IMG_TYPE')
|
||||||
INIT_FILE = os.getenv('INIT_FILE', "/root/init")
|
|
||||||
|
|
||||||
logger.info('Android version: {version} \n'
|
logger.info('Android version: {version} \n'
|
||||||
'API level: {level} \n'
|
'API level: {level} \n'
|
||||||
@@ -125,8 +119,7 @@ def appium_run(avd_name: str):
|
|||||||
cmd += ' --relaxed-security'
|
cmd += ' --relaxed-security'
|
||||||
|
|
||||||
default_web_browser = os.getenv('BROWSER')
|
default_web_browser = os.getenv('BROWSER')
|
||||||
if default_web_browser == 'chrome':
|
cmd += ' --chromedriver-executable {driver}'.format(driver=CHROME_DRIVER)
|
||||||
cmd += ' --chromedriver-executable {driver}'.format(driver=CHROME_DRIVER)
|
|
||||||
|
|
||||||
grid_connect = convert_str_to_bool(str(os.getenv('CONNECT_TO_GRID', False)))
|
grid_connect = convert_str_to_bool(str(os.getenv('CONNECT_TO_GRID', False)))
|
||||||
logger.info('Connect to selenium grid? {connect}'.format(connect=grid_connect))
|
logger.info('Connect to selenium grid? {connect}'.format(connect=grid_connect))
|
||||||
@@ -193,24 +186,26 @@ def run():
|
|||||||
"""Run app."""
|
"""Run app."""
|
||||||
device = os.getenv('DEVICE', 'Nexus 5')
|
device = os.getenv('DEVICE', 'Nexus 5')
|
||||||
logger.info('Device: {device}'.format(device=device))
|
logger.info('Device: {device}'.format(device=device))
|
||||||
|
custom_args=os.getenv('EMULATOR_ARGS', '')
|
||||||
|
logger.info('Custom Args: {custom_args}'.format(custom_args=custom_args))
|
||||||
|
|
||||||
avd_name = '{device}_{version}'.format(device=device.replace(' ', '_').lower(), version=ANDROID_VERSION)
|
avd_name = '{device}_{version}'.format(device=device.replace(' ', '_').lower(), version=ANDROID_VERSION)
|
||||||
logger.info('AVD name: {avd}'.format(avd=avd_name))
|
logger.info('AVD name: {avd}'.format(avd=avd_name))
|
||||||
|
is_first_run = not is_initialized()
|
||||||
|
|
||||||
if not is_initialized():
|
if is_first_run:
|
||||||
logger.info('Preparing emulator...')
|
logger.info('Preparing emulator...')
|
||||||
prepare_avd(device, avd_name)
|
prepare_avd(device, avd_name)
|
||||||
finish_initialization()
|
|
||||||
|
|
||||||
logger.info('Run emulator...')
|
logger.info('Run emulator...')
|
||||||
dp_size = os.getenv('DATAPARTITION', '550m')
|
dp_size = os.getenv('DATAPARTITION', '550m')
|
||||||
with open("/root/android_emulator/config.ini", "a") as cfg:
|
with open("/root/android_emulator/config.ini", "a") as cfg:
|
||||||
cfg.write('\ndisk.dataPartition.size={dp}'.format(dp=dp_size))
|
cfg.write('\ndisk.dataPartition.size={dp}'.format(dp=dp_size))
|
||||||
|
|
||||||
if not is_initialized():
|
if is_first_run:
|
||||||
cmd = 'emulator/emulator @{name} -gpu off -verbose -wipe-data'.format(name=avd_name)
|
cmd = 'emulator/emulator @{name} -gpu off -verbose -wipe-data {custom_args}'.format(name=avd_name, custom_args=custom_args)
|
||||||
else:
|
else:
|
||||||
cmd = 'emulator/emulator @{name} -gpu off -verbose'.format(name=avd_name)
|
cmd = 'emulator/emulator @{name} -gpu off -verbose {custom_args}'.format(name=avd_name, custom_args=custom_args)
|
||||||
appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
|
appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
|
||||||
if appium:
|
if appium:
|
||||||
subprocess.Popen(cmd.split())
|
subprocess.Popen(cmd.split())
|
||||||
|
|||||||
+147
-6
@@ -1,13 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ -z "$GENY_TEMPLATE" ]; then
|
types=($TYPES)
|
||||||
GENY_TEMPLATE="/root/tmp/devices.json"
|
echo "Available types: ${types[@]}"
|
||||||
fi
|
echo "Selected type of deployment: $TYPE, Template file: $TEMPLATE"
|
||||||
|
|
||||||
function prepare_geny_cloud() {
|
function prepare_geny_cloud() {
|
||||||
contents=$(cat $GENY_TEMPLATE)
|
contents=$(cat $TEMPLATE)
|
||||||
|
|
||||||
# Register
|
# Register
|
||||||
|
echo "Register user"
|
||||||
gmtool config username="${USER}" password="${PASS}"
|
gmtool config username="${USER}" password="${PASS}"
|
||||||
gmtool license register "${LICENSE}"
|
gmtool license register "${LICENSE}"
|
||||||
|
|
||||||
@@ -32,6 +33,135 @@ function prepare_geny_cloud() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prepare_geny_aws() {
|
||||||
|
contents=$(cat $TEMPLATE)
|
||||||
|
|
||||||
|
# Creating aws tf file(s)
|
||||||
|
echo "Creating tf file(s)"
|
||||||
|
index=1
|
||||||
|
port=5555
|
||||||
|
for row in $(echo "${contents}" | jq -r '.[] | @base64'); do
|
||||||
|
get_value() {
|
||||||
|
echo ${row} | base64 --decode | jq -r ${1}
|
||||||
|
}
|
||||||
|
|
||||||
|
region=$(get_value '.region')
|
||||||
|
android_version=$(get_value '.android_version')
|
||||||
|
instance=$(get_value '.instance')
|
||||||
|
|
||||||
|
|
||||||
|
echo $region
|
||||||
|
echo $android_version
|
||||||
|
echo $instance
|
||||||
|
|
||||||
|
aws_tf_content=$(cat <<_EOF
|
||||||
|
variable "aws_region_$index" {
|
||||||
|
type = "string"
|
||||||
|
default = "$region"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "android_version_$index" {
|
||||||
|
type = "string"
|
||||||
|
default = "$android_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "instance_type_$index" {
|
||||||
|
type = "string"
|
||||||
|
default = "$instance"
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "aws" {
|
||||||
|
alias = "provider_$index"
|
||||||
|
region = "\${var.aws_region_$index}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_security_group" "geny_sg_$index" {
|
||||||
|
provider = "aws.provider_$index"
|
||||||
|
ingress {
|
||||||
|
from_port = 0
|
||||||
|
to_port = 65535
|
||||||
|
protocol = "tcp"
|
||||||
|
cidr_blocks = ["0.0.0.0/0"]
|
||||||
|
}
|
||||||
|
egress {
|
||||||
|
from_port = 0
|
||||||
|
to_port = 65535
|
||||||
|
protocol = "udp"
|
||||||
|
cidr_blocks = ["0.0.0.0/0"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data "aws_ami" "geny_aws_$index" {
|
||||||
|
provider = "aws.provider_$index"
|
||||||
|
most_recent = true
|
||||||
|
|
||||||
|
filter {
|
||||||
|
name = "name"
|
||||||
|
values = ["genymotion-ami-\${var.android_version_$index}-*"]
|
||||||
|
}
|
||||||
|
|
||||||
|
owners = ["679593333241"] #Genymotion
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_key_pair" "geny_key_$index" {
|
||||||
|
provider = "aws.provider_$index"
|
||||||
|
public_key = "\${file("~/.ssh/id_rsa.pub")}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_instance" "geny_aws_$index" {
|
||||||
|
provider = "aws.provider_$index"
|
||||||
|
ami = "\${data.aws_ami.geny_aws_$index.id}"
|
||||||
|
instance_type = "\${var.instance_type_$index}"
|
||||||
|
vpc_security_group_ids = ["\${aws_security_group.geny_sg_$index.name}"]
|
||||||
|
key_name = "\${aws_key_pair.geny_key_$index.key_name}"
|
||||||
|
tags {
|
||||||
|
Name = "EK-\${data.aws_ami.geny_aws_$index.id}"
|
||||||
|
}
|
||||||
|
count = 1
|
||||||
|
|
||||||
|
provisioner "remote-exec" {
|
||||||
|
connection {
|
||||||
|
type = "ssh"
|
||||||
|
user = "shell"
|
||||||
|
private_key = "\${file("~/.ssh/id_rsa")}"
|
||||||
|
}
|
||||||
|
|
||||||
|
script = "/root/enable_adb.sh"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output "public_dns_$index" {
|
||||||
|
value = "\${aws_instance.geny_aws_$index.public_dns}"
|
||||||
|
}
|
||||||
|
_EOF
|
||||||
|
)
|
||||||
|
echo "$aws_tf_content" > /root/aws_tf_$index.tf
|
||||||
|
((index++))
|
||||||
|
((port++))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Deploy EC2 instance(s)
|
||||||
|
echo "Deploy EC2 instance(s) on AWS with Genymotion image based on given json file..."
|
||||||
|
./terraform init
|
||||||
|
./terraform plan
|
||||||
|
./terraform apply -auto-approve
|
||||||
|
|
||||||
|
# Workaround to connect adb remotely because there is a issue by using local-exec
|
||||||
|
time_sleep=5
|
||||||
|
interval_sleep=1
|
||||||
|
echo "Connect to adb remotely"
|
||||||
|
for ((i=index;i>=1;i--)); do
|
||||||
|
dns=$(./terraform output public_dns_$i)
|
||||||
|
((sleep ${interval_sleep} && adb connect localhost:${port}) > /dev/null & ssh -i ~/.ssh/id_rsa -oStrictHostKeyChecking=no -q -NL ${port}:localhost:5555 shell@${dns}) &
|
||||||
|
((port--))
|
||||||
|
time_sleep=$((time_sleep+interval_sleep))
|
||||||
|
done
|
||||||
|
echo "It will wait for ${time_sleep} until all device(s) to be connected"
|
||||||
|
sleep ${time_sleep}
|
||||||
|
adb devices
|
||||||
|
echo "Process is completed"
|
||||||
|
}
|
||||||
|
|
||||||
function run_appium() {
|
function run_appium() {
|
||||||
echo "Preparing appium-server..."
|
echo "Preparing appium-server..."
|
||||||
CMD="appium --log $APPIUM_LOG"
|
CMD="appium --log $APPIUM_LOG"
|
||||||
@@ -54,8 +184,19 @@ if [ "$REAL_DEVICE" = true ]; then
|
|||||||
run_appium
|
run_appium
|
||||||
elif [ "$GENYMOTION" = true ]; then
|
elif [ "$GENYMOTION" = true ]; then
|
||||||
echo "Using Genymotion"
|
echo "Using Genymotion"
|
||||||
prepare_geny_cloud
|
echo "${types[@]}"
|
||||||
run_appium
|
case $TYPE in
|
||||||
|
"${types[0]}" )
|
||||||
|
echo "Using Genymotion-Cloud"
|
||||||
|
prepare_geny_cloud
|
||||||
|
run_appium
|
||||||
|
;;
|
||||||
|
"${types[1]}" )
|
||||||
|
echo "Using Genymotion-AWS"
|
||||||
|
prepare_geny_aws
|
||||||
|
run_appium
|
||||||
|
;;
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
echo "Using Emulator"
|
echo "Using Emulator"
|
||||||
python3 -m src.app
|
python3 -m src.app
|
||||||
|
|||||||
Executable
+44
@@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function wait_emulator_to_be_ready () {
|
||||||
|
boot_completed=false
|
||||||
|
while [ "$boot_completed" == false ]; do
|
||||||
|
status=$(adb wait-for-device shell getprop sys.boot_completed | tr -d '\r')
|
||||||
|
echo "Boot Status: $status"
|
||||||
|
|
||||||
|
if [ "$status" == "1" ]; then
|
||||||
|
boot_completed=true
|
||||||
|
else
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function change_language_if_needed() {
|
||||||
|
if [ ! -z "${LANGUAGE// }" ] && [ ! -z "${COUNTRY// }" ]; then
|
||||||
|
wait_emulator_to_be_ready
|
||||||
|
echo "Languge will be changed to ${LANGUAGE}-${COUNTRY}"
|
||||||
|
adb root && adb shell "setprop persist.sys.language $LANGUAGE; setprop persist.sys.country $COUNTRY; stop; start" && adb unroot
|
||||||
|
echo "Language is changed!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_google_play () {
|
||||||
|
wait_emulator_to_be_ready
|
||||||
|
echo "Google Play Service will be installed"
|
||||||
|
adb install -r "/root/google_play_services.apk"
|
||||||
|
echo "Google Play Store will be installed"
|
||||||
|
adb install -r "/root/google_play_store.apk"
|
||||||
|
}
|
||||||
|
|
||||||
|
function disable_animation () {
|
||||||
|
# To improve performance
|
||||||
|
adb shell "settings put global window_animation_scale 0.0"
|
||||||
|
adb shell "settings put global transition_animation_scale 0.0"
|
||||||
|
adb shell "settings put global animator_duration_scale 0.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
change_language_if_needed
|
||||||
|
sleep 1
|
||||||
|
install_google_play
|
||||||
|
disable_animation
|
||||||
@@ -55,3 +55,10 @@ autorestart=false
|
|||||||
stdout_logfile=%(ENV_LOG_PATH)s/video-recording.stdout.log
|
stdout_logfile=%(ENV_LOG_PATH)s/video-recording.stdout.log
|
||||||
stderr_logfile=%(ENV_LOG_PATH)s/video-recording.stderr.log
|
stderr_logfile=%(ENV_LOG_PATH)s/video-recording.stderr.log
|
||||||
priority=4
|
priority=4
|
||||||
|
|
||||||
|
[program:adb-utils]
|
||||||
|
command=./src/utils.sh
|
||||||
|
autorestart=false
|
||||||
|
stdout_logfile=%(ENV_LOG_PATH)s/adb-utils.stdout.log
|
||||||
|
stderr_logfile=%(ENV_LOG_PATH)s/adb-utils.stderr.log
|
||||||
|
priority=5
|
||||||
|
|||||||
Reference in New Issue
Block a user