Bug 1325523 - Clean up after tests that modify tracker contents. r=markh

MozReview-Commit-ID: 45g4n4UipTW

--HG--
extra : rebase_source : 1be78706cab9b42d0c6c949243b9a835351486fa
This commit is contained in:
Kit Cambridge 2016-12-29 18:18:38 -07:00
Родитель 1e55fd2bd6
Коммит 1897a70d72
6 изменённых файлов: 70 добавлений и 49 удалений

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

@ -36,6 +36,7 @@ function advance_test() {
reconciler.saveState(null, cb);
cb.wait();
tracker.clearChangedIDs();
run_next_test();
}

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

@ -199,6 +199,7 @@ add_test(function test_properties() {
equal(engine.lastRecordUpload, Math.floor(now / 1000));
} finally {
Svc.Prefs.resetBranch("");
engine._tracker.clearChangedIDs();
run_next_test();
}
});
@ -359,6 +360,7 @@ add_test(function test_client_name_change() {
Svc.Obs.notify("weave:engine:stop-tracking");
engine._tracker.clearChangedIDs();
run_next_test();
});
@ -390,6 +392,7 @@ add_test(function test_send_command() {
notEqual(tracker.changedIDs[remoteId], undefined);
engine._tracker.clearChangedIDs();
run_next_test();
});
@ -446,6 +449,7 @@ add_test(function test_command_validation() {
}
}
engine._tracker.clearChangedIDs();
run_next_test();
});
@ -481,6 +485,7 @@ add_test(function test_command_duplication() {
clientCommands = engine._readCommands()[remoteId];
equal(clientCommands.length, 2);
engine._tracker.clearChangedIDs();
run_next_test();
});
@ -498,6 +503,7 @@ add_test(function test_command_invalid_client() {
equal(error.message.indexOf("Unknown remote client ID: "), 0);
engine._tracker.clearChangedIDs();
run_next_test();
});
@ -515,6 +521,7 @@ add_test(function test_process_incoming_commands() {
Service.recordManager.clearCache();
engine._resetClient();
engine._tracker.clearChangedIDs();
run_next_test();
};
@ -809,6 +816,7 @@ add_test(function test_send_uri_to_client_for_display() {
Service.recordManager.clearCache();
engine._resetClient();
engine._tracker.clearChangedIDs();
run_next_test();
});
@ -841,6 +849,7 @@ add_test(function test_receive_display_uri() {
equal(subject[0].title, title);
equal(data, null);
engine._tracker.clearChangedIDs();
run_next_test();
};
@ -877,6 +886,7 @@ add_test(function test_optional_client_fields() {
// See Bug 1100722, Bug 1100723.
engine._resetClient();
engine._tracker.clearChangedIDs();
run_next_test();
});
@ -1433,6 +1443,7 @@ add_task(async function test_command_sync() {
} finally {
Svc.Prefs.resetBranch("");
Service.recordManager.clearCache();
engine._tracker.clearChangedIDs();
try {
server.deleteCollections("foo");

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

@ -102,6 +102,7 @@ add_task(async function test_resetClient() {
engine.wasReset = false;
engineObserver.reset();
engine._tracker.clearChangedIDs();
});
add_task(async function test_invalidChangedIDs() {
@ -120,6 +121,7 @@ add_task(async function test_invalidChangedIDs() {
ok(tracker._storage.dataReady);
do_check_true(tracker.changedIDs.placeholder);
engine._tracker.clearChangedIDs();
});
add_task(async function test_wipeClient() {
@ -142,6 +144,7 @@ add_task(async function test_wipeClient() {
engine.wasReset = false;
engine._store.wasWiped = false;
engineObserver.reset();
engine._tracker.clearChangedIDs();
});
add_task(async function test_enabled() {
@ -180,6 +183,7 @@ add_task(async function test_sync() {
Svc.Prefs.resetBranch("");
engine.wasSynced = false;
engineObserver.reset();
engine._tracker.clearChangedIDs();
}
});
@ -208,4 +212,6 @@ add_task(async function test_disabled_no_track() {
Svc.Prefs.set("engine." + engine.prefName, false);
do_check_false(tracker._isTracking);
do_check_empty(tracker.changedIDs);
engine._tracker.clearChangedIDs();
});

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

@ -231,6 +231,7 @@ add_task(async function hmac_error_during_node_reassignment() {
Svc.Prefs.resetBranch("");
Service.recordManager.clearCache();
engine._tracker.clearChangedIDs();
server.stop(resolve);
};

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

@ -15,19 +15,20 @@ function makeRotaryEngine() {
return new RotaryEngine(Service);
}
function clean() {
function clean(engine) {
Svc.Prefs.resetBranch("");
Svc.Prefs.set("log.logger.engine.rotary", "Trace");
Service.recordManager.clearCache();
engine._tracker.clearChangedIDs();
}
async function cleanAndGo(server) {
clean();
async function cleanAndGo(engine, server) {
clean(engine);
await promiseStopServer(server);
}
async function promiseClean(server) {
clean();
async function promiseClean(engine, server) {
clean(engine);
await promiseStopServer(server);
}
@ -128,7 +129,7 @@ add_task(async function test_syncStartup_emptyOrOutdatedGlobalsResetsSync() {
do_check_eq(collection.payload("scotsman"), undefined);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -157,7 +158,7 @@ add_task(async function test_syncStartup_serverHasNewerVersion() {
do_check_eq(error.failureCode, VERSION_OUT_OF_DATE);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -193,7 +194,7 @@ add_task(async function test_syncStartup_syncIDMismatchResetsClient() {
do_check_eq(engine.lastSync, 0);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -217,7 +218,7 @@ add_task(async function test_processIncoming_emptyServer() {
do_check_eq(engine.lastSync, 0);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -278,7 +279,7 @@ add_task(async function test_processIncoming_createFromServer() {
do_check_eq(engine._store.items['../pathological'], "Pathological Case");
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -389,7 +390,7 @@ add_task(async function test_processIncoming_reconcile() {
// The 'nukeme' record marked as deleted is removed.
do_check_eq(engine._store.items.nukeme, undefined);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -425,7 +426,7 @@ add_task(async function test_processIncoming_reconcile_local_deleted() {
do_check_eq(1, collection.count());
do_check_neq(undefined, collection.wbo("DUPE_INCOMING"));
await cleanAndGo(server);
await cleanAndGo(engine, server);
});
add_task(async function test_processIncoming_reconcile_equivalent() {
@ -448,7 +449,7 @@ add_task(async function test_processIncoming_reconcile_equivalent() {
do_check_attribute_count(engine._store.items, 1);
await cleanAndGo(server);
await cleanAndGo(engine, server);
});
add_task(async function test_processIncoming_reconcile_locally_deleted_dupe_new() {
@ -487,7 +488,7 @@ add_task(async function test_processIncoming_reconcile_locally_deleted_dupe_new(
let payload = JSON.parse(JSON.parse(wbo.payload).ciphertext);
do_check_true(payload.deleted);
await cleanAndGo(server);
await cleanAndGo(engine, server);
});
add_task(async function test_processIncoming_reconcile_locally_deleted_dupe_old() {
@ -526,7 +527,7 @@ add_task(async function test_processIncoming_reconcile_locally_deleted_dupe_old(
let payload = JSON.parse(JSON.parse(wbo.payload).ciphertext);
do_check_eq("incoming", payload.denomination);
await cleanAndGo(server);
await cleanAndGo(engine, server);
});
add_task(async function test_processIncoming_reconcile_changed_dupe() {
@ -563,7 +564,7 @@ add_task(async function test_processIncoming_reconcile_changed_dupe() {
let payload = JSON.parse(JSON.parse(wbo.payload).ciphertext);
do_check_eq("local", payload.denomination);
await cleanAndGo(server);
await cleanAndGo(engine, server);
});
add_task(async function test_processIncoming_reconcile_changed_dupe_new() {
@ -600,7 +601,7 @@ add_task(async function test_processIncoming_reconcile_changed_dupe_new() {
do_check_neq(undefined, wbo);
let payload = JSON.parse(JSON.parse(wbo.payload).ciphertext);
do_check_eq("incoming", payload.denomination);
await cleanAndGo(server);
await cleanAndGo(engine, server);
});
add_task(async function test_processIncoming_mobile_batchSize() {
@ -669,7 +670,7 @@ add_task(async function test_processIncoming_mobile_batchSize() {
}
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -736,7 +737,7 @@ add_task(async function test_processIncoming_store_toFetch() {
do_check_eq(engine.lastSync, collection.wbo("record-no-99").modified);
} finally {
await promiseClean(server);
await promiseClean(engine, server);
}
});
@ -805,7 +806,7 @@ add_task(async function test_processIncoming_resume_toFetch() {
do_check_eq(engine._store.items.failed2, "Record No. 2");
do_check_eq(engine.previousFailed.length, 0);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -860,7 +861,7 @@ add_task(async function test_processIncoming_applyIncomingBatchSize_smaller() {
do_check_eq(engine.previousFailed[1], "record-no-8");
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -913,7 +914,7 @@ add_task(async function test_processIncoming_applyIncomingBatchSize_multiple() {
do_check_attribute_count(engine._store.items, APPLY_BATCH_SIZE * 3);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -1002,7 +1003,7 @@ add_task(async function test_processIncoming_notify_count() {
Svc.Obs.remove("weave:engine:sync:applied", onApplied);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -1088,7 +1089,7 @@ add_task(async function test_processIncoming_previousFailed() {
do_check_eq(engine._store.items['record-no-12'], "Record No. 12");
do_check_eq(engine._store.items['record-no-13'], "Record No. 13");
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -1222,7 +1223,7 @@ add_task(async function test_processIncoming_failed_records() {
do_check_eq(batchDownload(BOGUS_RECORDS.length), 4);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -1303,7 +1304,7 @@ add_task(async function test_processIncoming_decrypt_failed() {
do_check_eq(observerSubject.failed, 4);
} finally {
await promiseClean(server);
await promiseClean(engine, server);
}
});
@ -1362,7 +1363,7 @@ add_task(async function test_uploadOutgoing_toEmptyServer() {
do_check_eq(collection.payload("flying"), undefined);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -1409,7 +1410,7 @@ add_task(async function test_uploadOutgoing_huge() {
do_check_eq(engine._tracker.changedIDs["flying"], undefined);
} finally {
cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -1472,7 +1473,7 @@ add_task(async function test_uploadOutgoing_failed() {
do_check_eq(engine._tracker.changedIDs['peppercorn'], PEPPERCORN_CHANGED);
} finally {
await promiseClean(server);
await promiseClean(engine, server);
}
});
@ -1541,7 +1542,7 @@ add_task(async function test_uploadOutgoing_MAX_UPLOAD_RECORDS() {
do_check_eq(noOfUploads, Math.ceil(234/MAX_UPLOAD_RECORDS));
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -1579,7 +1580,7 @@ add_task(async function test_uploadOutgoing_largeRecords() {
}
ok(!!error);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -1636,7 +1637,7 @@ add_task(async function test_syncFinish_deleteByIds() {
do_check_eq(engine._delete.ids, undefined);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -1707,7 +1708,7 @@ add_task(async function test_syncFinish_deleteLotsInBatches() {
do_check_eq(engine._delete.ids, undefined);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -1783,7 +1784,7 @@ add_task(async function test_sync_partialUpload() {
}
} finally {
await promiseClean(server);
await promiseClean(engine, server);
}
});
@ -1810,7 +1811,7 @@ add_task(async function test_canDecrypt_noCryptoKeys() {
do_check_false(engine.canDecrypt());
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -1836,7 +1837,7 @@ add_task(async function test_canDecrypt_true() {
do_check_true(engine.canDecrypt());
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -1893,7 +1894,7 @@ add_task(async function test_syncapplied_observer() {
do_check_true(Service.scheduler.hasIncomingItems);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
Service.scheduler.hasIncomingItems = false;
Svc.Obs.remove("weave:engine:sync:applied", onApplied);
}

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

@ -58,10 +58,11 @@ function BogusEngine(service) {
BogusEngine.prototype = Object.create(SteamEngine.prototype);
async function cleanAndGo(server) {
async function cleanAndGo(engine, server) {
Svc.Prefs.resetBranch("");
Svc.Prefs.set("log.logger.engine.rotary", "Trace");
Service.recordManager.clearCache();
engine._tracker.clearChangedIDs();
await promiseStopServer(server);
}
@ -139,7 +140,7 @@ add_task(async function test_processIncoming_error() {
} finally {
store.wipe();
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -187,7 +188,7 @@ add_task(async function test_uploading() {
} finally {
// Clean up.
store.wipe();
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -237,7 +238,7 @@ add_task(async function test_upload_failed() {
deepEqual(ping.engines[0].outgoing, [{ sent: 2, failed: 2 }]);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -317,7 +318,7 @@ add_task(async function test_sync_partialUpload() {
deepEqual(ping.engines[0].failureReason, uploadFailureError);
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -344,7 +345,7 @@ add_task(async function test_generic_engine_fail() {
});
} finally {
Service.engineManager.unregister(engine);
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -380,7 +381,7 @@ add_task(async function test_engine_fail_ioerror() {
ok(failureReason.error.includes("[profileDir]"), failureReason.error);
} finally {
Service.engineManager.unregister(engine);
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -417,7 +418,7 @@ add_task(async function test_initial_sync_engines() {
equal(e.outgoing[0].failed, undefined);
}
} finally {
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -446,7 +447,7 @@ add_task(async function test_nserror() {
});
} finally {
Service.engineManager.unregister(engine);
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -512,7 +513,7 @@ add_task(async function test_no_foreign_engines_in_error_ping() {
ok(ping.engines.every(e => e.name !== "bogus"));
} finally {
Service.engineManager.unregister(engine);
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -538,7 +539,7 @@ add_task(async function test_sql_error() {
deepEqual(enginePing.failureReason, { name: "sqlerror", code: 1 });
} finally {
Service.engineManager.unregister(engine);
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});
@ -558,6 +559,6 @@ add_task(async function test_no_foreign_engines_in_success_ping() {
ok(ping.engines.every(e => e.name !== "bogus"));
} finally {
Service.engineManager.unregister(engine);
await cleanAndGo(server);
await cleanAndGo(engine, server);
}
});