Skip to content

Commit

Permalink
fixes related to initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
devilankur18 committed Aug 16, 2018
1 parent d7c9730 commit c653efc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

### 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

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***.
Expand Down
10 changes: 1 addition & 9 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,14 @@ def convert_str_to_bool(str: str) -> bool:


def is_initialized() -> bool:
return os.path.exists(INIT_FILE)


def finish_initialization():
file = open(INIT_FILE, 'w+')
file.close()

return os.path.exists(os.path.join(ROOT, '.android', 'devices.xml'))

ANDROID_HOME = get_or_raise('ANDROID_HOME')
ANDROID_VERSION = get_or_raise('ANDROID_VERSION')
API_LEVEL = get_or_raise('API_LEVEL')
PROCESSOR = get_or_raise('PROCESSOR')
SYS_IMG = get_or_raise('SYS_IMG')
IMG_TYPE = get_or_raise('IMG_TYPE')
INIT_FILE = os.getenv('INIT_FILE', "/root/init")

logger.info('Android version: {version} \n'
'API level: {level} \n'
Expand Down Expand Up @@ -203,7 +196,6 @@ def run():
if is_first_run:
logger.info('Preparing emulator...')
prepare_avd(device, avd_name)
finish_initialization()

logger.info('Run emulator...')
dp_size = os.getenv('DATAPARTITION', '550m')
Expand Down

0 comments on commit c653efc

Please sign in to comment.