Closed
Bug 735461
Opened 13 years ago
Closed 13 years ago
Robocop: Fennec does not interpret -profile argument correctly
Categories
(Testing :: Mochitest, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla16
People
(Reporter: gbrown, Assigned: gbrown)
References
Details
Attachments
(1 file, 8 obsolete files)
5.46 KB,
patch
|
blassey
:
review+
|
Details | Diff | Splinter Review |
When Fennec is started for a robocop test, it appears to contain the bookmarks, history, and top sites associated with the default profile on the phone.
Robocop creates, populates, and destroys its own profile directory at <tests>/profile, eg. /mnt/sdcard/tests/profile ... but it doesn't seem to use it!
A typical command line for launching Fennec from Robocop, as seen by devicemanagerADB.launchProcess:
['am', 'instrument', '-w', '-e', 'class', 'org.mozilla.fennec_mozdev.tests.testLoad', 'org.mozilla.roboexample.test/android.test.InstrumentationTestRunner']
Note that there is no -profile argument.
![]() |
Assignee | |
Comment 1•13 years ago
|
||
remoteautomation is aware of the remote profile, but ignores it, here:
https://hg.mozilla.org/mozilla-central/annotate/956e2f735262/build/mobile/remoteautomation.py#l125
...so it almost looks intentional...but I can't think of why.
![]() |
Assignee | |
Comment 2•13 years ago
|
||
(In reply to Geoff Brown [:gbrown] from comment #1)
> ...so it almost looks intentional...but I can't think of why.
Oh, of course -- this is just starting InstrumentationTestRunner, which wouldn't know what to do with -profile. The -profile stuff is in:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/tests/BaseTest.java.in#54
![]() |
Assignee | |
Comment 3•13 years ago
|
||
Robocop tests specify "-profile <dir>" on the Fennec command line, but there is some confusion in Fennec about the interpretation of these arguments. In Gecko (nsAppRunner), I think -profile <dir> is interpreted as intended -- use the specified directory as the profile directory.
But since bug 708651, Fennec (GeckoApp / GeckoProfile) interprets <dir> as a profile name:
https://hg.mozilla.org/mozilla-central/annotate/c71845b3b2a6/mobile/android/base/GeckoApp.java#l1657
Complicating issues, '/' is not expected in the profile name, so the -profile argument is mostly ignored.
![]() |
Assignee | |
Comment 4•13 years ago
|
||
![]() |
Assignee | |
Comment 5•13 years ago
|
||
More considerations:
1. Apparently we need to support both -profile <profile-dir> and -P <profile-name>
2. Database data is stored outside of the profile.
![]() |
Assignee | |
Updated•13 years ago
|
Summary: Robocop: Fennec is not using remote profile → Robocop: Fennec does not interpret -profile argument correctly
![]() |
Assignee | |
Comment 6•13 years ago
|
||
This accepts both -profile <profile-dir> and -P <profile-name> arguments. The profile name is used by BrowserDB to select a database name. This allows a test harness to select a database other than the default.
Attachment #605629 -
Attachment is obsolete: true
Attachment #610013 -
Flags: review?(blassey.bugs)
![]() |
Assignee | |
Comment 7•13 years ago
|
||
Attachment #610014 -
Flags: review?(blassey.bugs)
![]() |
Assignee | |
Updated•13 years ago
|
Attachment #610013 -
Attachment description: support -profile and -P command line arguments → patch 1/2: support -profile and -P command line arguments
Comment 8•13 years ago
|
||
Comment on attachment 610014 [details] [diff] [review]
patch 2/2: update robocop to use and cleanup its own DB with the -P argument
Review of attachment 610014 [details] [diff] [review]:
-----------------------------------------------------------------
let's not change the tests to work around this bug, instead fix the bug
Attachment #610014 -
Flags: review?(blassey.bugs) → review-
Comment 9•13 years ago
|
||
Comment on attachment 610013 [details] [diff] [review]
patch 1/2: support -profile and -P command line arguments
Review of attachment 610013 [details] [diff] [review]:
-----------------------------------------------------------------
this code looks approximately correct, but as we just discussed over vidyo LocalBrowserDB needs to base the content provider URI on the profile path not the profile name
Attachment #610013 -
Flags: review?(blassey.bugs) → review-
![]() |
Assignee | |
Comment 10•13 years ago
|
||
Attachment #610013 -
Attachment is obsolete: true
Attachment #610014 -
Attachment is obsolete: true
Attachment #610945 -
Flags: review?(blassey.bugs)
![]() |
Assignee | |
Comment 11•13 years ago
|
||
(Sorry - fingers slipped!)
I feel better about this patch. Now the test strategy stays the same and none of the test harness code needs to change: tests pass -profile <dir> and then clean up <dir> when done. When -profile is specified, the database is stored in the profile directory, so now history, bookmarks, and topsites are clean when running robocop tests.
Attachment #610945 -
Attachment is obsolete: true
Attachment #610948 -
Flags: review?(blassey.bugs)
Attachment #610945 -
Flags: review?(blassey.bugs)
Comment 12•13 years ago
|
||
Comment on attachment 610948 [details] [diff] [review]
support -profile and -P command line arguments
Review of attachment 610948 [details] [diff] [review]:
-----------------------------------------------------------------
r- to see another patch that drops the BrowserContract.PARAM_PROFILE
::: mobile/android/base/GeckoApp.java
@@ +1621,5 @@
> }
>
> + if (profilePath != null) {
> + BrowserDB.init((String)null, profilePath);
> + } else {
if (profilePath != null)
BrowserDB.init((String)null, profilePath);
else if (profileName != null)
BrowserDB.init(profileName, (String)null);
else
BrowserDB.init(BrowserContract.DEFAULT_PROFILE, (String)null);
or... add these checks in BrowserDB.init and just pass profileName and profileDir directly
::: mobile/android/base/db/LocalBrowserDB.java
@@ +142,5 @@
> private Uri appendProfile(Uri uri) {
> + if (mProfilePath != null) {
> + return uri.buildUpon().appendQueryParameter(BrowserContract.PARAM_PROFILE_PATH, mProfilePath).build();
> + }
> + return uri.buildUpon().appendQueryParameter(BrowserContract.PARAM_PROFILE, mProfileName).build();
let's drop the BrowserContract.PARAM_PROFILE constant entirely and do a look up of the profile path from the profile name if the profile path is null.
Comment 13•13 years ago
|
||
Comment on attachment 610948 [details] [diff] [review]
support -profile and -P command line arguments
Review of attachment 610948 [details] [diff] [review]:
-----------------------------------------------------------------
r- to see another patch that drops the BrowserContract.PARAM_PROFILE
::: mobile/android/base/GeckoApp.java
@@ +1621,5 @@
> }
>
> + if (profilePath != null) {
> + BrowserDB.init((String)null, profilePath);
> + } else {
if (profilePath != null)
BrowserDB.init((String)null, profilePath);
else if (profileName != null)
BrowserDB.init(profileName, (String)null);
else
BrowserDB.init(BrowserContract.DEFAULT_PROFILE, (String)null);
or... add these checks in BrowserDB.init and just pass profileName and profileDir directly
::: mobile/android/base/db/LocalBrowserDB.java
@@ +142,5 @@
> private Uri appendProfile(Uri uri) {
> + if (mProfilePath != null) {
> + return uri.buildUpon().appendQueryParameter(BrowserContract.PARAM_PROFILE_PATH, mProfilePath).build();
> + }
> + return uri.buildUpon().appendQueryParameter(BrowserContract.PARAM_PROFILE, mProfileName).build();
let's drop the BrowserContract.PARAM_PROFILE constant entirely and do a look up of the profile path from the profile name if the profile path is null.
Attachment #610948 -
Flags: review?(blassey.bugs) → review-
![]() |
Assignee | |
Comment 14•13 years ago
|
||
> if (profilePath != null)
> BrowserDB.init((String)null, profilePath);
> else if (profileName != null)
> BrowserDB.init(profileName, (String)null);
> else
> BrowserDB.init(BrowserContract.DEFAULT_PROFILE, (String)null);
Good idea - thanks!
> let's drop the BrowserContract.PARAM_PROFILE constant entirely and do a look
> up of the profile path from the profile name if the profile path is null.
This is more complicated than you might expect. There is additional logic in the provider that sometimes uses a different path than the directory associated with the named profile:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/db/BrowserProvider.java.in#921
That logic could be moved into LocalBrowserDB (or perhaps all the way back to GeckoApp, since we also need a Context to use the GeckoProfile), but I think it's better (more flexible) to keep it the way it is:
- LocalBrowserDB provides the profile request info (name or path)
- the provider determines the appropriate database location for the request
Attachment #610948 -
Attachment is obsolete: true
Attachment #611989 -
Flags: review?(blassey.bugs)
Comment 15•13 years ago
|
||
(In reply to Geoff Brown [:gbrown] from comment #14)
> > let's drop the BrowserContract.PARAM_PROFILE constant entirely and do a look
> > up of the profile path from the profile name if the profile path is null.
>
> This is more complicated than you might expect. There is additional logic in
> the provider that sometimes uses a different path than the directory
> associated with the named profile:
>
> http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/db/
> BrowserProvider.java.in#921]
here is the code in question:
921 public String getDatabasePath(String profile, boolean isTest) {
922 trace("Getting database path for profile: " + profile);
923
924 // On Android releases older than 2.3, it's not possible to use
925 // SQLiteOpenHelper with a full path. Fallback to using separate
926 // db files per profile in the app directory.
927 if (isTest) {
928 return DATABASE_NAME;
929 } else if(Build.VERSION.SDK_INT <= 8) {
930 return "browser-" + profile + ".db";
931 }
932
933 File profileDir = GeckoProfile.get(mContext, profile).getDir();
<snip>
How about we delete lines 927 - 931 and add this after 933:
if (Build.VERSION.SDK_INT <= 8)
return "browser-" + profileDir..getAbsolutePath().replace("/", "_") + ".db";
Comment 16•13 years ago
|
||
Comment on attachment 611989 [details] [diff] [review]
support -profile and -P command line arguments
Review of attachment 611989 [details] [diff] [review]:
-----------------------------------------------------------------
clearing the review based on my previous comment.
Attachment #611989 -
Flags: review?(blassey.bugs)
![]() |
Assignee | |
Comment 17•13 years ago
|
||
> if (Build.VERSION.SDK_INT <= 8)
> return "browser-" + profileDir..getAbsolutePath().replace("/", "_") + ".db";
That gives us a unique name, but it's not the same name: so older phones will lose their existing history / bookmarks / etc. - is that going to be okay?
In testing this, I realized that the older phones, including the tegras, will have their DB location constrained to something outside of the requested -profile. So this patch will change the tests from using the default database to using a test database...but that test database will not be cleaned up - not much of a win. More work to do...
Attachment #611989 -
Attachment is obsolete: true
Comment 18•13 years ago
|
||
(In reply to Geoff Brown [:gbrown] from comment #17)
> Created attachment 612355 [details] [diff] [review]
> suppor -profile and -P command line arguments
>
> > if (Build.VERSION.SDK_INT <= 8)
> > return "browser-" + profileDir..getAbsolutePath().replace("/", "_") + ".db";
>
> That gives us a unique name, but it's not the same name: so older phones
> will lose their existing history / bookmarks / etc. - is that going to be
> okay?
Yup, it will only effect nightly and aurora users. Also, anyone wiht sync set up will recover.
Comment 19•13 years ago
|
||
Geoff, since this seems to have stalled out let's get the fix landed for everything but Froyo and file a follow up but to fix Froyo.
Comment 20•13 years ago
|
||
Making sure that Wes and Vlad are aware of the changes since it affects profile and startup params. Chromeless activities might be affected by these changes (maybe in a positive way).
See bug 715307 for a patch about reading the profile from profile.ini
See bug 740586 about the chromeless window patch
This looks like it has part of the patch from bug 715307 in it, right?
![]() |
Assignee | |
Comment 22•13 years ago
|
||
Previous patch updated for bitrot.
Attachment #612355 -
Attachment is obsolete: true
![]() |
Assignee | |
Comment 23•13 years ago
|
||
(In reply to Vladimir Vukicevic (:vlad) from comment #21)
> This looks like it has part of the patch from bug 715307 in it, right?
I don't think so -- it looks different to me. I was unaware of that bug before today.
![]() |
Assignee | |
Comment 24•13 years ago
|
||
Comment on attachment 628004 [details] [diff] [review]
support -profile and -P command line arguments
So this is the patch exactly as it was during the last round of review comments, just updated for bitrot.
Looking at it with fresh eyes, I feel better about it. It doesn't break any tests. For Gingerbread and beyond, it fixes the -profile handling; for Froyo, it does not but we can come back to that...and also it changes the db name, causing a one-time loss of history. Good enough?
Attachment #628004 -
Flags: review?(blassey.bugs)
![]() |
Assignee | |
Comment 25•13 years ago
|
||
(In reply to Geoff Brown [:gbrown] from comment #24)
> ...It doesn't break any tests.
Now I am not so sure. I have good results when I run tests locally, but a try run is showing random failures in robocop (mochitest-robotium): https://tbpl.mozilla.org/?tree=Try&rev=0dd1c4608640
Updated•13 years ago
|
Attachment #628004 -
Flags: review?(blassey.bugs) → review+
![]() |
Assignee | |
Comment 26•13 years ago
|
||
(In reply to Geoff Brown [:gbrown] from comment #25)
> try run is showing random failures in robocop (mochitest-robotium):
I have investigated testBookmark and testBookmarklet failures. BrowserProvider sometimes gets a uri that does not contain profilePath= and that isn't handled well, typically resulting in a NullPointerException.
![]() |
Assignee | |
Comment 27•13 years ago
|
||
Here's a new, simpler approach: When -profile <path> is specified, create a GeckoProfile entry for {name="default", path=<path>} and leave BrowserProvider, etc untouched.
With the current code, this does not solve our testing problem on the tegras, because databases are created outside of the profile on Froyo. However, with the proposed patch for bug 768532, testing shows that the database moves to the requested path of /mnt/sdcard/tests/profile.
Attachment #628004 -
Attachment is obsolete: true
Attachment #637728 -
Flags: review?(blassey.bugs)
![]() |
Assignee | |
Comment 28•13 years ago
|
||
Try run is not as green as I would like, but I think it is okay (I'll keep testing):
https://tbpl.mozilla.org/?tree=Try&rev=815db8392a4d
Updated•13 years ago
|
Attachment #637728 -
Flags: review?(blassey.bugs) → review+
![]() |
Assignee | |
Comment 29•13 years ago
|
||
Comment 30•13 years ago
|
||
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla16
You need to log in
before you can comment on or make changes to this bug.
Description
•