update_engine: Increase periodic update check read allows
Delete the periodic update check interval marker file after 6 attempts
at reading it instead of the previous 3 so the auto updater tests can do
more interesting things with it.
BUG=chromium:953471
TEST=sudo FEATURES=test emerge update_engine
Change-Id: I1a67fc5dadfd1ae0fde1308e398e6eb21171df05
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2393098
Tested-by: Amin Hassani <ahassani@chromium.org>
Auto-Submit: Amin Hassani <ahassani@chromium.org>
Reviewed-by: David Haddock <dhaddock@chromium.org>
Commit-Queue: David Haddock <dhaddock@chromium.org>
diff --git a/update_manager/real_updater_provider.cc b/update_manager/real_updater_provider.cc
index 268f3bb..8465718 100644
--- a/update_manager/real_updater_provider.cc
+++ b/update_manager/real_updater_provider.cc
@@ -460,7 +460,7 @@
if (prefs_ && prefs_->Exists(key) && prefs_->GetInt64(key, &result)) {
// This specific value is used for testing only. So it should not be kept
// around and should be deleted after a few reads.
- if (++read_count_ > 2)
+ if (++read_count_ > 5)
prefs_->Delete(key);
// Limit the timeout interval to 10 minutes so it is not abused if it is
diff --git a/update_manager/real_updater_provider_unittest.cc b/update_manager/real_updater_provider_unittest.cc
index e31f6f3..f0804c4 100644
--- a/update_manager/real_updater_provider_unittest.cc
+++ b/update_manager/real_updater_provider_unittest.cc
@@ -458,15 +458,14 @@
// Make sure the value does not exceed a threshold of 10 minutes.
fake_prefs_.SetInt64(
chromeos_update_engine::kPrefsTestUpdateCheckIntervalTimeout, 11 * 60);
- UmTestUtils::ExpectVariableHasValue(
- static_cast<int64_t>(10 * 60),
- provider_->var_test_update_check_interval_timeout());
- UmTestUtils::ExpectVariableHasValue(
- static_cast<int64_t>(10 * 60),
- provider_->var_test_update_check_interval_timeout());
+ // The next 5 reads should return valid values.
+ for (int i = 0; i < 5; ++i)
+ UmTestUtils::ExpectVariableHasValue(
+ static_cast<int64_t>(10 * 60),
+ provider_->var_test_update_check_interval_timeout());
// Just to make sure it is not cached anywhere and deleted. The variable is
- // allowd to be read 3 times.
+ // allowd to be read 6 times.
UmTestUtils::ExpectVariableNotSet(
provider_->var_test_update_check_interval_timeout());
}