Closed Bug 1716571 Opened 3 years ago Closed 3 years ago

Dynamically set up android port forwarding

Categories

(Testing :: XPCShell Harness, enhancement, P2)

Default
enhancement

Tracking

(firefox93 fixed)

RESOLVED FIXED
93 Branch
Tracking Status
firefox93 --- fixed

People

(Reporter: valentin, Assigned: valentin)

Details

Attachments

(1 file)

NodeServer.execute allows us to define code in an xpcshell-test and run it in a separate node instance.
Running a HTTP/2 server like this is easy and userful, as it allows tests to be isolated from each-other, but it doesn't currently work on Android, as the ports are not forwarded as from the host to the emulator like we do here

Is there a way to provide a JS accessible way of setting this up? Calling it from either the xpcshell-test or the nodejs server would be acceptable.

My questions are:

  • what's the best way of doing that? Spawning a terminal command and waiting for it to finish?
  • Are there any downsides of doing that a large number of sockets?

Fixing this would allow us to enable the http3_ and trr_ tests on Android link

Flags: needinfo?(whole.grains)

(In reply to Valentin Gosu [:valentin] (he/him) from comment #0)

  • what's the best way of doing that? Spawning a terminal command and waiting for it to finish?

Yes, issuing commands through the adb executable is the most obvious approach, and of course that's how all the existing python test automation does it. https://developer.android.com/studio/command-line/adb

An alternative: Use a network connection to the emulator console to issue commands, https://developer.android.com/studio/run/emulator-console. I think the 'redir' command will work -- but I'm not very familiar with this.

Another way (but I think this is not advisable, too complicated): Implement the client side of the adb protocol in js and issue adb commands that way. See maybe https://android.googlesource.com/platform/system/core/+/dd7bc3319deb2b77c5d07a51b7d6cd7e11b5beb0/adb/OVERVIEW.TXT, https://github.com/cstyan/adbDocumentation

  • Are there any downsides of doing that a large number of sockets?

I don't know. Are you thinking of redirecting a whole range of sockets in the harness before running any tests? I think that would work, but haven't tried anything like that. I suppose there would be a risk of starving tests of ports needed for something else.

Flags: needinfo?(whole.grains)

(In reply to Geoff Brown [:gbrown] from comment #1)

(In reply to Valentin Gosu [:valentin] (he/him) from comment #0)

  • what's the best way of doing that? Spawning a terminal command and waiting for it to finish?

Yes, issuing commands through the adb executable is the most obvious approach, and of course that's how all the existing python test automation does it. https://developer.android.com/studio/command-line/adb

Seems like the easiest way forward. I'll give it a shot!

  • Are there any downsides of doing that a large number of sockets?

I don't know. Are you thinking of redirecting a whole range of sockets in the harness before running any tests? I think that would work, but haven't tried anything like that. I suppose there would be a risk of starving tests of ports needed for something else.

We would do this for each individual port when it's opened. Probably not so much as to starve other tests of ports (maybe in the future, if we end up doing this for hundreds of tests).
My concerns are more of the sort - if we add dozens/hundreds of rules, would the forwarding rules slow down connections? Probably hard to tell without actually doing it.

Assignee: nobody → valentin.gosu
Severity: -- → S3
Priority: -- → P2

I'm encountering some errors in automation (even though it works locally)
https://treeherder.mozilla.org/jobs?repo=try&revision=1c85c497c81c1708463c795074d7fba3aded6a54&selectedTaskRun=X_yPrwOXSyS62ddQZXURQw.0

[task 2021-06-21T22:14:55.254Z] 22:14:55     INFO -  /bin/sh: 1: adb: not found
[task 2021-06-21T22:14:55.255Z] 22:14:55     INFO -  error: Command failed: adb reverse tcp:39861 tcp:39861

Should I call the binary with an absolute path?
/usr/bin/adb Seems to also not work. Do you happen to know how I should find the binary?

[task 2021-06-22T08:10:38.167Z] 08:10:38     INFO -  /bin/sh: 1: /usr/bin/adb: not found
[task 2021-06-22T08:10:38.168Z] 08:10:38     INFO -  error: Command failed: /usr/bin/adb reverse tcp:42701 tcp:42701
[task 2021-06-22T08:10:38.168Z] 08:10:38     INFO -  /bin/sh: 1: /usr/bin/adb: not found
Flags: needinfo?(whole.grains)

adb should be at <android-sdk>/platform-tools/adb. Android tests run via mozharness usually find it in the $PATH because of

https://searchfox.org/mozilla-central/rev/f351e19360729b351bfc7c1386d6e4ca4ea676e2/testing/mozharness/configs/android/androidx86_7_0.py#20

or similar.

<android-sdk> is usually installed as a taskcluster "fetch", so $MOZ_FETCHES_DIR/android-sdk-linux/platform-tools/adb should do it.

https://searchfox.org/mozilla-central/rev/f351e19360729b351bfc7c1386d6e4ca4ea676e2/testing/mozharness/scripts/android_emulator_unittest.py#207-213

Flags: needinfo?(whole.grains)

Thanks, that seems to have worked!(In reply to Geoff Brown [:gbrown] from comment #5)

<android-sdk> is usually installed as a taskcluster "fetch", so $MOZ_FETCHES_DIR/android-sdk-linux/platform-tools/adb should do it.

Thanks, that seems to have worked!

There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:valentin, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(valentin.gosu)
Flags: needinfo?(dd.mozilla)

This only enables some more test on android, therefore it is not very critical.
The last update that I have was ha there is a problem with the patch. According to comment 6 it might be fix.

This bug can way for Valentin to comeback from PTO.

Flags: needinfo?(dd.mozilla)

It seems to break tests on non-android runs for some reason.
https://treeherder.mozilla.org/jobs?repo=try&revision=e932f89b8e12d5c603497c1e95d28c28d52fc5c5&selectedTaskRun=OVE8RHQRTny-t5qwSbHAPQ.0

I'm trying to figure out why.

Flags: needinfo?(valentin.gosu)
Pushed by valentin.gosu@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/1d901edbea52
Dynamically set up android port forwarding for trr tests r=necko-reviewers,dragana
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 93 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: