Bug 684783 - Fix intermittent test_errorhandler.js. r=philikon
authorRichard Newman <rnewman@mozilla.com>
Tue, 06 Sep 2011 08:26:35 -0700
changeset 77913 2dc945c5c66e3a39e4596e7cbbe10fe26593f777
parent 77912 db2ec1f8df574db9f67b3c7cddbe609545cf7ad2
child 77914 f921f632208e2a7e9eba943c6dce96a8b6a33b77
push id78
push userclegnitto@mozilla.com
push dateFri, 16 Dec 2011 17:32:24 +0000
treeherdermozilla-release@79d24e644fdd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilikon
bugs684783
milestone9.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 684783 - Fix intermittent test_errorhandler.js. r=philikon
services/sync/tests/unit/test_errorhandler.js
--- a/services/sync/tests/unit/test_errorhandler.js
+++ b/services/sync/tests/unit/test_errorhandler.js
@@ -762,80 +762,83 @@ add_test(function test_syncAndReportErro
 });
 
 add_test(function test_sync_engine_generic_fail() {
   let server = sync_httpd_setup();
 
   let engine = Engines.get("catapult");
   engine.enabled = true;
   engine.sync = function sync() {
-    Svc.Obs.notify("weave:engine:sync:error", "", "steam");
+    Svc.Obs.notify("weave:engine:sync:error", "", "catapult");
   };
 
   let log = Log4Moz.repository.getLogger("Sync.ErrorHandler");
   Svc.Prefs.set("log.appender.file.logOnError", true);
 
   Svc.Obs.add("weave:service:reset-file-log", function onResetFileLog() {
     Svc.Obs.remove("weave:service:reset-file-log", onResetFileLog);
 
+    // Put these checks here, not after sync(), so that we aren't racing the
+    // log handler... which resets everything just a few lines below!
+    _("Status.engines: " + JSON.stringify(Status.engines));
+    do_check_eq(Status.engines["catapult"], ENGINE_UNKNOWN_FAIL);
+    do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
+
     // Test Error log was written on SYNC_FAILED_PARTIAL.
     let entries = logsdir.directoryEntries;
     do_check_true(entries.hasMoreElements());
     let logfile = entries.getNext().QueryInterface(Ci.nsILocalFile);
     do_check_eq(logfile.leafName.slice(0, LOG_PREFIX_ERROR.length),
                 LOG_PREFIX_ERROR);
 
     Status.resetSync();
     Service.startOver();
 
     server.stop(run_next_test);
   });
 
-  do_check_eq(Status.engines["steam"], undefined);
+  do_check_eq(Status.engines["catapult"], undefined);
 
   do_check_true(setUp());
 
   Service.sync();
-
-  do_check_eq(Status.engines["steam"], ENGINE_UNKNOWN_FAIL);
-  do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
 });
 
 // This test should be the last one since it monkeypatches the engine object
 // and we should only have one engine object throughout the file (bug 629664).
 add_test(function test_engine_applyFailed() {
   let server = sync_httpd_setup();
 
   let engine = Engines.get("catapult");
   engine.enabled = true;
   delete engine.exception;
   engine.sync = function sync() {
-    Svc.Obs.notify("weave:engine:sync:applied", {newFailed:1}, "steam");
+    Svc.Obs.notify("weave:engine:sync:applied", {newFailed:1}, "catapult");
   };
 
   let log = Log4Moz.repository.getLogger("Sync.ErrorHandler");
   Svc.Prefs.set("log.appender.file.logOnError", true);
 
   Svc.Obs.add("weave:service:reset-file-log", function onResetFileLog() {
     Svc.Obs.remove("weave:service:reset-file-log", onResetFileLog);
 
+    do_check_eq(Status.engines["catapult"], ENGINE_APPLY_FAIL);
+    do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
+
     // Test Error log was written on SYNC_FAILED_PARTIAL.
     let entries = logsdir.directoryEntries;
     do_check_true(entries.hasMoreElements());
     let logfile = entries.getNext().QueryInterface(Ci.nsILocalFile);
     do_check_eq(logfile.leafName.slice(0, LOG_PREFIX_ERROR.length),
                 LOG_PREFIX_ERROR);
 
     Status.resetSync();
     Service.startOver();
 
     server.stop(run_next_test);
   });
 
-  do_check_eq(Status.engines["steam"], undefined);
+  do_check_eq(Status.engines["catapult"], undefined);
 
   do_check_true(setUp());
 
   Service.sync();
-
-  do_check_eq(Status.engines["steam"], ENGINE_APPLY_FAIL);
-  do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
 });