зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1763622 - Prevent telemetry to be sampled in uptake test r=gbeckley
Since Bug 1620175, we only send telemetry via events, which are sampled in ESR and Release. When the test suite is ran via a *Beta-as-release simulation*, the telemetry is sampled and tests fail. This patch fixes the failing test by forcing it to run as the Nightly channel Differential Revision: https://phabricator.services.mozilla.com/D143191
This commit is contained in:
Родитель
1dec4a6bda
Коммит
0f0d959c83
|
@ -57,10 +57,12 @@ add_task(async function test_each_status_can_be_caught_in_snapshot() {
|
|||
const startSnapshot = getUptakeTelemetrySnapshot(COMPONENT, source);
|
||||
|
||||
const expectedIncrements = {};
|
||||
for (const status of Object.values(UptakeTelemetry.STATUS)) {
|
||||
expectedIncrements[status] = 1;
|
||||
await UptakeTelemetry.report(COMPONENT, status, { source });
|
||||
}
|
||||
await withFakeChannel("nightly", async () => {
|
||||
for (const status of Object.values(UptakeTelemetry.STATUS)) {
|
||||
expectedIncrements[status] = 1;
|
||||
await UptakeTelemetry.report(COMPONENT, status, { source });
|
||||
}
|
||||
});
|
||||
|
||||
const endSnapshot = getUptakeTelemetrySnapshot(COMPONENT, source);
|
||||
checkUptakeTelemetry(startSnapshot, endSnapshot, expectedIncrements);
|
||||
|
|
|
@ -15,7 +15,7 @@ const { RemoteSettings } = ChromeUtils.import(
|
|||
"resource://services-settings/remote-settings.js"
|
||||
);
|
||||
const { Utils } = ChromeUtils.import("resource://services-settings/Utils.jsm");
|
||||
const { UptakeTelemetry } = ChromeUtils.import(
|
||||
const { UptakeTelemetry, Policy } = ChromeUtils.import(
|
||||
"resource://services-common/uptake-telemetry.js"
|
||||
);
|
||||
const { TelemetryTestUtils } = ChromeUtils.import(
|
||||
|
@ -62,6 +62,10 @@ function run_test() {
|
|||
server = new HttpServer();
|
||||
server.start(-1);
|
||||
|
||||
// Pretend we are in nightly channel to make sure all telemetry events are sent.
|
||||
let oldGetChannel = Policy.getChannel;
|
||||
Policy.getChannel = () => "nightly";
|
||||
|
||||
// Point the blocklist clients to use this local HTTP server.
|
||||
Services.prefs.setCharPref(
|
||||
"services.settings.server",
|
||||
|
@ -94,7 +98,8 @@ function run_test() {
|
|||
|
||||
run_next_test();
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
registerCleanupFunction(() => {
|
||||
Policy.getChannel = oldGetChannel;
|
||||
server.stop(() => {});
|
||||
});
|
||||
}
|
||||
|
@ -970,29 +975,27 @@ add_task(async function test_telemetry_reports_error_name_as_event_nightly() {
|
|||
throw e;
|
||||
};
|
||||
|
||||
await withFakeChannel("nightly", async () => {
|
||||
try {
|
||||
await client.maybeSync(2000);
|
||||
} catch (e) {}
|
||||
try {
|
||||
await client.maybeSync(2000);
|
||||
} catch (e) {}
|
||||
|
||||
TelemetryTestUtils.assertEvents(
|
||||
TelemetryTestUtils.assertEvents(
|
||||
[
|
||||
[
|
||||
[
|
||||
"uptake.remotecontent.result",
|
||||
"uptake",
|
||||
"remotesettings",
|
||||
UptakeTelemetry.STATUS.UNKNOWN_ERROR,
|
||||
{
|
||||
source: client.identifier,
|
||||
trigger: "manual",
|
||||
duration: v => v >= 0,
|
||||
errorName: "ThrownError",
|
||||
},
|
||||
],
|
||||
"uptake.remotecontent.result",
|
||||
"uptake",
|
||||
"remotesettings",
|
||||
UptakeTelemetry.STATUS.UNKNOWN_ERROR,
|
||||
{
|
||||
source: client.identifier,
|
||||
trigger: "manual",
|
||||
duration: v => v >= 0,
|
||||
errorName: "ThrownError",
|
||||
},
|
||||
],
|
||||
TELEMETRY_EVENTS_FILTERS
|
||||
);
|
||||
});
|
||||
],
|
||||
TELEMETRY_EVENTS_FILTERS
|
||||
);
|
||||
|
||||
client.db.list = backup;
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ const { AppConstants } = ChromeUtils.import(
|
|||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { setTimeout } = ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
||||
|
||||
const { UptakeTelemetry } = ChromeUtils.import(
|
||||
const { UptakeTelemetry, Policy } = ChromeUtils.import(
|
||||
"resource://services-common/uptake-telemetry.js"
|
||||
);
|
||||
const { RemoteSettingsClient } = ChromeUtils.import(
|
||||
|
@ -83,10 +83,15 @@ function run_test() {
|
|||
server = new HttpServer();
|
||||
server.start(-1);
|
||||
|
||||
// Pretend we are in nightly channel to make sure all telemetry events are sent.
|
||||
let oldGetChannel = Policy.getChannel;
|
||||
Policy.getChannel = () => "nightly";
|
||||
|
||||
run_next_test();
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
server.stop(function() {});
|
||||
registerCleanupFunction(() => {
|
||||
Policy.getChannel = oldGetChannel;
|
||||
server.stop(() => {});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -189,9 +194,7 @@ add_task(async function test_check_success() {
|
|||
};
|
||||
Services.obs.addObserver(observer, "remote-settings:changes-poll-end");
|
||||
|
||||
await withFakeChannel("nightly", async () => {
|
||||
await RemoteSettings.pollChanges();
|
||||
});
|
||||
await RemoteSettings.pollChanges();
|
||||
|
||||
// It didn't fail, hence we are sure that the unknown collection ``some-other-bucket/test-collection``
|
||||
// was ignored, otherwise it would have tried to reach the network.
|
||||
|
@ -401,21 +404,72 @@ const TELEMETRY_EVENTS_FILTERS = {
|
|||
method: "uptake",
|
||||
};
|
||||
add_task(async function test_age_of_data_is_reported_in_uptake_status() {
|
||||
await withFakeChannel("nightly", async () => {
|
||||
const serverTime = 1552323900000;
|
||||
const recordsTimestamp = serverTime - 3600 * 1000;
|
||||
const serverTime = 1552323900000;
|
||||
const recordsTimestamp = serverTime - 3600 * 1000;
|
||||
server.registerPathHandler(
|
||||
CHANGES_PATH,
|
||||
serveChangesEntries(serverTime, [
|
||||
{
|
||||
id: "b6ba7fab-a40a-4d03-a4af-6b627f3c5b36",
|
||||
last_modified: recordsTimestamp,
|
||||
host: "localhost",
|
||||
bucket: "main",
|
||||
collection: "some-entry",
|
||||
},
|
||||
])
|
||||
);
|
||||
|
||||
await RemoteSettings.pollChanges();
|
||||
|
||||
TelemetryTestUtils.assertEvents(
|
||||
[
|
||||
[
|
||||
"uptake.remotecontent.result",
|
||||
"uptake",
|
||||
"remotesettings",
|
||||
UptakeTelemetry.STATUS.SUCCESS,
|
||||
{
|
||||
source: TELEMETRY_SOURCE_POLL,
|
||||
age: "3600",
|
||||
trigger: "manual",
|
||||
},
|
||||
],
|
||||
[
|
||||
"uptake.remotecontent.result",
|
||||
"uptake",
|
||||
"remotesettings",
|
||||
UptakeTelemetry.STATUS.SUCCESS,
|
||||
{
|
||||
source: TELEMETRY_SOURCE_SYNC,
|
||||
duration: () => true,
|
||||
trigger: "manual",
|
||||
timestamp: `"${recordsTimestamp}"`,
|
||||
},
|
||||
],
|
||||
],
|
||||
TELEMETRY_EVENTS_FILTERS
|
||||
);
|
||||
});
|
||||
add_task(clear_state);
|
||||
|
||||
add_task(
|
||||
async function test_synchronization_duration_is_reported_in_uptake_status() {
|
||||
server.registerPathHandler(
|
||||
CHANGES_PATH,
|
||||
serveChangesEntries(serverTime, [
|
||||
serveChangesEntries(10000, [
|
||||
{
|
||||
id: "b6ba7fab-a40a-4d03-a4af-6b627f3c5b36",
|
||||
last_modified: recordsTimestamp,
|
||||
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();
|
||||
|
||||
|
@ -425,10 +479,10 @@ add_task(async function test_age_of_data_is_reported_in_uptake_status() {
|
|||
"uptake.remotecontent.result",
|
||||
"uptake",
|
||||
"remotesettings",
|
||||
UptakeTelemetry.STATUS.SUCCESS,
|
||||
"success",
|
||||
{
|
||||
source: TELEMETRY_SOURCE_POLL,
|
||||
age: "3600",
|
||||
age: () => true,
|
||||
trigger: "manual",
|
||||
},
|
||||
],
|
||||
|
@ -436,71 +490,16 @@ add_task(async function test_age_of_data_is_reported_in_uptake_status() {
|
|||
"uptake.remotecontent.result",
|
||||
"uptake",
|
||||
"remotesettings",
|
||||
UptakeTelemetry.STATUS.SUCCESS,
|
||||
"success",
|
||||
{
|
||||
source: TELEMETRY_SOURCE_SYNC,
|
||||
duration: () => true,
|
||||
duration: v => v >= 1000,
|
||||
trigger: "manual",
|
||||
timestamp: `"${recordsTimestamp}"`,
|
||||
},
|
||||
],
|
||||
],
|
||||
TELEMETRY_EVENTS_FILTERS
|
||||
);
|
||||
});
|
||||
});
|
||||
add_task(clear_state);
|
||||
|
||||
add_task(
|
||||
async function test_synchronization_duration_is_reported_in_uptake_status() {
|
||||
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();
|
||||
|
||||
TelemetryTestUtils.assertEvents(
|
||||
[
|
||||
[
|
||||
"uptake.remotecontent.result",
|
||||
"uptake",
|
||||
"remotesettings",
|
||||
"success",
|
||||
{
|
||||
source: TELEMETRY_SOURCE_POLL,
|
||||
age: () => true,
|
||||
trigger: "manual",
|
||||
},
|
||||
],
|
||||
[
|
||||
"uptake.remotecontent.result",
|
||||
"uptake",
|
||||
"remotesettings",
|
||||
"success",
|
||||
{
|
||||
source: TELEMETRY_SOURCE_SYNC,
|
||||
duration: v => v >= 1000,
|
||||
trigger: "manual",
|
||||
},
|
||||
],
|
||||
],
|
||||
TELEMETRY_EVENTS_FILTERS
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
add_task(clear_state);
|
||||
|
|
|
@ -9,7 +9,7 @@ const { RemoteSettings } = ChromeUtils.import(
|
|||
const { RemoteSettingsClient } = ChromeUtils.import(
|
||||
"resource://services-settings/RemoteSettingsClient.jsm"
|
||||
);
|
||||
const { UptakeTelemetry } = ChromeUtils.import(
|
||||
const { UptakeTelemetry, Policy } = ChromeUtils.import(
|
||||
"resource://services-common/uptake-telemetry.js"
|
||||
);
|
||||
const { TelemetryTestUtils } = ChromeUtils.import(
|
||||
|
@ -78,9 +78,16 @@ function run_test() {
|
|||
server = new HttpServer();
|
||||
server.start(-1);
|
||||
|
||||
// Pretend we are in nightly channel to make sure all telemetry events are sent.
|
||||
let oldGetChannel = Policy.getChannel;
|
||||
Policy.getChannel = () => "nightly";
|
||||
|
||||
run_next_test();
|
||||
|
||||
registerCleanupFunction(() => server.stop(() => {}));
|
||||
registerCleanupFunction(() => {
|
||||
Policy.getChannel = oldGetChannel;
|
||||
server.stop(() => {});
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function test_check_signatures() {
|
||||
|
@ -634,28 +641,26 @@ add_task(async function test_check_synchronization_with_signatures() {
|
|||
method: "uptake",
|
||||
};
|
||||
|
||||
await withFakeChannel("nightly", async () => {
|
||||
// Events telemetry is sampled on released, use fake channel.
|
||||
await client.maybeSync(5000);
|
||||
// Events telemetry is sampled on released, use fake channel.
|
||||
await client.maybeSync(5000);
|
||||
|
||||
// We should report a corruption_error.
|
||||
TelemetryTestUtils.assertEvents(
|
||||
// We should report a corruption_error.
|
||||
TelemetryTestUtils.assertEvents(
|
||||
[
|
||||
[
|
||||
[
|
||||
"uptake.remotecontent.result",
|
||||
"uptake",
|
||||
"remotesettings",
|
||||
UptakeTelemetry.STATUS.CORRUPTION_ERROR,
|
||||
{
|
||||
source: client.identifier,
|
||||
duration: v => v > 0,
|
||||
trigger: "manual",
|
||||
},
|
||||
],
|
||||
"uptake.remotecontent.result",
|
||||
"uptake",
|
||||
"remotesettings",
|
||||
UptakeTelemetry.STATUS.CORRUPTION_ERROR,
|
||||
{
|
||||
source: client.identifier,
|
||||
duration: v => v > 0,
|
||||
trigger: "manual",
|
||||
},
|
||||
],
|
||||
TELEMETRY_EVENTS_FILTERS
|
||||
);
|
||||
});
|
||||
],
|
||||
TELEMETRY_EVENTS_FILTERS
|
||||
);
|
||||
|
||||
// The local data was corrupted, and the Telemetry status reflects it.
|
||||
// But the sync overwrote the bad data and was eventually a success.
|
||||
|
|
Загрузка…
Ссылка в новой задаче