Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Issue 2024813004: Improving the fake clock and using it to fix a flaky STUN timeout test. (Closed)

Created:
4 years, 6 months ago by Taylor Brandstetter
Modified:
4 years, 6 months ago
CC:
webrtc-reviews_webrtc.org, tterriberry_mozilla.com
Base URL:
https://chromium.googlesource.com/external/webrtc.git@master
Target Ref:
refs/pending/heads/master
Project:
webrtc
Visibility:
Public.

Description

Reland of: Improving the fake clock and using it to fix a flaky STUN timeout test. When the fake clock's time is advanced, it now ensures all pending queued messages have been dispatched. This allows us to write a "SIMULATED_WAIT" macro that ticks the simulated clock by milliseconds up until the target time. Useful in this case, where we know the STUN timeout should take a total of 9500ms, but it would be overly complex to write test code that waits for each individual timeout, ensures a STUN packet has been retransmited, etc. (The test described above *should* be written, but it belongs in p2ptransportchannel_unittest.cc, not webrtcsession_unittest.cc). Committed: https://crrev.com/f5f03e823c2d522e84fce46bc8a7d57f913032ba Cr-Commit-Position: refs/heads/master@{#13052}

Patch Set 1 #

Total comments: 1

Patch Set 2 : Revising comments etc. #

Total comments: 10

Patch Set 3 : Addressing comments. #

Total comments: 6

Patch Set 4 : Renaming SetClock to SetClockForTesting. #

Patch Set 5 : Merge with master #

Patch Set 6 : Fixing compile warning (wanted 'override' on destructor) #

Patch Set 7 : Fix TSAN warning. #

Patch Set 8 : Fixing memory leak in unrelated test, which left an orphaned thread. #

Patch Set 9 : Fixing another TSan warning. #

Patch Set 10 : Fixing double linkage of testclock.cc. #

Patch Set 11 : Fixing another TSan warning. WebRtcSession wasn't completely shut down. #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+144 lines, -62 lines) Patch
M webrtc/api/webrtcsession_unittest.cc View 1 2 3 4 5 6 7 8 9 10 3 chunks +10 lines, -8 lines 0 comments Download
M webrtc/base/base_tests.gyp View 1 2 3 4 2 chunks +3 lines, -0 lines 0 comments Download
M webrtc/base/fakeclock.h View 1 2 3 4 5 6 7 2 chunks +13 lines, -0 lines 0 comments Download
M webrtc/base/fakeclock.cc View 1 2 3 4 5 6 7 1 chunk +15 lines, -5 lines 1 comment Download
M webrtc/base/gunit.h View 1 2 4 chunks +49 lines, -5 lines 0 comments Download
M webrtc/base/messagequeue.h View 2 chunks +6 lines, -7 lines 0 comments Download
M webrtc/base/messagequeue.cc View 1 2 3 4 5 6 7 8 3 chunks +24 lines, -18 lines 0 comments Download
M webrtc/base/signalthread_unittest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +3 lines, -0 lines 0 comments Download
M webrtc/base/timeutils.h View 1 2 3 2 chunks +5 lines, -3 lines 1 comment Download
M webrtc/base/timeutils.cc View 1 2 3 1 chunk +3 lines, -1 line 0 comments Download
M webrtc/base/timeutils_unittest.cc View 1 2 3 4 chunks +13 lines, -12 lines 0 comments Download
M webrtc/webrtc_tests.gypi View 1 2 3 4 5 6 7 8 9 2 chunks +0 lines, -3 lines 0 comments Download

Messages

Total messages: 32 (15 generated)
Taylor Brandstetter
https://codereview.webrtc.org/2024813004/diff/1/webrtc/base/gunit.h File webrtc/base/gunit.h (right): https://codereview.webrtc.org/2024813004/diff/1/webrtc/base/gunit.h#newcode28 webrtc/base/gunit.h:28: rtc::Thread::Current()->SleepMs(1); I had to do this because if you ...
4 years, 6 months ago (2016-06-01 15:54:59 UTC) #2
pthatcher1
I think it would be good to have Tommi review this as well since it ...
4 years, 6 months ago (2016-06-01 22:38:14 UTC) #4
Taylor Brandstetter
https://codereview.webrtc.org/2024813004/diff/20001/webrtc/base/fakeclock.h File webrtc/base/fakeclock.h (right): https://codereview.webrtc.org/2024813004/diff/20001/webrtc/base/fakeclock.h#newcode45 webrtc/base/fakeclock.h:45: class ScopedFakeClock { On 2016/06/01 22:38:14, pthatcher1 wrote: > ...
4 years, 6 months ago (2016-06-01 23:28:37 UTC) #5
tommi
https://codereview.webrtc.org/2024813004/diff/40001/webrtc/base/messagequeue.cc File webrtc/base/messagequeue.cc (right): https://codereview.webrtc.org/2024813004/diff/40001/webrtc/base/messagequeue.cc#newcode133 webrtc/base/messagequeue.cc:133: // process messages as well. Is the expectation that ...
4 years, 6 months ago (2016-06-02 07:59:01 UTC) #6
Taylor Brandstetter
https://codereview.webrtc.org/2024813004/diff/40001/webrtc/base/messagequeue.cc File webrtc/base/messagequeue.cc (right): https://codereview.webrtc.org/2024813004/diff/40001/webrtc/base/messagequeue.cc#newcode133 webrtc/base/messagequeue.cc:133: // process messages as well. On 2016/06/02 07:59:01, tommi-webrtc ...
4 years, 6 months ago (2016-06-02 17:19:54 UTC) #7
pthatcher1
lgtm
4 years, 6 months ago (2016-06-02 18:48:04 UTC) #8
tommi
lgtm
4 years, 6 months ago (2016-06-03 05:39:59 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2024813004/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2024813004/60001
4 years, 6 months ago (2016-06-03 05:40:06 UTC) #11
commit-bot: I haz the power
Try jobs failed on following builders: ios64_gn_dbg on tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/ios64_gn_dbg/builds/253) ios64_gn_rel on tryserver.webrtc (JOB_FAILED, ...
4 years, 6 months ago (2016-06-03 05:40:55 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2024813004/180001
4 years, 6 months ago (2016-06-03 22:29:51 UTC) #16
commit-bot: I haz the power
Committed patchset #10 (id:180001)
4 years, 6 months ago (2016-06-03 22:31:33 UTC) #17
commit-bot: I haz the power
Patchset 10 (id:??) landed as https://crrev.com/ffbe0e17e2c9b7fe101023acf40574dc0c95631a Cr-Commit-Position: refs/heads/master@{#13043}
4 years, 6 months ago (2016-06-03 22:31:42 UTC) #19
Taylor Brandstetter
A revert of this CL (patchset #10 id:180001) has been created in https://codereview.webrtc.org/2038213002/ by deadbeef@webrtc.org. ...
4 years, 6 months ago (2016-06-03 23:05:14 UTC) #20
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2024813004/200001
4 years, 6 months ago (2016-06-06 17:38:32 UTC) #26
commit-bot: I haz the power
Committed patchset #11 (id:200001)
4 years, 6 months ago (2016-06-06 18:16:10 UTC) #28
commit-bot: I haz the power
Patchset 11 (id:??) landed as https://crrev.com/f5f03e823c2d522e84fce46bc8a7d57f913032ba Cr-Commit-Position: refs/heads/master@{#13052}
4 years, 6 months ago (2016-06-06 18:16:19 UTC) #30
nisse-webrtc
4 years, 6 months ago (2016-06-08 09:47:30 UTC) #32
Message was sent while issue was closed.
Hi, here are a few late comments.

I haven't tried to really understand the interaction between the fake clock and
the thread machinery. 

Ideally, when using a fake clock, Thread::SleepMs() should just advance the fake
clock, but I have no idea how to make that work.

https://codereview.webrtc.org/2024813004/diff/200001/webrtc/base/fakeclock.cc
File webrtc/base/fakeclock.cc (right):

https://codereview.webrtc.org/2024813004/diff/200001/webrtc/base/fakeclock.cc...
webrtc/base/fakeclock.cc:47: SetClockForTesting(prev_clock_);
I think it's simpler to only ever allow one fake clock to be in use. I.e., let
the constructor RTC_CHECK that the old value was null, an let the destructor set
it back to null.

Or else, add an RTC_CHECK to the destructor to verify that the return value of
SetClockForTesting is |this|.

https://codereview.webrtc.org/2024813004/diff/200001/webrtc/base/timeutils.h
File webrtc/base/timeutils.h (right):

https://codereview.webrtc.org/2024813004/diff/200001/webrtc/base/timeutils.h#...
webrtc/base/timeutils.h:51: // TODO(deadbeef): Instead of having functions that
access this global
I don't think it's a good idea to pass around the clock everywhere (even if
there's some code using webrtc::Clock doing that).

Except maybe if we can cut down a lot on the number of places where the clock is
read. And in many cases, I think passing the current time as an argument
downstream makes more sense than passing down a clock object.

Powered by Google App Engine
This is Rietveld 408576698