mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
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:
parent
3f41c3104f
commit
9871d095db
@ -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);
|
||||
|
@ -344,12 +344,14 @@ 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);
|
||||
await withFakeChannel("nightly", 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);
|
||||
|
||||
|
@ -303,47 +303,51 @@ 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",
|
||||
}]));
|
||||
await withFakeChannel("nightly", 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));
|
||||
await withFakeChannel("nightly", 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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user