How do I know that device is busy?

Hi guys, I am trying to build testing lab with many devices. I have several projects that will run agains my testing lab.

My current problem is: How could I find out which device is busy with test and which is free for test?

Thank you in advance!

I think you’ve got to code some kind of checkout system. I’m thinking of a database with a web front end that does the following:

  1. allows you to ‘check out’ a device
  2. reports the state of device as ‘busy’
  3. starts an appium server with a unique port and records that as part of the state

I’m sure it will be a fairly complicated system, even moreso if you are intending to test iOS.

1 Like

Depending upon your needs, you could make it simple or complex.

I created a simple reservation system to solve just this problem a year and a half ago. Here are my assumptions and the reasons for or consequences of them.

  1. There may be timing issues with multiple entities requesting the same device
  • I created a lock file to use as a semaphore. Operations were blocked if you couldn’t get the semaphore. There is still a small chance of a timing issue here, but we never ran into that problem
  1. A device can be reserved for a long time
  • I don’t need to create an automated method to free reservations. Perhaps you’ll want this
  1. There should be an administrative method to clear out reservations in case they become inconsistent
  • I can’t predict every possible code path, and I may need this to clean up problems. I had to use this a few times
  1. There should be a method to get the list of currently attached devices
  • When new devices are attached to the system, or existing devices are removed, the user should be able to click and button and get the latest list.
  1. Only testing Android
  • This reduces the code that identifies the devices
  1. Only one server
  • If you have more than 4-8 devices, you’ll have to have some RPC mechanism to get the status of the devices on different machines, but that has nothing to do with reservations
  1. Some checks to see if connectivity to the device had failed
  • We had some issues with losing connectivity between Linux server and the android devices

I wrote all of this with less than 100 lines of ruby code. Assuming you require more than one server, you’d need an additional 25-50 lines of code at most to handle the connection.

Additionally, I wrote a script to execute the test cases against the different devices starting either locally or through a web UI, update the test repo, and clear out old logs. This was an additional 200 lines of ruby code.

2 Likes

Thank you for your ideas. I was thinking where it is possible to ask an instance of appium where it has active session or not? Please let me know if it is possible.

Sure, it will be something like this, but I need a decent mechanism to ask appium instance: “Hey, do you have active session running?”

Here is a link to issue tracker with the same question: https://github.com/appium/appium/issues/5976

I’m not sure this is possible. My recommendation is still that you record the port number as part of the device state in your database, then you can query the database for device/appium port pairs. This will also help you to keep track of the ports used for when you need to start a new appium server.