diff options
-rw-r--r-- | services/incremental/IncrementalService.cpp | 4 | ||||
-rw-r--r-- | services/incremental/test/IncrementalServiceTest.cpp | 39 |
2 files changed, 31 insertions, 12 deletions
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp index 932e99783c83..bd3f99a5efb8 100644 --- a/services/incremental/IncrementalService.cpp +++ b/services/incremental/IncrementalService.cpp @@ -81,8 +81,8 @@ struct Constants { static constexpr auto bindingTimeout = 1min; - // 10s, 100s (~2min), 1000s (~15min), 10000s (~3hrs) - static constexpr auto minBindDelay = 10s; + // 1s, 10s, 100s (~2min), 1000s (~15min), 10000s (~3hrs) + static constexpr auto minBindDelay = 1s; static constexpr auto maxBindDelay = 10000s; static constexpr auto bindDelayMultiplier = 10; static constexpr auto bindDelayJitterDivider = 10; diff --git a/services/incremental/test/IncrementalServiceTest.cpp b/services/incremental/test/IncrementalServiceTest.cpp index de8822dbf105..e6d487255eff 100644 --- a/services/incremental/test/IncrementalServiceTest.cpp +++ b/services/incremental/test/IncrementalServiceTest.cpp @@ -272,12 +272,20 @@ public: } return binder::Status::ok(); } + binder::Status bindToDataLoaderOkWith1sDelay(int32_t mountId, + const DataLoaderParamsParcel& params, + int bindDelayMs, + const sp<IDataLoaderStatusListener>& listener, + bool* _aidl_return) { + CHECK(100 * 9 <= bindDelayMs && bindDelayMs <= 100 * 11) << bindDelayMs; + return bindToDataLoaderOk(mountId, params, bindDelayMs, listener, _aidl_return); + } binder::Status bindToDataLoaderOkWith10sDelay(int32_t mountId, const DataLoaderParamsParcel& params, int bindDelayMs, const sp<IDataLoaderStatusListener>& listener, bool* _aidl_return) { - CHECK(1000 * 9 <= bindDelayMs && bindDelayMs <= 1000 * 11) << bindDelayMs; + CHECK(100 * 9 * 9 <= bindDelayMs && bindDelayMs <= 100 * 11 * 11) << bindDelayMs; return bindToDataLoaderOk(mountId, params, bindDelayMs, listener, _aidl_return); } binder::Status bindToDataLoaderOkWith100sDelay(int32_t mountId, @@ -285,7 +293,7 @@ public: int bindDelayMs, const sp<IDataLoaderStatusListener>& listener, bool* _aidl_return) { - CHECK(1000 * 9 * 9 < bindDelayMs && bindDelayMs < 1000 * 11 * 11) << bindDelayMs; + CHECK(100 * 9 * 9 * 9 < bindDelayMs && bindDelayMs < 100 * 11 * 11 * 11) << bindDelayMs; return bindToDataLoaderOk(mountId, params, bindDelayMs, listener, _aidl_return); } binder::Status bindToDataLoaderOkWith1000sDelay(int32_t mountId, @@ -293,7 +301,8 @@ public: int bindDelayMs, const sp<IDataLoaderStatusListener>& listener, bool* _aidl_return) { - CHECK(1000 * 9 * 9 * 9 < bindDelayMs && bindDelayMs < 1000 * 11 * 11 * 11) << bindDelayMs; + CHECK(100 * 9 * 9 * 9 * 9 < bindDelayMs && bindDelayMs < 100 * 11 * 11 * 11 * 11) + << bindDelayMs; return bindToDataLoaderOk(mountId, params, bindDelayMs, listener, _aidl_return); } binder::Status bindToDataLoaderOkWith10000sDelay(int32_t mountId, @@ -301,7 +310,7 @@ public: int bindDelayMs, const sp<IDataLoaderStatusListener>& listener, bool* _aidl_return) { - CHECK(1000 * 9 * 9 * 9 * 9 < bindDelayMs && bindDelayMs < 1000 * 11 * 11 * 11 * 11) + CHECK(100 * 9 * 9 * 9 * 9 * 9 < bindDelayMs && bindDelayMs < 100 * 11 * 11 * 11 * 11 * 11) << bindDelayMs; return bindToDataLoaderOk(mountId, params, bindDelayMs, listener, _aidl_return); } @@ -865,10 +874,10 @@ TEST_F(IncrementalServiceTest, testDeleteStorageSuccess) { } TEST_F(IncrementalServiceTest, testDataLoaderDestroyedAndDelayed) { - EXPECT_CALL(*mDataLoaderManager, bindToDataLoader(_, _, _, _, _)).Times(6); + EXPECT_CALL(*mDataLoaderManager, bindToDataLoader(_, _, _, _, _)).Times(7); EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_)).Times(1); - EXPECT_CALL(*mDataLoader, create(_, _, _, _)).Times(6); - EXPECT_CALL(*mDataLoader, start(_)).Times(6); + EXPECT_CALL(*mDataLoader, create(_, _, _, _)).Times(7); + EXPECT_CALL(*mDataLoader, start(_)).Times(7); EXPECT_CALL(*mDataLoader, destroy(_)).Times(1); EXPECT_CALL(*mVold, unmountIncFs(_)).Times(2); TemporaryDir tempDir; @@ -882,6 +891,11 @@ TEST_F(IncrementalServiceTest, testDataLoaderDestroyedAndDelayed) { ON_CALL(*mDataLoaderManager, bindToDataLoader(_, _, _, _, _)) .WillByDefault(Invoke(mDataLoaderManager, + &MockDataLoaderManager::bindToDataLoaderOkWith1sDelay)); + mDataLoaderManager->setDataLoaderStatusDestroyed(); + + ON_CALL(*mDataLoaderManager, bindToDataLoader(_, _, _, _, _)) + .WillByDefault(Invoke(mDataLoaderManager, &MockDataLoaderManager::bindToDataLoaderOkWith10sDelay)); mDataLoaderManager->setDataLoaderStatusDestroyed(); @@ -912,10 +926,10 @@ TEST_F(IncrementalServiceTest, testDataLoaderOnRestart) { constexpr auto bindRetryInterval = 5s; - EXPECT_CALL(*mDataLoaderManager, bindToDataLoader(_, _, _, _, _)).Times(10); + EXPECT_CALL(*mDataLoaderManager, bindToDataLoader(_, _, _, _, _)).Times(11); EXPECT_CALL(*mDataLoaderManager, unbindFromDataLoader(_)).Times(1); - EXPECT_CALL(*mDataLoader, create(_, _, _, _)).Times(6); - EXPECT_CALL(*mDataLoader, start(_)).Times(6); + EXPECT_CALL(*mDataLoader, create(_, _, _, _)).Times(7); + EXPECT_CALL(*mDataLoader, start(_)).Times(7); EXPECT_CALL(*mDataLoader, destroy(_)).Times(1); EXPECT_CALL(*mVold, unmountIncFs(_)).Times(2); EXPECT_CALL(*mTimedQueue, addJob(_, _, _)).Times(4); @@ -995,6 +1009,11 @@ TEST_F(IncrementalServiceTest, testDataLoaderOnRestart) { // Simulated crash/other connection breakage. ON_CALL(*mDataLoaderManager, bindToDataLoader(_, _, _, _, _)) .WillByDefault(Invoke(mDataLoaderManager, + &MockDataLoaderManager::bindToDataLoaderOkWith1sDelay)); + mDataLoaderManager->setDataLoaderStatusDestroyed(); + + ON_CALL(*mDataLoaderManager, bindToDataLoader(_, _, _, _, _)) + .WillByDefault(Invoke(mDataLoaderManager, &MockDataLoaderManager::bindToDataLoaderOkWith10sDelay)); mDataLoaderManager->setDataLoaderStatusDestroyed(); |