Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maestro says emulators are 'not connected' if more than one emulator is 'adb connect'ed. #2167

Open
1 task done
sleekweasel opened this issue Dec 2, 2024 · 5 comments
Open
1 task done
Labels

Comments

@sleekweasel
Copy link

sleekweasel commented Dec 2, 2024

Is there an existing issue for this?

  • I have searched the existing issues and didn't find mine.

Steps to reproduce

  1. Clone main (5f971ce) and build a distribution zip.
  2. Start 2 emulators at a nonstandard port, so adb can't see them - e.g. emulator -port 5528
  3. adb connect them both:
bash-4.2# adb devices
List of devices attached
automation2.xlan:5529	device
automation2.xlan:5531	device
  1. Download the sample tests, cd samples, install sample.apk to the first emulator, and try to run against ONLY that one:
  2. Run maestro --udid automation2.xlan:5529 test android-flow.yaml

Actual results

bash-4.2# maestro --udid automation2.xlan:5529 test android-flow.yaml 
Device automation2.xlan:5529 was requested, but it is not connected.

Jolly well IS connected:

bash-4.2# adb -s automation2.xlan:5529 shell date
Mon Dec  2 16:07:12 GMT 2024
bash-4.2# adb -s automation2.xlan:5531 shell date
Mon Dec  2 16:07:19 GMT 2024

Yet with just one:

bash-4.2# adb disconnect automation2.xlan:5531
disconnected automation2.xlan:5531
bash-4.2# adb devices
List of devices attached
automation2.xlan:5529	device

bash-4.2# maestro --udid automation2.xlan:5529 test android-flow.yaml 

Works fine:

Running on automation2.xlan:5529         
 ║  > Flow: android-flow                                            
 ║    ✅   Launch app "org.wikipedia"     

For what it's worth, I'm using Android Debug Bridge version 1.0.41 which I know is a bit old.

Expected results

I expect it to be able to work with multiple 'adb connect'ed emulators.

About app

It's your test sample app and your flow.

About environment

Happens both in a docker container on a Linux 64 box...
$ docker run --rm -it -v $PWD:$PWD --entrypoint bash docker/amazoncorretto:17.0.10
bash-4.2# yum install -y unzip
...
bash-4.2# unzip /maestro.zip
...
bash-4.2# maestro --version
16:21:24.723 [pool-1-thread-1] DEBUG io.micrometer.common.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
1.39.2

And on an M1 Macbook: corretto-17.0.12.7.1

Logs

Logs
bash-4.2# maestro --verbose --udid automation2.xlan:5529 test android-flow.yaml --no-ansi
[ INFO] ---- System Info ----
[ INFO] Maestro Version: 1.39.2
[ INFO] CI: Undefined
[ INFO] OS Name: Linux
[ INFO] OS Version: 4.18.0-553.16.1.el8_10.x86_64
[ INFO] Architecture: amd64
[ INFO] Java Version: 17
[ INFO] Xcode Version: null
[ INFO] Flutter Version: Undefined
[ INFO] Flutter Channel: Undefined
[ INFO] ---------------------
[DEBUG] Using SLF4J as the default logging framework
- Device automation2.xlan:5529 was requested, but it is not connected.
+ [ INFO] [shard 1] Selected device automation2.xlan:5529 using port 7001
+ ...
+  more stuff from a successful run, but this is the first and only difference between adb having one or two devices connected.

Maestro version

1.39.2

How did you install Maestro?

built from source (please include commit hash in the text area below)

Anything else?

Built from 5f971ce

I have a couple of days. I'll try to dig around, since I have an easy reproducible test case.

Worst case, my workaround is to use only one emulator for the time being.

@sleekweasel sleekweasel changed the title Maesto says emulators are 'not connected' if more than one emulator is 'adb connect'ed. Maestro says emulators are 'not connected' if more than one emulator is 'adb connect'ed. Dec 2, 2024
@sleekweasel
Copy link
Author

sleekweasel commented Dec 2, 2024

I added a try/catch around listAndroidDevices' runcatching{} body, and got this:

CAUGHT java.io.IOException: Command failed (host:features): more than one device/emulator

java.io.IOException: Command failed (host:features): more than one device/emulator
        at dadb.adbserver.AdbServer.send$dadb(AdbServer.kt:99)
        at dadb.adbserver.AdbServerDadb.open(AdbServer.kt:138)
        at dadb.adbserver.AdbServerDadb.<init>(AdbServer.kt:128)
        at dadb.adbserver.AdbServer.createDadb(AdbServer.kt:52)
        at dadb.adbserver.AdbServer.listDadbs(AdbServer.kt:81)
        at dadb.adbserver.AdbServer.listDadbs$default(AdbServer.kt:60)
        at dadb.Dadb$Companion.list(Dadb.kt:251)
        at dadb.Dadb$Companion.list$default(Dadb.kt:250)
        at maestro.cli.device.DeviceService.listAndroidDevices(DeviceService.kt:148)
        at maestro.cli.device.DeviceService.listDevices(DeviceService.kt:130)
        at maestro.cli.device.DeviceService.listConnectedDevices(DeviceService.kt:117)
        at maestro.cli.command.TestCommand$handleSessions$1.invokeSuspend(TestCommand.kt:213)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
        at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:585)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:802)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:706)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:693)

@sleekweasel
Copy link
Author

mobile-dev-inc/dadb#64

@sleekweasel
Copy link
Author

I may have a fix for this, see dadb#64.

@herval herval added the Maestro label Dec 3, 2024 — with Linear
@sleekweasel
Copy link
Author

Hopefully they'll take mobile-dev-inc/dadb#80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants