Cycle through httpd ports to prevent CI failures
We didn't seem to be doing this anymore, even though we had a comment for it, and some tests were failing with NS_ERROR_SOCKET_ADDRESS_IN_USE.
This commit is contained in:
parent
00651d670d
commit
14f7d3acad
1 changed files with 10 additions and 2 deletions
|
@ -329,6 +329,7 @@ describe("Zotero.Attachments", function() {
|
||||||
Components.utils.import("resource://zotero-unit/httpd.js");
|
Components.utils.import("resource://zotero-unit/httpd.js");
|
||||||
var testServerPath, httpd, prefix;
|
var testServerPath, httpd, prefix;
|
||||||
var testServerPort = 16213;
|
var testServerPort = 16213;
|
||||||
|
var maxTestServerPort = testServerPort + 10;
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
this.timeout(20000);
|
this.timeout(20000);
|
||||||
|
@ -336,9 +337,16 @@ describe("Zotero.Attachments", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
prefix = Zotero.Utilities.randomString();
|
// Cycle through ports to prevent NS_ERROR_SOCKET_ADDRESS_IN_USE errors from server
|
||||||
// Alternate ports to prevent exceptions not catchable in JS
|
// not always fully stopping in time
|
||||||
|
if (testServerPort < maxTestServerPort) {
|
||||||
|
testServerPort++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
testServerPort--;
|
||||||
|
}
|
||||||
// Use random prefix because httpd does not actually stop between tests
|
// Use random prefix because httpd does not actually stop between tests
|
||||||
|
prefix = Zotero.Utilities.randomString();
|
||||||
testServerPath = 'http://127.0.0.1:' + testServerPort + '/' + prefix;
|
testServerPath = 'http://127.0.0.1:' + testServerPort + '/' + prefix;
|
||||||
httpd = new HttpServer();
|
httpd = new HttpServer();
|
||||||
httpd.start(testServerPort);
|
httpd.start(testServerPort);
|
||||||
|
|
Loading…
Reference in a new issue