Fix DeviceCloudPolicyManagerChromeOSEnrollmentTest flakes
There was a race condition between the calls to
session_manager_client_.set_device_policy();
owner_key_util_->SetPublicKeyFromPrivateKey()
as well as TYPE_POLICY_FETCH job expectations and tasks queued by
test_url_loader_factory_.SimulateResponseForPendingRequest()
despite the RunUntilIdle() in between (why?). This caused for instance
policy validation errors since the key would sometimes be set, sometimes
not. This CL cleans this up.
The call to
owner_key_util_->SetPublicKeyFromPrivateKey()
is made right after the key has been set in SessionManagerClient, using
a callback from StorePolicy(). This is the right place since keys are
loaded from |owner_key_util_|.
The TYPE_POLICY_FETCH job expectations are moved up since otherwise they
would race with
test_url_loader_factory_.SimulateResponseForPendingRequest(),
which queues those jobs. If the expectations happen to be set too late,
the TYPE_POLICY_FETCH job is matched against the TYPE_REMOTE_COMMANDS
job expectations from AllowUninterestingRemoteCommandFetches().
The racy set_device_policy() was only used to simulate load error. Thus,
it is fixed by providing an explicit means to simulate load error in
FakeSessionManagerClient, see ForceRetrievePolicyLoadError().
BUG=chromium:779492
TEST=Flakiness dashboard should show no flakes.
https://test-results.appspot.com/dashboards/flakiness_dashboard.html#testType=unit_tests&tests=DeviceCloudPolicyManagerChromeOSEnrollmentTest
Change-Id: I6d46fbc2934856d71373fdbb7bf92e579e7a0183
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1545397
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Maksim Ivanov <emaxx@chromium.org>
Commit-Queue: Lutz Justen <ljusten@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646876}Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure .