Backed out changeset 20863de3b8f4 (bug 1329850) for eslint failure: redeclaration of collection in deeper scope in test_syncengine_sync.js. r=backout

This commit is contained in:
Sebastian Hengst 2017-01-31 18:46:39 +01:00
Родитель aed3479d18
Коммит 573326d526
3 изменённых файлов: 2 добавлений и 102 удалений

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

@ -1587,12 +1587,10 @@ SyncEngine.prototype = {
out.encrypt(this.service.collectionKeys.keyForCollection(this.name));
ok = true;
} catch (ex) {
this._log.warn("Error creating record", ex);
++counts.failed;
if (Async.isShutdownException(ex) || !this.allowSkippedRecord) {
Observers.notify("weave:engine:sync:uploaded", counts, this.name);
if (Async.isShutdownException(ex)) {
throw ex;
}
this._log.warn("Error creating record", ex);
}
if (ok) {
let { enqueued, error } = postQueue.enqueue(out);

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

@ -258,12 +258,6 @@ ClientEngine.prototype = {
return true;
},
_removeClientCommands(clientId) {
const allCommands = this._readCommands();
delete allCommands[clientId];
this._saveCommands(allCommands);
},
_syncStartup: function _syncStartup() {
// Reupload new client record periodically.
if (Date.now() / 1000 - this.lastRecordUpload > CLIENTS_TTL_REFRESH) {
@ -673,8 +667,6 @@ ClientEngine.prototype = {
_removeRemoteClient(id) {
delete this._store._remoteClients[id];
this._tracker.removeChangedID(id);
this._removeClientCommands(id);
this._modified.delete(id);
},
};

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

@ -1517,96 +1517,6 @@ add_task(async function test_uploadOutgoing_MAX_UPLOAD_RECORDS() {
}
});
async function createRecordFailTelemetry(allowSkippedRecord) {
Service.identity.username = "foo";
let collection = new ServerCollection();
collection._wbos.flying = new ServerWBO("flying");
collection._wbos.scotsman = new ServerWBO("scotsman");
let server = sync_httpd_setup({
"/1.1/foo/storage/rotary": collection.handler()
});
await SyncTestingInfrastructure(server);
let engine = makeRotaryEngine();
engine.allowSkippedRecord = allowSkippedRecord;
let oldCreateRecord = engine._store.createRecord;
engine._store.createRecord = (id, collection) => {
if (id != "flying") {
throw new Error("oops");
}
return oldCreateRecord.call(engine._store, id, collection);
}
engine.lastSync = 123; // needs to be non-zero so that tracker is queried
engine._store.items = {flying: "LNER Class A3 4472",
scotsman: "Flying Scotsman"};
// Mark these records as changed
const FLYING_CHANGED = 12345;
const SCOTSMAN_CHANGED = 23456;
engine._tracker.addChangedID("flying", FLYING_CHANGED);
engine._tracker.addChangedID("scotsman", SCOTSMAN_CHANGED);
let meta_global = Service.recordManager.set(engine.metaURL,
new WBORecord(engine.metaURL));
meta_global.payload.engines = {rotary: {version: engine.version,
syncID: engine.syncID}};
let ping;
try {
// Confirm initial environment
do_check_eq(engine.lastSyncLocal, 0);
do_check_eq(collection.payload("flying"), undefined);
do_check_eq(engine._tracker.changedIDs["flying"], FLYING_CHANGED);
do_check_eq(engine._tracker.changedIDs["scotsman"], SCOTSMAN_CHANGED);
engine.enabled = true;
ping = await sync_engine_and_validate_telem(engine, true, onErrorPing => {
ping = onErrorPing;
});
if (!allowSkippedRecord) {
do_throw("should not get here");
}
// Ensure the 'flying' record has been uploaded and is no longer marked.
do_check_true(!!collection.payload("flying"));
do_check_eq(engine._tracker.changedIDs["flying"], undefined);
} catch (err) {
if (allowSkippedRecord) {
do_throw("should not get here");
}
// Ensure the 'flying' record has not been uploaded and is still marked
do_check_false(collection.payload("flying"));
do_check_true(engine._tracker.changedIDs["flying"]);
} finally {
// Local timestamp has been set.
do_check_true(engine.lastSyncLocal > 0);
// We reported in telemetry that we failed a record
do_check_eq(ping.engines[0].outgoing[0].failed, 1);
// In any case, the 'scotsman' record couldn't be created so it wasn't
// uploaded nor it was not cleared from the tracker.
do_check_false(collection.payload("scotsman"));
do_check_eq(engine._tracker.changedIDs["scotsman"], SCOTSMAN_CHANGED);
engine._store.createRecord = oldCreateRecord;
await promiseClean(engine, server);
}
}
add_task(async function test_uploadOutgoing_createRecord_throws_reported_telemetry() {
_("SyncEngine._uploadOutgoing reports a failed record to telemetry if createRecord throws");
await createRecordFailTelemetry(true);
});
add_task(async function test_uploadOutgoing_createRecord_throws_dontAllowSkipRecord() {
_("SyncEngine._uploadOutgoing will throw if createRecord throws and allowSkipRecord is set to false");
await createRecordFailTelemetry(false);
});
add_task(async function test_uploadOutgoing_largeRecords() {
_("SyncEngine._uploadOutgoing throws on records larger than MAX_UPLOAD_BYTES");