Bug 1178262 - Add test-coverage for sending persisted deletion pings. r=gfritzsche
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Wed, 08 Jul 2015 23:23:00 +0200
changeset 286368 048f102c4dd85cd07409ebd3dd7b7d5b1709182e
parent 286367 b44452a6fdacbc2869310219e1e0ba675c10b5e2
child 286369 6a1fa063e5208ce01d6d3a22c2c93238323daa01
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1178262
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1178262 - Add test-coverage for sending persisted deletion pings. r=gfritzsche
toolkit/components/telemetry/tests/unit/test_TelemetryController.js
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryController.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryController.js
@@ -147,21 +147,47 @@ add_task(function* test_simplePing() {
 add_task(function* test_deletionPing() {
   const isUnified = Preferences.get(PREF_UNIFIED, false);
   if (!isUnified) {
     // Skipping the test if unified telemetry is off, as no deletion ping will
     // be generated.
     return;
   }
 
+  const PREF_TELEMETRY_SERVER = "toolkit.telemetry.server";
+
   // Disable FHR upload: this should trigger a deletion ping.
   Preferences.set(PREF_FHR_UPLOAD_ENABLED, false);
 
   let ping = yield PingServer.promiseNextPing();
   checkPingFormat(ping, DELETION_PING_TYPE, true, false);
+  // Wait on ping activity to settle.
+  yield TelemetrySend.testWaitOnOutgoingPings();
+
+  // Restore FHR Upload.
+  Preferences.set(PREF_FHR_UPLOAD_ENABLED, true);
+
+  // Simulate a failure in sending the deletion ping by disabling the HTTP server.
+  yield PingServer.stop();
+  // Disable FHR upload to send a deletion ping again.
+  Preferences.set(PREF_FHR_UPLOAD_ENABLED, false);
+  // Wait for the send task to terminate, flagging it to do so at the next opportunity and
+  // cancelling any timeouts.
+  yield TelemetryController.reset();
+
+  // Enable the ping server again.
+  PingServer.start();
+  // We set the new server using the pref, otherwise it would get reset with
+  // |TelemetryController.reset|.
+  Preferences.set(PREF_TELEMETRY_SERVER, "http://localhost:" + PingServer.port);
+
+  // Reset the controller to spin the ping sending task.
+  yield TelemetryController.reset();
+  ping = yield PingServer.promiseNextPing();
+  checkPingFormat(ping, DELETION_PING_TYPE, true, false);
 
   // Restore FHR Upload.
   Preferences.set(PREF_FHR_UPLOAD_ENABLED, true);
 });
 
 add_task(function* test_pingHasClientId() {
   // Send a ping with a clientId.
   yield sendPing(true, false);
@@ -257,17 +283,17 @@ add_task(function* test_archivePings() {
     "TelemetryController should still archive pings if ping upload is enabled.");
 });
 
 // Test that we fuzz the submission time around midnight properly
 // to avoid overloading the telemetry servers.
 add_task(function* test_midnightPingSendFuzzing() {
   const fuzzingDelay = 60 * 60 * 1000;
   fakeMidnightPingFuzzingDelay(fuzzingDelay);
-  let now = new Date(2030, 5, 1, 11, 00, 0);
+  let now = new Date(2030, 5, 1, 11, 0, 0);
   fakeNow(now);
 
   let waitForTimer = () => new Promise(resolve => {
     fakePingSendTimer((callback, timeout) => {
       resolve([callback, timeout]);
     }, () => {});
   });