TestProject Forum

TestProject Docker Agent connected with Android Emulators

Hello!
I know so far that we can run docker testproject/agent connected to chrome and firefox browser using the standalone selenium docker image with docker-compose.yml file as it is described here: Docker Hub

# NOTE: Make sure to update the 'testproject-agent' container volume with a valid local path.
# To execute this docker-compose, store it in a file (e.g. testproject-agent.yaml) an run:
# docker-compose -f <file_name> up -d

version: "3.1"
services:
  testproject-agent:
    image: testproject/agent:latest
    container_name: testproject-agent
    depends_on:
      - chrome
      - firefox
    environment:
      TP_API_KEY: "<YOUR API KEY>"
      TP_SDK_PORT: "8686"             # Agent will listen on port 8686 for SDK connections
      CHROME: "chrome:4444"           # Address for Agent to communicate with Chrome browser
      CHROME_EXT: "localhost:5555"    # Address for accessing the Chrome Selenium server
      FIREFOX: "firefox:4444"         # Address for Agent to communicate with Firefox browser
      FIREFOX_EXT: "localhost:5556"   # Address for accessing the Firefox Selenium server
    ports:
    - "8585:8585"
    - "8686:8686"                     # Expose port for SDK<->Agent communication
  chrome:
    image: selenium/standalone-chrome
    volumes:
      - /dev/shm:/dev/shm
    ports:
    - "5555:4444"                     # Expose Selenium on port 5555
  firefox:
    image: selenium/standalone-firefox
    volumes:
      - /dev/shm:/dev/shm
    ports:
    - "5556:4444"                     # Expose Selenium on port 5556

I just wanted to know if there is a way to do the same thing but with docker android containers, I mean I would like to connect the agent to a mobile device instead of a browser. There is already an available docker-android project (GitHub - budtmo/docker-android: Android in docker solution with noVNC supported and video recording) which has everything needed to set up and spine up an android emulator and I want to connect that android emulator (which is inside a container) with the agent using docker-compose syntax. I’ve built something similar to the docker-compose described above but I’m not able to make the testproject docker agent recognizes the docker android emulator. I just need a little help on how I can make the docker testproject agent communicate with docker-android emulator, do you think is that possible?

This is what I’ve done so far:

# NOTE: Make sure to update the 'testproject-agent' container volume with a valid local path.
# To execute this docker-compose, store it in a file (e.g. testproject-agent.yaml) an run:
# docker-compose -f <file_name> up -d

version: "3.1"
services:
  testproject-agent:
    image: testproject/agent:latest
    container_name: testproject-agent
    networks:
      - docker_network
    depends_on:
      - android
    environment:
      TP_API_KEY: "MY_API_KEY_HERE"
      TP_JOB_PARAMS: '"jobParameters" : {"devices": ["emulator-5554"],"queue": 
true,"restartDriver": false,"testParameters": [{"testId": "MY_TEST_ID_HERE","reinstallApp": 
true}],"tags": ["BFCO","Android","e2e"],"capabilities": {"platformName": "Android","deviceName": 
"Nexus 5","platformVersion": "8.0"}}'
      TP_JOB_ID: "MY_JOB_ID_HERE"
      TP_AGENT_ALIAS: "falabella-testproject-docker-agent"
    ports:
      - "8585:8585"
    volumes:
      - ./docker-resources/hosts:/etc/hosts

  android:
    image: budtmo/docker-android-x86-8.0
    container_name: android_emulator
    privileged: true
    networks:
      - docker_network
    ports:
      - "6080:6080"
      - "4723:4723"
      - "5554:5554"
      - "5555:5555"
    volumes:
      - ./docker-resources/hosts:/etc/hosts
    environment:
      - DEVICE=Nexus 5
      - APPIUM=true
      - MOBILE_WEB_TEST=false
      - AUTO_RECORD=true

networks:
  docker_network:

And it end ups always getting this error message from the docker agent:

2021-04-17 02:34:28.330 [ERROR] i.t.a.b.a.d POST https://api.testproject.io/api/v1/executions/jobs/_PYczISdi0OlV-ARL5HAIw - 412 (Mdjs3loG): The defined devices are either not connected or unauthorized

[699](https://gitlab.falabella.com/fif/canales-digitales/qa-automation/omni-mobile/bfcl_e2e_automation/-/jobs/2322085#L699)testproject-agent | 2021-04-17 02:34:28.331 [ERROR] i.t.a.b.b.c Failed to get execution guid for job _PYczISdi0OlV-ARL5HAIw

[700](https://gitlab.falabella.com/fif/canales-digitales/qa-automation/omni-mobile/bfcl_e2e_automation/-/jobs/2322085#L700)testproject-agent | 2021-04-17 02:34:28.331 [ERROR] i.t.a.m.d.h Docker will not execute job _PYczISdi0OlV-ARL5HAIw without an execution guid

[701](https://gitlab.falabella.com/fif/canales-digitales/qa-automation/omni-mobile/bfcl_e2e_automation/-/jobs/2322085#L701)testproject-agent | 2021-04-17 02:34:28.331 [ERROR] i.t.a.e.a.a.d Failed processing pre-configured execution, Agent will stop now.

I know the emulator is up and running, but I just cannot make the agent to recognize it,

Thank you so much!

Hello lerry,
It is not currently possible as the dockerized agent is yet to be implemented the abilities to detect emulated devices in the docker environment.
Even if the .yml is valid, the pulled agent doesn’t know how to detect the emulator.
We appreciate your input and we might add this feature in the future.

1 Like