Bug 1554178 - Disable events sampling for uptake telemetry tests r=glasserc

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mathieu Leplatre 2019-05-24 16:23:31 +00:00
Родитель 899ad56a3d
Коммит daebd4816c
4 изменённых файлов: 64 добавлений и 58 удалений

Просмотреть файл

@ -198,3 +198,17 @@ function checkUptakeTelemetry(snapshot1, snapshot2, expectedIncrements) {
equal(expected, actual, `check events for ${status}`);
}
}
async function withFakeChannel(channel, f) {
const module = ChromeUtils.import("resource://services-common/uptake-telemetry.js", null);
const oldPolicy = module.Policy;
module.Policy = {
...oldPolicy,
getChannel: () => channel,
};
try {
return await f();
} finally {
module.Policy = oldPolicy;
}
}

Просмотреть файл

@ -20,20 +20,6 @@ async function withFakeClientID(uuid, f) {
}
}
async function withFakeChannel(channel, f) {
const module = ChromeUtils.import("resource://services-common/uptake-telemetry.js", null);
const oldPolicy = module.Policy;
module.Policy = {
...oldPolicy,
getChannel: () => channel,
};
try {
return await f();
} finally {
module.Policy = oldPolicy;
}
}
add_task(async function test_unknown_status_is_not_reported() {
const source = "update-source";
const startHistogram = getUptakeTelemetrySnapshot(source);

Просмотреть файл

@ -343,14 +343,16 @@ add_task(async function test_telemetry_if_sync_succeeds() {
});
add_task(clear_state);
add_task(async function test_synchronization_duration_is_reported_in_uptake_status() {
await client.maybeSync(2000);
add_task(
withFakeChannel("nightly", /* test_synchronization_duration_is_reported_in_uptake_status */ async () => {
await client.maybeSync(2000);
TelemetryTestUtils.assertEvents([
["uptake.remotecontent.result", "uptake", "remotesettings", UptakeTelemetry.STATUS.SUCCESS,
{ source: client.identifier, duration: (v) => v > 0, trigger: "manual" }],
]);
});
TelemetryTestUtils.assertEvents([
["uptake.remotecontent.result", "uptake", "remotesettings", UptakeTelemetry.STATUS.SUCCESS,
{ source: client.identifier, duration: (v) => v > 0, trigger: "manual" }],
]);
})
);
add_task(clear_state);
add_task(async function test_telemetry_reports_if_application_fails() {

Просмотреть файл

@ -302,49 +302,53 @@ add_task(async function test_client_last_check_is_saved() {
add_task(clear_state);
add_task(async function test_age_of_data_is_reported_in_uptake_status() {
const serverTime = 1552323900000;
server.registerPathHandler(CHANGES_PATH, serveChangesEntries(serverTime, [{
id: "b6ba7fab-a40a-4d03-a4af-6b627f3c5b36",
last_modified: serverTime - 3600 * 1000,
host: "localhost",
bucket: "main",
collection: "some-entry",
}]));
add_task(
withFakeChannel("nightly", /* test_age_of_data_is_reported_in_uptake_status */ async () => {
const serverTime = 1552323900000;
server.registerPathHandler(CHANGES_PATH, serveChangesEntries(serverTime, [{
id: "b6ba7fab-a40a-4d03-a4af-6b627f3c5b36",
last_modified: serverTime - 3600 * 1000,
host: "localhost",
bucket: "main",
collection: "some-entry",
}]));
await RemoteSettings.pollChanges();
await RemoteSettings.pollChanges();
TelemetryTestUtils.assertEvents([
["uptake.remotecontent.result", "uptake", "remotesettings", UptakeTelemetry.STATUS.SUCCESS,
{ source: TELEMETRY_HISTOGRAM_POLL_KEY, age: "3600", trigger: "manual" }],
["uptake.remotecontent.result", "uptake", "remotesettings", UptakeTelemetry.STATUS.SUCCESS,
{ source: TELEMETRY_HISTOGRAM_SYNC_KEY, duration: () => true, trigger: "manual" }],
]);
});
TelemetryTestUtils.assertEvents([
["uptake.remotecontent.result", "uptake", "remotesettings", UptakeTelemetry.STATUS.SUCCESS,
{ source: TELEMETRY_HISTOGRAM_POLL_KEY, age: "3600", trigger: "manual" }],
["uptake.remotecontent.result", "uptake", "remotesettings", UptakeTelemetry.STATUS.SUCCESS,
{ source: TELEMETRY_HISTOGRAM_SYNC_KEY, duration: () => true, trigger: "manual" }],
]);
})
);
add_task(clear_state);
add_task(async function test_synchronization_duration_is_reported_in_uptake_status() {
server.registerPathHandler(CHANGES_PATH, serveChangesEntries(10000, [{
id: "b6ba7fab-a40a-4d03-a4af-6b627f3c5b36",
last_modified: 42,
host: "localhost",
bucket: "main",
collection: "some-entry",
}]));
const c = RemoteSettings("some-entry");
// Simulate a synchronization that lasts 1 sec.
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
c.maybeSync = () => new Promise(resolve => setTimeout(resolve, 1000));
add_task(
withFakeChannel("nightly", /* test_synchronization_duration_is_reported_in_uptake_status */ async () => {
server.registerPathHandler(CHANGES_PATH, serveChangesEntries(10000, [{
id: "b6ba7fab-a40a-4d03-a4af-6b627f3c5b36",
last_modified: 42,
host: "localhost",
bucket: "main",
collection: "some-entry",
}]));
const c = RemoteSettings("some-entry");
// Simulate a synchronization that lasts 1 sec.
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
c.maybeSync = () => new Promise(resolve => setTimeout(resolve, 1000));
await RemoteSettings.pollChanges();
await RemoteSettings.pollChanges();
TelemetryTestUtils.assertEvents([
["uptake.remotecontent.result", "uptake", "remotesettings", "success",
{ source: TELEMETRY_HISTOGRAM_POLL_KEY, age: () => true, trigger: "manual" }],
["uptake.remotecontent.result", "uptake", "remotesettings", "success",
{ source: TELEMETRY_HISTOGRAM_SYNC_KEY, duration: (v) => v >= 1000, trigger: "manual" }],
]);
});
TelemetryTestUtils.assertEvents([
["uptake.remotecontent.result", "uptake", "remotesettings", "success",
{ source: TELEMETRY_HISTOGRAM_POLL_KEY, age: () => true, trigger: "manual" }],
["uptake.remotecontent.result", "uptake", "remotesettings", "success",
{ source: TELEMETRY_HISTOGRAM_SYNC_KEY, duration: (v) => v >= 1000, trigger: "manual" }],
]);
})
);
add_task(clear_state);
add_task(async function test_success_with_partial_list() {