Bug 1357814 - Changes to sync's TPS tests to allow running from automation r?markh draft
authorThom Chiovoloni <tchiovoloni@mozilla.com>
Fri, 05 May 2017 14:54:03 -0400
changeset 573463 0ea799ba88c7c26b4e6e1ca1bc48a463a85e261a
parent 573462 9d46ca4e00c2c8111b1df15ab4cf185de23a2b50
child 627304 fba3ff6665ac7ad474624b6530007049e6bc0a30
push id57394
push userbmo:tchiovoloni@mozilla.com
push dateFri, 05 May 2017 19:10:32 +0000
reviewersmarkh
bugs1357814
milestone55.0a1
Bug 1357814 - Changes to sync's TPS tests to allow running from automation r?markh 1. Ensure we wait for browser-delayed-startup-finished 2. Parse the profile we're cleaning up from the cleanup phase name instead of using the selectedProfile. 3. Ensure that bookmark repair doesn't run randomly (this isn't necessary, but the repair code can make the actual reason for failure much more difficult to debug, and could probably cause a test to pass when it should not). 4. Add multiprocessCompatible flags so that TPS can still start in nightly (and because it is). MozReview-Commit-ID: 98UvRoFOdzv
services/sync/tps/extensions/mozmill/install.rdf
services/sync/tps/extensions/tps/components/tps-cmdline.js
services/sync/tps/extensions/tps/install.rdf
services/sync/tps/extensions/tps/resource/tps.jsm
testing/tps/tps/testrunner.py
--- a/services/sync/tps/extensions/mozmill/install.rdf
+++ b/services/sync/tps/extensions/mozmill/install.rdf
@@ -15,10 +15,11 @@
 
      <em:targetApplication>
        <Description>
          <em:id>toolkit@mozilla.org</em:id>
          <em:minVersion>10.0</em:minVersion>
          <em:maxVersion>38.*</em:maxVersion>
        </Description>
      </em:targetApplication>
+     <em:multiprocessCompatible>true</em:multiprocessCompatible>
    </Description>
 </RDF>
--- a/services/sync/tps/extensions/tps/components/tps-cmdline.js
+++ b/services/sync/tps/extensions/tps/components/tps-cmdline.js
@@ -15,16 +15,17 @@ const nsICategoryManager             = C
 const nsICmdLineHandler              = Components.interfaces.nsICmdLineHandler;
 const nsICommandLine                 = Components.interfaces.nsICommandLine;
 const nsICommandLineHandler          = Components.interfaces.nsICommandLineHandler;
 const nsIComponentRegistrar          = Components.interfaces.nsIComponentRegistrar;
 const nsISupportsString              = Components.interfaces.nsISupportsString;
 const nsIWindowWatcher               = Components.interfaces.nsIWindowWatcher;
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/Services.jsm");
 
 function TPSCmdLineHandler() {}
 
 TPSCmdLineHandler.prototype = {
   classDescription: "TPSCmdLineHandler",
   classID: TPS_CMDLINE_CLSID,
   contractID: TPS_CMDLINE_CONTRACTID,
 
@@ -51,30 +52,30 @@ TPSCmdLineHandler.prototype = {
     if (phase == null)
         throw Error("must specify --tpsphase with --tps");
     let logfile = cmdLine.handleFlagWithParam("tpslogfile", false);
     if (logfile == null)
         logfile = "";
 
     options.ignoreUnusedEngines = cmdLine.handleFlag("ignore-unused-engines",
                                                      false);
-
+    let uri = cmdLine.resolveURI(uristr).spec;
 
-    /* Ignore the platform's online/offline status while running tests. */
-    var ios = Components.classes["@mozilla.org/network/io-service;1"]
-              .getService(Components.interfaces.nsIIOService2);
-    ios.manageOfflineStatus = false;
-    ios.offline = false;
-
-    Components.utils.import("resource://tps/tps.jsm");
-    Components.utils.import("resource://tps/quit.js", TPS);
-    let uri = cmdLine.resolveURI(uristr).spec;
-    TPS.RunTestPhase(uri, phase, logfile, options);
-
-    // cmdLine.preventDefault = true;
+    const onStartupFinished = () => {
+      Services.obs.removeObserver(onStartupFinished, "browser-delayed-startup-finished");
+      /* Ignore the platform's online/offline status while running tests. */
+      var ios = Components.classes["@mozilla.org/network/io-service;1"]
+                .getService(Components.interfaces.nsIIOService2);
+      ios.manageOfflineStatus = false;
+      ios.offline = false;
+      Components.utils.import("resource://tps/tps.jsm");
+      Components.utils.import("resource://tps/quit.js", TPS);
+      TPS.RunTestPhase(uri, phase, logfile, options);
+    };
+    Services.obs.addObserver(onStartupFinished, "browser-delayed-startup-finished");
   },
 
   helpInfo: "  --tps <file>              Run TPS tests with the given test file.\n" +
             "  --tpsphase <phase>        Run the specified phase in the TPS test.\n" +
             "  --tpslogfile <file>       Logfile for TPS output.\n" +
             "  --ignore-unused-engines   Don't load engines not used in tests.\n",
 };
 
--- a/services/sync/tps/extensions/tps/install.rdf
+++ b/services/sync/tps/extensions/tps/install.rdf
@@ -19,10 +19,11 @@
     </em:targetApplication>
 
     <!-- front-end metadata -->
     <em:name>TPS</em:name>
     <em:description>Sync test extension</em:description>
     <em:creator>Jonathan Griffin</em:creator>
     <em:contributor>Henrik Skupin</em:contributor>
     <em:homepageURL>https://developer.mozilla.org/en-US/docs/TPS</em:homepageURL>
+    <em:multiprocessCompatible>true</em:multiprocessCompatible>
   </Description>
 </RDF>
--- a/services/sync/tps/extensions/tps/resource/tps.jsm
+++ b/services/sync/tps/extensions/tps/resource/tps.jsm
@@ -895,20 +895,19 @@ var TPS = {
    * This is called by RunTestPhase() after the environment is validated.
    */
   _executeTestPhase: function _executeTestPhase(file, phase, settings) {
     try {
       this.config = JSON.parse(prefs.getCharPref("tps.config"));
       // parse the test file
       Services.scriptloader.loadSubScript(file, this);
       this._currentPhase = phase;
+      // cleanup phases are in the format `cleanup-${profileName}`.
       if (this._currentPhase.startsWith("cleanup-")) {
-        let profileToClean = Cc["@mozilla.org/toolkit/profile-service;1"]
-                             .getService(Ci.nsIToolkitProfileService)
-                             .selectedProfile.name;
+        let profileToClean = this._currentPhase.slice("cleanup-".length);
         this.phases[this._currentPhase] = profileToClean;
         this.Phase(this._currentPhase, [[this.Cleanup]]);
       } else {
         // Don't bother doing this for cleanup phases.
         this._tryLoadPingSchema(file);
       }
       let this_phase = this._phaselist[this._currentPhase];
 
--- a/testing/tps/tps/testrunner.py
+++ b/testing/tps/tps/testrunner.py
@@ -72,16 +72,17 @@ class TPSTestRunner(object):
         # Don't open a dialog to show available add-on updates
         'extensions.update.notifyUser': False,
         '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,
         'services.sync.testing.tps': True,
+        'engine.bookmarks.repair.enabled': 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',