Bug 804479 - Intermittent test_password_tracker.js, test_history_tracker.js, test_bookmark_store.js, test_forms_tracker.js | test failed (with xpcshell return code: -2147483645), "ASSERTION: thread pool wasn't shutdown… " r=gps

This commit is contained in:
Richard Newman 2012-12-05 16:46:25 -08:00
Родитель 62a25069fc
Коммит 85cab35d85
10 изменённых файлов: 96 добавлений и 46 удалений

Просмотреть файл

@ -77,9 +77,19 @@ Tracker.prototype = {
this._score = 0;
},
saveChangedIDs: function T_saveChangedIDs() {
persistChangedIDs: true,
/**
* Persist changedIDs to disk at a later date.
* Optionally pass a callback to be invoked when the write has occurred.
*/
saveChangedIDs: function (cb) {
if (!this.persistChangedIDs) {
this._log.debug("Not saving changedIDs.");
return;
}
Utils.namedTimer(function() {
Utils.jsonSave("changes/" + this.file, this, this.changedIDs);
Utils.jsonSave("changes/" + this.file, this, this.changedIDs, cb);
}, 1000, this, "_lazySave");
},
@ -122,7 +132,7 @@ Tracker.prototype = {
if ((this.changedIDs[id] || -Infinity) < when) {
this._log.trace("Adding changed ID: " + [id, when]);
this.changedIDs[id] = when;
this.saveChangedIDs();
this.saveChangedIDs(this.onSavedChangedIDs);
}
return true;
},

Просмотреть файл

@ -20,6 +20,9 @@ let reconciler = engine._reconciler;
let store = engine._store;
let tracker = engine._tracker;
// Don't write out by default.
tracker.persistChangedIDs = false;
const addon1ID = "addon1@tests.mozilla.org";
function cleanup_and_advance() {
@ -28,7 +31,6 @@ function cleanup_and_advance() {
tracker.resetScore();
tracker.clearChangedIDs();
tracker._lazySave.clear();
reconciler._addons = {};
reconciler._changes = [];

Просмотреть файл

@ -9,8 +9,14 @@ Cu.import("resource://services-sync/util.js");
const PARENT_ANNO = "sync/parent";
Service.engineManager.register(BookmarksEngine);
let engine = Service.engineManager.get("bookmarks");
let store = engine._store;
let tracker = engine._tracker;
// Don't write some persistence files asynchronously.
tracker.persistChangedIDs = false;
let fxuri = Utils.makeURI("http://getfirefox.com/");
let tburi = Utils.makeURI("http://getthunderbird.com/");
@ -324,9 +330,9 @@ add_test(function test_move_order() {
toolbar.children = [bmk2_guid, bmk1_guid];
store.applyIncoming(toolbar);
// Bookmarks engine does this at the end of _processIncoming
engine._tracker.ignoreAll = true;
tracker.ignoreAll = true;
store._orderChildren();
engine._tracker.ignoreAll = false;
tracker.ignoreAll = false;
delete store._childrenToOrder;
_("Verify new order.");
@ -399,11 +405,6 @@ add_test(function test_reparentOrphans() {
} finally {
_("Clean up.");
store.wipe();
if (engine._tracker._lazySave) {
engine._tracker._lazySave.clear();
}
run_next_test();
}
});

Просмотреть файл

@ -11,7 +11,10 @@ Cu.import("resource://services-sync/util.js");
Service.engineManager.register(BookmarksEngine);
let engine = Service.engineManager.get("bookmarks");
let store = engine._store;
let tracker = engine._tracker;
store.wipe();
tracker.persistChangedIDs = false;
function test_tracking() {
_("Verify we've got an empty tracker to work with.");
@ -66,7 +69,6 @@ function test_tracking() {
store.wipe();
tracker.clearChangedIDs();
tracker.resetScore();
tracker._lazySave.clear();
Svc.Obs.notify("weave:engine:stop-tracking");
}
}
@ -105,7 +107,6 @@ function test_onItemChanged() {
store.wipe();
tracker.clearChangedIDs();
tracker.resetScore();
tracker._lazySave.clear();
Svc.Obs.notify("weave:engine:stop-tracking");
}
}
@ -158,7 +159,6 @@ function test_onItemMoved() {
store.wipe();
tracker.clearChangedIDs();
tracker.resetScore();
tracker._lazySave.clear();
Svc.Obs.notify("weave:engine:stop-tracking");
}

Просмотреть файл

@ -9,6 +9,9 @@ Cu.import("resource://services-sync/util.js");
function run_test() {
_("Verify we've got an empty tracker to work with.");
let tracker = new FormEngine(Service)._tracker;
// Don't do asynchronous writes.
tracker.persistChangedIDs = false;
do_check_empty(tracker.changedIDs);
Log4Moz.repository.rootLogger.addAppender(new Log4Moz.DumpAppender());
@ -46,8 +49,5 @@ function run_test() {
} finally {
_("Clean up.");
Svc.Form.removeAllEntries();
if (tracker._lazySave) {
tracker._lazySave.clear();
}
}
}

Просмотреть файл

@ -24,6 +24,9 @@ Service.engineManager.register(HistoryEngine);
let engine = Service.engineManager.get("history");
let tracker = engine._tracker;
// Don't write out by default.
tracker.persistChangedIDs = false;
let _counter = 0;
function addVisit() {
let uri = Utils.makeURI("http://getfirefox.com/" + _counter);
@ -55,12 +58,23 @@ add_test(function test_not_tracking(next) {
});
add_test(function test_start_tracking() {
_("Add hook for save completion.");
tracker.persistChangedIDs = true;
tracker.onSavedChangedIDs = function () {
_("changedIDs written to disk. Proceeding.");
// Turn this back off.
tracker.persistChangedIDs = false;
delete tracker.onSavedChangedIDs;
run_next_test();
};
_("Tell the tracker to start tracking changes.");
onScoreUpdated(function() {
do_check_attribute_count(tracker.changedIDs, 1);
do_check_eq(tracker.score, SCORE_INCREMENT_SMALL);
run_next_test();
});
Svc.Obs.notify("weave:engine:start-tracking");
addVisit();
});
@ -148,8 +162,5 @@ add_test(function test_stop_tracking_twice() {
add_test(function cleanup() {
_("Clean up.");
PlacesUtils.history.removeAllPages();
if (tracker._lazySave) {
tracker._lazySave.clear();
}
run_next_test();
});

Просмотреть файл

@ -10,12 +10,20 @@ Cu.import("resource://services-sync/util.js");
Service.engineManager.register(PasswordEngine);
let engine = Service.engineManager.get("passwords");
let store = engine._store;
let tracker = engine._tracker;
function test_tracking() {
// Don't do asynchronous writes.
tracker.persistChangedIDs = false;
function run_test() {
initTestLogging("Trace");
run_next_test();
}
add_test(function test_tracking() {
let recordNum = 0;
_("Verify we've got an empty tracker to work with.");
let tracker = engine._tracker;
do_check_empty(tracker.changedIDs);
function createPassword() {
@ -69,14 +77,13 @@ function test_tracking() {
store.wipe();
tracker.clearChangedIDs();
tracker.resetScore();
tracker._lazySave.clear();
Svc.Obs.notify("weave:engine:stop-tracking");
run_next_test();
}
}
});
function test_onWipe() {
add_test(function test_onWipe() {
_("Verify we've got an empty tracker to work with.");
let tracker = engine._tracker;
do_check_empty(tracker.changedIDs);
do_check_eq(tracker.score, 0);
@ -89,16 +96,6 @@ function test_onWipe() {
} finally {
tracker.resetScore();
Svc.Obs.notify("weave:engine:stop-tracking");
run_next_test();
}
}
function run_test() {
initTestLogging("Trace");
Log4Moz.repository.getLogger("Sync.Engine.Passwords").level = Log4Moz.Level.Trace;
Log4Moz.repository.getLogger("Sync.Store.Passwords").level = Log4Moz.Level.Trace;
Log4Moz.repository.getLogger("Sync.Tracker.Passwords").level = Log4Moz.Level.Trace;
test_tracking();
test_onWipe();
}
});

Просмотреть файл

@ -11,6 +11,10 @@ Cu.import("resource://services-sync/util.js");
function run_test() {
let engine = Service.engineManager.get("prefs");
let tracker = engine._tracker;
// Don't write out by default.
tracker.persistChangedIDs = false;
let prefs = new Preferences();
try {
@ -80,8 +84,5 @@ function run_test() {
} finally {
Svc.Obs.notify("weave:engine:stop-tracking");
prefs.resetBranch("");
if (tracker._lazySave) {
tracker._lazySave.clear();
}
}
}

Просмотреть файл

@ -51,6 +51,8 @@ function run_test() {
_("We assume that tabs have changed at startup.");
let tracker = engine._tracker;
tracker.persistChangedIDs = false;
do_check_true(tracker.modified);
do_check_true(Utils.deepEquals(Object.keys(engine.getChangedIDs()),
[clientsEngine.localID]));
@ -113,7 +115,4 @@ function run_test() {
do_check_true(Utils.deepEquals(Object.keys(engine.getChangedIDs()),
[clientsEngine.localID]));
do_check_eq(logs.length, idx); // test that setTabValue isn't called
if (tracker._lazySave) {
tracker._lazySave.clear();
}
}

Просмотреть файл

@ -3,9 +3,16 @@
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
function run_test() {
run_next_test();
}
add_test(function test_tracker_basics() {
let tracker = new Tracker("Tracker", Service);
tracker.persistChangedIDs = false;
let id = "the_id!";
_("Make sure nothing exists yet..");
@ -26,5 +33,27 @@ function run_test() {
_("Adding without time defaults to current time");
tracker.addChangedID(id);
do_check_true(tracker.changedIDs[id] > 10);
tracker._lazySave.clear()
}
run_next_test();
});
add_test(function test_tracker_persistence() {
let tracker = new Tracker("Tracker", Service);
let id = "abcdef";
tracker.persistChangedIDs = true;
tracker.onSavedChangedIDs = function () {
_("IDs saved.");
do_check_eq(5, tracker.changedIDs[id]);
// Verify the write by reading the file back.
Utils.jsonLoad("changes/tracker", this, function (json) {
do_check_eq(5, json[id]);
tracker.persistChangedIDs = false;
delete tracker.onSavedChangedIDs;
run_next_test();
});
};
tracker.addChangedID(id, 5);
});