Bug 701863 - add test for cloned histograms in telemetry pings; r=taras

This commit is contained in:
Nathan Froyd 2011-11-18 15:28:05 -05:00
parent 1be53b4ad1
commit da0598fbca

View File

@ -15,11 +15,16 @@ Cu.import("resource://gre/modules/LightweightThemeManager.jsm");
const PATH = "/submit/telemetry/test-ping";
const SERVER = "http://localhost:4444";
const IGNORE_HISTOGRAM = "test::ignore_me";
const HISTOGRAM_FOR_STARTUP = "PAGE_FAULTS_HARD"
const CLONED_STARTUP_HISTOGRAM = "STARTUP_PAGE_FAULTS_HARD"
const IGNORE_HISTOGRAM_TO_CLONE = "MEMORY_HEAP_ALLOCATED"
const IGNORE_CLONED_HISTOGRAM = "test::ignore_me_also"
const BinaryInputStream = Components.Constructor(
"@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream",
"setInputStream");
const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
var httpserver = new nsHttpServer();
var gFinished = false;
@ -27,6 +32,7 @@ var gFinished = false;
function telemetry_ping () {
const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsIObserver);
TelemetryPing.observe(null, "test-ping", SERVER);
TelemetryPing.observe(null, "sessionstore-windows-restored", null);
}
function nonexistentServerObserver(aSubject, aTopic, aData) {
@ -43,8 +49,9 @@ function nonexistentServerObserver(aSubject, aTopic, aData) {
function telemetryObserver(aSubject, aTopic, aData) {
Services.obs.removeObserver(telemetryObserver, aTopic);
httpserver.registerPathHandler(PATH, checkHistograms);
const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
Telemetry.newHistogram(IGNORE_HISTOGRAM, 1, 2, 3, Telemetry.HISTOGRAM_BOOLEAN);
Telemetry.histogramFrom(CLONED_STARTUP_HISTOGRAM, HISTOGRAM_FOR_STARTUP);
Telemetry.histogramFrom(IGNORE_CLONED_HISTOGRAM, IGNORE_HISTOGRAM_TO_CLONE);
Services.startup.interrupted = true;
telemetry_ping();
}
@ -77,7 +84,15 @@ function checkHistograms(request, response) {
const TELEMETRY_PING = "TELEMETRY_PING";
const TELEMETRY_SUCCESS = "TELEMETRY_SUCCESS";
do_check_true(TELEMETRY_PING in payload.histograms);
do_check_true(CLONED_STARTUP_HISTOGRAM in payload.histograms);
let rh = Telemetry.registeredHistograms;
for (let name in rh) {
if (/SQLITE/.test(name) && name in payload.histograms) {
do_check_true(("STARTUP_" + name) in payload.histograms);
}
}
do_check_false(IGNORE_HISTOGRAM in payload.histograms);
do_check_false(IGNORE_CLONED_HISTOGRAM in payload.histograms);
// There should be one successful report from the previous telemetry ping.
const expected_tc = {