Bug 578195 - Better description when the server asks for a backoff. r=philikon

--HG--
extra : rebase_source : b7ab66f6716fa708861d394320596259166b0652
This commit is contained in:
Marina Samuel 2011-08-26 16:45:08 -07:00
Родитель 563ed2e75c
Коммит 4d2c258712
5 изменённых файлов: 163 добавлений и 9 удалений

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

@ -6,7 +6,8 @@ error.login.reason.no_password2 = Missing password
error.login.reason.no_recoverykey= No saved Recovery Key to use
error.login.reason.server = Server incorrectly configured
error.sync.failed_partial = One or more data types could not be synced
error.sync.failed_partial = One or more data types could not be synced
error.sync.reason.server_maintenance = Firefox Sync server maintenance is underway, syncing will resume automatically.
invalid-captcha = Incorrect words, try again
weak-password = Use a stronger password

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

@ -163,6 +163,7 @@ ABORT_SYNC_COMMAND: "aborting sync, process commands said so"
NO_SYNC_NODE_FOUND: "error.sync.reason.no_node_found",
OVER_QUOTA: "error.sync.reason.over_quota",
PROLONGED_SYNC_FAILURE: "error.sync.prolonged_failure",
SERVER_MAINTENANCE: "error.sync.reason.server_maintenance",
RESPONSE_OVER_QUOTA: "14",

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

@ -514,14 +514,13 @@ let ErrorHandler = {
this.dontIgnoreErrors = false;
break;
case "weave:service:sync:finish":
this.dontIgnoreErrors = false;
if (Status.service == SYNC_FAILED_PARTIAL) {
this._log.debug("Some engines did not sync correctly.");
this.resetFileLog(Svc.Prefs.get("log.appender.file.logOnError"),
LOG_PREFIX_ERROR);
if (this.shouldReportError()) {
this.dontIgnoreErrors = false;
Svc.Obs.notify("weave:ui:sync:error");
break;
}
@ -529,6 +528,7 @@ let ErrorHandler = {
this.resetFileLog(Svc.Prefs.get("log.appender.file.logOnSuccess"),
LOG_PREFIX_SUCCESS);
}
this.dontIgnoreErrors = false;
Svc.Obs.notify("weave:ui:sync:finish");
break;
}
@ -610,6 +610,10 @@ let ErrorHandler = {
return false;
}
if (this.dontIgnoreErrors) {
return true;
}
let lastSync = Svc.Prefs.get("lastSync");
if (lastSync && ((Date.now() - Date.parse(lastSync)) >
Svc.Prefs.get("errorhandler.networkFailureReportTimeout") * 1000)) {
@ -617,7 +621,7 @@ let ErrorHandler = {
return true;
}
return (this.dontIgnoreErrors ||
return (Status.sync != SERVER_MAINTENANCE &&
[Status.login, Status.sync].indexOf(LOGIN_FAILED_NETWORK_ERROR) == -1);
},
@ -644,6 +648,7 @@ let ErrorHandler = {
case 504:
Status.enforceBackoff = true;
if (resp.status == 503 && resp.headers["retry-after"]) {
Status.sync = SERVER_MAINTENANCE;
Svc.Obs.notify("weave:service:backoff:interval",
parseInt(resp.headers["retry-after"], 10));
}

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

@ -30,7 +30,7 @@ function CatapultEngine() {
CatapultEngine.prototype = {
__proto__: SyncEngine.prototype,
exception: null, // tests fill this in
sync: function sync() {
_sync: function _sync() {
throw this.exception;
}
};
@ -268,6 +268,35 @@ add_test(function test_shouldReportError() {
Status.sync = LOGIN_FAILED_NETWORK_ERROR;
do_check_false(ErrorHandler.shouldReportError());
// Test server maintenance errors are not reported
Status.resetSync();
setLastSync(NON_PROLONGED_ERROR_DURATION);
ErrorHandler.dontIgnoreErrors = false;
Status.sync = SERVER_MAINTENANCE;
do_check_false(ErrorHandler.shouldReportError());
// Test prolonged server maintenance errors are reported
Status.resetSync();
setLastSync(PROLONGED_ERROR_DURATION);
ErrorHandler.dontIgnoreErrors = false;
Status.sync = SERVER_MAINTENANCE;
do_check_true(ErrorHandler.shouldReportError());
// Test dontIgnoreErrors, server maintenance errors are reported
Status.resetSync();
setLastSync(NON_PROLONGED_ERROR_DURATION);
ErrorHandler.dontIgnoreErrors = true;
Status.sync = SERVER_MAINTENANCE;
do_check_true(ErrorHandler.shouldReportError());
// Test dontIgnoreErrors, prolonged, server maintenance
// errors are reported
Status.resetSync();
setLastSync(PROLONGED_ERROR_DURATION);
ErrorHandler.dontIgnoreErrors = true;
Status.sync = SERVER_MAINTENANCE;
do_check_true(ErrorHandler.shouldReportError());
run_next_test();
});
@ -347,7 +376,7 @@ add_test(function test_login_syncAndReportErrors_prolonged_non_network_error() {
Svc.Obs.add("weave:ui:login:error", function onSyncError() {
Svc.Obs.remove("weave:ui:login:error", onSyncError);
do_check_eq(Status.sync, PROLONGED_SYNC_FAILURE);
do_check_eq(Status.login, LOGIN_FAILED_NO_PASSWORD);
Service.startOver();
server.stop(run_next_test);
@ -372,7 +401,7 @@ add_test(function test_sync_syncAndReportErrors_prolonged_non_network_error() {
Svc.Obs.add("weave:ui:sync:error", function onSyncError() {
Svc.Obs.remove("weave:ui:sync:error", onSyncError);
do_check_eq(Status.sync, PROLONGED_SYNC_FAILURE);
do_check_eq(Status.sync, CREDENTIALS_CHANGED);
Service.startOver();
server.stop(run_next_test);
@ -429,7 +458,7 @@ add_test(function test_login_syncAndReportErrors_prolonged_network_error() {
Svc.Obs.add("weave:ui:login:error", function onSyncError() {
Svc.Obs.remove("weave:ui:login:error", onSyncError);
do_check_eq(Status.sync, PROLONGED_SYNC_FAILURE);
do_check_eq(Status.sync, LOGIN_FAILED_NETWORK_ERROR);
Service.startOver();
run_next_test();
@ -446,7 +475,7 @@ add_test(function test_sync_syncAndReportErrors_prolonged_network_error() {
Svc.Obs.add("weave:ui:sync:error", function onSyncError() {
Svc.Obs.remove("weave:ui:sync:error", onSyncError);
do_check_eq(Status.sync, PROLONGED_SYNC_FAILURE);
do_check_eq(Status.sync, LOGIN_FAILED_NETWORK_ERROR);
Services.io.offline = false;
Service.startOver();
@ -598,6 +627,7 @@ add_test(function test_login_network_error() {
do_check_eq(Status.login, LOGIN_FAILED_NETWORK_ERROR);
Service.startOver();
Status.resetSync();
Services.io.offline = false;
run_next_test();
});
@ -625,6 +655,120 @@ add_test(function test_sync_network_error() {
Service.sync();
});
add_test(function test_sync_server_maintenance_error() {
// Test server maintenance errors are not reported.
let server = sync_httpd_setup();
setUp();
const BACKOFF = 42;
let engine = Engines.get("catapult");
engine.enabled = true;
engine.exception = {status: 503,
headers: {"retry-after": BACKOFF}};
function onUIUpdate() {
do_throw("Shouldn't get here!");
}
Svc.Obs.add("weave:ui:sync:error", onUIUpdate);
do_check_eq(Status.service, STATUS_OK);
// Last sync was 2 days ago
Svc.Prefs.set("lastSync", (new Date(Date.now() - 172800000)).toString());
Service.sync();
do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
do_check_eq(Status.sync, SERVER_MAINTENANCE);
Svc.Obs.remove("weave:ui:sync:error", onUIUpdate);
Service.startOver();
Status.resetSync();
server.stop(run_next_test);
});
add_test(function test_sync_prolonged_server_maintenance_error() {
// Test prolonged server maintenance errors are reported.
let server = sync_httpd_setup();
setUp();
const BACKOFF = 42;
let engine = Engines.get("catapult");
engine.enabled = true;
engine.exception = {status: 503,
headers: {"retry-after": BACKOFF}};
Svc.Obs.add("weave:ui:sync:error", function onUIUpdate() {
Svc.Obs.remove("weave:ui:sync:error", onUIUpdate);
do_check_eq(Status.service, SYNC_FAILED);
do_check_eq(Status.sync, PROLONGED_SYNC_FAILURE);
Service.startOver();
Status.resetSync();
server.stop(run_next_test);
});
do_check_eq(Status.service, STATUS_OK);
setLastSync(PROLONGED_ERROR_DURATION);
Service.sync();
});
add_test(function test_syncAndReportErrors_server_maintenance_error() {
// Test server maintenance errors are reported
// when calling syncAndReportErrors.
let server = sync_httpd_setup();
setUp();
const BACKOFF = 42;
let engine = Engines.get("catapult");
engine.enabled = true;
engine.exception = {status: 503,
headers: {"retry-after": BACKOFF}};
Svc.Obs.add("weave:ui:sync:error", function onUIUpdate() {
Svc.Obs.remove("weave:ui:sync:error", onUIUpdate);
do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
do_check_eq(Status.sync, SERVER_MAINTENANCE);
Service.startOver();
Status.resetSync();
server.stop(run_next_test);
});
do_check_eq(Status.service, STATUS_OK);
setLastSync(NON_PROLONGED_ERROR_DURATION);
ErrorHandler.syncAndReportErrors();
});
add_test(function test_syncAndReportErrors_prolonged_server_maintenance_error() {
// Test prolonged server maintenance errors are
// reported when calling syncAndReportErrors.
let server = sync_httpd_setup();
setUp();
const BACKOFF = 42;
let engine = Engines.get("catapult");
engine.enabled = true;
engine.exception = {status: 503,
headers: {"retry-after": BACKOFF}};
Svc.Obs.add("weave:ui:sync:error", function onUIUpdate() {
Svc.Obs.remove("weave:ui:sync:error", onUIUpdate);
do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
do_check_eq(Status.sync, SERVER_MAINTENANCE);
Service.startOver();
Status.resetSync();
server.stop(run_next_test);
});
do_check_eq(Status.service, STATUS_OK);
setLastSync(PROLONGED_ERROR_DURATION);
ErrorHandler.syncAndReportErrors();
});
add_test(function test_sync_engine_generic_fail() {
let server = sync_httpd_setup();

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

@ -81,6 +81,7 @@ add_test(function test_backoff500() {
Service.login();
Service.sync();
do_check_true(Status.enforceBackoff);
do_check_eq(Status.sync, SYNC_SUCCEEDED);
do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
} finally {
Status.resetBackoff();
@ -116,8 +117,10 @@ add_test(function test_backoff503() {
do_check_true(Status.enforceBackoff);
do_check_eq(backoffInterval, BACKOFF);
do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
do_check_eq(Status.sync, SERVER_MAINTENANCE);
} finally {
Status.resetBackoff();
Status.resetSync();
Service.startOver();
}
server.stop(run_next_test);