Bug 1229986 - get Sync tps tests starting again. r=whimboo
authorMark Hammond <mhammond@skippinet.com.au>
Fri, 04 Dec 2015 12:55:57 +1100
changeset 309670 6794f4bf3f8e2f1398134dc78433bba0495505fd
parent 309669 5161ded671e09997eaf27a7e8d5f3e5823e51ac5
child 309671 dfa767dc0c86d161b0d2c938358e7954a5f3bfbe
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1229986
milestone45.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 1229986 - get Sync tps tests starting again. r=whimboo
services/sync/tps/extensions/tps/resource/auth/fxaccounts.jsm
services/sync/tps/extensions/tps/resource/tps.jsm
testing/tps/.gitignore
testing/tps/.hgignore
testing/tps/setup.py
testing/tps/tps/testrunner.py
--- a/services/sync/tps/extensions/tps/resource/auth/fxaccounts.jsm
+++ b/services/sync/tps/extensions/tps/resource/auth/fxaccounts.jsm
@@ -62,20 +62,20 @@ var Authentication = {
    *        The user's password
    */
   signIn: function signIn(account) {
     let cb = Async.makeSpinningCallback();
 
     Logger.AssertTrue(account["username"], "Username has been found");
     Logger.AssertTrue(account["password"], "Password has been found");
 
-    Logger.logInfo("Login user: " + account["username"] + '\n');
+    Logger.logInfo("Login user: " + account["username"]);
 
     let client = new FxAccountsClient();
-    client.signIn(account["username"], account["password"]).then(credentials => {
+    client.signIn(account["username"], account["password"], true).then(credentials => {
       return fxAccounts.setSignedInUser(credentials);
     }).then(() => {
       cb(null, true);
     }, error => {
       cb(error, false);
     });
 
     try {
--- a/services/sync/tps/extensions/tps/resource/tps.jsm
+++ b/services/sync/tps/extensions/tps/resource/tps.jsm
@@ -103,42 +103,52 @@ var TPS = {
   _syncActive: false,
   _syncErrors: 0,
   _syncWipeAction: null,
   _tabsAdded: 0,
   _tabsFinished: 0,
   _test: null,
   _triggeredSync: false,
   _usSinceEpoch: 0,
+  _requestedQuit: false,
 
   _init: function TPS__init() {
     // Check if Firefox Accounts is enabled
     let service = Cc["@mozilla.org/weave/service;1"]
                   .getService(Components.interfaces.nsISupports)
                   .wrappedJSObject;
     this.fxaccounts_enabled = service.fxAccountsEnabled;
 
     this.delayAutoSync();
 
     OBSERVER_TOPICS.forEach(function (aTopic) {
       Services.obs.addObserver(this, aTopic, true);
     }, this);
 
+    // Configure some logging prefs for Sync itself.
+    Weave.Svc.Prefs.set("log.appender.dump", "Debug");
     // Import the appropriate authentication module
     if (this.fxaccounts_enabled) {
       Cu.import("resource://tps/auth/fxaccounts.jsm", module);
     }
     else {
       Cu.import("resource://tps/auth/sync.jsm", module);
     }
   },
 
-  DumpError: function TPS__DumpError(msg) {
+  DumpError(msg, exc = null) {
     this._errors++;
-    Logger.logError("[phase" + this._currentPhase + "] " + msg);
+    let errInfo;
+    if (exc) {
+      errInfo = Utils.exceptionStr(exc); // includes details and stack-trace.
+    } else {
+      // always write a stack even if no error passed.
+      errInfo = Utils.stackTrace(new Error());
+    }
+    Logger.logError(`[phase ${this._currentPhase}] ${msg} - ${errInfo}`);
     this.quit();
   },
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
                                          Ci.nsISupportsWeakReference]),
 
   observe: function TPS__observe(subject, topic, data) {
     try {
@@ -227,17 +237,17 @@ var TPS = {
           break;
 
         case "weave:engine:stop-tracking":
           this._isTracking = false;
           break;
       }
     }
     catch (e) {
-      this.DumpError("Exception caught: " + Utils.exceptionStr(e));
+      this.DumpError("Observer failed", e);
       return;
     }
   },
 
   /**
    * Given that we cannot complely disable the automatic sync operations, we
    * massively delay the next sync. Sync operations have to only happen when
    * directly called via TPS.Sync()!
@@ -260,16 +270,17 @@ var TPS = {
       this._currentAction++;
       Utils.nextTick(function() {
         this.RunNextTestAction();
       }, this);
     }
   },
 
   quit: function TPS__quit() {
+    this._requestedQuit = true;
     this.goQuitApplication();
   },
 
   HandleWindows: function (aWindow, action) {
     Logger.logInfo("executing action " + action.toUpperCase() +
                    " on window " + JSON.stringify(aWindow));
     switch(action) {
       case ACTION_ADD:
@@ -409,36 +420,36 @@ var TPS = {
   },
 
   HandlePasswords: function (passwords, action) {
     try {
       for (let password of passwords) {
         let password_id = -1;
         Logger.logInfo("executing action " + action.toUpperCase() +
                       " on password " + JSON.stringify(password));
-        var password = new Password(password);
+        let passwordOb = new Password(password);
         switch (action) {
           case ACTION_ADD:
-            Logger.AssertTrue(password.Create() > -1, "error adding password");
+            Logger.AssertTrue(passwordOb.Create() > -1, "error adding password");
             break;
           case ACTION_VERIFY:
-            Logger.AssertTrue(password.Find() != -1, "password not found");
+            Logger.AssertTrue(passwordOb.Find() != -1, "password not found");
             break;
           case ACTION_VERIFY_NOT:
-            Logger.AssertTrue(password.Find() == -1,
+            Logger.AssertTrue(passwordOb.Find() == -1,
               "password found, but it shouldn't exist");
             break;
           case ACTION_DELETE:
-            Logger.AssertTrue(password.Find() != -1, "password not found");
-            password.Remove();
+            Logger.AssertTrue(passwordOb.Find() != -1, "password not found");
+            passwordOb.Remove();
             break;
           case ACTION_MODIFY:
-            if (password.updateProps != null) {
-              Logger.AssertTrue(password.Find() != -1, "password not found");
-              password.Update();
+            if (passwordOb.updateProps != null) {
+              Logger.AssertTrue(passwordOb.Find() != -1, "password not found");
+              passwordOb.Update();
             }
             break;
           default:
             Logger.AssertTrue(false, "invalid action: " + action);
         }
       }
       Logger.logPass("executing action " + action.toUpperCase() +
                      " on passwords");
@@ -596,17 +607,25 @@ var TPS = {
 
       // if we're in an async operation, don't continue on to the next action
       if (this._operations_pending)
         return;
 
       this._currentAction++;
     }
     catch(e) {
-      this.DumpError("Exception caught: " + Utils.exceptionStr(e));
+      if (Async.isShutdownException(e)) {
+        if (this._requestedQuit) {
+          Logger.logInfo("Sync aborted due to requested shutdown");
+        } else {
+          this.DumpError("Sync aborted due to shutdown, but we didn't request it");
+        }
+      } else {
+        this.DumpError("RunNextTestAction failed", e);
+      }
       return;
     }
     this.RunNextTestAction();
   },
 
   /**
    * Runs a single test phase.
    *
@@ -653,17 +672,17 @@ var TPS = {
         this.waitForEvent("weave:service:ready");
       }
 
       // Always give Sync an extra tick to initialize. If we waited for the
       // service:ready event, this is required to ensure all handlers have
       // executed.
       Utils.nextTick(this._executeTestPhase.bind(this, file, phase, settings));
     } catch(e) {
-      this.DumpError("Exception caught: " + Utils.exceptionStr(e));
+      this.DumpError("RunTestPhase failed", e);
       return;
     }
   },
 
   /**
    * Executes a single test phase.
    *
    * This is called by RunTestPhase() after the environment is validated.
@@ -738,17 +757,17 @@ var TPS = {
         prefs.setCharPref('tps.account.password', this.config.sync_account.password);
         prefs.setCharPref('tps.account.passphrase', this.config.sync_account.passphrase);
       }
 
       // start processing the test actions
       this._currentAction = 0;
     }
     catch(e) {
-      this.DumpError("Exception caught: " + Utils.exceptionStr(e));
+      this.DumpError("_executeTestPhase failed", e);
       return;
     }
   },
 
   /**
    * Register a single phase with the test harness.
    *
    * This is called when loading individual test files.
@@ -814,20 +833,16 @@ var TPS = {
    */
   waitForEvent: function waitForEvent(aEventName) {
     Logger.logInfo("Waiting for " + aEventName + "...");
     let cb = Async.makeSpinningCallback();
     Svc.Obs.add(aEventName, cb);
     cb.wait();
     Svc.Obs.remove(aEventName, cb);
     Logger.logInfo(aEventName + " observed!");
-
-    cb = Async.makeSpinningCallback();
-    Utils.nextTick(cb);
-    cb.wait();
   },
 
 
   /**
    * Waits for Sync to logged in before returning
    */
   waitForSetupComplete: function waitForSetup() {
     if (!this._setupComplete) {
@@ -863,16 +878,23 @@ var TPS = {
 
     Logger.logInfo("Setting client credentials and login.");
     let account = this.fxaccounts_enabled ? this.config.fx_account
                                           : this.config.sync_account;
     Authentication.signIn(account);
     this.waitForSetupComplete();
     Logger.AssertEqual(Weave.Status.service, Weave.STATUS_OK, "Weave status OK");
     this.waitForTracking();
+    // If fxaccounts is enabled we get an initial sync at login time - let
+    // that complete.
+    if (this.fxaccounts_enabled) {
+      this._triggeredSync = true;
+      this.waitForEvent("weave:service:sync:start");
+      this.waitForSyncFinished();
+    }
   },
 
   /**
    * Triggers a sync operation
    *
    * @param {String} [wipeAction]
    *        Type of wipe to perform (resetClient, wipeClient, wipeRemote)
    *
new file mode 100644
--- /dev/null
+++ b/testing/tps/.gitignore
@@ -0,0 +1,4 @@
+# These files are added by running the TPS test suite.
+build/
+dist/
+tps.egg-info/
new file mode 100644
--- /dev/null
+++ b/testing/tps/.hgignore
@@ -0,0 +1,4 @@
+# These files are added by running the TPS test suite.
+build/
+dist/
+tps.egg-info/
--- a/testing/tps/setup.py
+++ b/testing/tps/setup.py
@@ -8,19 +8,19 @@ import sys
 version = '0.5'
 
 deps = ['httplib2 == 0.7.3',
         'mozfile == 1.1',
         'mozhttpd == 0.7',
         'mozinfo == 0.7',
         'mozinstall == 1.10',
         'mozprocess == 0.19',
-        'mozprofile == 0.21',
+        'mozprofile == 0.27',
         'mozrunner == 6.0',
-        'mozversion == 0.6',
+        'mozversion == 1.4',
        ]
 
 # we only support python 2.6+ right now
 assert sys.version_info[0] == 2
 assert sys.version_info[1] >= 6
 
 setup(name='tps',
       version=version,
--- a/testing/tps/tps/testrunner.py
+++ b/testing/tps/tps/testrunner.py
@@ -67,16 +67,18 @@ class TPSTestRunner(object):
         'extensions.getAddons.get.url': 'http://127.0.0.1:4567/addons/api/%IDS%.xml',
         'extensions.update.enabled': False,
         # Don't open a dialog to show available add-on updates
         'extensions.update.notifyUser': False,
         'services.sync.addons.ignoreRepositoryChecking': True,
         'services.sync.firstSync': 'notReady',
         'services.sync.lastversion': '1.0',
         'toolkit.startup.max_resumed_crashes': -1,
+        # hrm - not sure what the release/beta channels will do?
+        'xpinstall.signatures.required': False,
     }
 
     debug_preferences = {
         'services.sync.log.appender.console': 'Trace',
         'services.sync.log.appender.dump': 'Trace',
         'services.sync.log.appender.file.level': 'Trace',
         'services.sync.log.appender.file.logOnSuccess': True,
         'services.sync.log.rootLogger': 'Trace',