fixes related to initialization

This commit is contained in:
Ankur Agarwal 2018-08-15 17:33:16 +00:00
parent d7c9730712
commit c653efc7b1
2 changed files with 15 additions and 9 deletions

View file

@ -123,6 +123,20 @@ To run tests for mobile browser, following parameter can be passed:
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
``` ```
### 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
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***. 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***.

View file

@ -51,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')
@ -65,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'
@ -203,7 +196,6 @@ def run():
if is_first_run: 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')