Bug 1546261 - Fix the app update phase telemetry tests so they work with BITS update downloads. r=bytesized

Changes BITS downloads to use the patch's errorCode to determine whether a partial staging failure should make the code download a complete update. This makes it so an apply failure will use the same logic.
Fixes a Truncating float/double number JavaScript Warning when submitting telemetry for the apply interval.
Modifies getTelemetryUpdatePhaseValues for BITS support.
Fixes all of the app update phase telemetry tests.

Differential Revision: https://phabricator.services.mozilla.com/D28814

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Robert Strong 2019-04-25 18:14:38 +00:00
parent 7ecca43f85
commit 101a310643
6 changed files with 109 additions and 23 deletions

View File

@ -3228,6 +3228,8 @@ UpdateManager.prototype = {
handleFallbackToCompleteUpdate(update, true);
}
// This can be removed after the update ui under update/content is
// removed.
update.QueryInterface(Ci.nsIWritablePropertyBag);
update.setProperty("stagingFailed", "true");
}
@ -3821,12 +3823,20 @@ Downloader.prototype = {
return null;
}
// When downloading the patch failed using BITS, there hasn't been an
// attempt to download the patch using the internal application download
// mechanism, and an attempt to stage or apply the patch hasn't failed
// which indicates that a different patch should be downloaded since
// re-downloading the same patch with the internal application download
// mechanism will likely also fail when trying to stage or apply it then
// try to download the same patch using the internal application download
// mechanism.
selectedPatch.QueryInterface(Ci.nsIWritablePropertyBag);
if (selectedPatch.getProperty("bitsResult") != null &&
selectedPatch.getProperty("internalResult") == null &&
selectedPatch.getProperty("stagingFailed") == null) {
!selectedPatch.errorCode) {
LOG("Downloader:_selectPatch - Falling back to non-BITS download " +
"mechanism due to existing BITS result: " +
"mechanism for the same patch due to existing BITS result: " +
selectedPatch.getProperty("bitsResult"));
return selectedPatch;
}

View File

@ -512,7 +512,7 @@ var AUSTLMY = {
// is applied during a restart and then to try the complete patch.
let applyStart = patch.getProperty("applyStart");
if (applyStart !== null) {
let applyFinished = Date.now() / 1000;
let applyFinished = Math.ceil(Date.now() / 1000);
scalarSet(prefix + "apply_" + type,
Math.max((applyFinished - applyStart), 1));
}

View File

@ -48,3 +48,19 @@ prefs =
[browser_doorhanger_bc_downloadOptIn_staging.js]
[browser_doorhanger_sp_patch_partialApplyFailure_complete.js]
[browser_doorhanger_sp_patch_partialApplyFailure_complete_staging.js]
# Telemetry Application Update Tests
[browser_telemetry_completeBadSize.js]
[browser_telemetry_partialBadSize_completeBadSize.js]
[browser_telemetry_complete_stageFailure.js]
[browser_telemetry_partial_stageFailure_complete_stageFailure.js]
[browser_telemetry_complete_applyFailure.js]
[browser_telemetry_partial_applyFailure_complete_applyFailure.js]
[browser_telemetry_partial_applyFailure_complete_stageFailure.js]
[browser_telemetry_partial_applyFailure_complete_applied.js]
[browser_telemetry_partial_applyFailure_complete_staged_applied.js]
[browser_telemetry_partialBadSize_complete_staged_applied.js]
[browser_telemetry_complete_applied.js]
[browser_telemetry_partial_applied.js]
[browser_telemetry_partial_staged_applied.js]
[browser_telemetry_complete_staged_applied.js]

View File

@ -17,6 +17,7 @@ add_task(async function telemetry_partial_applied() {
let expected = getTelemetryUpdatePhaseValues({
noInternalComplete: true,
noBitsComplete: true,
});
checkTelemetryUpdatePhases(expected);

View File

@ -23,6 +23,7 @@ add_task(async function telemetry_partial_staged_applied() {
testPostUpdateProcessing();
let expected = getTelemetryUpdatePhaseValues({
noBitsComplete: true,
noInternalComplete: true,
});
checkTelemetryUpdatePhases(expected);

View File

@ -984,7 +984,11 @@ function runTelemetryUpdateTest(updateParams, event, stageFailure = false) {
* @return An object that can be passed to checkTelemetryUpdatePhases for update
* phase telemetry tests.
*/
/* This function is intentionally complex so tests don't have to be */
/* eslint-disable-next-line complexity */
function getTelemetryUpdatePhaseValues(overrides) {
let bitsEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_BITS_ENABLED);
// Set values that could never be recorded due to values that would prevent
// them from occurring. This makes it so callers only have to specify a couple
// of values.
@ -992,16 +996,22 @@ function getTelemetryUpdatePhaseValues(overrides) {
if (!overrides.noInternalPartial) {
overrides.noInternalPartial = true;
}
if (!overrides.noBitsPartial) {
overrides.noBitsPartial = true;
}
}
if (overrides.noCompletePatch) {
if (!overrides.noInternalComplete) {
overrides.noInternalComplete = true;
}
if (!overrides.noBitsComplete) {
overrides.noBitsComplete = true;
}
}
if (overrides.noPartialPatch || overrides.partialBadSize ||
overrides.noInternalPartial) {
overrides.noInternalPartial || overrides.noBitsPartial) {
if (!overrides.noStagePartial) {
overrides.noStagePartial = true;
}
@ -1011,7 +1021,7 @@ function getTelemetryUpdatePhaseValues(overrides) {
}
if (overrides.noCompletePatch || overrides.completeBadSize ||
overrides.noInternalComplete) {
overrides.noInternalComplete || overrides.noBitsComplete) {
if (!overrides.noStageComplete) {
overrides.noStageComplete = true;
}
@ -1051,12 +1061,31 @@ function getTelemetryUpdatePhaseValues(overrides) {
obj.intervals = {};
obj.intervals.check = 1;
obj.intervals.download_bits_partial = null;
obj.intervals.download_bits_complete = null;
obj.intervals.download_internal_partial =
overrides.noInternalPartial ? null : 1;
obj.intervals.download_internal_complete =
overrides.noInternalComplete ? null : 1;
if (bitsEnabled) {
obj.intervals.download_bits_partial =
overrides.noBitsPartial ? null : 1;
obj.intervals.download_bits_complete =
overrides.noBitsComplete ? null : 1;
if (overrides.partialBadSize) {
obj.intervals.download_internal_partial =
overrides.noInternalPartial ? null : 1;
} else {
obj.intervals.download_internal_partial = null;
}
if (overrides.completeBadSize) {
obj.intervals.download_internal_complete =
overrides.noInternalComplete ? null : 1;
} else {
obj.intervals.download_internal_complete = null;
}
} else {
obj.intervals.download_bits_partial = null;
obj.intervals.download_bits_complete = null;
obj.intervals.download_internal_partial =
overrides.noInternalPartial ? null : 1;
obj.intervals.download_internal_complete =
overrides.noInternalComplete ? null : 1;
}
obj.intervals.stage_partial = overrides.noStagePartial ? null : 1;
obj.intervals.stage_complete = overrides.noStageComplete ? null : 1;
obj.intervals.apply_partial = overrides.noApplyPartial ? null : 1;
@ -1064,21 +1093,50 @@ function getTelemetryUpdatePhaseValues(overrides) {
obj.downloads = {};
obj.downloads.bits_partial_ = {};
obj.downloads.bits_partial_.bytes = null;
obj.downloads.bits_partial_.seconds = null;
obj.downloads.bits_complete_ = {};
obj.downloads.bits_complete_.bytes = null;
obj.downloads.bits_complete_.seconds = null;
obj.downloads.internal_partial_ = {};
obj.downloads.internal_partial_.bytes =
overrides.noInternalPartial ? null : partialDownloadBytes;
obj.downloads.internal_partial_.seconds =
overrides.noInternalPartial ? null : 1;
obj.downloads.internal_complete_ = {};
obj.downloads.internal_complete_.bytes =
overrides.noInternalComplete ? null : completeDownloadBytes;
obj.downloads.internal_complete_.seconds =
overrides.noInternalComplete ? null : 1;
if (bitsEnabled) {
obj.downloads.bits_partial_.bytes =
overrides.noBitsPartial ? null : partialDownloadBytes;
obj.downloads.bits_partial_.seconds =
overrides.noBitsPartial ? null : 1;
obj.downloads.bits_complete_.bytes =
overrides.noBitsComplete ? null : completeDownloadBytes;
obj.downloads.bits_complete_.seconds =
overrides.noBitsComplete ? null : 1;
if (overrides.partialBadSize) {
obj.downloads.internal_partial_.seconds =
overrides.noInternalPartial ? null : 1;
obj.downloads.internal_partial_.bytes =
overrides.noInternalPartial ? null : partialDownloadBytes;
} else {
obj.downloads.internal_partial_.bytes = null;
obj.downloads.internal_partial_.seconds = null;
}
if (overrides.completeBadSize) {
obj.downloads.internal_complete_.seconds =
overrides.noInternalComplete ? null : 1;
obj.downloads.internal_complete_.bytes =
overrides.noInternalComplete ? null : completeDownloadBytes;
} else {
obj.downloads.internal_complete_.bytes = null;
obj.downloads.internal_complete_.seconds = null;
}
} else {
obj.downloads.bits_partial_.bytes = null;
obj.downloads.bits_partial_.seconds = null;
obj.downloads.bits_complete_.bytes = null;
obj.downloads.bits_complete_.seconds = null;
obj.downloads.internal_partial_.bytes =
overrides.noInternalPartial ? null : partialDownloadBytes;
obj.downloads.internal_partial_.seconds =
overrides.noInternalPartial ? null : 1;
obj.downloads.internal_complete_.bytes =
overrides.noInternalComplete ? null : completeDownloadBytes;
obj.downloads.internal_complete_.seconds =
overrides.noInternalComplete ? null : 1;
}
return obj;
}