From ee0813b36408bbe18e5a580dc2ae7a6b2790a228 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Wed, 26 Jul 2023 05:50:40 +0000 Subject: [PATCH 1/9] test.replication: remove "down-server" The naming of the replication test which accessed the "down server" implies it's attempting to connect to a server which is down. The test actually passed for any non-pouchdb server, including: * a hostname which doesn't resolve * a hostname which resolves but server does not respond * a server which responds, but not as a couch server --- bin/down-server.js | 12 ------------ bin/test-node.sh | 6 ------ tests/integration/test.replication.js | 8 ++------ 3 files changed, 2 insertions(+), 24 deletions(-) delete mode 100644 bin/down-server.js diff --git a/bin/down-server.js b/bin/down-server.js deleted file mode 100644 index 7e5c79d01f..0000000000 --- a/bin/down-server.js +++ /dev/null @@ -1,12 +0,0 @@ -const http = require('http'); - -const [port] = process.argv.slice(2); - -const server = http.createServer((request, response) => { - response.writeHead(500, { 'Content-Type': 'application/json' }); - response.end('{}'); -}); - -server.listen(port, () => { - console.log(`Down server listening on port ${port}`); -}); diff --git a/bin/test-node.sh b/bin/test-node.sh index 98a7887416..2bda261417 100755 --- a/bin/test-node.sh +++ b/bin/test-node.sh @@ -12,12 +12,6 @@ else fi if [ $TYPE = "integration" ]; then - if (: < /dev/tcp/127.0.0.1/3010) 2>/dev/null; then - echo "down-server port already in use" - else - node bin/down-server.js 3010 & export DOWN_SERVER_PID=$! - fi - TESTS_PATH="tests/integration/test.*.js" fi if [ $TYPE = "fuzzy" ]; then diff --git a/tests/integration/test.replication.js b/tests/integration/test.replication.js index 77dc0e5ce8..34932eb2be 100644 --- a/tests/integration/test.replication.js +++ b/tests/integration/test.replication.js @@ -4260,15 +4260,11 @@ describe('suite2 test.replication.js-down-test', function () { }); it('replicate from down server test', async () => { - const source = new PouchDB('http://127.0.0.1:3010', { + const source = new PouchDB('http://10.1.1.1:1234/store', { ajax: {timeout: 10} }); const target = new PouchDB(dbs.name); - try { - await source.replicate.to(target); - } catch (error) { - should.exist(error); - } + await source.replicate.to(target).should.be.rejectedWith(/^Failed to fetch$/); }); }); From 0bd9c9ddb36bf8b07524803a8777590bdee4ba84 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Thu, 27 Jul 2023 09:21:24 +0000 Subject: [PATCH 2/9] Make error message check more general --- tests/integration/test.replication.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/test.replication.js b/tests/integration/test.replication.js index 34932eb2be..69d17339d7 100644 --- a/tests/integration/test.replication.js +++ b/tests/integration/test.replication.js @@ -4264,7 +4264,8 @@ describe('suite2 test.replication.js-down-test', function () { ajax: {timeout: 10} }); const target = new PouchDB(dbs.name); - await source.replicate.to(target).should.be.rejectedWith(/^Failed to fetch$/); + await source.replicate.to(target).should.be + .rejectedWith(/(^(Failed to fetch|NetworkError when attempting to fetch resource\.)$)|ECONNREFUSED/); }); }); From 56a481f64d26d4057781921b21294c88a58c563a Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Thu, 27 Jul 2023 11:44:22 +0000 Subject: [PATCH 3/9] Add alternative error msg --- tests/integration/test.replication.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test.replication.js b/tests/integration/test.replication.js index 69d17339d7..079b9b7676 100644 --- a/tests/integration/test.replication.js +++ b/tests/integration/test.replication.js @@ -4265,7 +4265,7 @@ describe('suite2 test.replication.js-down-test', function () { }); const target = new PouchDB(dbs.name); await source.replicate.to(target).should.be - .rejectedWith(/(^(Failed to fetch|NetworkError when attempting to fetch resource\.)$)|ECONNREFUSED/); + .rejectedWith(/(^(Failed to fetch|NetworkError when attempting to fetch resource\.)$)|ECONNREFUSED|EHOSTUNREACH/); }); }); From eaffa24b2156c4e20c4908908ea1e8f48ccbd3dd Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Thu, 27 Jul 2023 11:48:31 +0000 Subject: [PATCH 4/9] add alternative timeout --- tests/integration/test.replication.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/test.replication.js b/tests/integration/test.replication.js index 079b9b7676..9201ef2158 100644 --- a/tests/integration/test.replication.js +++ b/tests/integration/test.replication.js @@ -4261,7 +4261,8 @@ describe('suite2 test.replication.js-down-test', function () { it('replicate from down server test', async () => { const source = new PouchDB('http://10.1.1.1:1234/store', { - ajax: {timeout: 10} + ajax: {timeout: 10}, + timeout: 10, }); const target = new PouchDB(dbs.name); await source.replicate.to(target).should.be From 8a223f999f84cc3390696e50499698bc35636e12 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Tue, 15 Aug 2023 08:36:31 +0000 Subject: [PATCH 5/9] add massive timeout --- tests/integration/test.replication.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/integration/test.replication.js b/tests/integration/test.replication.js index 9201ef2158..09559ea163 100644 --- a/tests/integration/test.replication.js +++ b/tests/integration/test.replication.js @@ -4248,6 +4248,8 @@ adapters.forEach(function (adapters) { // This test only needs to run for one configuration, and it slows stuff // down describe('suite2 test.replication.js-down-test', function () { + this.timeout(120000); + let dbs = {}; beforeEach(function (done) { From 7d850c4d8daf048fa076f01b038b3940e149d376 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Tue, 15 Aug 2023 08:37:06 +0000 Subject: [PATCH 6/9] Add bigger timeout --- tests/integration/test.replication.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test.replication.js b/tests/integration/test.replication.js index 09559ea163..c292fa72af 100644 --- a/tests/integration/test.replication.js +++ b/tests/integration/test.replication.js @@ -4248,7 +4248,7 @@ adapters.forEach(function (adapters) { // This test only needs to run for one configuration, and it slows stuff // down describe('suite2 test.replication.js-down-test', function () { - this.timeout(120000); + this.timeout(360000); let dbs = {}; From 779f14b054d787592d14186fe64e28aaa11832ed Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Tue, 15 Aug 2023 11:27:40 +0000 Subject: [PATCH 7/9] ETIMEDOUT --- tests/integration/test.replication.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test.replication.js b/tests/integration/test.replication.js index c292fa72af..0596c22cfe 100644 --- a/tests/integration/test.replication.js +++ b/tests/integration/test.replication.js @@ -4268,7 +4268,7 @@ describe('suite2 test.replication.js-down-test', function () { }); const target = new PouchDB(dbs.name); await source.replicate.to(target).should.be - .rejectedWith(/(^(Failed to fetch|NetworkError when attempting to fetch resource\.)$)|ECONNREFUSED|EHOSTUNREACH/); + .rejectedWith(/(^(Failed to fetch|NetworkError when attempting to fetch resource\.)$)|ECONNREFUSED|EHOSTUNREACH|ETIMEDOUT/); }); }); From 7dc6bab907ea6295e77974c20afeef7b21e96f4a Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Tue, 15 Aug 2023 18:04:57 +0000 Subject: [PATCH 8/9] decrease timeout to 120s --- tests/integration/test.replication.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test.replication.js b/tests/integration/test.replication.js index 0596c22cfe..5f5fcb23a2 100644 --- a/tests/integration/test.replication.js +++ b/tests/integration/test.replication.js @@ -4248,7 +4248,7 @@ adapters.forEach(function (adapters) { // This test only needs to run for one configuration, and it slows stuff // down describe('suite2 test.replication.js-down-test', function () { - this.timeout(360000); + this.timeout(120000); let dbs = {}; From f39a2cca92fcf68b80d36192a235d678a7f6eb18 Mon Sep 17 00:00:00 2001 From: alxndrsn Date: Tue, 15 Aug 2023 18:30:32 +0000 Subject: [PATCH 9/9] Revert "decrease timeout to 120s" This reverts commit 7dc6bab907ea6295e77974c20afeef7b21e96f4a. --- tests/integration/test.replication.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test.replication.js b/tests/integration/test.replication.js index 5f5fcb23a2..0596c22cfe 100644 --- a/tests/integration/test.replication.js +++ b/tests/integration/test.replication.js @@ -4248,7 +4248,7 @@ adapters.forEach(function (adapters) { // This test only needs to run for one configuration, and it slows stuff // down describe('suite2 test.replication.js-down-test', function () { - this.timeout(120000); + this.timeout(360000); let dbs = {};