Compare commits

..
34 Commits
Author SHA1 Message Date
Budi UtomoandGitHub 9a714e5fb3 Merge pull request #111 from devilankur18/custom_args
Able to pass custom arguments to Emulator
2018-08-21 16:23:22 +02:00
Ankur Agarwal a6394bcf74 added support for custom arguments while running/creating emulator 2018-08-21 17:50:50 +05:30
Budi UtomoandGitHub f3abb0a828 Merge pull request #110 from devilankur18/emulator_backup_restore
AVD initialisation based on devices xml file
2018-08-16 18:04:20 +02:00
Ankur Agarwal c653efc7b1 fixes related to initialization 2018-08-16 12:36:51 +00:00
butomo1989 d7c9730712 Fixed issue #90 2018-08-03 15:58:07 +02:00
butomo1989 735bc64a2d Cleaned up 2018-08-03 15:56:36 +02:00
butomo1989 307d6502af Fixed string 2018-08-02 12:52:31 +02:00
butomo1989 91a4e270c6 Refactored code 2018-08-02 11:42:19 +02:00
Budi UtomoandGitHub d13e60a122 Merge pull request #104 from devilankur18/master
Added device_id support via ENV variable or auto uuid values
2018-07-31 09:04:58 +02:00
Ankur AgarwalandGitHub c4be3a1ac0 Merge branch 'master' into master 2018-07-31 01:24:15 +05:30
Ankur AgarwalandGitHub 7c7eed4a3d Fixing trailing whitespaces 2018-07-31 01:17:01 +05:30
Budi UtomoandGitHub d0271e0be0 Merge pull request #103 from mehrdad-abdoli/master
Update Google Play Store app
2018-07-30 17:00:42 +02:00
App-Test 9d71ecded7 Update Google Play Services and some other useful stuff by adb 2018-07-30 16:30:19 +04:30
App-Test 81af88e7a4 Update Google Play Services and some other useful stuff by adb 2018-07-30 16:28:41 +04:30
App-Test a8f7fd2d02 Update Google Play Services and some other useful stuff by adb 2018-07-30 16:26:57 +04:30
App-Test de71e5156c Update Google Play Services and some other useful stuff by adb 2018-07-30 16:19:05 +04:30
Ankur AgarwalandGitHub bcf27f0489 Added logging 2018-07-28 23:20:06 +05:30
Ankur AgarwalandGitHub 972445a8bc Assign device_id via environment variable 2018-07-28 23:07:03 +05:30
App-Test 460e0b8daf Update Google Play Services and some other useful stuff by adb 2018-07-28 16:53:26 +04:30
Budi UtomoandGitHub 3673d195ea Updated Readme 2018-07-25 12:27:09 +02:00
Budi UtomoandGitHub 77c6ac8507 Updated Readme 2018-07-25 12:24:34 +02:00
Budi UtomoandGitHub cd35f4a3ab Merge pull request #100 from bonigarcia/master
Download proper version of chromedriver for each Android version
2018-07-25 12:20:11 +02:00
Boni Garcia 217df7cd65 Include browser name, browser version, and chromedriver version in Docker images table 2018-07-25 11:44:21 +02:00
Boni Garcia ccfdef4fe8 Set default chromedriver version 2018-07-24 17:18:41 +02:00
Boni Garcia b40ec48136 Download proper version of chromedriver 2018-07-24 15:59:11 +02:00
Budi UtomoandGitHub 064331de0e Merge pull request #97 from shadow1163/issue87
Once container start, add flag -wipe-data to command.
2018-07-20 08:01:40 +02:00
Budi UtomoandGitHub 5ef52ca622 Merge branch 'master' into issue87 2018-07-20 07:57:23 +02:00
junbo 15c51a4ab1 roll back is_initialized 2018-07-20 09:53:46 +08:00
Budi UtomoandGitHub 7e2b364c08 Merge pull request #96 from JoeSSS/patch-2
Add information about connecting to adb from outside the container in README
2018-07-19 13:02:04 +02:00
Serghei MoretandGitHub 0b18e4995c Update README.md 2018-07-19 12:41:04 +02:00
Serghei MoretandGitHub f0fb5ef009 Update README.md 2018-07-19 12:39:16 +02:00
Serghei MoretandGitHub ec0c381fb6 Update README.md 2018-07-19 12:38:24 +02:00
Serghei MoretandGitHub 58f7693024 Add adbkey part to README 2018-07-19 12:35:28 +02:00
junbo 40f6e67d83 fix issue 87 2018-07-19 18:11:59 +08:00
6 changed files with 152 additions and 41 deletions
+61 -19
View File
@@ -12,7 +12,7 @@ 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
:---------------------------:|:---------------------------:|:---------------------------: :---------------------------:|:---------------------------:|:---------------------------:
@@ -41,17 +41,17 @@ Advantages compare with other docker-android projects
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://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.0.1|21|browser|37.0|2.12|butomo1989/docker-android-x86-5.0.1|[![](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/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|5.1.1|22|browser|39.0|2.13|butomo1989/docker-android-x86-5.1.1|[![](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/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|6.0|23|browser|44.0|2.18|butomo1989/docker-android-x86-6.0|[![](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/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.0|24|chrome|51.0|2.23|butomo1989/docker-android-x86-7.0|[![](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/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.1.1|25|chrome|55.0|2.28|butomo1989/docker-android-x86-7.1.1|[![](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|8.0|26|butomo1989/docker-android-x86-8.0|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-x86-8.0.svg)](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://images.microbadger.com/badges/image/butomo1989/docker-android-x86-8.0.svg)](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://images.microbadger.com/badges/image/butomo1989/docker-android-x86-8.1.svg)](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://images.microbadger.com/badges/image/butomo1989/docker-android-x86-8.1.svg)](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://images.microbadger.com/badges/image/butomo1989/docker-android-real-device.svg)](https://microbadger.com/images/butomo1989/docker-android-real-device "Get your own image badge on microbadger.com")| |All |-|-|-|-|-|butomo1989/docker-android-real-device|[![](https://images.microbadger.com/badges/image/butomo1989/docker-android-real-device.svg)](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://images.microbadger.com/badges/image/butomo1989/docker-android-genymotion.svg)](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://images.microbadger.com/badges/image/butomo1989/docker-android-genymotion.svg)](https://microbadger.com/images/butomo1989/docker-android-genymotion "Get your own image badge on microbadger.com")|
List of Devices List of Devices
--------------- ---------------
@@ -122,6 +122,27 @@ To run tests for mobile browser, following parameter can be passed:
```bash ```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 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
``` ```
### Custom Emulator Arguments
If you want to add more arguments for running emulator, you can ***pass an evnironemnt 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" -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
```
### 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" -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
```
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`
### Share Volume ### Share Volume
@@ -135,6 +156,13 @@ docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -
You can deactivate auto_record by changing the value to "False" in docker-compose file. e.g. change value to "False" in this [line]. You can deactivate auto_record by changing the value to "False" in docker-compose file. e.g. change value to "False" in this [line].
### Language
You can change the language setting of Android Emulator on the fly by passing following environment variable:
- LANGUAGE="\<language>"
- COUNTRY="\<country>"
### Docker-Compose ### Docker-Compose
![][compose] ![][compose]
@@ -145,6 +173,10 @@ There is [example of compose file] to run complete selenium grid and docker-andr
docker-compose up -d docker-compose up -d
``` ```
### Google Play Services and Google Play Store
The Docker "Android Emulator" images contain 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.
Build Android project Build Android project
--------------------- ---------------------
@@ -167,7 +199,7 @@ Proxy
You can enable proxy inside container by passing following environment variables: You can enable proxy inside container by passing following environment variables:
- HTTP_PROXY="\<docker\_bridge\_ip\_address>" - HTTP_PROXY="\<language>docker\_bridge\_ip\_address>"
- HTTPS_PROXY="\<docker\_bridge\_ip\_address>" - HTTPS_PROXY="\<docker\_bridge\_ip\_address>"
- NO_PROXY="localhost" - NO_PROXY="localhost"
@@ -181,9 +213,9 @@ Genymotion
![Genymotion](images/logo_genymotion.png) ![Genymotion](images/logo_genymotion.png)
Docker-Android supports [Genymotion Cloud]. Docker-Android supports [Genymotion Cloud].
You can easily scale your Appium tests on Genymotion Android virtual devices in the 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 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 ```bash
@@ -212,6 +244,15 @@ adb connect <docker-machine-ip-address>:5555
**Note:** You need to have Android Debug Bridge (adb) installed in your host machine. **Note:** You need to have Android Debug Bridge (adb) installed in your host machine.
Get rid of unauthorized device popup while connecting to the emulator outside the container
------------------------------------------
In order to connect to the emulator using already generated adbkey on your machine you will need to mount your `.android` folder to the container (this is needed only when you work with emulator based on playstore image):
```
docker run -v <local Android key directory>:/root/.android/ ...
```
SMS Simulation SMS Simulation
-------------- --------------
@@ -270,7 +311,7 @@ The following instructions are used for OS X. You'll need [docker-machine-parall
```bash ```bash
$ docker-machine create --driver=parallels prl-dev $ 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. 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. Setup the virtual machine for nested virtualization support
@@ -281,11 +322,11 @@ The following instructions are used for OS X. You'll need [docker-machine-parall
``` ```
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 VMWare Fusion, go to menu bar > Vitual Machine > Settings > Processors and Memory, expand Advanced options, and select `Enable hypervisor applications in this virtual machine`.
![Enable nested virtualization for VMWare Fusion](images/vmwarefusion_enable_nested_virtualization.png) ![Enable nested virtualization for VMWare Fusion](images/vmwarefusion_enable_nested_virtualization.png)
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`. 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`.
![Enable nested virtualization for Parallels Desktop](images/parallels_enable_nested_virtualization.png) ![Enable nested virtualization for Parallels Desktop](images/parallels_enable_nested_virtualization.png)
4. Enable kvm inside virtual machine 4. Enable kvm inside virtual machine
@@ -342,6 +383,7 @@ Special Thanks
[compose]: <images/compose.png> [compose]: <images/compose.png>
[line]: <https://github.com/butomo1989/docker-android/blob/master/docker-compose.yml#L70> [line]: <https://github.com/butomo1989/docker-android/blob/master/docker-compose.yml#L70>
[example of compose file]: <docker-compose.yml> [example of compose file]: <docker-compose.yml>
[utils bash file]: <src/utils.sh>
[docker-compose]: <https://docs.docker.com/compose/install/> [docker-compose]: <https://docs.docker.com/compose/install/>
[1.13.0]: <https://github.com/docker/compose/releases/tag/1.13.0> [1.13.0]: <https://github.com/docker/compose/releases/tag/1.13.0>
[Genymotion Cloud]: <https://www.genymotion.com/cloud/> [Genymotion Cloud]: <https://www.genymotion.com/cloud/>
+14 -3
View File
@@ -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 -4
View File
@@ -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.12"
[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
View File
@@ -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())
Executable
+44
View File
@@ -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"
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
+7
View File
@@ -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