At work we are transitioning from Bamboo to Jenkins. Currently we have multiple agents (Windows and macOS) each having a number of mobile devices attached (Android and iOS).
Historically, Bamboo jobs have looked for a suitable agent to run on and then run module tests against single mobile device. If module/unit/robustness tests are required to be run against multiple mobile devices then either jobs get queued or they run on multiple agents at the same time.
With the move to Jenkins, we have the ability to more easily run jobs in parallel on a single agent thanks to Jenkins' Executors. This now presents us with a problem: If multiple jobs want to run on the same mobile device attached to the same agent, how can we signal that the device is currently in use?
We have thought about using lock files or updating labels, but thinking the solutions through we come up against possible race-conditions (e.g. a 'third' job sees that the lock file has gone and starts executing before the 'second' job, that has been waiting longer, sees the lock file is gone; multiple executors update labels in quick succession and overwrite each others updates).
For much of what we do, and for the machines we have, virtualising hosts and passing through single devices is not economical for us. I have also been informed by the developments teams that because our product relies on certain hardware characteristics (and in some cases like robustness testing we must test the product on hardware), simulators/emulators are unsuitable for our CI use case.
We usually have multiple devices of the same make and model, or with similar enough characteristics that tests run on one can be confidently assumed to pass on another. It would be good if part of the signalling that a device was currently in use would result in a job looking for a suitable agent moved on to see if other agents were free.