Bug 95346 - Get rid of device/host clock synchronization.
Summary: Get rid of device/host clock synchronization.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Android Unspecified
: P2 Normal
Assignee: Peter Beverloo
URL:
Keywords:
Depends on: 96393
Blocks: 91872
  Show dependency treegraph
 
Reported: 2012-08-29 08:18 PDT by Philippe Liard
Modified: 2012-09-11 10:27 PDT (History)
8 users (show)

See Also:


Attachments
Patch (12.97 KB, patch)
2012-08-29 08:27 PDT, Philippe Liard
no flags Details | Formatted Diff | Diff
Patch (16.07 KB, patch)
2012-08-31 05:39 PDT, Philippe Liard
no flags Details | Formatted Diff | Diff
Patch (16.07 KB, patch)
2012-08-31 05:55 PDT, Philippe Liard
no flags Details | Formatted Diff | Diff
Patch (16.07 KB, patch)
2012-09-05 02:36 PDT, Philippe Liard
no flags Details | Formatted Diff | Diff
Patch (16.31 KB, patch)
2012-09-05 04:55 PDT, Philippe Liard
no flags Details | Formatted Diff | Diff
Patch (16.14 KB, patch)
2012-09-10 05:31 PDT, Philippe Liard
no flags Details | Formatted Diff | Diff
Patch (16.71 KB, patch)
2012-09-10 05:54 PDT, Philippe Liard
no flags Details | Formatted Diff | Diff
Patch (16.81 KB, patch)
2012-09-10 07:16 PDT, Philippe Liard
no flags Details | Formatted Diff | Diff
Patch (16.80 KB, patch)
2012-09-10 08:22 PDT, Philippe Liard
no flags Details | Formatted Diff | Diff
Patch (16.85 KB, patch)
2012-09-11 02:40 PDT, Philippe Liard
no flags Details | Formatted Diff | Diff
Patch (16.92 KB, patch)
2012-09-11 05:35 PDT, Philippe Liard
no flags Details | Formatted Diff | Diff
Patch for landing (16.94 KB, patch)
2012-09-11 06:17 PDT, Peter Beverloo
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Liard 2012-08-29 08:18:35 PDT
This prevents us from running tests on non-rooted devices.
Comment 1 Philippe Liard 2012-08-29 08:27:31 PDT
Created attachment 161233 [details]
Patch
Comment 2 Peter Beverloo 2012-08-29 08:47:16 PDT
Comment on attachment 161233 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=161233&action=review

Thank you Philippe! A few more comments.

> Tools/ChangeLog:3
> +        Support LayoutTests on non-rooted devices for Chromium Android.

This should be equal to the bug's title. Maybe this would work?

Get rid of device/host clock synchronization for Chromium Android.

> Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py:44
> +    os.path.join(os.environ['CHROME_SRC'], 'build', 'android', 'pylib'))

Peter:
I'm not comfortable introducing this dependency. We're trying to get rid of dependencies on environment variable (like CHROME_SRC), and since we need adb commands in order parts of WebKit as well, I'd prefer to have a smaller but similar runner on the WebKit side. This is out of scope, but is there any way we can work around needing this right now?

Philippe:
I can avoid relying on $CHROME_SRC and use a relative path assuming that this file won't be moved. Regarding the use of android_commands, AndroidCommands.PushIfNeeded() provides a way to sync data files with the device by using a custom implementation of md5sum (written in C++ and depending on Chromium's base/). Although we could have our own Python layer for that in WebKit, we can hardly do the same for md5sum (I don't think you want to duplicate it either). So it seems that we would have to use Chromium's md5sum (being submitted under tools/android/md5sum) anyway.

Since we own that file, which is Chromium-specific, I think that preventing us from depending on Chromium might be an unnecessary constraint. I agree that we could introduce at least a thin layer in WebKit, calling Chromium's python, rather than calling it directly though.
But I'm sure that I don't see the full picture since this is my first WebKit contribution. What do you think? Is this dependency to Chromium the only one?

Peter:
The relative path would be different depending on whether layout tests are being run in a Chromium or WebKit environment (from WebKit's root: ../../build/android/pylib/ for Chromium versus Source/WebKit/chromium/build/android/pylib/ for WebKit). I don't think anything else in the layout tests runners depend on Chromium code right now, which also is the reason we have our own adb interface. Since we only need a subset of functionality here, and we need it for running other targets as well, eventually we'll probably end up with a script of our own.

Going back to this case: CHROME_SRC will not be available when running layout tests in a WebKit environment, which is my worry. If we can add the md5sum target as a dependency of DumpRenderTree, will that allow you to implement a similar PushIfNeeded method in the ChromiumAndroidDriver?

> LayoutTests/http/tests/cache/resources/current-time.cgi:5
> +print time()

nit: statements end with a semi-colon.

> LayoutTests/http/tests/cache/resources/subresource-test.js:28
> +var serverClientTimeDelta = getServerDate().getTime() - new Date().getTime();

Thanks! Very minor nit for readability: maybe define this property after the getServerDate() function?
Comment 3 Dirk Pranke 2012-08-29 09:36:00 PDT
Note that you can use self.path_from_chromium_base() in the python code instead of relying on CHROME_SRC. That will work reliably in both a webkit-in-chromium or chromium-in-webkit checkout.
Comment 4 Philippe Liard 2012-08-29 09:52:02 PDT
(In reply to comment #3)
> Note that you can use self.path_from_chromium_base() in the python code instead of relying on CHROME_SRC. That will work reliably in both a webkit-in-chromium or chromium-in-webkit checkout.

Nice. Going back to your comment Peter, can I use what Dirk suggested to include the android_commands module and use AndroidCommands.PushIfNeeded() or do we still really want to avoid this dependency (which would make this patch much larger)? My understanding is that if we have a way to fetch chromium's path, it might not be totally alien to depend on some code coming from it.
Comment 5 Peter Beverloo 2012-08-30 05:56:27 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > Note that you can use self.path_from_chromium_base() in the python code instead of relying on CHROME_SRC. That will work reliably in both a webkit-in-chromium or chromium-in-webkit checkout.
> 
> Nice. Going back to your comment Peter, can I use what Dirk suggested to include the android_commands module and use AndroidCommands.PushIfNeeded() or do we still really want to avoid this dependency (which would make this patch much larger)? My understanding is that if we have a way to fetch chromium's path, it might not be totally alien to depend on some code coming from it.

There are a number of similar dependencies WebKit has on Chromium already. The implication of starting to rely on test-runner scripts is that refactoring / "API" changes would need the new method to be introduced on the Chromium side, then usage of the old versions removed within WebKit, before the old code can be removed. A cross-project three-way patch is significantly more painful than a single patch.

Given the amount of random build breakages due to Chromium infrastructure changes recently, we should try to minimize the number of dependencies until the code stabilizes. While android_commands.py probably will be more stable, our branch still has a 165 line diff and it's not unthinkable more refactoring will happen too.

As discussed on chat, adding a dependency to md5sum in DumpRenderTree's gyp configuration is perfectly fine. It'll introduce some additional code for now, but we'll be able to clean that up later again.
Comment 6 Philippe Liard 2012-08-31 05:39:45 PDT
Created attachment 161674 [details]
Patch
Comment 7 WebKit Review Bot 2012-08-31 05:46:58 PDT
Comment on attachment 161674 [details]
Patch

Attachment 161674 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13725122
Comment 8 Peter Beverloo (cr-android ews) 2012-08-31 05:51:26 PDT
Comment on attachment 161674 [details]
Patch

Attachment 161674 [details] did not pass cr-android-ews (chromium-android):
Output: http://queues.webkit.org/results/13728063
Comment 9 Philippe Liard 2012-08-31 05:52:41 PDT
FYI, the try bots fail because this CL depends on https://chromiumcodereview.appspot.com/10867008/ which is not submitted yet.
Comment 10 Philippe Liard 2012-08-31 05:55:33 PDT
Created attachment 161680 [details]
Patch
Comment 11 Philippe Liard 2012-08-31 05:57:29 PDT
I uploaded a new patch. Is that the right way to iterate on a CL? I'm still new to the WebKit contribution process :)

Quick question: does ChromiumAndroidDriver need to be thread safe? I added a static variable which is not guarded by any lock at the moment. I supposed that the class was accessed from a single thread. Is that correct?
Comment 12 WebKit Review Bot 2012-08-31 06:03:34 PDT
Comment on attachment 161680 [details]
Patch

Attachment 161680 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13728069
Comment 13 Peter Beverloo (cr-android ews) 2012-08-31 06:13:40 PDT
Comment on attachment 161680 [details]
Patch

Attachment 161680 [details] did not pass cr-android-ews (chromium-android):
Output: http://queues.webkit.org/results/13721160
Comment 14 Philippe Liard 2012-09-05 02:36:00 PDT
Created attachment 162197 [details]
Patch
Comment 15 Philippe Liard 2012-09-05 02:38:29 PDT
I've just re-uploaded the exact same patch now that the other CL on the chromium side has landed. This will re-trigger the try bots which will be green hopefully this time.

This is also a way to be back to the top of your inbox :)
Comment 16 Philippe Liard 2012-09-05 04:55:30 PDT
Created attachment 162220 [details]
Patch
Comment 17 Philippe Liard 2012-09-05 05:06:03 PDT
I uploaded a new patch since the old one didn't apply correctly anymore to the current master.
Comment 18 Peter Beverloo (cr-android ews) 2012-09-05 06:04:24 PDT
Comment on attachment 162220 [details]
Patch

Attachment 162220 [details] did not pass cr-android-ews (chromium-android):
Output: http://queues.webkit.org/results/13753767
Comment 19 Philippe Liard 2012-09-05 06:12:29 PDT
Ah I forgot that we need to roll a new revision of Chromium too. I will re-trigger the try bots by uploading a new patch once we did that.
Comment 20 WebKit Review Bot 2012-09-05 09:10:18 PDT
Comment on attachment 162220 [details]
Patch

Attachment 162220 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13744971
Comment 21 Philippe Liard 2012-09-10 05:31:43 PDT
Created attachment 163098 [details]
Patch
Comment 22 WebKit Review Bot 2012-09-10 05:34:43 PDT
Comment on attachment 163098 [details]
Patch

Attachment 163098 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13804539
Comment 23 Peter Beverloo 2012-09-10 05:44:43 PDT
Comment on attachment 163098 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=163098&action=review

A few minor nits. Looks fine overall, except for the build failure (I commented on that later on).

> Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp:128
> +                '<(chromium_src_dir)/tools/android/md5sum/md5sum.gyp:md5sum',

This needs to be specific to Android, i.e. in a conditional block.

> Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py:328
> +        if not worker_number in self._data_already_pushed_for_worker:

The _data_already_pushed_for_worker variable is a member of this class, and since this is the __init__ method, won't it always be empty at this point?

> Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py:385
> +                                 stdout=subprocess.PIPE).stdout)

nit: It's fine to leave it like this (since it may become unreadable otherwise), but WebKit has no limit on line lengths.

> Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py:677
> +                if last_char in ['#', '$']:

nit: could use a tuple here (which is preferred for lists in gyp).
Comment 24 Philippe Liard 2012-09-10 05:54:32 PDT
Created attachment 163105 [details]
Patch
Comment 25 Philippe Liard 2012-09-10 06:23:43 PDT
Comment on attachment 163098 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=163098&action=review

>> Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp:128
>> +                '<(chromium_src_dir)/tools/android/md5sum/md5sum.gyp:md5sum',
> 
> This needs to be specific to Android, i.e. in a conditional block.

Indeed.

>> Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py:328
>> +        if not worker_number in self._data_already_pushed_for_worker:
> 
> The _data_already_pushed_for_worker variable is a member of this class, and since this is the __init__ method, won't it always be empty at this point?

I'm still quite new to Python. I wanted to make it a static member. Isn't that the case? I read somewhere that member variables declared in the non-method scope are static.
Comment 26 Peter Beverloo 2012-09-10 06:27:50 PDT
(In reply to comment #25)
> (From update of attachment 163098 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=163098&action=review
> 
> >> Tools/DumpRenderTree/DumpRenderTree.gyp/DumpRenderTree.gyp:128
> >> +                '<(chromium_src_dir)/tools/android/md5sum/md5sum.gyp:md5sum',
> > 
> > This needs to be specific to Android, i.e. in a conditional block.
> 
> Indeed.
> 
> >> Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py:328
> >> +        if not worker_number in self._data_already_pushed_for_worker:
> > 
> > The _data_already_pushed_for_worker variable is a member of this class, and since this is the __init__ method, won't it always be empty at this point?
> 
> I'm still quite new to Python. I wanted to make it a static member. Isn't that the case? I read somewhere that member variables declared in the non-method scope are static.

Ah, I see. You probably should be using "ChromiumAndroidDriver._data_already_pushed_for_worker" to access the variable, then.

The rest LGTM.
Comment 27 Philippe Liard 2012-09-10 07:16:04 PDT
Created attachment 163125 [details]
Patch
Comment 28 Philippe Liard 2012-09-10 07:18:06 PDT
Comment on attachment 163098 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=163098&action=review

>>> Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py:328
>>> +        if not worker_number in self._data_already_pushed_for_worker:
>> 
>> The _data_already_pushed_for_worker variable is a member of this class, and since this is the __init__ method, won't it always be empty at this point?
> 
> I'm still quite new to Python. I wanted to make it a static member. Isn't that the case? I read somewhere that member variables declared in the non-method scope are static.

I have updated this part to refer to the static variable through 'ChromiumAndroidDriver' rather than 'self' which doesn't make sense for a non-instance member.
Comment 29 Peter Beverloo 2012-09-10 07:22:02 PDT
Thanks! Adam, could you do a formal review please?
Comment 30 WebKit Review Bot 2012-09-10 08:03:33 PDT
Comment on attachment 163125 [details]
Patch

Attachment 163125 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/13796915

New failing tests:
http/tests/cache/subresource-expiration-2.html
http/tests/cache/subresource-expiration-1.html
Comment 31 Philippe Liard 2012-09-10 08:06:06 PDT
I'm looking at the test failures.
Comment 32 Philippe Liard 2012-09-10 08:20:06 PDT
I believe the failure is due to the missing execution permission on current-time.cgi. I will re-upload a patch right now.
Comment 33 Philippe Liard 2012-09-10 08:22:40 PDT
Created attachment 163137 [details]
Patch
Comment 34 Dirk Pranke 2012-09-10 15:11:07 PDT
Comment on attachment 163137 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=163137&action=review

> Tools/Scripts/webkitpy/layout_tests/port/chromium.py:410
> +                                 'Please pass --%s.', configuration, most_recent_binary, most_recent_binary.lower())

As an aside, this warning has always kinda annoyed me since there's no way to make it go away; if you're trying to run both Release and Debug, one will always be newer than the other (unless you hack the mtime, of course). I wonder how much this warning actually helps people.

> Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py:385
> +                                 stdout=subprocess.PIPE).stdout)

You can use self._port.host.executive.popen() here and below -  that's slightly preferred to calling subprocess.Popen() directly.
Comment 35 Philippe Liard 2012-09-11 02:40:43 PDT
Created attachment 163313 [details]
Patch
Comment 36 Philippe Liard 2012-09-11 02:47:17 PDT
Comment on attachment 163137 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=163137&action=review

>> Tools/Scripts/webkitpy/layout_tests/port/chromium.py:410
>> +                                 'Please pass --%s.', configuration, most_recent_binary, most_recent_binary.lower())
> 
> As an aside, this warning has always kinda annoyed me since there's no way to make it go away; if you're trying to run both Release and Debug, one will always be newer than the other (unless you hack the mtime, of course). I wonder how much this warning actually helps people.

This kind of code is duplicated across multiple places in the Chromium Android Python codebase. We clearly miss a way to figure out the build type in a single line regardless of the language (Python or Shell). I think we have a bug tracking that. If I remember correctly we plan to make GYP output the build type to a file in out/. This code can be updated once we landed that change.

>> Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py:385
>> +                                 stdout=subprocess.PIPE).stdout)
> 
> You can use self._port.host.executive.popen() here and below -  that's slightly preferred to calling subprocess.Popen() directly.

Done.
Comment 37 Peter Beverloo 2012-09-11 03:18:30 PDT
Comment on attachment 163313 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=163313&action=review

Thanks Philippe!

> Tools/ChangeLog:5
> +

This needs a "Reviewed by" line. As Dirk already reviewed it, it's fine to add "Reviewed by Dirk Pranke".

> LayoutTests/ChangeLog:5
> +

dito.
Comment 38 Philippe Liard 2012-09-11 05:35:10 PDT
Created attachment 163341 [details]
Patch
Comment 39 Philippe Liard 2012-09-11 05:37:27 PDT
Comment on attachment 163313 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=163313&action=review

>> Tools/ChangeLog:5
>> +
> 
> This needs a "Reviewed by" line. As Dirk already reviewed it, it's fine to add "Reviewed by Dirk Pranke".

Done.

>> LayoutTests/ChangeLog:5
>> +
> 
> dito.

Done.
Comment 40 Peter Beverloo 2012-09-11 06:17:27 PDT
Created attachment 163345 [details]
Patch for landing
Comment 41 Peter Beverloo 2012-09-11 06:18:24 PDT
Comment on attachment 163345 [details]
Patch for landing

Putting on the queue. I only touched _setup_md5sum() to make sure it works both on Chromium and on WebKit, of course with Philippe's consent.
Comment 42 WebKit Review Bot 2012-09-11 07:10:25 PDT
Comment on attachment 163345 [details]
Patch for landing

Clearing flags on attachment: 163345

Committed r128181: <http://trac.webkit.org/changeset/128181>
Comment 43 WebKit Review Bot 2012-09-11 07:10:31 PDT
All reviewed patches have been landed.  Closing bug.
Comment 44 James Robinson 2012-09-11 09:45:13 PDT
This broke webkitpy-test, at least on mac:

http://build.webkit.org/builders/Chromium%20Linux%20Release%20%28Tests%29/builds/38183/steps/webkitpy-test/logs/stdio

[462/1616] webkitpy.layout_tests.port.chromium_android_unittest.ChromiumAndroidDriverTest.test_cmd_line erred:
  Traceback (most recent call last):
    File "/mnt/data/b/WebKit-BuildSlave/chromium-linux-release-tests/build/Tools/Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py", line 175, in setUp
      self.driver = chromium_android.ChromiumAndroidDriver(self.port, worker_number=0, pixel_tests=True)
    File "/mnt/data/b/WebKit-BuildSlave/chromium-linux-release-tests/build/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py", line 327, in __init__
      self._setup_md5sum()
    File "/mnt/data/b/WebKit-BuildSlave/chromium-linux-release-tests/build/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py", line 340, in _setup_md5sum
      assert os.path.exists(self._md5sum_path)
  AssertionError
Comment 45 Philippe Liard 2012-09-11 09:46:38 PDT
Yeah it did. Sorry for the inconvenience. The fix has just landed: https://bugs.webkit.org/show_bug.cgi?id=96393.
Comment 46 Peter Beverloo 2012-09-11 09:53:25 PDT
The Qt bot is happy again:
http://build.webkit.org/builders/GTK%20Linux%2032-bit%20Release/builds/26726/steps/webkitpy-test/logs/stdio

Closing.
Comment 47 Dirk Pranke 2012-09-11 10:27:42 PDT
(In reply to comment #36)
> (From update of attachment 163137 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=163137&action=review
> 
> >> Tools/Scripts/webkitpy/layout_tests/port/chromium.py:410
> >> +                                 'Please pass --%s.', configuration, most_recent_binary, most_recent_binary.lower())
> > 
> > As an aside, this warning has always kinda annoyed me since there's no way to make it go away; if you're trying to run both Release and Debug, one will always be newer than the other (unless you hack the mtime, of course). I wonder how much this warning actually helps people.
> 
> This kind of code is duplicated across multiple places in the Chromium Android Python codebase. We clearly miss a way to figure out the build type in a single line regardless of the language (Python or Shell). I think we have a bug tracking that. If I remember correctly we plan to make GYP output the build type to a file in out/. This code can be updated once we landed that change.
> 

You lost me here. I think you're talking about something different from what I'm talking about; are you talking about picking the "correct" configuration by default so that you don't have to specify either --release or --debug to get the one you want? You can use set-webkit-configuration to specify that. I'm talking about what happens when you have *both* release and debug configurations and are alternating between them - one of them will *always* produce this error.