ActivityPub-federated video streaming platform using P2P directly in your web browser
Cleanup tests
Chocobozzz210feb6cc484
diff --git a/scripts/clean/server/test.sh b/scripts/clean/server/test.shindex b897c30baf..5694ac9225 100755--- a/scripts/clean/server/test.sh+++ b/scripts/clean/server/test.sh@@ -21,7 +21,14 @@ dropRedis () {redis-cli KEYS "redis-localhost:900$1*" | grep -v empty | xargs --no-run-if-empty redis-cli DEL}-for i in $(seq 1 6); do+seq=$(seq 1 6)++if [ ! -z ${1+x} ]; then+ seq=$1+fi+++for i in $seq; dorecreateDB "$i" &dropRedis "$i" &removeFiles "$i" &diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.tsindex 52e7e27f8b..edf588c166 100644--- a/server/tests/api/activitypub/client.ts+++ b/server/tests/api/activitypub/client.ts@@ -22,8 +22,6 @@ describe('Test activitypub', function () {before(async function () {this.timeout(30000)- await flushTests()-servers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -61,7 +59,7 @@ describe('Test activitypub', function () {expect(res.header.location).to.equal('http://localhost:9001/videos/watch/' + videoUUID)})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.tsindex f9dba3418d..7240bb0fb4 100644--- a/server/tests/api/activitypub/fetch.ts+++ b/server/tests/api/activitypub/fetch.ts@@ -81,10 +81,5 @@ describe('Test ActivityPub fetcher', function () {killallServers(servers)await closeAllSequelize(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.tsindex 7b08b1dabc..9be9aa495b 100644--- a/server/tests/api/activitypub/refresher.ts+++ b/server/tests/api/activitypub/refresher.ts@@ -153,7 +153,7 @@ describe('Test AP refresher', function () {})})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.tsindex 2346e9c8eb..11e6859bfb 100644--- a/server/tests/api/activitypub/security.ts+++ b/server/tests/api/activitypub/security.ts@@ -180,10 +180,5 @@ describe('Test ActivityPub security', function () {killallServers(servers)await closeAllSequelize(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.tsindex 4c145c41d4..0860905339 100644--- a/server/tests/api/check-params/accounts.ts+++ b/server/tests/api/check-params/accounts.ts@@ -2,7 +2,7 @@import 'mocha'-import { flushTests, killallServers, runServer, ServerInfo } from '../../../../shared/extra-utils'+import { flushTests, killallServers, flushAndRunServer, ServerInfo } from '../../../../shared/extra-utils'import {checkBadCountPagination,checkBadSortPagination,@@ -19,9 +19,7 @@ describe('Test accounts API validators', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)})describe('When listing accounts', function () {@@ -44,12 +42,7 @@ describe('Test accounts API validators', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.tsindex 6c7351d388..d815a83634 100644--- a/server/tests/api/check-params/blocklist.ts+++ b/server/tests/api/check-params/blocklist.ts@@ -28,8 +28,6 @@ describe('Test blocklist API validators', function () {before(async function () {this.timeout(60000)- await flushTests()-servers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -487,12 +485,7 @@ describe('Test blocklist API validators', function () {})})- after(async function () {+ after(function () {killallServers(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.tsindex ba07552cfa..3d80c629e2 100644--- a/server/tests/api/check-params/config.ts+++ b/server/tests/api/check-params/config.ts@@ -5,7 +5,7 @@ import 'mocha'import { CustomConfig } from '../../../../shared/models/server/custom-config.model'import {- createUser, flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePutBodyRequest, runServer, ServerInfo,+ createUser, flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePutBodyRequest, flushAndRunServer, ServerInfo,setAccessTokensToServers, userLogin, immutableAssign} from '../../../../shared/extra-utils'@@ -101,8 +101,7 @@ describe('Test config API validators', function () {before(async function () {this.timeout(30000)- await flushTests()- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -230,12 +229,7 @@ describe('Test config API validators', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.tsindex 9ba6136aae..6c7781f13c 100644--- a/server/tests/api/check-params/contact-form.ts+++ b/server/tests/api/check-params/contact-form.ts@@ -7,7 +7,7 @@ import {immutableAssign,killallServers,reRunServer,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers} from '../../../../shared/extra-utils'@@ -34,11 +34,10 @@ describe('Test contact form API validators', function () {before(async function () {this.timeout(60000)- await flushTests()await MockSmtpServer.Instance.collectEmails(emails)// Email is disabled- server = await runServer(1)+ server = await flushAndRunServer(1)})it('Should not accept a contact form if emails are disabled', async function () {@@ -84,13 +83,8 @@ describe('Test contact form API validators', function () {await sendContactForm(immutableAssign(defaultBody, { url: server.url }))})- after(async function () {+ after(function () {MockSmtpServer.Instance.kill()killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.tsindex 8ba7e04305..dd00ed9e1a 100644--- a/server/tests/api/check-params/debug.ts+++ b/server/tests/api/check-params/debug.ts@@ -6,7 +6,7 @@ import {createUser,flushTests,killallServers,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,userLogin@@ -23,9 +23,7 @@ describe('Test debug API validators', function () {before(async function () {this.timeout(120000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -67,12 +65,7 @@ describe('Test debug API validators', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.tsindex e756313120..02f47c2bb1 100644--- a/server/tests/api/check-params/follows.ts+++ b/server/tests/api/check-params/follows.ts@@ -3,7 +3,7 @@import 'mocha'import {- createUser, flushTests, killallServers, makeDeleteRequest, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers,+ createUser, flushTests, killallServers, makeDeleteRequest, makePostBodyRequest, flushAndRunServer, ServerInfo, setAccessTokensToServers,userLogin} from '../../../../shared/extra-utils'import {@@ -20,8 +20,7 @@ describe('Test server follows API validators', function () {before(async function () {this.timeout(30000)- await flushTests()- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])})@@ -296,12 +295,7 @@ describe('Test server follows API validators', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.tsindex 682406e872..ec2be0b9f8 100644--- a/server/tests/api/check-params/jobs.ts+++ b/server/tests/api/check-params/jobs.ts@@ -6,7 +6,7 @@ import {createUser,flushTests,killallServers,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,userLogin@@ -28,9 +28,7 @@ describe('Test jobs API validators', function () {before(async function () {this.timeout(120000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -82,12 +80,7 @@ describe('Test jobs API validators', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.tsindex 0948f7c5e6..46cb2392d9 100644--- a/server/tests/api/check-params/logs.ts+++ b/server/tests/api/check-params/logs.ts@@ -6,7 +6,7 @@ import {createUser,flushTests,killallServers,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,userLogin@@ -23,9 +23,7 @@ describe('Test logs API validators', function () {before(async function () {this.timeout(120000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -106,12 +104,7 @@ describe('Test logs API validators', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.tsindex 93b905feab..8f930fbbc4 100644--- a/server/tests/api/check-params/redundancy.ts+++ b/server/tests/api/check-params/redundancy.ts@@ -23,7 +23,6 @@ describe('Test server redundancy API validators', function () {before(async function () {this.timeout(30000)- await flushTests()servers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -92,12 +91,7 @@ describe('Test server redundancy API validators', function () {})})- after(async function () {+ after(function () {killallServers(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.tsindex 1fcdedd90a..816719779e 100644--- a/server/tests/api/check-params/search.ts+++ b/server/tests/api/check-params/search.ts@@ -2,7 +2,7 @@import 'mocha'-import { flushTests, immutableAssign, killallServers, makeGetRequest, runServer, ServerInfo } from '../../../../shared/extra-utils'+import { flushTests, immutableAssign, killallServers, makeGetRequest, flushAndRunServer, ServerInfo } from '../../../../shared/extra-utils'import {checkBadCountPagination,checkBadSortPagination,@@ -17,9 +17,7 @@ describe('Test videos API validator', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)})describe('When searching videos', function () {@@ -146,12 +144,7 @@ describe('Test videos API validator', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.tsindex 813bc7e364..33580ddb12 100644--- a/server/tests/api/check-params/services.ts+++ b/server/tests/api/check-params/services.ts@@ -6,7 +6,7 @@ import {flushTests,killallServers,makeGetRequest,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,uploadVideo@@ -20,9 +20,7 @@ describe('Test services API validators', function () {before(async function () {this.timeout(60000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])const res = await uploadVideo(server.url, server.accessToken, { name: 'my super name' })@@ -93,13 +91,8 @@ describe('Test services API validators', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.tsindex c563284069..32619d7e16 100644--- a/server/tests/api/check-params/user-notifications.ts+++ b/server/tests/api/check-params/user-notifications.ts@@ -10,7 +10,7 @@ import {makeGetRequest,makePostBodyRequest,makePutBodyRequest,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,wait@@ -30,9 +30,7 @@ describe('Test user notifications API validators', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])})@@ -288,12 +286,7 @@ describe('Test user notifications API validators', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.tsindex d33b3bca63..1fe67fa7c4 100644--- a/server/tests/api/check-params/user-subscriptions.ts+++ b/server/tests/api/check-params/user-subscriptions.ts@@ -9,7 +9,7 @@ import {makeDeleteRequest,makeGetRequest,makePostBodyRequest,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,userLogin@@ -32,9 +32,7 @@ describe('Test user subscriptions API validators', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -303,12 +301,7 @@ describe('Test user subscriptions API validators', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.tsindex b62806554b..00d0a7e2be 100644--- a/server/tests/api/check-params/users.ts+++ b/server/tests/api/check-params/users.ts@@ -7,7 +7,7 @@ import { UserRole, VideoImport, VideoImportState } from '../../../../shared'import {createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest,- makePostBodyRequest, makeUploadRequest, makePutBodyRequest, registerUser, removeUser, runServer, ServerInfo, setAccessTokensToServers,+ makePostBodyRequest, makeUploadRequest, makePutBodyRequest, registerUser, removeUser, flushAndRunServer, ServerInfo, setAccessTokensToServers,updateUser, uploadVideo, userLogin, deleteMe, unblockUser, blockUser} from '../../../../shared/extra-utils'import {@@ -40,10 +40,8 @@ describe('Test users API validators', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)- serverWithRegistrationDisabled = await runServer(2)+ server = await flushAndRunServer(1)+ serverWithRegistrationDisabled = await flushAndRunServer(2)await setAccessTokensToServers([ server ])@@ -881,12 +879,7 @@ describe('Test users API validators', function () {})})- after(async function () {+ after(function () {killallServers([ server, serverWithRegistrationDisabled ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/video-abuses.ts b/server/tests/api/check-params/video-abuses.tsindex 78e4acf2fe..e2813d470c 100644--- a/server/tests/api/check-params/video-abuses.ts+++ b/server/tests/api/check-params/video-abuses.ts@@ -9,7 +9,7 @@ import {killallServers,makeGetRequest,makePostBodyRequest,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,updateVideoAbuse,@@ -33,9 +33,7 @@ describe('Test video abuses API validators', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -190,12 +188,7 @@ describe('Test video abuses API validators', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.tsindex c2e9622cc4..f9c7d9e9a5 100644--- a/server/tests/api/check-params/video-blacklist.ts+++ b/server/tests/api/check-params/video-blacklist.ts@@ -39,7 +39,6 @@ describe('Test video blacklist API validators', function () {before(async function () {this.timeout(120000)- await flushTests()servers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -248,12 +247,7 @@ describe('Test video blacklist API validators', function () {})})- after(async function () {+ after(function () {killallServers(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.tsindex 4ef5e03ede..64265865a9 100644--- a/server/tests/api/check-params/video-captions.ts+++ b/server/tests/api/check-params/video-captions.ts@@ -8,7 +8,7 @@ import {makeDeleteRequest,makeGetRequest,makeUploadRequest,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,uploadVideo,@@ -29,9 +29,7 @@ describe('Test video captions API validator', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -271,12 +269,7 @@ describe('Test video captions API validator', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.tsindex b6aa745ab5..06da4f5413 100644--- a/server/tests/api/check-params/video-channels.ts+++ b/server/tests/api/check-params/video-channels.ts@@ -16,7 +16,7 @@ import {makePostBodyRequest,makePutBodyRequest,makeUploadRequest,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,userLogin@@ -41,9 +41,7 @@ describe('Test video channels API validator', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -312,12 +310,7 @@ describe('Test video channels API validator', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.tsindex b80d912799..bb14abbfd2 100644--- a/server/tests/api/check-params/video-comments.ts+++ b/server/tests/api/check-params/video-comments.ts@@ -4,7 +4,7 @@ import * as chai from 'chai'import 'mocha'import {createUser,- flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers,+ flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePostBodyRequest, flushAndRunServer, ServerInfo, setAccessTokensToServers,uploadVideo, userLogin} from '../../../../shared/extra-utils'import {@@ -29,9 +29,7 @@ describe('Test video comments API validator', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -253,12 +251,7 @@ describe('Test video comments API validator', function () {it('Should return conflict on comment thread add')})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.tsindex ad4c4def03..82fdc06670 100644--- a/server/tests/api/check-params/video-imports.ts+++ b/server/tests/api/check-params/video-imports.ts@@ -13,7 +13,7 @@ import {makeGetRequest,makePostBodyRequest,makeUploadRequest,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,updateCustomSubConfig,@@ -38,9 +38,7 @@ describe('Test video imports API validator', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -313,12 +311,7 @@ describe('Test video imports API validator', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.tsindex 0f34847633..0edb51682b 100644--- a/server/tests/api/check-params/video-playlists.ts+++ b/server/tests/api/check-params/video-playlists.ts@@ -14,7 +14,7 @@ import {makeGetRequest,removeVideoFromPlaylist,reorderVideosPlaylist,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers, setDefaultVideoChannel,updateVideoPlaylist,@@ -43,9 +43,7 @@ describe('Test video playlists API validator', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])await setDefaultVideoChannel([ server ])@@ -670,12 +668,7 @@ describe('Test video playlists API validator', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.tsindex 971867b27d..82cc0f638e 100644--- a/server/tests/api/check-params/videos-filter.ts+++ b/server/tests/api/check-params/videos-filter.ts@@ -7,7 +7,7 @@ import {flushTests,killallServers,makeGetRequest,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers, setDefaultVideoChannel,userLogin@@ -48,9 +48,7 @@ describe('Test videos filters', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])await setDefaultVideoChannel([ server ])@@ -131,12 +129,7 @@ describe('Test videos filters', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.tsindex 11e2776440..32f65f5103 100644--- a/server/tests/api/check-params/videos-history.ts+++ b/server/tests/api/check-params/videos-history.ts@@ -10,7 +10,7 @@ import {makeGetRequest,makePostBodyRequest,makePutBodyRequest,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,uploadVideo@@ -29,9 +29,7 @@ describe('Test videos history API validator', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -128,12 +126,7 @@ describe('Test videos history API validator', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.tsindex e96f324cc2..bc321e91fc 100644--- a/server/tests/api/check-params/videos.ts+++ b/server/tests/api/check-params/videos.ts@@ -8,7 +8,7 @@ import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enuimport {createUser, flushTests, getMyUserInformation, getVideo, getVideosList, immutableAssign, killallServers, makeDeleteRequest,makeGetRequest, makeUploadRequest, makePutBodyRequest, removeVideo, uploadVideo,- runServer, ServerInfo, setAccessTokensToServers, userLogin, updateCustomSubConfig+ flushAndRunServer, ServerInfo, setAccessTokensToServers, userLogin, updateCustomSubConfig} from '../../../../shared/extra-utils'import {checkBadCountPagination,@@ -33,9 +33,7 @@ describe('Test videos API validator', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -730,12 +728,7 @@ describe('Test videos API validator', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.tsindex 8f7ce82a48..eb4fdb87c9 100644--- a/server/tests/api/notifications/user-notifications.ts+++ b/server/tests/api/notifications/user-notifications.ts@@ -112,8 +112,6 @@ describe('Test users notifications', function () {await MockSmtpServer.Instance.collectEmails(emails)- await flushTests()-const overrideConfig = {smtp: {hostname: 'localhost'@@ -1297,7 +1295,7 @@ describe('Test users notifications', function () {})})- after(async function () {+ after(function () {MockSmtpServer.Instance.kill()killallServers(servers)diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.tsindex 1f59a951be..c5662f049a 100644--- a/server/tests/api/search/search-activitypub-video-channels.ts+++ b/server/tests/api/search/search-activitypub-video-channels.ts@@ -33,8 +33,6 @@ describe('Test a ActivityPub video channels search', function () {before(async function () {this.timeout(120000)- await flushTests()-servers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -207,12 +205,7 @@ describe('Test a ActivityPub video channels search', function () {expect(res.body.data).to.have.lengthOf(0)})- after(async function () {+ after(function () {killallServers(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.tsindex d984c696c2..5c2a44ad53 100644--- a/server/tests/api/search/search-activitypub-videos.ts+++ b/server/tests/api/search/search-activitypub-videos.ts@@ -30,8 +30,6 @@ describe('Test a ActivityPub videos search', function () {before(async function () {this.timeout(120000)- await flushTests()-servers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -151,12 +149,7 @@ describe('Test a ActivityPub videos search', function () {expect(res.body.data).to.have.lengthOf(0)})- after(async function () {+ after(function () {killallServers(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.tsindex 65f3c91862..d1520a9aa8 100644--- a/server/tests/api/search/search-videos.ts+++ b/server/tests/api/search/search-videos.ts@@ -6,7 +6,7 @@ import {advancedVideosSearch,flushTests,killallServers,- runServer,+ flushAndRunServer,searchVideo,ServerInfo,setAccessTokensToServers,@@ -24,9 +24,7 @@ describe('Test a videos search', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -407,12 +405,7 @@ describe('Test a videos search', function () {}})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.tsindex a999166278..d8137b3397 100644--- a/server/tests/api/server/config.ts+++ b/server/tests/api/server/config.ts@@ -13,7 +13,7 @@ import {getConfig,getCustomConfig,registerUser,- runServer,+ flushAndRunServer,setAccessTokensToServers,updateCustomConfig} from '../../../../shared/extra-utils'@@ -118,9 +118,7 @@ describe('Test config', function () {before(async function () {this.timeout(30000)-- await flushTests()- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])})@@ -302,7 +300,7 @@ describe('Test config', function () {checkInitialConfig(data)})- after(async function () {+ after(function () {killallServers([ server ])})})diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.tsindex fdd5e97302..26ebb4ed7a 100644--- a/server/tests/api/server/contact-form.ts+++ b/server/tests/api/server/contact-form.ts@@ -2,7 +2,7 @@import * as chai from 'chai'import 'mocha'-import { flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, wait } from '../../../../shared/extra-utils'+import { flushTests, killallServers, flushAndRunServer, ServerInfo, setAccessTokensToServers, wait } from '../../../../shared/extra-utils'import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'import { waitJobs } from '../../../../shared/extra-utils/server/jobs'import { sendContactForm } from '../../../../shared/extra-utils/server/contact-form'@@ -18,14 +18,12 @@ describe('Test contact form', function () {await MockSmtpServer.Instance.collectEmails(emails)- await flushTests()-const overrideConfig = {smtp: {hostname: 'localhost'}}- server = await runServer(1, overrideConfig)+ server = await flushAndRunServer(1, overrideConfig)await setAccessTokensToServers([ server ])})@@ -80,7 +78,7 @@ describe('Test contact form', function () {})})- after(async function () {+ after(function () {MockSmtpServer.Instance.kill()killallServers([ server ])})diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.tsindex a40a281f82..1158ceb0ed 100644--- a/server/tests/api/server/email.ts+++ b/server/tests/api/server/email.ts@@ -10,7 +10,7 @@ import {createUser, removeVideoFromBlacklist,reportVideoAbuse,resetPassword,- runServer,+ flushAndRunServer,unblockUser,uploadVideo,userLogin,@@ -43,14 +43,12 @@ describe('Test emails', function () {await MockSmtpServer.Instance.collectEmails(emails)- await flushTests()-const overrideConfig = {smtp: {hostname: 'localhost'}}- server = await runServer(1, overrideConfig)+ server = await flushAndRunServer(1, overrideConfig)await setAccessTokensToServers([ server ]){@@ -258,7 +256,7 @@ describe('Test emails', function () {})})- after(async function () {+ after(function () {MockSmtpServer.Instance.kill()killallServers([ server ])})diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.tsindex bdd8b1c700..cf40018b38 100644--- a/server/tests/api/server/follow-constraints.ts+++ b/server/tests/api/server/follow-constraints.ts@@ -219,7 +219,7 @@ describe('Test follow constraints', function () {})})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.tsindex f4a826ea8e..ae8716184f 100644--- a/server/tests/api/server/follows-moderation.ts+++ b/server/tests/api/server/follows-moderation.ts@@ -189,7 +189,7 @@ describe('Test follows moderation', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.tsindex 527b54e1ed..f1b4a450ef 100644--- a/server/tests/api/server/follows.ts+++ b/server/tests/api/server/follows.ts@@ -435,7 +435,7 @@ describe('Test follows', function () {})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.tsindex 8c49541ee1..d0f700bdad 100644--- a/server/tests/api/server/handle-down.ts+++ b/server/tests/api/server/handle-down.ts@@ -296,7 +296,7 @@ describe('Test handle downs', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.tsindex 1d74298733..01f561b0df 100644--- a/server/tests/api/server/jobs.ts+++ b/server/tests/api/server/jobs.ts@@ -56,7 +56,7 @@ describe('Test jobs', function () {expect(dateIsValid(job.finishedOn)).to.be.true})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/server/logs.ts b/server/tests/api/server/logs.tsindex f55e124076..5ca3522059 100644--- a/server/tests/api/server/logs.ts+++ b/server/tests/api/server/logs.ts@@ -2,7 +2,7 @@import * as chai from 'chai'import 'mocha'-import { flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'+import { flushTests, killallServers, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'import { waitJobs } from '../../../../shared/extra-utils/server/jobs'import { uploadVideo } from '../../../../shared/extra-utils/videos/videos'import { getLogs } from '../../../../shared/extra-utils/logs/logs'@@ -15,9 +15,7 @@ describe('Test logs', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])})@@ -86,7 +84,7 @@ describe('Test logs', function () {}})- after(async function () {+ after(function () {killallServers([ server ])})})diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.tsindex 88d34063cb..226fbfda41 100644--- a/server/tests/api/server/no-client.ts+++ b/server/tests/api/server/no-client.ts@@ -5,7 +5,7 @@ import {killallServers,ServerInfo} from '../../../../shared/extra-utils'-import { runServer } from '../../../../shared/extra-utils/server/servers'+import { flushAndRunServer } from '../../../../shared/extra-utils/server/servers'describe('Start and stop server without web client routes', function () {let server: ServerInfo@@ -13,9 +13,7 @@ describe('Start and stop server without web client routes', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1, {}, ['--no-client'])+ server = await flushAndRunServer(1, {}, ['--no-client'])})it('Should fail getting the client', function () {@@ -25,12 +23,7 @@ describe('Start and stop server without web client routes', function () {return req.expect(404)})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.tsindex e7dc165315..e55b12bfcf 100644--- a/server/tests/api/server/reverse-proxy.ts+++ b/server/tests/api/server/reverse-proxy.ts@@ -21,7 +21,7 @@ const expect = chai.expectimport {getConfig,flushTests,- runServer,+ flushAndRunServer,registerUser, getCustomConfig, setAccessTokensToServers, updateCustomConfig} from '../../../../shared/extra-utils/index'@@ -31,9 +31,7 @@ describe('Test application behind a reverse proxy', function () {before(async function () {this.timeout(30000)-- await flushTests()- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])const { body } = await uploadVideo(server.url, server.accessToken, {})@@ -102,7 +100,7 @@ describe('Test application behind a reverse proxy', function () {await userLogin(server, user, 429)})- after(async function () {+ after(function () {killallServers([ server ])})})diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.tsindex 48addad227..bd3d2155c5 100644--- a/server/tests/api/server/stats.ts+++ b/server/tests/api/server/stats.ts@@ -26,8 +26,6 @@ describe('Test stats (excluding redundancy)', function () {before(async function () {this.timeout(60000)-- await flushTests()servers = await flushAndRunMultipleServers(3)await setAccessTokensToServers(servers)@@ -97,7 +95,7 @@ describe('Test stats (excluding redundancy)', function () {expect(data.totalInstanceFollowers).to.equal(0)})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.tsindex 4f7cc05a7a..1b4e190f1b 100644--- a/server/tests/api/server/tracker.ts+++ b/server/tests/api/server/tracker.ts@@ -2,7 +2,7 @@import * as magnetUtil from 'magnet-uri'import 'mocha'-import { getVideo, killallServers, reRunServer, runServer, ServerInfo, uploadVideo } from '../../../../shared/extra-utils'+import { getVideo, killallServers, reRunServer, flushAndRunServer, ServerInfo, uploadVideo } from '../../../../shared/extra-utils'import { flushTests, setAccessTokensToServers } from '../../../../shared/extra-utils/index'import { VideoDetails } from '../../../../shared/models/videos'import * as WebTorrent from 'webtorrent'@@ -14,9 +14,7 @@ describe('Test tracker', function () {before(async function () {this.timeout(60000)-- await flushTests()- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ]){@@ -84,7 +82,7 @@ describe('Test tracker', function () {})})- after(async function () {+ after(function () {killallServers([ server ])})})diff --git a/server/tests/api/users/blocklist.ts b/server/tests/api/users/blocklist.tsindex cd96ffe2ac..34eabf2e6c 100644--- a/server/tests/api/users/blocklist.ts+++ b/server/tests/api/users/blocklist.ts@@ -79,8 +79,6 @@ describe('Test blocklist', function () {before(async function () {this.timeout(60000)- await flushTests()-servers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -500,12 +498,7 @@ describe('Test blocklist', function () {})})- after(async function () {+ after(function () {killallServers(servers)-- // Keep the logs if the test failed- if (this[ 'ok' ]) {- await flushTests()- }})})diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.tsindex 5be185678a..ee5abd6b73 100644--- a/server/tests/api/users/user-subscriptions.ts+++ b/server/tests/api/users/user-subscriptions.ts@@ -368,7 +368,7 @@ describe('Test users subscriptions', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.tsindex 9b8db00725..7097d90d1f 100644--- a/server/tests/api/users/users-multiple-servers.ts+++ b/server/tests/api/users/users-multiple-servers.ts@@ -235,7 +235,7 @@ describe('Test users with multiple servers', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.tsindex 7fcd3e50b5..295caae978 100644--- a/server/tests/api/users/users-verification.ts+++ b/server/tests/api/users/users-verification.ts@@ -4,7 +4,7 @@ import * as chai from 'chai'import 'mocha'import {registerUser, flushTests, getUserInformation, getMyUserInformation, killallServers,- userLogin, login, runServer, ServerInfo, verifyEmail, updateCustomSubConfig, wait+ userLogin, login, flushAndRunServer, ServerInfo, verifyEmail, updateCustomSubConfig, wait} from '../../../../shared/extra-utils'import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'@@ -32,14 +32,12 @@ describe('Test users account verification', function () {await MockSmtpServer.Instance.collectEmails(emails)- await flushTests()-const overrideConfig = {smtp: {hostname: 'localhost'}}- server = await runServer(1, overrideConfig)+ server = await flushAndRunServer(1, overrideConfig)await setAccessTokensToServers([ server ])})@@ -122,13 +120,8 @@ describe('Test users account verification', function () {await userLogin(server, user2)})- after(async function () {+ after(function () {MockSmtpServer.Instance.kill()killallServers([ server ])-- // Keep the logs if the test failed- if (this[ 'ok' ]) {- await flushTests()- }})})diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.tsindex 472ff511cc..8efff12ad4 100644--- a/server/tests/api/users/users.ts+++ b/server/tests/api/users/users.ts@@ -24,7 +24,7 @@ import {registerUser,removeUser,removeVideo,- runServer,+ flushAndRunServer,ServerInfo,testImage,unblockUser,@@ -54,9 +54,7 @@ describe('Test users', function () {before(async function () {this.timeout(30000)-- await flushTests()- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])})@@ -679,12 +677,7 @@ describe('Test users', function () {})})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this[ 'ok' ]) {- await flushTests()- }})})diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.tsindex dd50f905d2..50b231555e 100644--- a/server/tests/api/videos/multiple-servers.ts+++ b/server/tests/api/videos/multiple-servers.ts@@ -1029,12 +1029,7 @@ describe('Test multiple servers', function () {})})- after(async function () {+ after(function () {killallServers(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.tsindex e79ce59a6a..1397347d1b 100644--- a/server/tests/api/videos/services.ts+++ b/server/tests/api/videos/services.ts@@ -11,7 +11,7 @@ import {setAccessTokensToServers,uploadVideo} from '../../../../shared/extra-utils/index'-import { runServer } from '../../../../shared/extra-utils/server/servers'+import { flushAndRunServer } from '../../../../shared/extra-utils/server/servers'const expect = chai.expect@@ -21,9 +21,7 @@ describe('Test services', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -76,7 +74,7 @@ describe('Test services', function () {expect(res.body).to.not.have.property('thumbnail_height')})- after(async function () {+ after(function () {killallServers([ server ])})})diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.tsindex ea3e7c4214..db2a3779fd 100644--- a/server/tests/api/videos/single-server.ts+++ b/server/tests/api/videos/single-server.ts@@ -20,7 +20,7 @@ import {killallServers,rateVideo,removeVideo,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,testImage,@@ -107,9 +107,7 @@ describe('Test a single server', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])})@@ -426,12 +424,7 @@ describe('Test a single server', function () {expect(video.dislikes).to.equal(1)})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.tsindex 2ae1bf34d0..06bb31348f 100644--- a/server/tests/api/videos/video-abuse.ts+++ b/server/tests/api/videos/video-abuse.ts@@ -172,7 +172,7 @@ describe('Test video abuses', function () {expect(res.body.data.length).to.equal(0)})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/videos/video-blacklist.ts b/server/tests/api/videos/video-blacklist.tsindex 582c82e05b..cb15d1a52a 100644--- a/server/tests/api/videos/video-blacklist.ts+++ b/server/tests/api/videos/video-blacklist.ts@@ -425,7 +425,7 @@ describe('Test video blacklist', function () {})})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.tsindex da920e00c5..c6f59762ac 100644--- a/server/tests/api/videos/video-captions.ts+++ b/server/tests/api/videos/video-captions.ts@@ -29,8 +29,6 @@ describe('Test video captions', function () {before(async function () {this.timeout(30000)- await flushTests()-servers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -197,7 +195,7 @@ describe('Test video captions', function () {await checkVideoFilesWereRemoved(videoUUID, 1)})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.tsindex 9040ac3084..db12206779 100644--- a/server/tests/api/videos/video-change-ownership.ts+++ b/server/tests/api/videos/video-change-ownership.ts@@ -5,19 +5,20 @@ import 'mocha'import {acceptChangeOwnership,changeVideoOwnership,- createUser, doubleFollow, flushAndRunMultipleServers,- flushTests,+ createUser,+ doubleFollow,+ flushAndRunMultipleServers,+ flushAndRunServer,getMyUserInformation,+ getVideo,getVideoChangeOwnershipList,getVideosList,killallServers,refuseChangeOwnership,- runServer,ServerInfo,setAccessTokensToServers,uploadVideo,- userLogin,- getVideo+ userLogin} from '../../../../shared/extra-utils'import { waitJobs } from '../../../../shared/extra-utils/server/jobs'import { User } from '../../../../shared/models/users'@@ -202,7 +203,7 @@ describe('Test video change ownership - nominal', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})@@ -225,8 +226,7 @@ describe('Test video change ownership - quota too small', function () {this.timeout(50000)// Run one server- await flushTests()- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([server])const videoQuota = 42000000@@ -297,7 +297,7 @@ describe('Test video change ownership - quota too small', function () {await acceptChangeOwnership(server.url, secondUserAccessToken, lastRequestChangeOwnershipId, channelId, 403)})- after(async function () {+ after(function () {killallServers([server])})})diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.tsindex e30e6bb4fc..60b84e4437 100644--- a/server/tests/api/videos/video-channels.ts+++ b/server/tests/api/videos/video-channels.ts@@ -42,8 +42,6 @@ describe('Test video channels', function () {before(async function () {this.timeout(30000)- await flushTests()-servers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -279,7 +277,7 @@ describe('Test video channels', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.tsindex abf4d0c449..50224ee473 100644--- a/server/tests/api/videos/video-comments.ts+++ b/server/tests/api/videos/video-comments.ts@@ -8,7 +8,7 @@ import {dateIsValid,flushTests,killallServers,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,updateMyAvatar,@@ -34,9 +34,7 @@ describe('Test video comments', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -201,7 +199,7 @@ describe('Test video comments', function () {expect(res.body.data[1].totalReplies).to.equal(0)})- after(async function () {+ after(function () {killallServers([ server ])})})diff --git a/server/tests/api/videos/video-description.ts b/server/tests/api/videos/video-description.tsindex 0c03d17d85..333d539f46 100644--- a/server/tests/api/videos/video-description.ts+++ b/server/tests/api/videos/video-description.ts@@ -99,7 +99,7 @@ describe('Test video description', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.tsindex a9251406ab..0ac84a6561 100644--- a/server/tests/api/videos/video-hls.ts+++ b/server/tests/api/videos/video-hls.ts@@ -128,12 +128,7 @@ describe('Test HLS videos', function () {}})- after(async function () {+ after(function () {killallServers(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.tsindex f8b2c0407e..49a28e207c 100644--- a/server/tests/api/videos/video-imports.ts+++ b/server/tests/api/videos/video-imports.ts@@ -241,7 +241,7 @@ describe('Test video imports', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.tsindex 9f2d99ffec..811705212b 100644--- a/server/tests/api/videos/video-nsfw.ts+++ b/server/tests/api/videos/video-nsfw.ts@@ -20,7 +20,7 @@ import {getMyUserInformation,getVideoChannelVideos,getVideosListWithToken,- runServer,+ flushAndRunServer,searchVideo,searchVideoWithToken,updateCustomConfig,@@ -64,9 +64,7 @@ describe('Test video NSFW policy', function () {before(async function () {this.timeout(50000)-- await flushTests()- server = await runServer(1)+ server = await flushAndRunServer(1)// Get the access tokensawait setAccessTokensToServers([ server ])@@ -243,7 +241,7 @@ describe('Test video NSFW policy', function () {})})- after(async function () {+ after(function () {killallServers([ server ])})})diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.tsindex 8c3542906d..ea349f09be 100644--- a/server/tests/api/videos/video-playlists.ts+++ b/server/tests/api/videos/video-playlists.ts@@ -860,12 +860,7 @@ describe('Test video playlists', function () {}})- after(async function () {+ after(function () {killallServers(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.tsindex ba5e0f044d..a823993b2d 100644--- a/server/tests/api/videos/video-privacy.ts+++ b/server/tests/api/videos/video-privacy.ts@@ -152,7 +152,7 @@ describe('Test video privacy', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.tsindex b19a9116aa..d7301a1377 100644--- a/server/tests/api/videos/video-schedule-update.ts+++ b/server/tests/api/videos/video-schedule-update.ts@@ -165,7 +165,7 @@ describe('Test video update scheduler', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.tsindex 3d4739ca96..92888f1376 100644--- a/server/tests/api/videos/video-transcoder.ts+++ b/server/tests/api/videos/video-transcoder.ts@@ -349,7 +349,7 @@ describe('Test video transcoding', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.tsindex 36664b17fc..179610595c 100644--- a/server/tests/api/videos/videos-filter.ts+++ b/server/tests/api/videos/videos-filter.ts@@ -55,8 +55,6 @@ describe('Test videos filter validator', function () {before(async function () {this.timeout(120000)- await flushTests()-servers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -121,12 +119,7 @@ describe('Test videos filter validator', function () {})})- after(async function () {+ after(function () {killallServers(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.tsindex 6f75ce42c6..2a904c6592 100644--- a/server/tests/api/videos/videos-history.ts+++ b/server/tests/api/videos/videos-history.ts@@ -8,7 +8,7 @@ import {getVideosListWithToken,getVideoWithToken,killallServers, reRunServer,- runServer,+ flushAndRunServer,searchVideoWithToken,ServerInfo,setAccessTokensToServers,@@ -33,9 +33,7 @@ describe('Test videos history', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])@@ -222,12 +220,7 @@ describe('Test videos history', function () {expect(res.body.total).to.equal(0)})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.tsindex 233ca8a5dd..c921eb74dd 100644--- a/server/tests/api/videos/videos-overview.ts+++ b/server/tests/api/videos/videos-overview.ts@@ -2,7 +2,7 @@import * as chai from 'chai'import 'mocha'-import { flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils'+import { flushTests, killallServers, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils'import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'import { VideosOverview } from '../../../../shared/models/overviews'@@ -14,9 +14,7 @@ describe('Test a videos overview', function () {before(async function () {this.timeout(30000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])})@@ -89,12 +87,7 @@ describe('Test a videos overview', function () {expect(overview.channels[0].channel.name).to.equal('root_channel')})- after(async function () {+ after(function () {killallServers([ server ])-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.tsindex 4001969c3c..80cecdd236 100644--- a/server/tests/api/videos/videos-views-cleaner.ts+++ b/server/tests/api/videos/videos-views-cleaner.ts@@ -7,7 +7,7 @@ import {flushTests,killallServers,reRunServer,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs@@ -27,8 +27,6 @@ describe('Test video views cleaner', function () {before(async function () {this.timeout(50000)- await flushTests()-servers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -102,12 +100,7 @@ describe('Test video views cleaner', function () {}})- after(async function () {+ after(function () {killallServers(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.tsindex 4dc12a1c61..191d4b4609 100644--- a/server/tests/cli/create-import-video-file-job.ts+++ b/server/tests/cli/create-import-video-file-job.ts@@ -39,7 +39,6 @@ describe('Test create import video jobs', function () {before(async function () {this.timeout(90000)- await flushTests()// Run server 2 to have transcoding enabledservers = await flushAndRunMultipleServers(2)@@ -131,7 +130,7 @@ describe('Test create import video jobs', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.tsindex bd1de20794..61c310bc3f 100644--- a/server/tests/cli/create-transcoding-job.ts+++ b/server/tests/cli/create-transcoding-job.ts@@ -28,8 +28,6 @@ describe('Test create transcoding jobs', function () {before(async function () {this.timeout(60000)- await flushTests()-// Run server 2 to have transcoding enabledservers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -126,7 +124,7 @@ describe('Test create transcoding jobs', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.tsindex b3724476b1..14625f8c0b 100644--- a/server/tests/cli/optimize-old-videos.ts+++ b/server/tests/cli/optimize-old-videos.ts@@ -31,8 +31,6 @@ describe('Test optimize old videos', function () {before(async function () {this.timeout(200000)- await flushTests()-// Run server 2 to have transcoding enabledservers = await flushAndRunMultipleServers(2)await setAccessTokensToServers(servers)@@ -114,7 +112,7 @@ describe('Test optimize old videos', function () {}})- after(async function () {+ after(function () {killallServers(servers)})})diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.tsindex 45411bdbc6..0c11945e0d 100644--- a/server/tests/cli/peertube.ts+++ b/server/tests/cli/peertube.ts@@ -8,7 +8,7 @@ import {flushTests,getEnvCli,killallServers,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers} from '../../../shared/extra-utils'@@ -19,9 +19,7 @@ describe('Test CLI wrapper', function () {before(async function () {this.timeout(30000)-- await flushTests()- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])await createUser({ url: server.url, accessToken: server.accessToken, username: 'user_1', password: 'super password' })diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.tsindex 3c56bf45b7..1d64238141 100644--- a/server/tests/cli/reset-password.ts+++ b/server/tests/cli/reset-password.ts@@ -7,7 +7,7 @@ import {getEnvCli,killallServers,login,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers} from '../../../shared/extra-utils'@@ -17,9 +17,7 @@ describe('Test reset password scripts', function () {before(async function () {this.timeout(30000)-- await flushTests()- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])await createUser({ url: server.url, accessToken: server.accessToken, username: 'user_1', password: 'super password' })@@ -34,7 +32,7 @@ describe('Test reset password scripts', function () {await login(server.url, server.client, { username: 'user_1', password: 'coucou' }, 200)})- after(async function () {+ after(function () {killallServers([ server ])})})diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.tsindex 2270ff4945..dd594779bb 100644--- a/server/tests/cli/update-host.ts+++ b/server/tests/cli/update-host.ts@@ -17,7 +17,7 @@ import {killallServers,makeActivityPubGetRequest,parseTorrentVideo,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,uploadVideo@@ -32,15 +32,13 @@ describe('Test update host scripts', function () {before(async function () {this.timeout(60000)- await flushTests()-const overrideConfig = {webserver: {port: 9256}}// Run server 2 to have transcoding enabled- server = await runServer(2, overrideConfig)+ server = await flushAndRunServer(2, overrideConfig)await setAccessTokensToServers([ server ])// Upload two videos for our needs@@ -72,7 +70,7 @@ describe('Test update host scripts', function () {killallServers([ server ])// Run server with standard configuration- server = await runServer(2)+ server = await flushAndRunServer(2)const env = getEnvCli(server)await execCLI(`${env} npm run update-host`)@@ -148,7 +146,7 @@ describe('Test update host scripts', function () {}})- after(async function () {+ after(function () {killallServers([ server ])})})diff --git a/server/tests/client.ts b/server/tests/client.tsindex 1161895100..cdf0ce2ced 100644--- a/server/tests/client.ts+++ b/server/tests/client.ts@@ -9,7 +9,7 @@ import {getVideosList,killallServers,makeHTMLRequest,- runServer,+ flushAndRunServer,ServerInfo,serverLogin,updateCustomConfig,@@ -31,9 +31,7 @@ describe('Test a client controllers', function () {before(async function () {this.timeout(120000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)server.accessToken = await serverLogin(server)const videoAttributes = {@@ -147,7 +145,7 @@ describe('Test a client controllers', function () {checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')})- after(async function () {+ after(function () {killallServers([ server ])})})diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.tsindex 0e9ea1a18e..fc6543474e 100644--- a/server/tests/feeds/feeds.ts+++ b/server/tests/feeds/feeds.ts@@ -207,12 +207,7 @@ describe('Test syndication feeds', () => {})})- after(async function () {+ after(function () {killallServers(servers)-- // Keep the logs if the test failed- if (this['ok']) {- await flushTests()- }})})diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.tsindex d78b62d60c..d5c7d9dd40 100644--- a/server/tests/misc-endpoints.ts+++ b/server/tests/misc-endpoints.ts@@ -8,7 +8,7 @@ import {flushTests,killallServers,makeGetRequest,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,uploadVideo@@ -23,9 +23,7 @@ describe('Test misc endpoints', function () {before(async function () {this.timeout(120000)- await flushTests()-- server = await runServer(1)+ server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])})@@ -173,7 +171,7 @@ describe('Test misc endpoints', function () {})})- after(async function () {+ after(function () {killallServers([ server ])})})diff --git a/server/tests/real-world/populate-database.ts b/server/tests/real-world/populate-database.tsindex 459c9cbd83..b1c1688e7c 100644--- a/server/tests/real-world/populate-database.ts+++ b/server/tests/real-world/populate-database.ts@@ -6,7 +6,7 @@ import {getVideosList,killallServers,rateVideo,- runServer,+ flushAndRunServer,ServerInfo,setAccessTokensToServers,uploadVideo@@ -19,11 +19,10 @@ start()// ----------------------------------------------------------------------------async function start () {- await flushTests()console.log('Flushed tests.')- const server = await runServer(6)+ const server = await flushAndRunServer(6)process.on('exit', async () => {killallServers([ server ])diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.tsindex 5288d253a5..b0cb869f48 100644--- a/shared/extra-utils/server/servers.ts+++ b/shared/extra-utils/server/servers.ts@@ -58,18 +58,17 @@ function flushAndRunMultipleServers (totalServers: number, configOverride?: Obje}}- flushTests()- .then(() => {- for (let j = 1; j <= totalServers; j++) {- runServer(j, configOverride).then(app => anotherServerDone(j, app))- }- })+ for (let j = 1; j <= totalServers; j++) {+ flushAndRunServer(j, configOverride).then(app => anotherServerDone(j, app))+ }})}-function flushTests () {+function flushTests (serverNumber?: number) {return new Promise<void>((res, rej) => {- return exec('npm run clean:server:test', err => {+ const suffix = serverNumber ? ` -- ${serverNumber}` : ''++ return exec('npm run clean:server:test' + suffix, err => {if (err) return rej(err)return res()@@ -77,7 +76,7 @@ function flushTests () {})}-function runServer (serverNumber: number, configOverride?: Object, args = []) {+function flushAndRunServer (serverNumber: number, configOverride?: Object, args = []) {const server: ServerInfo = {app: null,serverNumber: serverNumber,@@ -123,47 +122,51 @@ function runServer (serverNumber: number, configOverride?: Object, args = []) {}return new Promise<ServerInfo>(res => {- server.app = fork(join(root(), 'dist', 'server.js'), args, options)- server.app.stdout.on('data', function onStdout (data) {- let dontContinue = false-- // Capture things if we want to- for (const key of Object.keys(regexps)) {- const regexp = regexps[key]- const matches = data.toString().match(regexp)- if (matches !== null) {- if (key === 'client_id') server.client.id = matches[1]- else if (key === 'client_secret') server.client.secret = matches[1]- else if (key === 'user_username') server.user.username = matches[1]- else if (key === 'user_password') server.user.password = matches[1]- }- }-- // Check if all required sentences are here- for (const key of Object.keys(serverRunString)) {- if (data.toString().indexOf(key) !== -1) serverRunString[key] = true- if (serverRunString[key] === false) dontContinue = true- }-- // If no, there is maybe one thing not already initialized (client/user credentials generation...)- if (dontContinue === true) return-- server.app.stdout.removeListener('data', onStdout)+ flushTests(serverNumber)+ .then(() => {- process.on('exit', () => {- try {- process.kill(server.app.pid)- } catch { /* empty */ }+ server.app = fork(join(root(), 'dist', 'server.js'), args, options)+ server.app.stdout.on('data', function onStdout (data) {+ let dontContinue = false++ // Capture things if we want to+ for (const key of Object.keys(regexps)) {+ const regexp = regexps[ key ]+ const matches = data.toString().match(regexp)+ if (matches !== null) {+ if (key === 'client_id') server.client.id = matches[ 1 ]+ else if (key === 'client_secret') server.client.secret = matches[ 1 ]+ else if (key === 'user_username') server.user.username = matches[ 1 ]+ else if (key === 'user_password') server.user.password = matches[ 1 ]+ }+ }++ // Check if all required sentences are here+ for (const key of Object.keys(serverRunString)) {+ if (data.toString().indexOf(key) !== -1) serverRunString[ key ] = true+ if (serverRunString[ key ] === false) dontContinue = true+ }++ // If no, there is maybe one thing not already initialized (client/user credentials generation...)+ if (dontContinue === true) return++ server.app.stdout.removeListener('data', onStdout)++ process.on('exit', () => {+ try {+ process.kill(server.app.pid)+ } catch { /* empty */+ }+ })++ res(server)+ })})-- res(server)- })-})}async function reRunServer (server: ServerInfo, configOverride?: any) {- const newServer = await runServer(server.serverNumber, configOverride)+ const newServer = await flushAndRunServer(server.serverNumber, configOverride)server.app = newServer.appreturn server@@ -212,7 +215,7 @@ export {ServerInfo,flushAndRunMultipleServers,flushTests,- runServer,+ flushAndRunServer,killallServers,reRunServer,waitUntilLog