update_engine: Change time restrictions to return kSucceeded
Change UpdateTimeRestrictionsPolicyImpl to return kSucceeded
in place of kAskMeAgainLater. Since the former is not an expected
return value.
Background:
Policies in UpdateCanBeApplied should return kSucceeded when
they want to force a decision, since UpdateCanBeApplied is
supposed to only contain sync policies. kAskMeAgainLater is
reserved for async policies.
BUG=chromium:852860
TEST=cros_workon_make update_engine --test and local tests
Change-Id: Ie81a3d09f98ad7aba3c36183873bc153a6b530cf
Reviewed-on: https://chromium-review.googlesource.com/1153624
Commit-Ready: Adolfo Higueros <adokar@google.com>
Tested-by: Adolfo Higueros <adokar@google.com>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: May Lippert <maybelle@chromium.org>
diff --git a/update_manager/chromeos_policy_unittest.cc b/update_manager/chromeos_policy_unittest.cc
index b5b1bd9..96f3d79 100644
--- a/update_manager/chromeos_policy_unittest.cc
+++ b/update_manager/chromeos_policy_unittest.cc
@@ -151,7 +151,7 @@
// Sets up a test with the given intervals and the current fake wallclock
// time.
void TestDisallowedTimeIntervals(const WeeklyTimeIntervalVector& intervals,
- const EvalStatus& expected_status,
+ const ErrorCode& expected_error_code,
bool kiosk) {
SetUpDefaultTimeProvider();
if (kiosk)
@@ -165,12 +165,11 @@
// Check that |expected_status| matches the value of UpdateCheckAllowed
ErrorCode result;
InstallPlan install_plan;
- ExpectPolicyStatus(
- expected_status, &Policy::UpdateCanBeApplied, &result, &install_plan);
- if (expected_status == EvalStatus::kAskMeAgainLater)
- EXPECT_EQ(result, ErrorCode::kOmahaUpdateDeferredPerPolicy);
- else
- EXPECT_EQ(result, ErrorCode::kSuccess);
+ ExpectPolicyStatus(EvalStatus::kSucceeded,
+ &Policy::UpdateCanBeApplied,
+ &result,
+ &install_plan);
+ EXPECT_EQ(result, expected_error_code);
}
};
@@ -1615,7 +1614,7 @@
{WeeklyTimeInterval(
WeeklyTime::FromTime(curr_time),
WeeklyTime::FromTime(curr_time + TimeDelta::FromMinutes(1)))},
- EvalStatus::kSucceeded,
+ ErrorCode::kSuccess,
/* kiosk = */ true);
}
@@ -1625,7 +1624,7 @@
{WeeklyTimeInterval(
WeeklyTime::FromTime(curr_time),
WeeklyTime::FromTime(curr_time + TimeDelta::FromMinutes(1)))},
- EvalStatus::kAskMeAgainLater,
+ ErrorCode::kOmahaUpdateDeferredPerPolicy,
/* kiosk = */ true);
}
@@ -1635,7 +1634,7 @@
{WeeklyTimeInterval(
WeeklyTime::FromTime(curr_time - TimeDelta::FromHours(3)),
WeeklyTime::FromTime(curr_time))},
- EvalStatus::kSucceeded,
+ ErrorCode::kSuccess,
/* kiosk = */ true);
}
@@ -1645,7 +1644,7 @@
{WeeklyTimeInterval(
WeeklyTime::FromTime(curr_time),
WeeklyTime::FromTime(curr_time + TimeDelta::FromMinutes(1)))},
- EvalStatus::kSucceeded,
+ ErrorCode::kSuccess,
/* kiosk = */ false);
}
diff --git a/update_manager/update_time_restrictions_policy_impl.cc b/update_manager/update_time_restrictions_policy_impl.cc
index 8179f89..f9b83de 100644
--- a/update_manager/update_time_restrictions_policy_impl.cc
+++ b/update_manager/update_time_restrictions_policy_impl.cc
@@ -64,7 +64,7 @@
for (const auto& interval : *intervals) {
if (interval.InRange(now)) {
*result = ErrorCode::kOmahaUpdateDeferredPerPolicy;
- return EvalStatus::kAskMeAgainLater;
+ return EvalStatus::kSucceeded;
}
}
diff --git a/update_manager/update_time_restrictions_policy_impl.h b/update_manager/update_time_restrictions_policy_impl.h
index 6a810ba..11cbceb 100644
--- a/update_manager/update_time_restrictions_policy_impl.h
+++ b/update_manager/update_time_restrictions_policy_impl.h
@@ -37,9 +37,9 @@
~UpdateTimeRestrictionsPolicyImpl() override = default;
// When the current time is inside one of the intervals returns
- // kAskMeAgainLater. If the current time is not inside any intervals returns
- // kContinue. In case of errors, i.e. cannot access intervals or time, return
- // kContinue.
+ // kSucceeded and sets |result| to kOmahaUpdateDeferredPerPolicy. If the
+ // current time is not inside any intervals returns kContinue. In case of
+ // errors, i.e. cannot access intervals or time, return kContinue.
EvalStatus UpdateCanBeApplied(
EvaluationContext* ec,
State* state,
diff --git a/update_manager/update_time_restrictions_policy_impl_unittest.cc b/update_manager/update_time_restrictions_policy_impl_unittest.cc
index bfb43dc..ac4e0e9 100644
--- a/update_manager/update_time_restrictions_policy_impl_unittest.cc
+++ b/update_manager/update_time_restrictions_policy_impl_unittest.cc
@@ -66,7 +66,7 @@
InstallPlan install_plan;
ExpectPolicyStatus(
expected_value, &Policy::UpdateCanBeApplied, &result, &install_plan);
- if (expected_value == EvalStatus::kAskMeAgainLater)
+ if (expected_value == EvalStatus::kSucceeded)
EXPECT_EQ(result, ErrorCode::kOmahaUpdateDeferredPerPolicy);
}
};
@@ -86,7 +86,7 @@
Time::Exploded first_interval_time{2018, 7, 1, 9, 12, 30, 0, 0};
TestPolicy(first_interval_time,
kTestIntervals,
- EvalStatus::kAskMeAgainLater,
+ EvalStatus::kSucceeded,
/* kiosk = */ true);
// Check second interval.
@@ -94,7 +94,7 @@
Time::Exploded second_interval_time{2018, 7, 4, 12, 4, 30, 0, 0};
TestPolicy(second_interval_time,
kTestIntervals,
- EvalStatus::kAskMeAgainLater,
+ EvalStatus::kSucceeded,
/* kiosk = */ true);
}