Closed Bug 1478502 Opened 6 years ago Closed 6 years ago

mozdevice test_root requires a rooted device

Categories

(Testing :: Mozbase, enhancement, P3)

Version 3
enhancement

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1482898

People

(Reporter: agashlin, Unassigned)

References

Details

I have been trying to use mozregression with a non-rooted Pixel, but it fails with:

>Traceback (most recent call last):
> 
>  File ".../site-packages/mozregression/launchers.py", line 66, in start
>    self._start(**kwargs)
> 
>  File ".../site-packages/mozregression/launchers.py", line 366, in _start
>    self.remote_profile = "/".join([self.adb.test_root,
> 
>  File ".../site-packages/mozdevice/adb.py", line 798, in test_root
>    if self._try_test_root(test_root):
> 
>  File ".../site-packages/mozdevice/adb.py", line 814, in _try_test_root
>    if not self.is_dir(base_path, root=True):
> 
>  File ".../site-packages/mozdevice/adb.py", line 1572, in is_dir
>    return self.shell_bool('ls -a %s/' % path, timeout=timeout, root=root)
> 
>  File ".../site-packages/mozdevice/adb.py", line 1158, in shell_bool
>    timeout=timeout, root=root)
> 
>  File ".../site-packages/mozdevice/adb.py", line 1073, in shell
>    raise ADBRootError('Can not run command %s as root!' % cmd)
> 
>ADBRootError: Can not run command ls -a /storage/sdcard0/ as root!

however if I change these lines to `root=False`:
https://searchfox.org/mozilla-central/rev/943a6cf31a96eb439db8f241ab4df25c14003bb8/testing/mozbase/mozdevice/mozdevice/adb.py#821,826-829
it will work fine. Could this perhaps instead attempt to access/delete/create the directory without root, and only attempt to use root if that fails?
That *might* work but I feel there are other places where you will hit the need for root which would still leave us with the ultimate need for a rooted device. We have always hated the fact that we need rooted devices but haven't figured out a good way to remove the requirement.

We have several options going forward:

1. You can root your device. I've recently found Magisk to be useful.

https://github.com/topjohnwu/Magisk/releases
https://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445 using Magisk Manager.

I know this isn't something I would like to do on my personal phone and can understand if you don't want to do it either. With a fast network you can easily download the factory images and restore your device afterwards, but restoring your personal data and settings would be a pain.

2. You can help us out by trying your suggested change on try and then chasing down the other places which current specify root=True and seeing which ones you can remove. You'll need to make sure to test the physical devices @ bitbar (platform android-hw) since the emulators all run as root. We currently only have mochitest dom media tests and jit tests enabled. To get full coverage you would need to enable the tests you are interested in.

I don't recommend this as I expect you will still find instances where root will be required and it isn't guaranteed that this will result in a win for you and it is guaranteed to take a lot of your time.

3. You can enable whatever tests you are running on try. You will be able to manually bisect using the physical devices. This would work but isn't the greatest solution either.

A future possibility would be to ask the mozregression owners if they would support running tests on try. Then you could easily do bisections there.

4. Request a pixel device from service desk. I recommend Pixel2 unless you are definitely interested in an original Pixel since all of our future devices @ bitbar will be Pixel2.

The cost of a Pixel2 is nothing compared to the amount of time that would be required to support an unrooted device.

5. Autophone has one old Pixel that hasn't broken which we could transfer to you. That would solve your problem but leave it to the next person.
Yeah, it's a personal phone and I don't do enough Android work to justify getting one just for testing, every once in a while I just spot something and this is the first time I've tried to track it down.

I'm going with a variant of #2, I'll just run with those changes locally for when I need to do a bisection, and if I find more time I'll give it a spin on try.

Thanks!
>That *might* work but I feel there are other places where you will hit the need for root which would still leave us with the ultimate need for a rooted device.

I'm a bit confused what mozregression does that would require root in the first place. Is this for launching an activitiy with a specific URL or something? Just having a fallback that installs and launches the correct Android build would cover so many use cases.

And yes, I have a Pixel 2 that I can root, but that doesn't help if the bug is reported in the field or device specific.
It is not so much what mozregression does but what the test frameworks do such as accessing various locations in storage and killing processes which are not owned by the shell user or other things that might pop up such as accessing locations owned by a different user. Our test frameworks were developed for android emulators which run the shell as root by default and as a result tend to hide where root is actually required.
Priority: -- → P3
Depends on: 1482898
See Also: → 1482843
This is essentially a duplicate of bug 1482898, where we have applied a fix for this exact issue.

This isn't the first time that mozdevice changes have broken mozregression. It's not really a surprise, since we have no automated testing of the interaction between the two, and mozregression's requirements are easily forgotten. My eventual plan is to make mozregression use python-adb instead of mozdevice for interfacing with the device, which should fix the problem for good. See: https://bugzilla.mozilla.org/show_bug.cgi?id=1425102
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
No longer depends on: 1482898

agashlin: This may have been fixed by mozdevice 4.0.0 and mozregression 4.0.11.

You need to log in before you can comment on or make changes to this bug.