diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-12 07:18:55 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-12 07:18:55 +0000 |
commit | fc3dd6cd40b82b6fb71d2543032e8c87d202e1d2 (patch) | |
tree | d4f910d973d13c04bf00cc5b3da356d6e689618c /sync/engine/sync_scheduler_unittest.cc | |
parent | 0b438a6cb14afd1ba84cb27156ee4d5b64de2d16 (diff) | |
download | chromium_src-fc3dd6cd40b82b6fb71d2543032e8c87d202e1d2.zip chromium_src-fc3dd6cd40b82b6fb71d2543032e8c87d202e1d2.tar.gz chromium_src-fc3dd6cd40b82b6fb71d2543032e8c87d202e1d2.tar.bz2 |
Revert 244381 "Support GU retry command in sync engine. The comm..."
Test fails on the valgrind bot:
http://build.chromium.org/p/chromium.memory.fyi/builders/Linux%20Tests%20%28tsan%29%281%29/builds/11739/steps/memory%20test%3A%20unit/logs/EphemeralAppServiceTest.RemoveOverflow
EphemeralAppServiceTest.RemoveOverflow:
../../chrome/browser/apps/ephemeral_app_service_unittest.cc:83: Failure
Value of: removed->first < retained->first
Actual: false
Expected: true
> Support GU retry command in sync engine. The command specifies a delay after which syncer should issue a GU to pick up updates missed by last GU.
>
> BUG=
>
> Review URL: https://codereview.chromium.org/124083002
TBR=haitaol@chromium.org
Review URL: https://codereview.chromium.org/135923002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244438 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/engine/sync_scheduler_unittest.cc')
-rw-r--r-- | sync/engine/sync_scheduler_unittest.cc | 122 |
1 files changed, 13 insertions, 109 deletions
diff --git a/sync/engine/sync_scheduler_unittest.cc b/sync/engine/sync_scheduler_unittest.cc index 5ea1f7b..97d9ab8 100644 --- a/sync/engine/sync_scheduler_unittest.cc +++ b/sync/engine/sync_scheduler_unittest.cc @@ -34,7 +34,6 @@ using testing::Mock; using testing::Return; using testing::WithArg; using testing::WithArgs; -using testing::WithoutArgs; namespace syncer { using sessions::SyncSession; @@ -52,7 +51,6 @@ class MockSyncer : public Syncer { sync_pb::GetUpdatesCallerInfo::GetUpdatesSource, SyncSession*)); MOCK_METHOD2(PollSyncShare, bool(ModelTypeSet, sessions::SyncSession*)); - MOCK_METHOD2(RetrySyncShare, bool(ModelTypeSet, sessions::SyncSession*)); }; MockSyncer::MockSyncer() @@ -212,11 +210,6 @@ class SyncSchedulerTest : public testing::Test { return scheduler_->nudge_tracker_.GetThrottledTypes(); } - base::TimeDelta GetRetryTimerDelay() { - EXPECT_TRUE(scheduler_->retry_timer_.IsRunning()); - return scheduler_->retry_timer_.GetCurrentDelay(); - } - private: syncable::Directory* directory() { return dir_maker_.directory(); @@ -546,9 +539,8 @@ TEST_F(SyncSchedulerTest, Polling) { SyncShareTimes times; TimeDelta poll_interval(TimeDelta::FromMilliseconds(30)); EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples)) - .WillRepeatedly( - DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), - RecordSyncShareMultiple(×, kMinNumSamples))); + .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), + RecordSyncShareMultiple(×, kMinNumSamples))); scheduler()->OnReceivedLongPollIntervalUpdate(poll_interval); @@ -567,9 +559,8 @@ TEST_F(SyncSchedulerTest, PollNotificationsDisabled) { SyncShareTimes times; TimeDelta poll_interval(TimeDelta::FromMilliseconds(30)); EXPECT_CALL(*syncer(), PollSyncShare(_,_)).Times(AtLeast(kMinNumSamples)) - .WillRepeatedly( - DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), - RecordSyncShareMultiple(×, kMinNumSamples))); + .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), + RecordSyncShareMultiple(×, kMinNumSamples))); scheduler()->OnReceivedShortPollIntervalUpdate(poll_interval); scheduler()->SetNotificationsEnabled(false); @@ -596,7 +587,7 @@ TEST_F(SyncSchedulerTest, PollIntervalUpdate) { sessions::test_util::SimulatePollIntervalUpdate(poll2)), Return(true))) .WillRepeatedly( - DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), + DoAll(Invoke(sessions::test_util::SimulatePollSuccess), WithArg<1>( RecordSyncShareMultiple(×, kMinNumSamples)))); @@ -687,9 +678,8 @@ TEST_F(SyncSchedulerTest, ThrottlingExpiresFromPoll) { Return(true))) .RetiresOnSaturation(); EXPECT_CALL(*syncer(), PollSyncShare(_,_)) - .WillRepeatedly( - DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), - RecordSyncShareMultiple(×, kMinNumSamples))); + .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), + RecordSyncShareMultiple(×, kMinNumSamples))); TimeTicks optimal_start = TimeTicks::Now() + poll + throttle1; StartSyncScheduler(SyncScheduler::NORMAL_MODE); @@ -1121,7 +1111,7 @@ TEST_F(SyncSchedulerTest, BackoffRelief) { // Now let the Poll timer do its thing. EXPECT_CALL(*syncer(), PollSyncShare(_,_)) .WillRepeatedly(DoAll( - Invoke(sessions::test_util::SimulatePollRetrySuccess), + Invoke(sessions::test_util::SimulatePollSuccess), RecordSyncShareMultiple(×, kMinNumSamples))); RunLoop(); Mock::VerifyAndClearExpectations(syncer()); @@ -1144,9 +1134,9 @@ TEST_F(SyncSchedulerTest, TransientPollFailure) { UseMockDelayProvider(); // Will cause test failure if backoff is initiated. EXPECT_CALL(*syncer(), PollSyncShare(_,_)) - .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollRetryFailed), + .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollFailed), RecordSyncShare(×))) - .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), + .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), RecordSyncShare(×))); StartSyncScheduler(SyncScheduler::NORMAL_MODE); @@ -1279,9 +1269,8 @@ TEST_F(SyncSchedulerTest, PollFromCanaryAfterAuthError) { ::testing::InSequence seq; EXPECT_CALL(*syncer(), PollSyncShare(_,_)) - .WillRepeatedly( - DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), - RecordSyncShareMultiple(×, kMinNumSamples))); + .WillRepeatedly(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), + RecordSyncShareMultiple(×, kMinNumSamples))); connection()->SetServerStatus(HttpResponse::SYNC_AUTH_ERROR); StartSyncScheduler(SyncScheduler::NORMAL_MODE); @@ -1293,7 +1282,7 @@ TEST_F(SyncSchedulerTest, PollFromCanaryAfterAuthError) { // but after poll finished with auth error from poll timer it should retry // poll once more EXPECT_CALL(*syncer(), PollSyncShare(_,_)) - .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), + .WillOnce(DoAll(Invoke(sessions::test_util::SimulatePollSuccess), RecordSyncShare(×))); scheduler()->OnCredentialsUpdated(); connection()->SetServerStatus(HttpResponse::SERVER_CONNECTION_OK); @@ -1301,89 +1290,4 @@ TEST_F(SyncSchedulerTest, PollFromCanaryAfterAuthError) { StopSyncScheduler(); } -TEST_F(SyncSchedulerTest, SuccessfulRetry) { - StartSyncScheduler(SyncScheduler::NORMAL_MODE); - - SyncShareTimes times; - base::TimeDelta delay = base::TimeDelta::FromMilliseconds(1); - scheduler()->OnReceivedGuRetryDelay(delay); - EXPECT_EQ(delay, GetRetryTimerDelay()); - - EXPECT_CALL(*syncer(), RetrySyncShare(_,_)) - .WillOnce( - DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), - RecordSyncShare(×))); - - // Run to wait for retrying. - RunLoop(); - - StopSyncScheduler(); -} - -TEST_F(SyncSchedulerTest, FailedRetry) { - UseMockDelayProvider(); - EXPECT_CALL(*delay(), GetDelay(_)) - .WillRepeatedly(Return(TimeDelta::FromMilliseconds(1))); - - StartSyncScheduler(SyncScheduler::NORMAL_MODE); - - base::TimeDelta delay = base::TimeDelta::FromMilliseconds(1); - scheduler()->OnReceivedGuRetryDelay(delay); - - EXPECT_CALL(*syncer(), RetrySyncShare(_,_)) - .WillOnce( - DoAll(Invoke(sessions::test_util::SimulatePollRetryFailed), - QuitLoopNowAction())); - - // Run to wait for retrying. - RunLoop(); - - EXPECT_TRUE(scheduler()->IsBackingOff()); - EXPECT_CALL(*syncer(), RetrySyncShare(_,_)) - .WillOnce( - DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), - QuitLoopNowAction())); - - // Run to wait for second retrying. - RunLoop(); - - StopSyncScheduler(); -} - -ACTION_P2(VerifyRetryTimerDelay, scheduler_test, expected_delay) { - EXPECT_EQ(expected_delay, scheduler_test->GetRetryTimerDelay()); -} - -TEST_F(SyncSchedulerTest, ReceiveNewRetryDelay) { - StartSyncScheduler(SyncScheduler::NORMAL_MODE); - - SyncShareTimes times; - base::TimeDelta delay1 = base::TimeDelta::FromMilliseconds(10); - base::TimeDelta delay2 = base::TimeDelta::FromMilliseconds(20); - - scheduler()->OnReceivedGuRetryDelay(delay1); - scheduler()->ScheduleLocalRefreshRequest(zero(), ModelTypeSet(BOOKMARKS), - FROM_HERE); - - EXPECT_CALL(*syncer(), NormalSyncShare(_,_,_)) - .WillOnce(DoAll( - WithoutArgs(VerifyRetryTimerDelay(this, delay1)), - WithArg<2>(sessions::test_util::SimulateGuRetryDelayCommand(delay2)), - WithoutArgs(VerifyRetryTimerDelay(this, delay2)), - RecordSyncShare(×))); - - // Run nudge GU. - RunLoop(); - - EXPECT_CALL(*syncer(), RetrySyncShare(_,_)) - .WillOnce( - DoAll(Invoke(sessions::test_util::SimulatePollRetrySuccess), - RecordSyncShare(×))); - - // Run to wait for retrying. - RunLoop(); - - StopSyncScheduler(); -} - } // namespace syncer |