Closed Bug 1692253 Opened 3 years ago Closed 3 years ago

mozdevice.adb.ADBDEvice: Support yielding output with device.shell() processes.

Categories

(Testing :: Mozbase, enhancement)

Firefox 87
enhancement

Tracking

(firefox88 fixed)

RESOLVED FIXED
88 Branch
Tracking Status
firefox88 --- fixed

People

(Reporter: nbp, Assigned: nbp)

References

Details

Attachments

(1 file)

The JS test suite are processing the output of tests by using a generator to iterate over the list of outputs. To avoid spawning multiple adb processes while reading the output of each test as the output are produced we would batch commands. However we have to process the output as it is produced, as the amount of data produced could be very large otherwise.

Using an ADBDevice.shell on another thread with stdout_callback set does not work, as the _timed_read_line implementation relies on signals which are not supported on a different thread than the main thread.

One proposal, is that instead of using an extra file to capture the output, we could use a subprocess.PIPE for stdout, implement a timeout using an additional Thread responsible of kill()-ing the process and recording the exitcode. In the mean time, the output can be collected by using the default stdout.readlines() iterator which would be blocking as long as the stdout is not closed by the adb command. Thus allowing the JS test suite to yield results as they are aggregated.

That sounds reasonable.

I'll just mention that android mochitest and reftest face a similar challenge: The firefox app under test generates a lot of test output over a long time. Those test harnesses use a simple compromise, using https://searchfox.org/mozilla-central/rev/d3343662ce0aced933b30e053b33c93f759292eb/testing/mozbase/mozdevice/mozdevice/remote_process_monitor.py: All test output is written to a file on device, the file is periodically pulled to the host, and new output dumped to the harness' stdout. The polling aspect is not optimal, but has been good enough for those test suites.

This change add the ability to yield the output as it is produced, by
creating a thread responsible for killing the process if it takes too
long.

This way we can loop with blocking I/O on stdout in python, while the
process is running concurrently. The loop ends when the process exit
either by itself or after being killed by the timeout.

Pushed by npierron@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ac8e8e6cf77c
Create a thread to handle ADB process timeout. r=jmaher,gbrown
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 88 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: