update_engine: Providing testing capability for periodic update checks
Currently, we are not able to properly test periodic update checks
because these update checks are disabled on test images. To solve this
problem this CL introduces a new pref test-update-check-interval-timeout
that contains the number of seconds between periodic update checks. The
tests can put this file in /var/lib/update_engine/prefs and restart the
update_engine. The update_engine should start checking for update after
the number of seconds identified in the above pref and continue checking
for update with that interval. The tests also need to make sure this
file is deleted at the end so it doesn't interfere with future device
updates. This pref internally is deleted after it has been read/used 3
times so it can't be abused. For the same reason, the maximum value that
can be set in the pref is limited to 10 minutes.
BUG=chromium:953471
TEST=FEATURES=test emerge-reef update_engine
TEST=flashed a device with this new image, put the pref with value of 10
seconds and restarted the update_engine, the update check happened.
Change-Id: I3ad0e300f7908f17da26b0eb0d1510348a2d2435
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2333308
Commit-Queue: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
Reviewed-by: Andrew Lassalle <andrewlassalle@chromium.org>
diff --git a/update_manager/variable.h b/update_manager/variable.h
index 6c7d350..9ac7dae 100644
--- a/update_manager/variable.h
+++ b/update_manager/variable.h
@@ -83,6 +83,10 @@
// variable. In other case, it returns 0.
base::TimeDelta GetPollInterval() const { return poll_interval_; }
+ // Returns true, if the value for this variable is expected to be missing
+ // sometimes so we can avoid printing confusing error logs.
+ bool IsMissingOk() const { return missing_ok_; }
+
// Adds and removes observers for value changes on the variable. This only
// works for kVariableAsync variables since the other modes don't track value
// changes. Adding the same observer twice has no effect.
@@ -115,6 +119,8 @@
poll_interval_ = poll_interval;
}
+ void SetMissingOk() { missing_ok_ = true; }
+
// Calls ValueChanged on all the observers.
void NotifyValueChanged() {
// Fire all the observer methods from the main loop as single call. In order
@@ -140,7 +146,8 @@
: name_(name),
mode_(mode),
poll_interval_(mode == kVariableModePoll ? poll_interval
- : base::TimeDelta()) {}
+ : base::TimeDelta()),
+ missing_ok_(false) {}
void OnValueChangedNotification() {
// A ValueChanged() method can change the list of observers, for example
@@ -174,6 +181,9 @@
// The list of value changes observers.
std::list<BaseVariable::ObserverInterface*> observer_list_;
+ // Defines whether this variable is expected to have no value.
+ bool missing_ok_;
+
DISALLOW_COPY_AND_ASSIGN(BaseVariable);
};