зеркало из https://github.com/mozilla/pjs.git
Bug 629664 - Attempt at improving randomly failing test. r=rnewman a=orange
This commit is contained in:
Родитель
320733ecaf
Коммит
2e65370d70
|
@ -1,3 +1,4 @@
|
|||
Cu.import("resource://services-sync/util.js");
|
||||
var btoa;
|
||||
|
||||
// initialize nss
|
||||
|
@ -48,8 +49,6 @@ function loadInSandbox(aUri) {
|
|||
}
|
||||
|
||||
function FakeTimerService() {
|
||||
Cu.import("resource://services-sync/util.js");
|
||||
|
||||
this.callbackQueue = [];
|
||||
|
||||
var self = this;
|
||||
|
@ -360,6 +359,10 @@ function ensureThrows(func) {
|
|||
};
|
||||
}
|
||||
|
||||
function asyncChainTests() {
|
||||
return Utils.asyncChain.apply(this, Array.map(arguments, ensureThrows));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print some debug message to the console. All arguments will be printed,
|
||||
|
|
|
@ -45,10 +45,9 @@ function setUp() {
|
|||
new FakeCryptoService();
|
||||
}
|
||||
|
||||
function test_backoff500() {
|
||||
function test_backoff500(next) {
|
||||
_("Test: HTTP 500 sets backoff status.");
|
||||
let server = sync_httpd_setup();
|
||||
do_test_pending();
|
||||
setUp();
|
||||
|
||||
Engines.register(CatapultEngine);
|
||||
|
@ -67,17 +66,16 @@ function test_backoff500() {
|
|||
Service.sync();
|
||||
do_check_true(Status.enforceBackoff);
|
||||
} finally {
|
||||
server.stop(do_test_finished);
|
||||
Engines.unregister("catapult");
|
||||
Status.resetBackoff();
|
||||
Service.startOver();
|
||||
server.stop(next);
|
||||
}
|
||||
}
|
||||
|
||||
function test_backoff503() {
|
||||
function test_backoff503(next) {
|
||||
_("Test: HTTP 503 with Retry-After header leads to backoff notification and sets backoff status.");
|
||||
let server = sync_httpd_setup();
|
||||
do_test_pending();
|
||||
setUp();
|
||||
|
||||
const BACKOFF = 42;
|
||||
|
@ -101,17 +99,16 @@ function test_backoff503() {
|
|||
do_check_true(Status.enforceBackoff);
|
||||
do_check_eq(backoffInterval, BACKOFF);
|
||||
} finally {
|
||||
server.stop(do_test_finished);
|
||||
Engines.unregister("catapult");
|
||||
Status.resetBackoff();
|
||||
Service.startOver();
|
||||
server.stop(next);
|
||||
}
|
||||
}
|
||||
|
||||
function test_overQuota() {
|
||||
function test_overQuota(next) {
|
||||
_("Test: HTTP 400 with body error code 14 means over quota.");
|
||||
let server = sync_httpd_setup();
|
||||
do_test_pending();
|
||||
setUp();
|
||||
|
||||
Engines.register(CatapultEngine);
|
||||
|
@ -128,18 +125,17 @@ function test_overQuota() {
|
|||
|
||||
do_check_eq(Status.sync, OVER_QUOTA);
|
||||
} finally {
|
||||
server.stop(do_test_finished);
|
||||
Engines.unregister("catapult");
|
||||
Status.resetSync();
|
||||
Service.startOver();
|
||||
server.stop(next);
|
||||
}
|
||||
}
|
||||
|
||||
// Slightly misplaced test as it doesn't actually test checkServerError,
|
||||
// but the observer for "weave:engine:sync:apply-failed".
|
||||
function test_engine_applyFailed() {
|
||||
function test_engine_applyFailed(next) {
|
||||
let server = sync_httpd_setup();
|
||||
do_test_pending();
|
||||
setUp();
|
||||
|
||||
Engines.register(CatapultEngine);
|
||||
|
@ -157,10 +153,10 @@ function test_engine_applyFailed() {
|
|||
|
||||
do_check_eq(Status.engines["steam"], ENGINE_APPLY_FAIL);
|
||||
} finally {
|
||||
server.stop(do_test_finished);
|
||||
Engines.unregister("catapult");
|
||||
Status.resetSync();
|
||||
Service.startOver();
|
||||
server.stop(next);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,8 +164,10 @@ function run_test() {
|
|||
if (DISABLE_TESTS_BUG_604565)
|
||||
return;
|
||||
|
||||
test_backoff500();
|
||||
test_backoff503();
|
||||
test_overQuota();
|
||||
test_engine_applyFailed();
|
||||
do_test_pending();
|
||||
asyncChainTests(test_backoff500,
|
||||
test_backoff503,
|
||||
test_overQuota,
|
||||
test_engine_applyFailed,
|
||||
do_test_finished)();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче