зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1794409 - Tests for Telemetry on Utility r=chutten
Differential Revision: https://phabricator.services.mozilla.com/D159042
This commit is contained in:
Родитель
3b6b8e904e
Коммит
41d4db4ed9
|
@ -78,6 +78,8 @@ child:
|
|||
// The unused returned value is to have a promise we can await.
|
||||
async TestTriggerMetrics() returns (bool unused);
|
||||
|
||||
async TestTelemetryProbes();
|
||||
|
||||
async StartUtilityAudioDecoderService(Endpoint<PUtilityAudioDecoderParent> aEndpoint);
|
||||
|
||||
#if defined(MOZ_SANDBOX) && defined(MOZ_DEBUG) && defined(ENABLE_TESTS)
|
||||
|
|
|
@ -214,6 +214,13 @@ mozilla::ipc::IPCResult UtilityProcessChild::RecvTestTriggerMetrics(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult UtilityProcessChild::RecvTestTelemetryProbes() {
|
||||
const uint32_t kExpectedUintValue = 42;
|
||||
Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_UTILITY_ONLY_UINT,
|
||||
kExpectedUintValue);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
UtilityProcessChild::RecvStartUtilityAudioDecoderService(
|
||||
Endpoint<PUtilityAudioDecoderParent>&& aEndpoint) {
|
||||
|
|
|
@ -50,6 +50,8 @@ class UtilityProcessChild final : public PUtilityProcessChild {
|
|||
mozilla::ipc::IPCResult RecvTestTriggerMetrics(
|
||||
TestTriggerMetricsResolver&& aResolve);
|
||||
|
||||
mozilla::ipc::IPCResult RecvTestTelemetryProbes();
|
||||
|
||||
mozilla::ipc::IPCResult RecvStartUtilityAudioDecoderService(
|
||||
Endpoint<PUtilityAudioDecoderParent>&& aEndpoint);
|
||||
|
||||
|
|
|
@ -78,6 +78,20 @@ UtilityProcessTest::StopProcess() {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
UtilityProcessTest::TestTelemetryProbes() {
|
||||
RefPtr<UtilityProcessManager> utilityProc =
|
||||
UtilityProcessManager::GetSingleton();
|
||||
MOZ_ASSERT(utilityProc, "No UtilityprocessManager?");
|
||||
|
||||
for (RefPtr<UtilityProcessParent>& parent :
|
||||
utilityProc->GetAllProcessesProcessParent()) {
|
||||
Unused << parent->SendTestTelemetryProbes();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(UtilityProcessTest, nsIUtilityProcessTest)
|
||||
|
||||
} // namespace mozilla::ipc
|
||||
|
|
|
@ -22,4 +22,11 @@ interface nsIUtilityProcessTest : nsISupports
|
|||
* Allowing to stop Utility Process from JS code.
|
||||
*/
|
||||
void stopProcess();
|
||||
|
||||
/**
|
||||
* ** Test-only Method **
|
||||
*
|
||||
* Sending Telemetry probes
|
||||
*/
|
||||
void testTelemetryProbes();
|
||||
};
|
||||
|
|
|
@ -8284,6 +8284,21 @@ telemetry.test:
|
|||
record_in_processes:
|
||||
- 'socket'
|
||||
|
||||
utility_only_uint:
|
||||
bug_numbers:
|
||||
- 1794409
|
||||
description: A testing uint scalar; not meant to be touched.
|
||||
expires: never
|
||||
kind: uint
|
||||
notification_emails:
|
||||
- telemetry-client-dev@mozilla.com
|
||||
products:
|
||||
- 'firefox'
|
||||
- 'fennec'
|
||||
- 'thunderbird'
|
||||
record_in_processes:
|
||||
- 'utility'
|
||||
|
||||
all_processes_uint:
|
||||
bug_numbers:
|
||||
- 1278556
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
const { TelemetryController } = ChromeUtils.import(
|
||||
"resource://gre/modules/TelemetryController.jsm"
|
||||
);
|
||||
const { ContentTaskUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/ContentTaskUtils.jsm"
|
||||
);
|
||||
|
||||
const UTILITY_ONLY_UINT_SCALAR = "telemetry.test.utility_only_uint";
|
||||
|
||||
const utilityProcessTest = () => {
|
||||
return Cc["@mozilla.org/utility-process-test;1"].createInstance(
|
||||
Ci.nsIUtilityProcessTest
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* This function waits until utility scalars are reported into the
|
||||
* scalar snapshot.
|
||||
*/
|
||||
async function waitForUtilityScalars() {
|
||||
await ContentTaskUtils.waitForCondition(() => {
|
||||
const scalars = Telemetry.getSnapshotForScalars("main", false);
|
||||
return Object.keys(scalars).includes("utility");
|
||||
}, "Waiting for utility scalars to have been set");
|
||||
}
|
||||
|
||||
async function waitForUtilityValue() {
|
||||
await ContentTaskUtils.waitForCondition(() => {
|
||||
return (
|
||||
UTILITY_ONLY_UINT_SCALAR in
|
||||
Telemetry.getSnapshotForScalars("main", false).utility
|
||||
);
|
||||
}, "Waiting for utility uint value");
|
||||
}
|
||||
|
||||
add_setup(async function setup_telemetry_utility() {
|
||||
Assert.ok(
|
||||
Services.prefs.getBoolPref("media.utility-process.enabled"),
|
||||
"Utility process should be enabled"
|
||||
);
|
||||
|
||||
info("Start a UtilityProcess");
|
||||
await utilityProcessTest().startProcess();
|
||||
|
||||
do_get_profile(true);
|
||||
await TelemetryController.testSetup();
|
||||
});
|
||||
|
||||
add_task(async function test_scalars_in_utility_process() {
|
||||
Telemetry.clearScalars();
|
||||
await utilityProcessTest().testTelemetryProbes();
|
||||
|
||||
// Once scalars are set by the utility process, they don't immediately get
|
||||
// sent to the parent process. Wait for the Telemetry IPC Timer to trigger
|
||||
// and batch send the data back to the parent process.
|
||||
await waitForUtilityScalars();
|
||||
await waitForUtilityValue();
|
||||
|
||||
Assert.equal(
|
||||
Telemetry.getSnapshotForScalars("main", false).utility[
|
||||
UTILITY_ONLY_UINT_SCALAR
|
||||
],
|
||||
42,
|
||||
`${UTILITY_ONLY_UINT_SCALAR} must have the correct value (utility process).`
|
||||
);
|
||||
});
|
|
@ -115,5 +115,6 @@ tags = coverage
|
|||
[test_bug1555798.js]
|
||||
[test_UninstallPing.js]
|
||||
run-if = os == "win"
|
||||
[test_UtilityScalars.js]
|
||||
[test_failover_retry.js]
|
||||
skip-if = os == "android" # Android doesn't support telemetry though some tests manage to pass with xpcshell
|
||||
|
|
Загрузка…
Ссылка в новой задаче