Bug 1367543 - Make sync's TPS tests handle cases where resyncs are triggered r?kitcambridge draft
authorThom Chiovoloni <tchiovoloni@mozilla.com>
Wed, 24 May 2017 16:16:23 -0400
changeset 583953 f294e08fe20819a4ef25151e350b24b0ea45ac82
parent 583952 8547e166d6d0fefa4edfe5bea4bf2e40c612c901
child 630258 3543198d8477de188e756c5b3c69c44d84704479
push id60606
push userbmo:tchiovoloni@mozilla.com
push dateWed, 24 May 2017 20:16:51 +0000
reviewerskitcambridge
bugs1367543
milestone55.0a1
Bug 1367543 - Make sync's TPS tests handle cases where resyncs are triggered r?kitcambridge MozReview-Commit-ID: 4owlGyLw5jU
services/sync/modules/policies.js
services/sync/tps/extensions/tps/resource/tps.jsm
--- a/services/sync/modules/policies.js
+++ b/services/sync/modules/policies.js
@@ -179,19 +179,21 @@ SyncScheduler.prototype = {
           // changed during the last sync, and we should schedule an immediate
           // follow-up sync.
           this._resyncs++;
           if (this._resyncs <= this.maxResyncs) {
             sync_interval = 0;
           } else {
             this._log.warn(`Resync attempt ${this._resyncs} exceeded ` +
                            `maximum ${this.maxResyncs}`);
+            Svc.Obs.notify("weave:service:resyncs-finished");
           }
         } else {
           this._resyncs = 0;
+          Svc.Obs.notify("weave:service:resyncs-finished");
         }
 
         this._syncErrors = 0;
         if (Status.sync == NO_SYNC_NODE_FOUND) {
           // If we don't have a Sync node, override the interval, even if we've
           // scheduled a follow-up sync.
           this._log.trace("Scheduling a sync at interval NO_SYNC_NODE_FOUND.");
           sync_interval = NO_SYNC_NODE_INTERVAL;
--- a/services/sync/tps/extensions/tps/resource/tps.jsm
+++ b/services/sync/tps/extensions/tps/resource/tps.jsm
@@ -95,17 +95,18 @@ const OBSERVER_TOPICS = ["fxaccounts:onl
                          "sessionstore-windows-restored",
                          "weave:engine:start-tracking",
                          "weave:engine:stop-tracking",
                          "weave:service:login:error",
                          "weave:service:setup-complete",
                          "weave:service:sync:finish",
                          "weave:service:sync:delayed",
                          "weave:service:sync:error",
-                         "weave:service:sync:start"
+                         "weave:service:sync:start",
+                         "weave:service:resyncs-finished",
                         ];
 
 var TPS = {
   _currentAction: -1,
   _currentPhase: -1,
   _enabledEngines: null,
   _errors: 0,
   _isTracking: false,
@@ -208,17 +209,17 @@ var TPS = {
           } else {
             this._triggeredSync = false;
             this.DumpError("Sync error; aborting test");
             return;
           }
 
           break;
 
-        case "weave:service:sync:finish":
+        case "weave:service:resyncs-finished":
           this._syncActive = false;
           this._syncErrors = 0;
           this._triggeredSync = false;
 
           this.delayAutoSync();
 
           // Wait a second before continuing, otherwise we can get
           // 'sync not complete' errors.
@@ -1112,17 +1113,17 @@ var TPS = {
     }
   },
 
   /**
    * Waits for Sync to be finished before returning
    */
   waitForSyncFinished: function TPS__waitForSyncFinished() {
     if (this._syncActive) {
-      this.waitForEvent("weave:service:sync:finished");
+      this.waitForEvent("weave:service:resyncs-finished");
     }
   },
 
   /**
    * Waits for Sync to start tracking before returning.
    */
   waitForTracking: function waitForTracking() {
     if (!this._isTracking) {