~registry/chromium-os-update-engine/trunk

« back to all changes in this revision

Viewing changes to payload_state_unittest.cc

  • Committer: ChromeBot
  • Author(s): Alex Deymo
  • Date: 2013-08-10 01:59:14 UTC
  • Revision ID: git-v1:b33b0f0a0d8648542a0633cc708de149d52829b6
Add Installer.UpdatesAbandonedEventCount metric.

This patch adds a new metric similar to
Installer.UpdatesAbandonedCount that reports the number of abandoned
payloads every time a payload is abandoned. A payload is considered
"abandoned" when it was already attempted but not finished for any
reason, and a newer payload is avaibled. In this situation,
update_engine drops the previous payload and starts again with the
new one.

Every time a payload is abandoned, the new metric
Installer.UpdatesAbandonedEventCount is sent with the number of
consecutive different abandoned payloads since the last successful
update. A high number of entries greater than 1 in this metric will
imply that we are releasing new payloads too often, or that the users
are taking too long to download an update.

Finally, when a payload is successfully applied, the total number of
abandoned payloads since the previous successful update is sent as
the the metric Installer.UpdatesAbandonedCount.

BUG=chromium:261370
TEST=unittests

Change-Id: I47054b541c4700a86183461a5cf92830883ea4f3
Reviewed-on: https://gerrit.chromium.org/gerrit/65328
Commit-Queue: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>

Show diffs side-by-side

added added

removed removed

Lines of Context:
297
297
 
298
298
  EXPECT_TRUE(payload_state.Initialize(&mock_system_state));
299
299
 
 
300
  // The first response doesn't send an abandoned event.
 
301
  EXPECT_CALL(*mock_system_state.mock_metrics_lib(), SendToUMA(
 
302
      "Installer.UpdatesAbandonedEventCount", 0, _, _, _)).Times(0);
 
303
 
300
304
  // Set the first response.
301
305
  SetupPayloadStateWith2Urls("Hash5823", true, &payload_state, &response);
302
306
  EXPECT_EQ(1, payload_state.GetNumResponsesSeen());
307
311
  EXPECT_EQ("https://test", payload_state.GetCurrentUrl());
308
312
  EXPECT_EQ(1, payload_state.GetUrlSwitchCount());
309
313
 
 
314
  EXPECT_CALL(*mock_system_state.mock_metrics_lib(), SendToUMA(
 
315
      "Installer.UpdatesAbandonedEventCount", 1, _, _, _));
 
316
 
310
317
  // Now, slightly change the response and set it again.
311
318
  SetupPayloadStateWith2Urls("Hash8225", true, &payload_state, &response);
312
319
  EXPECT_EQ(2, payload_state.GetNumResponsesSeen());
313
320
 
 
321
  // Fake an error again.
 
322
  payload_state.UpdateFailed(error);
 
323
  EXPECT_EQ("https://test", payload_state.GetCurrentUrl());
 
324
  EXPECT_EQ(1, payload_state.GetUrlSwitchCount());
 
325
 
 
326
  EXPECT_CALL(*mock_system_state.mock_metrics_lib(), SendToUMA(
 
327
      "Installer.UpdatesAbandonedEventCount", 2, _, _, _));
 
328
 
 
329
  // Return a third different response.
 
330
  SetupPayloadStateWith2Urls("Hash9999", true, &payload_state, &response);
 
331
  EXPECT_EQ(3, payload_state.GetNumResponsesSeen());
 
332
 
314
333
  // Make sure the url index was reset to 0 because of the new response.
315
334
  EXPECT_EQ("http://test", payload_state.GetCurrentUrl());
316
335
  EXPECT_EQ(0, payload_state.GetUrlFailureCount());