shamanec / GADS-devices-provider

Set up iOS/Android devices for remote control with GADS UI and Appium test execution
MIT License
30 stars 4 forks source link

devices-list is the same of devices-config? #11

Closed alexsantosdev closed 1 year ago

alexsantosdev commented 1 year ago

Captura de tela de 2023-02-06 10-36-30

At second step in "Register devices in config.json", we have to change the devices-list, but in the config.json only exists devices-config. Is it the same?

alexsantosdev commented 1 year ago

I have one more issue, i have followed all instructions, but here in "Update Appium Config" and appium-config i have to setup my own configuration that the container will spin up automatically or i need to install Appium on my PC start it and get host configuration? Where i find the Selenium Grid configuration?

I skipped this step and I can't see anything in the GADS log and the container didn't start :(. If I finish this step, when I plug my device in, will the container start automatically?

shamanec commented 1 year ago

On the first question - yes, it seems I didn't update the readme properly after doing the latest changes 😓 On the second question - you do not need Appium on the host, each container has Appium installed inside the image and spins its own Appium server automatically. The appium-config is used only if you want to connect to Selenium Grid (which I believe might not be working at the moment) but you don't have to use it at all. Just set connect_selenium_grid field to false (which is the default value).

  1. Have you built the docker image as described in the provider setup?
  2. Have you created the udev rules after setting up config.json with the devices? If you have the device connected before you setup the udev rules you might need to reconnect it. Then go to /dev and see if you have a symlink created which name starts with device_your device UDID
  3. Did you kill adb-server after all this is done?
  4. And a stupid question - did you build and run the provider?
alexsantosdev commented 1 year ago

I did the process again, considering your observations, and I noticed that inside logs/provider.log some events were being fired, one of the errors is the following:

{"event":"android_container_create","level":"error","msg":"Device with UDID:RQ8RC06TLJK.tmp-c189:11 is not registered in the 'config.json' file. will be created.","time":"2023-02-06T14:48:49-03:00"}.

I also took a look at 90-devices.rules and realized that for some reason it is generating the default rules when the project is cloned, even if I change config.json, there are any workaround for these errors i am taking?

Complete log:

{"event":"android_container_create","level":"error","msg":"Device with UDID:RQ8RC06TLJK.tmp-c189:8 is not registered in the 'config.json' file. No container will be created.","time":"2023-02-06T16:08:38-03:00"}
{"event":"android_container_create","level":"info","msg":"Attempting to create a container for Android device with udid: RQ8RC06TLJK","time":"2023-02-06T16:08:38-03:00"}
{"event":"android_container_create","level":"error","msg":"Could not create a container for device with udid: RQ8RC06TLJK. Error: Error response from daemon: invalid mount config for type \"bind\": bind source path does not exist: /root/.android","time":"2023-02-06T16:08:38-03:00"}
shamanec commented 1 year ago

By the error you can see it tries to mount /root/.android folder but it doesnt exist on your machine. If I remember correctly this contains the adbkeys for your devices so that the container does not ask each time for connection. If you havent done it, stop the provider and:

  1. Run adb server on the host.
  2. Enable USB debugging on the Android phone through the developer tools.
  3. Connect the device.
  4. You should see a pairing request on device - accept it. This should create an .android folder which contains the pairing key for the device Kill adb server on the host, disconnect the device, run the provider and connect the device. I've worked less on Android and I may have forgotten this in readme :(
alexsantosdev commented 1 year ago

I run it, but i have another error. Sorry for my stupid question, but i can't solve this error :(

Complete log:

{"event":"create_udev_rules","level":"info","msg":"Creating udev rules","time":"2023-02-07T00:32:57-03:00"}
{"event":"android_container_create","level":"info","msg":"Attempting to create a container for Android device with udid: 11df8d42.tmp-c189:9","time":"2023-02-07T00:34:01-03:00"}
{"event":"android_container_create","level":"error","msg":"Device with UDID:11df8d42.tmp-c189:9 is not registered in the 'config.json' file. No container will be created.","time":"2023-02-07T00:34:01-03:00"}
{"event":"android_container_create","level":"info","msg":"Attempting to create a container for Android device with udid: 11df8d42","time":"2023-02-07T00:34:01-03:00"}
{"event":"android_container_create","level":"info","msg":"Attempting to create a container for Android device with udid: 11df8d42.tmp-c189:9","time":"2023-02-07T00:34:01-03:00"}
{"event":"android_container_create","level":"error","msg":"Device with UDID:11df8d42.tmp-c189:9 is not registered in the 'config.json' file. No container will be created.","time":"2023-02-07T00:34:01-03:00"}
{"event":"android_container_create","level":"info","msg":"Attempting to create a container for Android device with udid: 11df8d42","time":"2023-02-07T00:34:01-03:00"}
{"event":"android_container_create","level":"error","msg":"Could not create a container for device with udid: 11df8d42. Error: Error response from daemon: Conflict. The container name \"/androidDevice_11df8d42\" is already in use by container \"a35c07ffa24c32b81ab9897d3c7b563b252a4420c5591b4d68698c4730bf28cd\". You have to remove (or rename) that container to be able to reuse that name.","time":"2023-02-07T00:34:01-03:00"}
{"event":"android_container_create","level":"info","msg":"Successfully created a container for Android device with udid: 11df8d42","time":"2023-02-07T00:34:03-03:00"}

The last log it's a message saying that container was created, but when i run sudo docker container ls the list is empty.

shamanec commented 1 year ago

What OS are you running it on? These symlink names that include tmp-c189:9 are a bit weird and I've never seen them - that is not the reason though. Judging by the logs everything should be okay - Could not create a container error appears because when you connect a device sometimes the udev rules trigger multiple times and this is part of the "handling". It creates a container, then tries to create it again but it already exists and the provider found it. Then the initially created container is successfully started and we can see the message in the logs. On the top of my mind a possible reason could be that you are using sudo - I've never used docker with it and I assume there might be different docker instances with and without sudo. Did you try just docker ps -a?

shamanec commented 1 year ago

Also you should note that containers get destroyed if the symlink disappears from /dev - if you disconnect the device for example or the usb connection fails for some reason. This is just a heads up, I doubt that you are having a problem with this

alexsantosdev commented 1 year ago

I'm using Ubuntu 20.04

Alright, i'll try to use without sudo.

Thanks for the quick reply :D

alexsantosdev commented 1 year ago

Hey! sorry for one more issue, but i did again without sudo and i'm having the same error :(

I've followed all steps in readme, but i don't know what's happened. When i call docker ps -a i see my container with status "Exited" i try to see logs using the api call [/containers/{container_id}/logs], but this shows this message "There are no existing logs for this container.", i've tried to restart the container, but nothing happens. :(

i'd like to test this project :( this is the most complete project I've seen so far

shamanec commented 1 year ago

Hah, you are the only person that I know of that is trying to use it beside me so there might be some unforeseen issues that I havent thought of or something that I missed in readmes. Right now on the top of my head I can't imagine what could be the problem - you can contact me in Discord: shamanec#4281 or LinkedIn so we can chat faster when I am available. Also we can try and do a live session tomorrow evening if you want - I live in Bulgaria which is UTC+2

alexsantosdev commented 1 year ago

Thank you!! i'll contact you. :)

shamanec commented 1 year ago

Issues resolved!