Bug 1450204 - Reset the ping id genrator after each test. r?chutten draft
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Tue, 03 Apr 2018 18:00:28 +0200
changeset 777204 cc07dce567e1b7ce47772a2a056b52510c00ef88
parent 776583 4a3275936ddf871103b53e00608e2b8d5aee7e69
push id105105
push useralessio.placitelli@gmail.com
push dateWed, 04 Apr 2018 11:30:31 +0000
reviewerschutten
bugs1450204
milestone61.0a1
Bug 1450204 - Reset the ping id genrator after each test. r?chutten MozReview-Commit-ID: UA6LWI0y67
toolkit/components/telemetry/tests/unit/test_TelemetrySend.js
--- a/toolkit/components/telemetry/tests/unit/test_TelemetrySend.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetrySend.js
@@ -201,16 +201,18 @@ add_task(async function test_sendPending
   pings = await PingServer.promiseNextPings(5);
   PingServer.registerPingHandler(() => Assert.ok(false, "Should not have received any pings now"));
   countByType = countPingTypes(pings);
 
   Assert.equal(countByType.get(TEST_TYPE_A), 5, "Should have received the correct amount of type A pings");
 
   await TelemetrySend.testWaitOnOutgoingPings();
   PingServer.resetPingHandler();
+  // Restore the default ping id generator.
+  fakeGeneratePingId(() => TelemetryUtils.generateUUID());
 });
 
 add_task(async function test_sendDateHeader() {
   fakeNow(new Date(Date.UTC(2011, 1, 1, 11, 0, 0)));
   await TelemetrySend.reset();
 
   let pingId = await TelemetryController.submitExternalPing("test-send-date-header", {});
   let req = await PingServer.promiseNextRequest();
@@ -308,16 +310,19 @@ add_task(async function test_backoffTime
   Assert.deepEqual(histSuccess.snapshot().counts, [sendAttempts, 3, 0],
                "Should have recorded sending failure in histograms.");
   Assert.greaterOrEqual(histSendTimeSuccess.snapshot().sum, 0,
                         "Should have recorded sending success in histograms.");
   Assert.equal(histogramValueCount(histSendTimeSuccess.snapshot()), 3,
                "Should have recorded sending success in histograms.");
   Assert.equal(histogramValueCount(histSendTimeFail.snapshot()), sendAttempts,
                "Should have recorded send failure times in histograms.");
+
+  // Restore the default ping id generator.
+  fakeGeneratePingId(() => TelemetryUtils.generateUUID());
 });
 
 add_task(async function test_discardBigPings() {
   const TEST_PING_TYPE = "test-ping-type";
 
   let histSizeExceeded = Telemetry.getHistogramById("TELEMETRY_PING_SIZE_EXCEEDED_SEND");
   let histDiscardedSize = Telemetry.getHistogramById("TELEMETRY_DISCARDED_SEND_PINGS_SIZE_MB");
   let histSuccess = Telemetry.getHistogramById("TELEMETRY_SUCCESS");
@@ -475,16 +480,19 @@ add_task(async function test_persistCurr
 
   // Triggering a shutdown should persist the pings.
   await TelemetrySend.shutdown();
   Assert.ok((await checkPingsSaved(ids)), "All pending pings should have been persisted");
 
   // After a restart the pings should have been found when scanning.
   await TelemetrySend.reset();
   Assert.equal(TelemetrySend.pendingPingCount, PING_COUNT, "Should have the correct pending ping count");
+
+  // Restore the default ping id generator.
+  fakeGeneratePingId(() => TelemetryUtils.generateUUID());
 });
 
 add_task(async function test_sendCheckOverride() {
   const TEST_PING_TYPE = "test-sendCheckOverride";
 
   // Clear any pending pings.
   await TelemetryController.testShutdown();
   await TelemetryStorage.testClearPendingPings();