Bug 521225 - Stop syncing for random failing Places tests, and make sheriffs happier, r=sdwilsh
authorMarco Bonardo <mbonardo@mozilla.com>
Tue, 13 Oct 2009 15:31:46 +0200
changeset 33793 239c5018acec543240100561dacace5bf5cc5db3
parent 33792 5cfc030d928ddade8cbacc17c7372cc48941eb5c
child 33794 7769be27ba62e7cc0fe3dce05914a027601237e4
push id9689
push usermak77@bonardo.net
push dateTue, 13 Oct 2009 13:33:27 +0000
treeherdermozilla-central@b6c6c4b45875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssdwilsh
bugs521225
milestone1.9.3a1pre
Bug 521225 - Stop syncing for random failing Places tests, and make sheriffs happier, r=sdwilsh
browser/components/places/tests/unit/head_bookmarks.js
toolkit/components/places/src/nsPlacesDBFlush.js
toolkit/components/places/tests/bookmarks/head_bookmarks.js
toolkit/components/places/tests/queries/head_queries.js
toolkit/components/places/tests/queries/test_results-as-visit.js
toolkit/components/places/tests/unit/head_bookmarks.js
--- a/browser/components/places/tests/unit/head_bookmarks.js
+++ b/browser/components/places/tests/unit/head_bookmarks.js
@@ -324,8 +324,20 @@ function dump_table(aName)
  * Flushes any events in the event loop of the main thread.
  */
 function flush_main_thread_events()
 {
   let tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
   while (tm.mainThread.hasPendingEvents())
     tm.mainThread.processNextEvent(false);
 }
+
+// These tests are known to randomly fail due to bug 507790 when database
+// flushes are active, so we turn off syncing for them.
+let randomFailingSyncTests = [
+  "test_browserGlue_smartBookmarks.js",
+];
+let currentTestFilename = do_get_file(_TEST_FILE[0], true).leafName;
+if (randomFailingSyncTests.indexOf(currentTestFilename) != -1) {
+  print("Test " + currentTestFilename + " is known random due to bug 507790, disabling PlacesDBFlush component.");
+  let sync = Cc["@mozilla.org/places/sync;1"].getService(Ci.nsIObserver);
+  sync.observe(null, "places-debug-stop-sync", null);
+}
--- a/toolkit/components/places/src/nsPlacesDBFlush.js
+++ b/toolkit/components/places/src/nsPlacesDBFlush.js
@@ -45,16 +45,18 @@ Components.utils.import("resource://gre/
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
 const kQuitApplication = "quit-application";
 const kSyncFinished = "places-sync-finished";
+const kDebugStopSync = "places-debug-stop-sync";
+const kDebugStartSync = "places-debug-start-sync";
 
 const kSyncPrefName = "places.syncDBTableIntervalInSecs";
 const kDefaultSyncInterval = 120;
 const kExpireDaysPrefName = "browser.history_expire_days";
 const kDefaultExpireDays = 90;
 
 // The number of milliseconds in a day.
 const kMSPerDay = 86400000;
@@ -103,16 +105,18 @@ function nsPlacesDBFlush()
     // The preference did not exist, so use the default.
     this._expireDays = kDefaultExpireDays;
   }
 
   // Register observers
   this._os = Cc["@mozilla.org/observer-service;1"].
              getService(Ci.nsIObserverService);
   this._os.addObserver(this, kQuitApplication, false);
+  this._os.addObserver(this, kDebugStopSync, false);
+  this._os.addObserver(this, kDebugStartSync, false);
 
   let (pb2 = this._prefs.QueryInterface(Ci.nsIPrefBranch2)) {
     pb2.addObserver(kSyncPrefName, this, false);
     pb2.addObserver(kExpireDaysPrefName, this, false);
   }
 
   // Create our timer to update everything
   this._timer = this._newTimer();
@@ -142,16 +146,19 @@ function nsPlacesDBFlush()
 nsPlacesDBFlush.prototype = {
   //////////////////////////////////////////////////////////////////////////////
   //// nsIObserver
 
   observe: function DBFlush_observe(aSubject, aTopic, aData)
   {
     if (aTopic == kQuitApplication) {
       this._os.removeObserver(this, kQuitApplication);
+      this._os.removeObserver(this, kDebugStopSync);
+      this._os.removeObserver(this, kDebugStartSync);
+
       let (pb2 = this._prefs.QueryInterface(Ci.nsIPrefBranch2)) {
         pb2.removeObserver(kSyncPrefName, this);
         pb2.removeObserver(kExpireDaysPrefName, this);
       }
       this._timer.cancel();
       this._timer = null;
       // Other components could still make changes to history at this point,
       // for example to clear private data on shutdown, so here we dispatch
@@ -190,16 +197,23 @@ nsPlacesDBFlush.prototype = {
       this._timer = this._newTimer();
     }
     else if (aTopic == "nsPref:changed" && aData == kExpireDaysPrefName) {
       // Get the new pref and store it.
       this._expireDays = this._prefs.getIntPref(kExpireDaysPrefName);
       if (this._expireDays <= 0)
         this._expireDays = kDefaultExpireDays;
     }
+    else if (aTopic == kDebugStopSync) {
+      this._syncStopped = true;
+    }
+    else if (aTopic == kDebugStartSync) {
+      if (_syncStopped in this)
+        delete this._syncStopped;
+    }
   },
 
   //////////////////////////////////////////////////////////////////////////////
   //// nsINavBookmarkObserver
 
   onBeginUpdateBatch: function DBFlush_onBeginUpdateBatch()
   {
     this._inBatchMode = true;
@@ -333,17 +347,17 @@ nsPlacesDBFlush.prototype = {
    * Execute async statements to flush tables with the specified queries.
    *
    * @param aQueryNames
    *        The names of the queries to use with this flush.
    */
   _flushWithQueries: function DBFlush_flushWithQueries(aQueryNames)
   {
     // No need to do extra work if we are in batch mode
-    if (this._inBatchMode)
+    if (this._inBatchMode || this._syncStopped)
       return;
 
     let statements = [];
     for (let i = 0; i < aQueryNames.length; i++)
       statements.push(this._getQuery(aQueryNames[i]));
 
     // Execute sync statements async in a transaction
     this._db.executeAsync(statements, statements.length, this);
--- a/toolkit/components/places/tests/bookmarks/head_bookmarks.js
+++ b/toolkit/components/places/tests/bookmarks/head_bookmarks.js
@@ -159,8 +159,24 @@ function check_no_bookmarks() {
  * Flushes any events in the event loop of the main thread.
  */
 function flush_main_thread_events()
 {
   let tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
   while (tm.mainThread.hasPendingEvents())
     tm.mainThread.processNextEvent(false);
 }
+
+// These tests are known to randomly fail due to bug 507790 when database
+// flushes are active, so we turn off syncing for them.
+let randomFailingSyncTests = [
+  "test_384228.js",
+  "test_395593.js",
+  "test_405938_restore_queries.js",
+  "test_423515_forceCopyShortcuts.js",
+  "test_448584.js",
+];
+let currentTestFilename = do_get_file(_TEST_FILE[0], true).leafName;
+if (randomFailingSyncTests.indexOf(currentTestFilename) != -1) {
+  print("Test " + currentTestFilename + " is known random due to bug 507790, disabling PlacesDBFlush component.");
+  let sync = Cc["@mozilla.org/places/sync;1"].getService(Ci.nsIObserver);
+  sync.observe(null, "places-debug-stop-sync", null);
+}
--- a/toolkit/components/places/tests/queries/head_queries.js
+++ b/toolkit/components/places/tests/queries/head_queries.js
@@ -557,8 +557,20 @@ function dump_table(aName)
  * Flushes any events in the event loop of the main thread.
  */
 function flush_main_thread_events()
 {
   let tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
   while (tm.mainThread.hasPendingEvents())
     tm.mainThread.processNextEvent(false);
 }
+
+// These tests are known to randomly fail due to bug 507790 when database
+// flushes are active, so we turn off syncing for them.
+let randomFailingSyncTests = [
+  " test_results-as-visits.js",
+];
+let currentTestFilename = do_get_file(_TEST_FILE[0], true).leafName;
+if (randomFailingSyncTests.indexOf(currentTestFilename) != -1) {
+  print("Test " + currentTestFilename + " is known random due to bug 507790, disabling PlacesDBFlush component.");
+  let sync = Cc["@mozilla.org/places/sync;1"].getService(Ci.nsIObserver);
+  sync.observe(null, "places-debug-stop-sync", null);
+}
--- a/toolkit/components/places/tests/queries/test_results-as-visit.js
+++ b/toolkit/components/places/tests/queries/test_results-as-visit.js
@@ -59,19 +59,16 @@ function createTestData() {
   ];
   pages.forEach(generateVisits);
 }
 
  /**
   * This test will test Queries that use relative search terms and URI options
   */
  function run_test() {
-   /* Temporarly disabled till we figure out what's up. See  Bug 511860 */
-   return;
-
    createTestData();
    populateDB(testData);
    var query = histsvc.getNewQuery();
    query.searchTerms = "moz";
    query.minVisits = 2;
 
    // Options
    var options = histsvc.getNewQueryOptions();
--- a/toolkit/components/places/tests/unit/head_bookmarks.js
+++ b/toolkit/components/places/tests/unit/head_bookmarks.js
@@ -201,8 +201,24 @@ function finish_test()
  * Flushes any events in the event loop of the main thread.
  */
 function flush_main_thread_events()
 {
   let tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
   while (tm.mainThread.hasPendingEvents())
     tm.mainThread.processNextEvent(false);
 }
+
+// These tests are known to randomly fail due to bug 507790 when database
+// flushes are active, so we turn off syncing for them.
+let randomFailingSyncTests = [
+  "test_annotations.js",
+  "test_multi_word_tags.js",
+  "test_removeVisitsByTimeframe.js",
+  "test_tagging.js",
+  "test_utils_getURLsForContainerNode.js",
+];
+let currentTestFilename = do_get_file(_TEST_FILE[0], true).leafName;
+if (randomFailingSyncTests.indexOf(currentTestFilename) != -1) {
+  print("Test " + currentTestFilename + " is known random due to bug 507790, disabling PlacesDBFlush component.");
+  let sync = Cc["@mozilla.org/places/sync;1"].getService(Ci.nsIObserver);
+  sync.observe(null, "places-debug-stop-sync", null);
+}