aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-24 15:10:37 +0200
committerChocobozzz <me@florianbigard.com>2019-04-24 16:26:25 +0200
commit7c3b79768bd174b22154e8d2df0b1211e01ee56a (patch)
tree9e45c9302083f0438f7ea174f5fb7d6042be5712 /server/tests
parent913b1d71e630d5a959c763bf565a171b4dc61434 (diff)
downloadPeerTube-7c3b79768bd174b22154e8d2df0b1211e01ee56a.tar.gz
PeerTube-7c3b79768bd174b22154e8d2df0b1211e01ee56a.tar.zst
PeerTube-7c3b79768bd174b22154e8d2df0b1211e01ee56a.zip
Use test wrapper exit function
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/config.ts8
-rw-r--r--server/tests/api/check-params/contact-form.ts14
-rw-r--r--server/tests/api/check-params/debug.ts6
-rw-r--r--server/tests/api/check-params/follows.ts12
-rw-r--r--server/tests/api/check-params/jobs.ts7
-rw-r--r--server/tests/api/check-params/logs.ts7
-rw-r--r--server/tests/api/check-params/redundancy.ts13
-rw-r--r--server/tests/api/check-params/search.ts6
-rw-r--r--server/tests/api/check-params/services.ts25
-rw-r--r--server/tests/api/check-params/user-notifications.ts15
-rw-r--r--server/tests/api/check-params/user-subscriptions.ts27
-rw-r--r--server/tests/api/check-params/users.ts8
-rw-r--r--server/tests/api/check-params/video-abuses.ts9
-rw-r--r--server/tests/api/check-params/video-blacklist.ts5
-rw-r--r--server/tests/api/check-params/video-captions.ts9
-rw-r--r--server/tests/api/check-params/video-channels.ts12
-rw-r--r--server/tests/api/check-params/video-comments.ts6
-rw-r--r--server/tests/api/check-params/video-imports.ts9
-rw-r--r--server/tests/api/check-params/video-playlists.ts12
-rw-r--r--server/tests/api/check-params/videos-filter.ts12
-rw-r--r--server/tests/api/check-params/videos-history.ts9
-rw-r--r--server/tests/api/check-params/videos.ts60
-rw-r--r--server/tests/api/notifications/user-notifications.ts6
-rw-r--r--server/tests/api/redundancy/redundancy.ts38
-rw-r--r--server/tests/api/search/search-activitypub-video-channels.ts6
-rw-r--r--server/tests/api/search/search-activitypub-videos.ts6
-rw-r--r--server/tests/api/search/search-videos.ts7
-rw-r--r--server/tests/api/server/config.ts12
-rw-r--r--server/tests/api/server/contact-form.ts15
-rw-r--r--server/tests/api/server/email.ts7
-rw-r--r--server/tests/api/server/follow-constraints.ts6
-rw-r--r--server/tests/api/server/follows-moderation.ts6
-rw-r--r--server/tests/api/server/follows.ts6
-rw-r--r--server/tests/api/server/handle-down.ts5
-rw-r--r--server/tests/api/server/jobs.ts6
-rw-r--r--server/tests/api/server/logs.ts13
-rw-r--r--server/tests/api/server/no-client.ts12
-rw-r--r--server/tests/api/server/reverse-proxy.ts28
-rw-r--r--server/tests/api/server/stats.ts5
-rw-r--r--server/tests/api/server/tracker.ts16
-rw-r--r--server/tests/api/users/blocklist.ts5
-rw-r--r--server/tests/api/users/user-subscriptions.ts5
-rw-r--r--server/tests/api/users/users-multiple-servers.ts6
-rw-r--r--server/tests/api/users/users-verification.ts7
-rw-r--r--server/tests/api/users/users.ts9
-rw-r--r--server/tests/api/videos/multiple-servers.ts6
-rw-r--r--server/tests/api/videos/services.ts16
-rw-r--r--server/tests/api/videos/single-server.ts9
-rw-r--r--server/tests/api/videos/video-abuse.ts5
-rw-r--r--server/tests/api/videos/video-blacklist.ts6
-rw-r--r--server/tests/api/videos/video-captions.ts6
-rw-r--r--server/tests/api/videos/video-change-ownership.ts6
-rw-r--r--server/tests/api/videos/video-channels.ts5
-rw-r--r--server/tests/api/videos/video-comments.ts8
-rw-r--r--server/tests/api/videos/video-description.ts5
-rw-r--r--server/tests/api/videos/video-hls.ts6
-rw-r--r--server/tests/api/videos/video-imports.ts5
-rw-r--r--server/tests/api/videos/video-nsfw.ts15
-rw-r--r--server/tests/api/videos/video-playlists.ts6
-rw-r--r--server/tests/api/videos/video-privacy.ts5
-rw-r--r--server/tests/api/videos/video-schedule-update.ts5
-rw-r--r--server/tests/api/videos/video-transcoder.ts6
-rw-r--r--server/tests/api/videos/videos-filter.ts5
-rw-r--r--server/tests/api/videos/videos-history.ts11
-rw-r--r--server/tests/api/videos/videos-overview.ts6
-rw-r--r--server/tests/api/videos/videos-views-cleaner.ts6
-rw-r--r--server/tests/cli/create-import-video-file-job.ts5
-rw-r--r--server/tests/cli/create-transcoding-job.ts5
-rw-r--r--server/tests/cli/optimize-old-videos.ts5
-rw-r--r--server/tests/cli/peertube.ts4
-rw-r--r--server/tests/cli/reset-password.ts9
-rw-r--r--server/tests/cli/update-host.ts12
-rw-r--r--server/tests/client.ts9
-rw-r--r--server/tests/feeds/feeds.ts5
-rw-r--r--server/tests/misc-endpoints.ts9
75 files changed, 371 insertions, 363 deletions
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index 3d80c629e..2a2ec606a 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -6,7 +6,7 @@ import { CustomConfig } from '../../../../shared/models/server/custom-config.mod
6 6
7import { 7import {
8 createUser, flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePutBodyRequest, flushAndRunServer, ServerInfo, 8 createUser, flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePutBodyRequest, flushAndRunServer, ServerInfo,
9 setAccessTokensToServers, userLogin, immutableAssign 9 setAccessTokensToServers, userLogin, immutableAssign, cleanupTests
10} from '../../../../shared/extra-utils' 10} from '../../../../shared/extra-utils'
11 11
12describe('Test config API validators', function () { 12describe('Test config API validators', function () {
@@ -181,7 +181,7 @@ describe('Test config API validators', function () {
181 }) 181 })
182 182
183 it('Should fail if email disabled and signup requires email verification', async function () { 183 it('Should fail if email disabled and signup requires email verification', async function () {
184 // opposite scenario - succcess when enable enabled - covered via tests/api/users/user-verification.ts 184 // opposite scenario - success when enable enabled - covered via tests/api/users/user-verification.ts
185 const newUpdateParams = immutableAssign(updateParams, { 185 const newUpdateParams = immutableAssign(updateParams, {
186 signup: { 186 signup: {
187 enabled: true, 187 enabled: true,
@@ -229,7 +229,7 @@ describe('Test config API validators', function () {
229 }) 229 })
230 }) 230 })
231 231
232 after(function () { 232 after(async function () {
233 killallServers([ server ]) 233 await cleanupTests([ server ])
234 }) 234 })
235}) 235})
diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts
index 6c7781f13..55004020f 100644
--- a/server/tests/api/check-params/contact-form.ts
+++ b/server/tests/api/check-params/contact-form.ts
@@ -9,7 +9,7 @@ import {
9 reRunServer, 9 reRunServer,
10 flushAndRunServer, 10 flushAndRunServer,
11 ServerInfo, 11 ServerInfo,
12 setAccessTokensToServers 12 setAccessTokensToServers, cleanupTests
13} from '../../../../shared/extra-utils' 13} from '../../../../shared/extra-utils'
14import { 14import {
15 checkBadCountPagination, 15 checkBadCountPagination,
@@ -28,13 +28,14 @@ describe('Test contact form API validators', function () {
28 fromEmail: 'toto@example.com', 28 fromEmail: 'toto@example.com',
29 body: 'Hello, how are you?' 29 body: 'Hello, how are you?'
30 } 30 }
31 let emailPort: number
31 32
32 // --------------------------------------------------------------- 33 // ---------------------------------------------------------------
33 34
34 before(async function () { 35 before(async function () {
35 this.timeout(60000) 36 this.timeout(60000)
36 37
37 await MockSmtpServer.Instance.collectEmails(emails) 38 emailPort = await MockSmtpServer.Instance.collectEmails(emails)
38 39
39 // Email is disabled 40 // Email is disabled
40 server = await flushAndRunServer(1) 41 server = await flushAndRunServer(1)
@@ -50,7 +51,7 @@ describe('Test contact form API validators', function () {
50 killallServers([ server ]) 51 killallServers([ server ])
51 52
52 // Contact form is disabled 53 // Contact form is disabled
53 await reRunServer(server, { smtp: { hostname: 'localhost' }, contact_form: { enabled: false } }) 54 await reRunServer(server, { smtp: { hostname: 'localhost', port: emailPort }, contact_form: { enabled: false } })
54 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 409 })) 55 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 409 }))
55 }) 56 })
56 57
@@ -60,7 +61,7 @@ describe('Test contact form API validators', function () {
60 killallServers([ server ]) 61 killallServers([ server ])
61 62
62 // Email & contact form enabled 63 // Email & contact form enabled
63 await reRunServer(server, { smtp: { hostname: 'localhost' } }) 64 await reRunServer(server, { smtp: { hostname: 'localhost', port: emailPort } })
64 65
65 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromEmail: 'badEmail' })) 66 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromEmail: 'badEmail' }))
66 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromEmail: 'badEmail@' })) 67 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromEmail: 'badEmail@' }))
@@ -83,8 +84,9 @@ describe('Test contact form API validators', function () {
83 await sendContactForm(immutableAssign(defaultBody, { url: server.url })) 84 await sendContactForm(immutableAssign(defaultBody, { url: server.url }))
84 }) 85 })
85 86
86 after(function () { 87 after(async function () {
87 MockSmtpServer.Instance.kill() 88 MockSmtpServer.Instance.kill()
88 killallServers([ server ]) 89
90 // await cleanupTests([ server ])
89 }) 91 })
90}) 92})
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts
index dd00ed9e1..8dad26723 100644
--- a/server/tests/api/check-params/debug.ts
+++ b/server/tests/api/check-params/debug.ts
@@ -9,7 +9,7 @@ import {
9 flushAndRunServer, 9 flushAndRunServer,
10 ServerInfo, 10 ServerInfo,
11 setAccessTokensToServers, 11 setAccessTokensToServers,
12 userLogin 12 userLogin, cleanupTests
13} from '../../../../shared/extra-utils' 13} from '../../../../shared/extra-utils'
14import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' 14import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
15 15
@@ -65,7 +65,7 @@ describe('Test debug API validators', function () {
65 }) 65 })
66 }) 66 })
67 67
68 after(function () { 68 after(async function () {
69 killallServers([ server ]) 69 await cleanupTests([ server ])
70 }) 70 })
71}) 71})
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts
index 02f47c2bb..2eb54cb0a 100644
--- a/server/tests/api/check-params/follows.ts
+++ b/server/tests/api/check-params/follows.ts
@@ -3,7 +3,13 @@
3import 'mocha' 3import 'mocha'
4 4
5import { 5import {
6 createUser, flushTests, killallServers, makeDeleteRequest, makePostBodyRequest, flushAndRunServer, ServerInfo, setAccessTokensToServers, 6 cleanupTests,
7 createUser,
8 flushAndRunServer,
9 makeDeleteRequest,
10 makePostBodyRequest,
11 ServerInfo,
12 setAccessTokensToServers,
7 userLogin 13 userLogin
8} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
9import { 15import {
@@ -295,7 +301,7 @@ describe('Test server follows API validators', function () {
295 }) 301 })
296 }) 302 })
297 303
298 after(function () { 304 after(async function () {
299 killallServers([ server ]) 305 await cleanupTests([ server ])
300 }) 306 })
301}) 307})
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index ec2be0b9f..c70139514 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -9,7 +9,8 @@ import {
9 flushAndRunServer, 9 flushAndRunServer,
10 ServerInfo, 10 ServerInfo,
11 setAccessTokensToServers, 11 setAccessTokensToServers,
12 userLogin 12 userLogin,
13 cleanupTests
13} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
14import { 15import {
15 checkBadCountPagination, 16 checkBadCountPagination,
@@ -80,7 +81,7 @@ describe('Test jobs API validators', function () {
80 }) 81 })
81 }) 82 })
82 83
83 after(function () { 84 after(async function () {
84 killallServers([ server ]) 85 await cleanupTests([ server ])
85 }) 86 })
86}) 87})
diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.ts
index 46cb2392d..f9d96bcc0 100644
--- a/server/tests/api/check-params/logs.ts
+++ b/server/tests/api/check-params/logs.ts
@@ -9,7 +9,8 @@ import {
9 flushAndRunServer, 9 flushAndRunServer,
10 ServerInfo, 10 ServerInfo,
11 setAccessTokensToServers, 11 setAccessTokensToServers,
12 userLogin 12 userLogin,
13 cleanupTests
13} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
14import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' 15import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
15 16
@@ -104,7 +105,7 @@ describe('Test logs API validators', function () {
104 }) 105 })
105 }) 106 })
106 107
107 after(function () { 108 after(async function () {
108 killallServers([ server ]) 109 await cleanupTests([ server ])
109 }) 110 })
110}) 111})
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts
index 8f930fbbc..6471da840 100644
--- a/server/tests/api/check-params/redundancy.ts
+++ b/server/tests/api/check-params/redundancy.ts
@@ -3,6 +3,7 @@
3import 'mocha' 3import 'mocha'
4 4
5import { 5import {
6 cleanupTests,
6 createUser, 7 createUser,
7 doubleFollow, 8 doubleFollow,
8 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
@@ -43,7 +44,7 @@ describe('Test server redundancy API validators', function () {
43 it('Should fail with an invalid token', async function () { 44 it('Should fail with an invalid token', async function () {
44 await makePutBodyRequest({ 45 await makePutBodyRequest({
45 url: servers[0].url, 46 url: servers[0].url,
46 path: path + '/localhost:9002', 47 path: path + '/localhost:' + servers[1].port,
47 fields: { redundancyAllowed: true }, 48 fields: { redundancyAllowed: true },
48 token: 'fake_token', 49 token: 'fake_token',
49 statusCodeExpected: 401 50 statusCodeExpected: 401
@@ -53,7 +54,7 @@ describe('Test server redundancy API validators', function () {
53 it('Should fail if the user is not an administrator', async function () { 54 it('Should fail if the user is not an administrator', async function () {
54 await makePutBodyRequest({ 55 await makePutBodyRequest({
55 url: servers[0].url, 56 url: servers[0].url,
56 path: path + '/localhost:9002', 57 path: path + '/localhost:' + servers[1].port,
57 fields: { redundancyAllowed: true }, 58 fields: { redundancyAllowed: true },
58 token: userAccessToken, 59 token: userAccessToken,
59 statusCodeExpected: 403 60 statusCodeExpected: 403
@@ -73,7 +74,7 @@ describe('Test server redundancy API validators', function () {
73 it('Should fail without de redundancyAllowed param', async function () { 74 it('Should fail without de redundancyAllowed param', async function () {
74 await makePutBodyRequest({ 75 await makePutBodyRequest({
75 url: servers[0].url, 76 url: servers[0].url,
76 path: path + '/localhost:9002', 77 path: path + '/localhost:' + servers[1].port,
77 fields: { blabla: true }, 78 fields: { blabla: true },
78 token: servers[0].accessToken, 79 token: servers[0].accessToken,
79 statusCodeExpected: 400 80 statusCodeExpected: 400
@@ -83,7 +84,7 @@ describe('Test server redundancy API validators', function () {
83 it('Should succeed with the correct parameters', async function () { 84 it('Should succeed with the correct parameters', async function () {
84 await makePutBodyRequest({ 85 await makePutBodyRequest({
85 url: servers[0].url, 86 url: servers[0].url,
86 path: path + '/localhost:9002', 87 path: path + '/localhost:' + servers[1].port,
87 fields: { redundancyAllowed: true }, 88 fields: { redundancyAllowed: true },
88 token: servers[0].accessToken, 89 token: servers[0].accessToken,
89 statusCodeExpected: 204 90 statusCodeExpected: 204
@@ -91,7 +92,7 @@ describe('Test server redundancy API validators', function () {
91 }) 92 })
92 }) 93 })
93 94
94 after(function () { 95 after(async function () {
95 killallServers(servers) 96 await cleanupTests(servers)
96 }) 97 })
97}) 98})
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts
index 816719779..8ad9d98bf 100644
--- a/server/tests/api/check-params/search.ts
+++ b/server/tests/api/check-params/search.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4 4
5import { flushTests, immutableAssign, killallServers, makeGetRequest, flushAndRunServer, ServerInfo } from '../../../../shared/extra-utils' 5import { cleanupTests, flushAndRunServer, immutableAssign, makeGetRequest, ServerInfo } from '../../../../shared/extra-utils'
6import { 6import {
7 checkBadCountPagination, 7 checkBadCountPagination,
8 checkBadSortPagination, 8 checkBadSortPagination,
@@ -144,7 +144,7 @@ describe('Test videos API validator', function () {
144 }) 144 })
145 }) 145 })
146 146
147 after(function () { 147 after(async function () {
148 killallServers([ server ]) 148 await cleanupTests([ server ])
149 }) 149 })
150}) 150})
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index 33580ddb1..d15753aed 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -3,10 +3,9 @@
3import 'mocha' 3import 'mocha'
4 4
5import { 5import {
6 flushTests, 6 cleanupTests,
7 killallServers,
8 makeGetRequest,
9 flushAndRunServer, 7 flushAndRunServer,
8 makeGetRequest,
10 ServerInfo, 9 ServerInfo,
11 setAccessTokensToServers, 10 setAccessTokensToServers,
12 uploadVideo 11 uploadVideo
@@ -40,47 +39,47 @@ describe('Test services API validators', function () {
40 }) 39 })
41 40
42 it('Should fail with an invalid video id', async function () { 41 it('Should fail with an invalid video id', async function () {
43 const embedUrl = 'http://localhost:9001/videos/watch/blabla' 42 const embedUrl = `http://localhost:${server.port}/videos/watch/blabla`
44 await checkParamEmbed(server, embedUrl) 43 await checkParamEmbed(server, embedUrl)
45 }) 44 })
46 45
47 it('Should fail with an unknown video', async function () { 46 it('Should fail with an unknown video', async function () {
48 const embedUrl = 'http://localhost:9001/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c' 47 const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c`
49 await checkParamEmbed(server, embedUrl, 404) 48 await checkParamEmbed(server, embedUrl, 404)
50 }) 49 })
51 50
52 it('Should fail with an invalid path', async function () { 51 it('Should fail with an invalid path', async function () {
53 const embedUrl = 'http://localhost:9001/videos/watchs/' + server.video.uuid 52 const embedUrl = `http://localhost:${server.port}/videos/watchs/${server.video.uuid}`
54 53
55 await checkParamEmbed(server, embedUrl) 54 await checkParamEmbed(server, embedUrl)
56 }) 55 })
57 56
58 it('Should fail with an invalid max height', async function () { 57 it('Should fail with an invalid max height', async function () {
59 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid 58 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
60 59
61 await checkParamEmbed(server, embedUrl, 400, { maxheight: 'hello' }) 60 await checkParamEmbed(server, embedUrl, 400, { maxheight: 'hello' })
62 }) 61 })
63 62
64 it('Should fail with an invalid max width', async function () { 63 it('Should fail with an invalid max width', async function () {
65 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid 64 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
66 65
67 await checkParamEmbed(server, embedUrl, 400, { maxwidth: 'hello' }) 66 await checkParamEmbed(server, embedUrl, 400, { maxwidth: 'hello' })
68 }) 67 })
69 68
70 it('Should fail with an invalid format', async function () { 69 it('Should fail with an invalid format', async function () {
71 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid 70 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
72 71
73 await checkParamEmbed(server, embedUrl, 400, { format: 'blabla' }) 72 await checkParamEmbed(server, embedUrl, 400, { format: 'blabla' })
74 }) 73 })
75 74
76 it('Should fail with a non supported format', async function () { 75 it('Should fail with a non supported format', async function () {
77 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid 76 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
78 77
79 await checkParamEmbed(server, embedUrl, 501, { format: 'xml' }) 78 await checkParamEmbed(server, embedUrl, 501, { format: 'xml' })
80 }) 79 })
81 80
82 it('Should succeed with the correct params', async function () { 81 it('Should succeed with the correct params', async function () {
83 const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid 82 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
84 const query = { 83 const query = {
85 format: 'json', 84 format: 'json',
86 maxheight: 400, 85 maxheight: 400,
@@ -91,8 +90,8 @@ describe('Test services API validators', function () {
91 }) 90 })
92 }) 91 })
93 92
94 after(function () { 93 after(async function () {
95 killallServers([ server ]) 94 await cleanupTests([ server ])
96 }) 95 })
97}) 96})
98 97
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts
index 32619d7e1..14ee20d45 100644
--- a/server/tests/api/check-params/user-notifications.ts
+++ b/server/tests/api/check-params/user-notifications.ts
@@ -4,13 +4,12 @@ import 'mocha'
4import * as io from 'socket.io-client' 4import * as io from 'socket.io-client'
5 5
6import { 6import {
7 flushTests, 7 cleanupTests,
8 flushAndRunServer,
8 immutableAssign, 9 immutableAssign,
9 killallServers,
10 makeGetRequest, 10 makeGetRequest,
11 makePostBodyRequest, 11 makePostBodyRequest,
12 makePutBodyRequest, 12 makePutBodyRequest,
13 flushAndRunServer,
14 ServerInfo, 13 ServerInfo,
15 setAccessTokensToServers, 14 setAccessTokensToServers,
16 wait 15 wait
@@ -234,7 +233,7 @@ describe('Test user notifications API validators', function () {
234 233
235 describe('When connecting to my notification socket', function () { 234 describe('When connecting to my notification socket', function () {
236 it('Should fail with no token', function (next) { 235 it('Should fail with no token', function (next) {
237 const socket = io('http://localhost:9001/user-notifications', { reconnection: false }) 236 const socket = io(`http://localhost:${server.port}/user-notifications`, { reconnection: false })
238 237
239 socket.on('error', () => { 238 socket.on('error', () => {
240 socket.removeListener('error', this) 239 socket.removeListener('error', this)
@@ -249,7 +248,7 @@ describe('Test user notifications API validators', function () {
249 }) 248 })
250 249
251 it('Should fail with an invalid token', function (next) { 250 it('Should fail with an invalid token', function (next) {
252 const socket = io('http://localhost:9001/user-notifications', { 251 const socket = io(`http://localhost:${server.port}/user-notifications`, {
253 query: { accessToken: 'bad_access_token' }, 252 query: { accessToken: 'bad_access_token' },
254 reconnection: false 253 reconnection: false
255 }) 254 })
@@ -267,7 +266,7 @@ describe('Test user notifications API validators', function () {
267 }) 266 })
268 267
269 it('Should success with the correct token', function (next) { 268 it('Should success with the correct token', function (next) {
270 const socket = io('http://localhost:9001/user-notifications', { 269 const socket = io(`http://localhost:${server.port}/user-notifications`, {
271 query: { accessToken: server.accessToken }, 270 query: { accessToken: server.accessToken },
272 reconnection: false 271 reconnection: false
273 }) 272 })
@@ -286,7 +285,7 @@ describe('Test user notifications API validators', function () {
286 }) 285 })
287 }) 286 })
288 287
289 after(function () { 288 after(async function () {
290 killallServers([ server ]) 289 await cleanupTests([ server ])
291 }) 290 })
292}) 291})
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 1fe67fa7c..fa36c4078 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -3,13 +3,12 @@
3import 'mocha' 3import 'mocha'
4 4
5import { 5import {
6 cleanupTests,
6 createUser, 7 createUser,
7 flushTests, 8 flushAndRunServer,
8 killallServers,
9 makeDeleteRequest, 9 makeDeleteRequest,
10 makeGetRequest, 10 makeGetRequest,
11 makePostBodyRequest, 11 makePostBodyRequest,
12 flushAndRunServer,
13 ServerInfo, 12 ServerInfo,
14 setAccessTokensToServers, 13 setAccessTokensToServers,
15 userLogin 14 userLogin
@@ -113,7 +112,7 @@ describe('Test user subscriptions API validators', function () {
113 await makePostBodyRequest({ 112 await makePostBodyRequest({
114 url: server.url, 113 url: server.url,
115 path, 114 path,
116 fields: { uri: 'user1_channel@localhost:9001' }, 115 fields: { uri: 'user1_channel@localhost:' + server.port },
117 statusCodeExpected: 401 116 statusCodeExpected: 401
118 }) 117 })
119 }) 118 })
@@ -151,7 +150,7 @@ describe('Test user subscriptions API validators', function () {
151 url: server.url, 150 url: server.url,
152 path, 151 path,
153 token: server.accessToken, 152 token: server.accessToken,
154 fields: { uri: 'user1_channel@localhost:9001' }, 153 fields: { uri: 'user1_channel@localhost:' + server.port },
155 statusCodeExpected: 204 154 statusCodeExpected: 204
156 }) 155 })
157 156
@@ -163,7 +162,7 @@ describe('Test user subscriptions API validators', function () {
163 it('Should fail with a non authenticated user', async function () { 162 it('Should fail with a non authenticated user', async function () {
164 await makeGetRequest({ 163 await makeGetRequest({
165 url: server.url, 164 url: server.url,
166 path: path + '/user1_channel@localhost:9001', 165 path: path + '/user1_channel@localhost:' + server.port,
167 statusCodeExpected: 401 166 statusCodeExpected: 401
168 }) 167 })
169 }) 168 })
@@ -194,7 +193,7 @@ describe('Test user subscriptions API validators', function () {
194 it('Should fail with an unknown subscription', async function () { 193 it('Should fail with an unknown subscription', async function () {
195 await makeGetRequest({ 194 await makeGetRequest({
196 url: server.url, 195 url: server.url,
197 path: path + '/root1@localhost:9001', 196 path: path + '/root1@localhost:' + server.port,
198 token: server.accessToken, 197 token: server.accessToken,
199 statusCodeExpected: 404 198 statusCodeExpected: 404
200 }) 199 })
@@ -203,7 +202,7 @@ describe('Test user subscriptions API validators', function () {
203 it('Should succeed with the correct parameters', async function () { 202 it('Should succeed with the correct parameters', async function () {
204 await makeGetRequest({ 203 await makeGetRequest({
205 url: server.url, 204 url: server.url,
206 path: path + '/user1_channel@localhost:9001', 205 path: path + '/user1_channel@localhost:' + server.port,
207 token: server.accessToken, 206 token: server.accessToken,
208 statusCodeExpected: 200 207 statusCodeExpected: 200
209 }) 208 })
@@ -243,7 +242,7 @@ describe('Test user subscriptions API validators', function () {
243 await makeGetRequest({ 242 await makeGetRequest({
244 url: server.url, 243 url: server.url,
245 path: existPath, 244 path: existPath,
246 query: { 'uris[]': 'coucou@localhost:9001' }, 245 query: { 'uris[]': 'coucou@localhost:' + server.port },
247 token: server.accessToken, 246 token: server.accessToken,
248 statusCodeExpected: 200 247 statusCodeExpected: 200
249 }) 248 })
@@ -254,7 +253,7 @@ describe('Test user subscriptions API validators', function () {
254 it('Should fail with a non authenticated user', async function () { 253 it('Should fail with a non authenticated user', async function () {
255 await makeDeleteRequest({ 254 await makeDeleteRequest({
256 url: server.url, 255 url: server.url,
257 path: path + '/user1_channel@localhost:9001', 256 path: path + '/user1_channel@localhost:' + server.port,
258 statusCodeExpected: 401 257 statusCodeExpected: 401
259 }) 258 })
260 }) 259 })
@@ -285,7 +284,7 @@ describe('Test user subscriptions API validators', function () {
285 it('Should fail with an unknown subscription', async function () { 284 it('Should fail with an unknown subscription', async function () {
286 await makeDeleteRequest({ 285 await makeDeleteRequest({
287 url: server.url, 286 url: server.url,
288 path: path + '/root1@localhost:9001', 287 path: path + '/root1@localhost:' + server.port,
289 token: server.accessToken, 288 token: server.accessToken,
290 statusCodeExpected: 404 289 statusCodeExpected: 404
291 }) 290 })
@@ -294,14 +293,14 @@ describe('Test user subscriptions API validators', function () {
294 it('Should succeed with the correct parameters', async function () { 293 it('Should succeed with the correct parameters', async function () {
295 await makeDeleteRequest({ 294 await makeDeleteRequest({
296 url: server.url, 295 url: server.url,
297 path: path + '/user1_channel@localhost:9001', 296 path: path + '/user1_channel@localhost:' + server.port,
298 token: server.accessToken, 297 token: server.accessToken,
299 statusCodeExpected: 204 298 statusCodeExpected: 204
300 }) 299 })
301 }) 300 })
302 }) 301 })
303 302
304 after(function () { 303 after(async function () {
305 killallServers([ server ]) 304 await cleanupTests([ server ])
306 }) 305 })
307}) 306})
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index d2fea65f6..5935104a5 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -7,6 +7,7 @@ import { UserRole, VideoImport, VideoImportState } from '../../../../shared'
7 7
8import { 8import {
9 blockUser, 9 blockUser,
10 cleanupTests,
10 createUser, 11 createUser,
11 deleteMe, 12 deleteMe,
12 flushAndRunServer, 13 flushAndRunServer,
@@ -14,7 +15,6 @@ import {
14 getMyUserVideoRating, 15 getMyUserVideoRating,
15 getUsersList, 16 getUsersList,
16 immutableAssign, 17 immutableAssign,
17 killallServers,
18 makeGetRequest, 18 makeGetRequest,
19 makePostBodyRequest, 19 makePostBodyRequest,
20 makePutBodyRequest, 20 makePutBodyRequest,
@@ -713,7 +713,7 @@ describe('Test users API validators', function () {
713 }) 713 })
714 714
715 it('Should fail if we register a user with the same email', async function () { 715 it('Should fail if we register a user with the same email', async function () {
716 const fields = immutableAssign(baseCorrectParams, { email: 'admin1@example.com' }) 716 const fields = immutableAssign(baseCorrectParams, { email: 'admin' + server.internalServerNumber + '@example.com' })
717 717
718 await makePostBodyRequest({ 718 await makePostBodyRequest({
719 url: server.url, 719 url: server.url,
@@ -897,7 +897,7 @@ describe('Test users API validators', function () {
897 }) 897 })
898 }) 898 })
899 899
900 after(function () { 900 after(async function () {
901 killallServers([ server, serverWithRegistrationDisabled ]) 901 await cleanupTests([ server, serverWithRegistrationDisabled ])
902 }) 902 })
903}) 903})
diff --git a/server/tests/api/check-params/video-abuses.ts b/server/tests/api/check-params/video-abuses.ts
index e2813d470..bf29f8d4d 100644
--- a/server/tests/api/check-params/video-abuses.ts
+++ b/server/tests/api/check-params/video-abuses.ts
@@ -3,13 +3,12 @@
3import 'mocha' 3import 'mocha'
4 4
5import { 5import {
6 cleanupTests,
6 createUser, 7 createUser,
7 deleteVideoAbuse, 8 deleteVideoAbuse,
8 flushTests, 9 flushAndRunServer,
9 killallServers,
10 makeGetRequest, 10 makeGetRequest,
11 makePostBodyRequest, 11 makePostBodyRequest,
12 flushAndRunServer,
13 ServerInfo, 12 ServerInfo,
14 setAccessTokensToServers, 13 setAccessTokensToServers,
15 updateVideoAbuse, 14 updateVideoAbuse,
@@ -188,7 +187,7 @@ describe('Test video abuses API validators', function () {
188 }) 187 })
189 }) 188 })
190 189
191 after(function () { 190 after(async function () {
192 killallServers([ server ]) 191 await cleanupTests([ server ])
193 }) 192 })
194}) 193})
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index f9c7d9e9a..6466888fb 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -3,6 +3,7 @@
3import 'mocha' 3import 'mocha'
4 4
5import { 5import {
6 cleanupTests,
6 createUser, 7 createUser,
7 doubleFollow, 8 doubleFollow,
8 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
@@ -247,7 +248,7 @@ describe('Test video blacklist API validators', function () {
247 }) 248 })
248 }) 249 })
249 250
250 after(function () { 251 after(async function () {
251 killallServers(servers) 252 await cleanupTests(servers)
252 }) 253 })
253}) 254})
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts
index 64265865a..4a373d43d 100644
--- a/server/tests/api/check-params/video-captions.ts
+++ b/server/tests/api/check-params/video-captions.ts
@@ -2,13 +2,12 @@
2 2
3import 'mocha' 3import 'mocha'
4import { 4import {
5 cleanupTests,
5 createUser, 6 createUser,
6 flushTests, 7 flushAndRunServer,
7 killallServers,
8 makeDeleteRequest, 8 makeDeleteRequest,
9 makeGetRequest, 9 makeGetRequest,
10 makeUploadRequest, 10 makeUploadRequest,
11 flushAndRunServer,
12 ServerInfo, 11 ServerInfo,
13 setAccessTokensToServers, 12 setAccessTokensToServers,
14 uploadVideo, 13 uploadVideo,
@@ -269,7 +268,7 @@ describe('Test video captions API validator', function () {
269 }) 268 })
270 }) 269 })
271 270
272 after(function () { 271 after(async function () {
273 killallServers([ server ]) 272 await cleanupTests([ server ])
274 }) 273 })
275}) 274})
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 06da4f541..65bc20613 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -4,19 +4,16 @@ import * as chai from 'chai'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import 'mocha' 5import 'mocha'
6import { 6import {
7 cleanupTests,
7 createUser, 8 createUser,
8 deleteVideoChannel, 9 deleteVideoChannel,
9 flushTests, 10 flushAndRunServer,
10 getAccountVideoChannelsList, 11 getAccountVideoChannelsList,
11 getMyUserInformation,
12 getVideoChannelsList,
13 immutableAssign, 12 immutableAssign,
14 killallServers,
15 makeGetRequest, 13 makeGetRequest,
16 makePostBodyRequest, 14 makePostBodyRequest,
17 makePutBodyRequest, 15 makePutBodyRequest,
18 makeUploadRequest, 16 makeUploadRequest,
19 flushAndRunServer,
20 ServerInfo, 17 ServerInfo,
21 setAccessTokensToServers, 18 setAccessTokensToServers,
22 userLogin 19 userLogin
@@ -26,7 +23,6 @@ import {
26 checkBadSortPagination, 23 checkBadSortPagination,
27 checkBadStartPagination 24 checkBadStartPagination
28} from '../../../../shared/extra-utils/requests/check-api-params' 25} from '../../../../shared/extra-utils/requests/check-api-params'
29import { User } from '../../../../shared/models/users'
30import { join } from 'path' 26import { join } from 'path'
31 27
32const expect = chai.expect 28const expect = chai.expect
@@ -310,7 +306,7 @@ describe('Test video channels API validator', function () {
310 }) 306 })
311 }) 307 })
312 308
313 after(function () { 309 after(async function () {
314 killallServers([ server ]) 310 await cleanupTests([ server ])
315 }) 311 })
316}) 312})
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index dfa4c29b6..5cf90bacc 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -3,9 +3,9 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 cleanupTests,
6 createUser, 7 createUser,
7 flushAndRunServer, 8 flushAndRunServer,
8 killallServers,
9 makeDeleteRequest, 9 makeDeleteRequest,
10 makeGetRequest, 10 makeGetRequest,
11 makePostBodyRequest, 11 makePostBodyRequest,
@@ -258,7 +258,7 @@ describe('Test video comments API validator', function () {
258 it('Should return conflict on comment thread add') 258 it('Should return conflict on comment thread add')
259 }) 259 })
260 260
261 after(function () { 261 after(async function () {
262 killallServers([ server ]) 262 await cleanupTests([ server ])
263 }) 263 })
264}) 264})
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index 82fdc0667..8ff115e7b 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -5,15 +5,14 @@ import 'mocha'
5import { join } from 'path' 5import { join } from 'path'
6import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' 6import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
7import { 7import {
8 cleanupTests,
8 createUser, 9 createUser,
9 flushTests, 10 flushAndRunServer,
10 getMyUserInformation, 11 getMyUserInformation,
11 immutableAssign, 12 immutableAssign,
12 killallServers,
13 makeGetRequest, 13 makeGetRequest,
14 makePostBodyRequest, 14 makePostBodyRequest,
15 makeUploadRequest, 15 makeUploadRequest,
16 flushAndRunServer,
17 ServerInfo, 16 ServerInfo,
18 setAccessTokensToServers, 17 setAccessTokensToServers,
19 updateCustomSubConfig, 18 updateCustomSubConfig,
@@ -311,7 +310,7 @@ describe('Test video imports API validator', function () {
311 }) 310 })
312 }) 311 })
313 312
314 after(function () { 313 after(async function () {
315 killallServers([ server ]) 314 await cleanupTests([ server ])
316 }) 315 })
317}) 316})
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
index 0edb51682..b7b94c035 100644
--- a/server/tests/api/check-params/video-playlists.ts
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -3,20 +3,20 @@
3import 'mocha' 3import 'mocha'
4import { 4import {
5 addVideoInPlaylist, 5 addVideoInPlaylist,
6 cleanupTests,
6 createVideoPlaylist, 7 createVideoPlaylist,
7 deleteVideoPlaylist, 8 deleteVideoPlaylist,
8 flushTests, 9 flushAndRunServer,
9 generateUserAccessToken, 10 generateUserAccessToken,
10 getAccountPlaylistsListWithToken, 11 getAccountPlaylistsListWithToken,
11 getVideoPlaylist, 12 getVideoPlaylist,
12 immutableAssign, 13 immutableAssign,
13 killallServers,
14 makeGetRequest, 14 makeGetRequest,
15 removeVideoFromPlaylist, 15 removeVideoFromPlaylist,
16 reorderVideosPlaylist, 16 reorderVideosPlaylist,
17 flushAndRunServer,
18 ServerInfo, 17 ServerInfo,
19 setAccessTokensToServers, setDefaultVideoChannel, 18 setAccessTokensToServers,
19 setDefaultVideoChannel,
20 updateVideoPlaylist, 20 updateVideoPlaylist,
21 updateVideoPlaylistElement, 21 updateVideoPlaylistElement,
22 uploadVideoAndGetId 22 uploadVideoAndGetId
@@ -668,7 +668,7 @@ describe('Test video playlists API validator', function () {
668 }) 668 })
669 }) 669 })
670 670
671 after(function () { 671 after(async function () {
672 killallServers([ server ]) 672 await cleanupTests([ server ])
673 }) 673 })
674}) 674})
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts
index 82cc0f638..babef8223 100644
--- a/server/tests/api/check-params/videos-filter.ts
+++ b/server/tests/api/check-params/videos-filter.ts
@@ -2,14 +2,14 @@
2 2
3import 'mocha' 3import 'mocha'
4import { 4import {
5 cleanupTests,
5 createUser, 6 createUser,
6 createVideoPlaylist, 7 createVideoPlaylist,
7 flushTests,
8 killallServers,
9 makeGetRequest,
10 flushAndRunServer, 8 flushAndRunServer,
9 makeGetRequest,
11 ServerInfo, 10 ServerInfo,
12 setAccessTokensToServers, setDefaultVideoChannel, 11 setAccessTokensToServers,
12 setDefaultVideoChannel,
13 userLogin 13 userLogin
14} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
15import { UserRole } from '../../../../shared/models/users' 15import { UserRole } from '../../../../shared/models/users'
@@ -129,7 +129,7 @@ describe('Test videos filters', function () {
129 }) 129 })
130 }) 130 })
131 131
132 after(function () { 132 after(async function () {
133 killallServers([ server ]) 133 await cleanupTests([ server ])
134 }) 134 })
135}) 135})
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts
index 32f65f510..3739e3fad 100644
--- a/server/tests/api/check-params/videos-history.ts
+++ b/server/tests/api/check-params/videos-history.ts
@@ -5,12 +5,11 @@ import 'mocha'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadStartPagination, 7 checkBadStartPagination,
8 flushTests, 8 cleanupTests,
9 killallServers, 9 flushAndRunServer,
10 makeGetRequest, 10 makeGetRequest,
11 makePostBodyRequest, 11 makePostBodyRequest,
12 makePutBodyRequest, 12 makePutBodyRequest,
13 flushAndRunServer,
14 ServerInfo, 13 ServerInfo,
15 setAccessTokensToServers, 14 setAccessTokensToServers,
16 uploadVideo 15 uploadVideo
@@ -126,7 +125,7 @@ describe('Test videos history API validator', function () {
126 }) 125 })
127 }) 126 })
128 127
129 after(function () { 128 after(async function () {
130 killallServers([ server ]) 129 await cleanupTests([ server ])
131 }) 130 })
132}) 131})
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index bc321e91f..51e592a15 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -6,16 +6,28 @@ import 'mocha'
6import { join } from 'path' 6import { join } from 'path'
7import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' 7import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
8import { 8import {
9 createUser, flushTests, getMyUserInformation, getVideo, getVideosList, immutableAssign, killallServers, makeDeleteRequest, 9 cleanupTests,
10 makeGetRequest, makeUploadRequest, makePutBodyRequest, removeVideo, uploadVideo, 10 createUser,
11 flushAndRunServer, ServerInfo, setAccessTokensToServers, userLogin, updateCustomSubConfig 11 flushAndRunServer,
12 getMyUserInformation,
13 getVideo,
14 getVideosList,
15 immutableAssign,
16 makeDeleteRequest,
17 makeGetRequest,
18 makePutBodyRequest,
19 makeUploadRequest,
20 removeVideo,
21 ServerInfo,
22 setAccessTokensToServers,
23 userLogin,
24 root
12} from '../../../../shared/extra-utils' 25} from '../../../../shared/extra-utils'
13import { 26import {
14 checkBadCountPagination, 27 checkBadCountPagination,
15 checkBadSortPagination, 28 checkBadSortPagination,
16 checkBadStartPagination 29 checkBadStartPagination
17} from '../../../../shared/extra-utils/requests/check-api-params' 30} from '../../../../shared/extra-utils/requests/check-api-params'
18import { getAccountsList } from '../../../../shared/extra-utils/users/accounts'
19 31
20const expect = chai.expect 32const expect = chai.expect
21 33
@@ -166,7 +178,7 @@ describe('Test videos API validator', function () {
166 describe('When adding a video', function () { 178 describe('When adding a video', function () {
167 let baseCorrectParams 179 let baseCorrectParams
168 const baseCorrectAttaches = { 180 const baseCorrectAttaches = {
169 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.webm') 181 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.webm')
170 } 182 }
171 183
172 before(function () { 184 before(function () {
@@ -326,15 +338,15 @@ describe('Test videos API validator', function () {
326 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 338 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
327 }) 339 })
328 340
329 it('Should fail without an incorrect input file', async function () { 341 it('Should fail with an incorrect input file', async function () {
330 const fields = baseCorrectParams 342 const fields = baseCorrectParams
331 let attaches = { 343 let attaches = {
332 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm') 344 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm')
333 } 345 }
334 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 346 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
335 347
336 attaches = { 348 attaches = {
337 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mkv') 349 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv')
338 } 350 }
339 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 351 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
340 }) 352 })
@@ -342,8 +354,8 @@ describe('Test videos API validator', function () {
342 it('Should fail with an incorrect thumbnail file', async function () { 354 it('Should fail with an incorrect thumbnail file', async function () {
343 const fields = baseCorrectParams 355 const fields = baseCorrectParams
344 const attaches = { 356 const attaches = {
345 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'), 357 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png'),
346 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') 358 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
347 } 359 }
348 360
349 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 361 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
@@ -352,8 +364,8 @@ describe('Test videos API validator', function () {
352 it('Should fail with a big thumbnail file', async function () { 364 it('Should fail with a big thumbnail file', async function () {
353 const fields = baseCorrectParams 365 const fields = baseCorrectParams
354 const attaches = { 366 const attaches = {
355 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'), 367 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png'),
356 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') 368 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
357 } 369 }
358 370
359 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 371 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
@@ -362,8 +374,8 @@ describe('Test videos API validator', function () {
362 it('Should fail with an incorrect preview file', async function () { 374 it('Should fail with an incorrect preview file', async function () {
363 const fields = baseCorrectParams 375 const fields = baseCorrectParams
364 const attaches = { 376 const attaches = {
365 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'), 377 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png'),
366 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') 378 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
367 } 379 }
368 380
369 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 381 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
@@ -372,8 +384,8 @@ describe('Test videos API validator', function () {
372 it('Should fail with a big preview file', async function () { 384 it('Should fail with a big preview file', async function () {
373 const fields = baseCorrectParams 385 const fields = baseCorrectParams
374 const attaches = { 386 const attaches = {
375 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'), 387 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png'),
376 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') 388 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
377 } 389 }
378 390
379 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 391 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
@@ -398,7 +410,7 @@ describe('Test videos API validator', function () {
398 410
399 { 411 {
400 const attaches = immutableAssign(baseCorrectAttaches, { 412 const attaches = immutableAssign(baseCorrectAttaches, {
401 videofile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') 413 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
402 }) 414 })
403 415
404 await makeUploadRequest({ 416 await makeUploadRequest({
@@ -413,7 +425,7 @@ describe('Test videos API validator', function () {
413 425
414 { 426 {
415 const attaches = immutableAssign(baseCorrectAttaches, { 427 const attaches = immutableAssign(baseCorrectAttaches, {
416 videofile: join(__dirname, '..', '..', 'fixtures', 'video_short.ogv') 428 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv')
417 }) 429 })
418 430
419 await makeUploadRequest({ 431 await makeUploadRequest({
@@ -550,7 +562,7 @@ describe('Test videos API validator', function () {
550 it('Should fail with an incorrect thumbnail file', async function () { 562 it('Should fail with an incorrect thumbnail file', async function () {
551 const fields = baseCorrectParams 563 const fields = baseCorrectParams
552 const attaches = { 564 const attaches = {
553 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png') 565 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png')
554 } 566 }
555 567
556 await makeUploadRequest({ 568 await makeUploadRequest({
@@ -566,7 +578,7 @@ describe('Test videos API validator', function () {
566 it('Should fail with a big thumbnail file', async function () { 578 it('Should fail with a big thumbnail file', async function () {
567 const fields = baseCorrectParams 579 const fields = baseCorrectParams
568 const attaches = { 580 const attaches = {
569 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') 581 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png')
570 } 582 }
571 583
572 await makeUploadRequest({ 584 await makeUploadRequest({
@@ -582,7 +594,7 @@ describe('Test videos API validator', function () {
582 it('Should fail with an incorrect preview file', async function () { 594 it('Should fail with an incorrect preview file', async function () {
583 const fields = baseCorrectParams 595 const fields = baseCorrectParams
584 const attaches = { 596 const attaches = {
585 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png') 597 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png')
586 } 598 }
587 599
588 await makeUploadRequest({ 600 await makeUploadRequest({
@@ -598,7 +610,7 @@ describe('Test videos API validator', function () {
598 it('Should fail with a big preview file', async function () { 610 it('Should fail with a big preview file', async function () {
599 const fields = baseCorrectParams 611 const fields = baseCorrectParams
600 const attaches = { 612 const attaches = {
601 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') 613 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png')
602 } 614 }
603 615
604 await makeUploadRequest({ 616 await makeUploadRequest({
@@ -728,7 +740,7 @@ describe('Test videos API validator', function () {
728 }) 740 })
729 }) 741 })
730 742
731 after(function () { 743 after(async function () {
732 killallServers([ server ]) 744 await cleanupTests([ server ])
733 }) 745 })
734}) 746})
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index eb4fdb87c..3874b0aab 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -19,7 +19,7 @@ import {
19 userLogin, 19 userLogin,
20 wait, 20 wait,
21 getCustomConfig, 21 getCustomConfig,
22 updateCustomConfig, getVideoThreadComments, getVideoCommentThreads, follow 22 updateCustomConfig, getVideoThreadComments, getVideoCommentThreads, follow, cleanupTests
23} from '../../../../shared/extra-utils' 23} from '../../../../shared/extra-utils'
24import { killallServers, ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index' 24import { killallServers, ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
25import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' 25import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
@@ -1295,9 +1295,9 @@ describe('Test users notifications', function () {
1295 }) 1295 })
1296 }) 1296 })
1297 1297
1298 after(function () { 1298 after(async function () {
1299 MockSmtpServer.Instance.kill() 1299 MockSmtpServer.Instance.kill()
1300 1300
1301 killallServers(servers) 1301 await cleanupTests(servers)
1302 }) 1302 })
1303}) 1303})
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 280a4c64b..e31329c25 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -5,7 +5,7 @@ import 'mocha'
5import { VideoDetails } from '../../../../shared/models/videos' 5import { VideoDetails } from '../../../../shared/models/videos'
6import { 6import {
7 checkSegmentHash, 7 checkSegmentHash,
8 checkVideoFilesWereRemoved, 8 checkVideoFilesWereRemoved, cleanupTests,
9 doubleFollow, 9 doubleFollow,
10 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
11 getFollowingListPaginationAndSort, 11 getFollowingListPaginationAndSort,
@@ -52,7 +52,7 @@ function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: numbe
52 expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length) 52 expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length)
53} 53}
54 54
55async function runServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) { 55async function flushAndRunServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) {
56 const config = { 56 const config = {
57 transcoding: { 57 transcoding: {
58 hls: { 58 hls: {
@@ -264,10 +264,6 @@ async function disableRedundancyOnServer1 () {
264 expect(server2.following.hostRedundancyAllowed).to.be.false 264 expect(server2.following.hostRedundancyAllowed).to.be.false
265} 265}
266 266
267async function cleanServers () {
268 killallServers(servers)
269}
270
271describe('Test videos redundancy', function () { 267describe('Test videos redundancy', function () {
272 268
273 describe('With most-views strategy', function () { 269 describe('With most-views strategy', function () {
@@ -276,7 +272,7 @@ describe('Test videos redundancy', function () {
276 before(function () { 272 before(function () {
277 this.timeout(120000) 273 this.timeout(120000)
278 274
279 return runServers(strategy) 275 return flushAndRunServers(strategy)
280 }) 276 })
281 277
282 it('Should have 1 webseed on the first video', async function () { 278 it('Should have 1 webseed on the first video', async function () {
@@ -315,8 +311,8 @@ describe('Test videos redundancy', function () {
315 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos', join('playlists', 'hls') ]) 311 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos', join('playlists', 'hls') ])
316 }) 312 })
317 313
318 after(function () { 314 after(async function () {
319 return cleanServers() 315 return cleanupTests(servers)
320 }) 316 })
321 }) 317 })
322 318
@@ -326,7 +322,7 @@ describe('Test videos redundancy', function () {
326 before(function () { 322 before(function () {
327 this.timeout(120000) 323 this.timeout(120000)
328 324
329 return runServers(strategy) 325 return flushAndRunServers(strategy)
330 }) 326 })
331 327
332 it('Should have 1 webseed on the first video', async function () { 328 it('Should have 1 webseed on the first video', async function () {
@@ -365,8 +361,8 @@ describe('Test videos redundancy', function () {
365 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos' ]) 361 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos' ])
366 }) 362 })
367 363
368 after(function () { 364 after(async function () {
369 return cleanServers() 365 await cleanupTests(servers)
370 }) 366 })
371 }) 367 })
372 368
@@ -376,7 +372,7 @@ describe('Test videos redundancy', function () {
376 before(function () { 372 before(function () {
377 this.timeout(120000) 373 this.timeout(120000)
378 374
379 return runServers(strategy, { min_views: 3 }) 375 return flushAndRunServers(strategy, { min_views: 3 })
380 }) 376 })
381 377
382 it('Should have 1 webseed on the first video', async function () { 378 it('Should have 1 webseed on the first video', async function () {
@@ -435,8 +431,8 @@ describe('Test videos redundancy', function () {
435 } 431 }
436 }) 432 })
437 433
438 after(function () { 434 after(async function () {
439 return cleanServers() 435 await cleanupTests(servers)
440 }) 436 })
441 }) 437 })
442 438
@@ -468,7 +464,7 @@ describe('Test videos redundancy', function () {
468 before(async function () { 464 before(async function () {
469 this.timeout(120000) 465 this.timeout(120000)
470 466
471 await runServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) 467 await flushAndRunServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
472 468
473 await enableRedundancyOnServer1() 469 await enableRedundancyOnServer1()
474 }) 470 })
@@ -498,8 +494,8 @@ describe('Test videos redundancy', function () {
498 await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A9001') 494 await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A9001')
499 }) 495 })
500 496
501 after(function () { 497 after(async function () {
502 return killallServers([ servers[1], servers[2] ]) 498 await cleanupTests(servers)
503 }) 499 })
504 }) 500 })
505 501
@@ -510,7 +506,7 @@ describe('Test videos redundancy', function () {
510 before(async function () { 506 before(async function () {
511 this.timeout(120000) 507 this.timeout(120000)
512 508
513 await runServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) 509 await flushAndRunServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
514 510
515 await enableRedundancyOnServer1() 511 await enableRedundancyOnServer1()
516 512
@@ -569,8 +565,8 @@ describe('Test videos redundancy', function () {
569 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ join('redundancy', 'hls') ]) 565 await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ join('redundancy', 'hls') ])
570 }) 566 })
571 567
572 after(function () { 568 after(async function () {
573 return cleanServers() 569 await cleanupTests(servers)
574 }) 570 })
575 }) 571 })
576}) 572})
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts
index c5662f049..4d1ceb767 100644
--- a/server/tests/api/search/search-activitypub-video-channels.ts
+++ b/server/tests/api/search/search-activitypub-video-channels.ts
@@ -3,7 +3,7 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 addVideoChannel, 6 addVideoChannel, cleanupTests,
7 createUser, 7 createUser,
8 deleteVideoChannel, 8 deleteVideoChannel,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
@@ -205,7 +205,7 @@ describe('Test a ActivityPub video channels search', function () {
205 expect(res.body.data).to.have.lengthOf(0) 205 expect(res.body.data).to.have.lengthOf(0)
206 }) 206 })
207 207
208 after(function () { 208 after(async function () {
209 killallServers(servers) 209 await cleanupTests(servers)
210 }) 210 })
211}) 211})
diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts
index 5c2a44ad5..e039961cb 100644
--- a/server/tests/api/search/search-activitypub-videos.ts
+++ b/server/tests/api/search/search-activitypub-videos.ts
@@ -15,7 +15,7 @@ import {
15 updateVideo, 15 updateVideo,
16 uploadVideo, 16 uploadVideo,
17 wait, 17 wait,
18 searchVideo 18 searchVideo, cleanupTests
19} from '../../../../shared/extra-utils' 19} from '../../../../shared/extra-utils'
20import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 20import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
21import { Video, VideoPrivacy } from '../../../../shared/models/videos' 21import { Video, VideoPrivacy } from '../../../../shared/models/videos'
@@ -149,7 +149,7 @@ describe('Test a ActivityPub videos search', function () {
149 expect(res.body.data).to.have.lengthOf(0) 149 expect(res.body.data).to.have.lengthOf(0)
150 }) 150 })
151 151
152 after(function () { 152 after(async function () {
153 killallServers(servers) 153 await cleanupTests(servers)
154 }) 154 })
155}) 155})
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts
index d1520a9aa..1a086b33a 100644
--- a/server/tests/api/search/search-videos.ts
+++ b/server/tests/api/search/search-videos.ts
@@ -12,7 +12,8 @@ import {
12 setAccessTokensToServers, 12 setAccessTokensToServers,
13 uploadVideo, 13 uploadVideo,
14 wait, 14 wait,
15 immutableAssign 15 immutableAssign,
16 cleanupTests
16} from '../../../../shared/extra-utils' 17} from '../../../../shared/extra-utils'
17 18
18const expect = chai.expect 19const expect = chai.expect
@@ -405,7 +406,7 @@ describe('Test a videos search', function () {
405 } 406 }
406 }) 407 })
407 408
408 after(function () { 409 after(async function () {
409 killallServers([ server ]) 410 await cleanupTests([ server ])
410 }) 411 })
411}) 412})
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index d8137b339..c0d11914b 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -5,15 +5,15 @@ import * as chai from 'chai'
5import { About } from '../../../../shared/models/server/about.model' 5import { About } from '../../../../shared/models/server/about.model'
6import { CustomConfig } from '../../../../shared/models/server/custom-config.model' 6import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
7import { 7import {
8 cleanupTests,
8 deleteCustomConfig, 9 deleteCustomConfig,
10 flushAndRunServer,
9 getAbout, 11 getAbout,
10 killallServers,
11 reRunServer,
12 flushTests,
13 getConfig, 12 getConfig,
14 getCustomConfig, 13 getCustomConfig,
14 killallServers,
15 registerUser, 15 registerUser,
16 flushAndRunServer, 16 reRunServer,
17 setAccessTokensToServers, 17 setAccessTokensToServers,
18 updateCustomConfig 18 updateCustomConfig
19} from '../../../../shared/extra-utils' 19} from '../../../../shared/extra-utils'
@@ -300,7 +300,7 @@ describe('Test config', function () {
300 checkInitialConfig(data) 300 checkInitialConfig(data)
301 }) 301 })
302 302
303 after(function () { 303 after(async function () {
304 killallServers([ server ]) 304 await cleanupTests([ server ])
305 }) 305 })
306}) 306})
diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts
index 26ebb4ed7..ba51198b3 100644
--- a/server/tests/api/server/contact-form.ts
+++ b/server/tests/api/server/contact-form.ts
@@ -2,7 +2,15 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { flushTests, killallServers, flushAndRunServer, ServerInfo, setAccessTokensToServers, wait } from '../../../../shared/extra-utils' 5import {
6 flushTests,
7 killallServers,
8 flushAndRunServer,
9 ServerInfo,
10 setAccessTokensToServers,
11 wait,
12 cleanupTests
13} from '../../../../shared/extra-utils'
6import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' 14import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
7import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 15import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
8import { sendContactForm } from '../../../../shared/extra-utils/server/contact-form' 16import { sendContactForm } from '../../../../shared/extra-utils/server/contact-form'
@@ -78,8 +86,9 @@ describe('Test contact form', function () {
78 }) 86 })
79 }) 87 })
80 88
81 after(function () { 89 after(async function () {
82 MockSmtpServer.Instance.kill() 90 MockSmtpServer.Instance.kill()
83 killallServers([ server ]) 91
92 await cleanupTests([ server ])
84 }) 93 })
85}) 94})
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index 1158ceb0e..bacdf1b1b 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -18,7 +18,7 @@ import {
18 flushTests, 18 flushTests,
19 killallServers, 19 killallServers,
20 ServerInfo, 20 ServerInfo,
21 setAccessTokensToServers 21 setAccessTokensToServers, cleanupTests
22} from '../../../../shared/extra-utils' 22} from '../../../../shared/extra-utils'
23import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' 23import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
24import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 24import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
@@ -256,8 +256,9 @@ describe('Test emails', function () {
256 }) 256 })
257 }) 257 })
258 258
259 after(function () { 259 after(async function () {
260 MockSmtpServer.Instance.kill() 260 MockSmtpServer.Instance.kill()
261 killallServers([ server ]) 261
262 await cleanupTests([ server ])
262 }) 263 })
263}) 264})
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts
index cf40018b3..4285a9e7a 100644
--- a/server/tests/api/server/follow-constraints.ts
+++ b/server/tests/api/server/follow-constraints.ts
@@ -12,7 +12,7 @@ import {
12 killallServers, 12 killallServers,
13 ServerInfo, 13 ServerInfo,
14 setAccessTokensToServers, 14 setAccessTokensToServers,
15 uploadVideo 15 uploadVideo, cleanupTests
16} from '../../../../shared/extra-utils' 16} from '../../../../shared/extra-utils'
17import { unfollow } from '../../../../shared/extra-utils/server/follows' 17import { unfollow } from '../../../../shared/extra-utils/server/follows'
18import { userLogin } from '../../../../shared/extra-utils/users/login' 18import { userLogin } from '../../../../shared/extra-utils/users/login'
@@ -219,7 +219,7 @@ describe('Test follow constraints', function () {
219 }) 219 })
220 }) 220 })
221 221
222 after(function () { 222 after(async function () {
223 killallServers(servers) 223 await cleanupTests(servers)
224 }) 224 })
225}) 225})
diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.ts
index ae8716184..2a3a4d5c8 100644
--- a/server/tests/api/server/follows-moderation.ts
+++ b/server/tests/api/server/follows-moderation.ts
@@ -3,7 +3,7 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 acceptFollower, 6 acceptFollower, cleanupTests,
7 flushAndRunMultipleServers, 7 flushAndRunMultipleServers,
8 killallServers, 8 killallServers,
9 ServerInfo, 9 ServerInfo,
@@ -189,7 +189,7 @@ describe('Test follows moderation', function () {
189 } 189 }
190 }) 190 })
191 191
192 after(function () { 192 after(async function () {
193 killallServers(servers) 193 await cleanupTests(servers)
194 }) 194 })
195}) 195})
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index f1b4a450e..397093cdb 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -4,7 +4,7 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { Video, VideoPrivacy } from '../../../../shared/models/videos' 5import { Video, VideoPrivacy } from '../../../../shared/models/videos'
6import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' 6import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
7import { completeVideoCheck } from '../../../../shared/extra-utils' 7import { cleanupTests, completeVideoCheck } from '../../../../shared/extra-utils'
8import { 8import {
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 getVideosList, 10 getVideosList,
@@ -435,7 +435,7 @@ describe('Test follows', function () {
435 435
436 }) 436 })
437 437
438 after(function () { 438 after(async function () {
439 killallServers(servers) 439 await cleanupTests(servers)
440 }) 440 })
441}) 441})
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index d0f700bda..19010dbc1 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -7,6 +7,7 @@ import { VideoPrivacy } from '../../../../shared/models/videos'
7import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' 7import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
8 8
9import { 9import {
10 cleanupTests,
10 completeVideoCheck, 11 completeVideoCheck,
11 flushAndRunMultipleServers, 12 flushAndRunMultipleServers,
12 getVideo, 13 getVideo,
@@ -296,7 +297,7 @@ describe('Test handle downs', function () {
296 } 297 }
297 }) 298 })
298 299
299 after(function () { 300 after(async function () {
300 killallServers(servers) 301 await cleanupTests(servers)
301 }) 302 })
302}) 303})
diff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.ts
index 01f561b0d..634654626 100644
--- a/server/tests/api/server/jobs.ts
+++ b/server/tests/api/server/jobs.ts
@@ -2,7 +2,7 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { killallServers, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index' 5import { cleanupTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
6import { doubleFollow } from '../../../../shared/extra-utils/server/follows' 6import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
7import { getJobsList, getJobsListPaginationAndSort, waitJobs } from '../../../../shared/extra-utils/server/jobs' 7import { getJobsList, getJobsListPaginationAndSort, waitJobs } from '../../../../shared/extra-utils/server/jobs'
8import { flushAndRunMultipleServers } from '../../../../shared/extra-utils/server/servers' 8import { flushAndRunMultipleServers } from '../../../../shared/extra-utils/server/servers'
@@ -56,7 +56,7 @@ describe('Test jobs', function () {
56 expect(dateIsValid(job.finishedOn)).to.be.true 56 expect(dateIsValid(job.finishedOn)).to.be.true
57 }) 57 })
58 58
59 after(function () { 59 after(async function () {
60 killallServers(servers) 60 await cleanupTests(servers)
61 }) 61 })
62}) 62})
diff --git a/server/tests/api/server/logs.ts b/server/tests/api/server/logs.ts
index 5ca352205..3644fa0d3 100644
--- a/server/tests/api/server/logs.ts
+++ b/server/tests/api/server/logs.ts
@@ -2,7 +2,14 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { flushTests, killallServers, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index' 5import {
6 flushTests,
7 killallServers,
8 flushAndRunServer,
9 ServerInfo,
10 setAccessTokensToServers,
11 cleanupTests
12} from '../../../../shared/extra-utils/index'
6import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 13import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
7import { uploadVideo } from '../../../../shared/extra-utils/videos/videos' 14import { uploadVideo } from '../../../../shared/extra-utils/videos/videos'
8import { getLogs } from '../../../../shared/extra-utils/logs/logs' 15import { getLogs } from '../../../../shared/extra-utils/logs/logs'
@@ -84,7 +91,7 @@ describe('Test logs', function () {
84 } 91 }
85 }) 92 })
86 93
87 after(function () { 94 after(async function () {
88 killallServers([ server ]) 95 await cleanupTests([ server ])
89 }) 96 })
90}) 97})
diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.ts
index 226fbfda4..86edeb289 100644
--- a/server/tests/api/server/no-client.ts
+++ b/server/tests/api/server/no-client.ts
@@ -1,11 +1,7 @@
1import 'mocha' 1import 'mocha'
2import * as request from 'supertest' 2import * as request from 'supertest'
3import { 3import { ServerInfo } from '../../../../shared/extra-utils'
4 flushTests, 4import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
5 killallServers,
6 ServerInfo
7} from '../../../../shared/extra-utils'
8import { flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
9 5
10describe('Start and stop server without web client routes', function () { 6describe('Start and stop server without web client routes', function () {
11 let server: ServerInfo 7 let server: ServerInfo
@@ -23,7 +19,7 @@ describe('Start and stop server without web client routes', function () {
23 return req.expect(404) 19 return req.expect(404)
24 }) 20 })
25 21
26 after(function () { 22 after(async function () {
27 killallServers([ server ]) 23 await cleanupTests([ server ])
28 }) 24 })
29}) 25})
diff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.ts
index e55b12bfc..987538237 100644
--- a/server/tests/api/server/reverse-proxy.ts
+++ b/server/tests/api/server/reverse-proxy.ts
@@ -2,28 +2,10 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { About } from '../../../../shared/models/server/about.model' 5import { cleanupTests, getVideo, uploadVideo, userLogin, viewVideo, wait } from '../../../../shared/extra-utils'
6import { CustomConfig } from '../../../../shared/models/server/custom-config.model' 6import { flushAndRunServer, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
7import {
8 deleteCustomConfig,
9 getAbout,
10 getVideo,
11 killallServers,
12 login,
13 reRunServer,
14 uploadVideo,
15 userLogin,
16 viewVideo,
17 wait
18} from '../../../../shared/extra-utils'
19const expect = chai.expect
20 7
21import { 8const expect = chai.expect
22 getConfig,
23 flushTests,
24 flushAndRunServer,
25 registerUser, getCustomConfig, setAccessTokensToServers, updateCustomConfig
26} from '../../../../shared/extra-utils/index'
27 9
28describe('Test application behind a reverse proxy', function () { 10describe('Test application behind a reverse proxy', function () {
29 let server = null 11 let server = null
@@ -100,7 +82,7 @@ describe('Test application behind a reverse proxy', function () {
100 await userLogin(server, user, 429) 82 await userLogin(server, user, 429)
101 }) 83 })
102 84
103 after(function () { 85 after(async function () {
104 killallServers([ server ]) 86 await cleanupTests([ server ])
105 }) 87 })
106}) 88})
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts
index bd3d2155c..a01cd4b38 100644
--- a/server/tests/api/server/stats.ts
+++ b/server/tests/api/server/stats.ts
@@ -4,6 +4,7 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { ServerStats } from '../../../../shared/models/server/server-stats.model' 5import { ServerStats } from '../../../../shared/models/server/server-stats.model'
6import { 6import {
7 cleanupTests,
7 createUser, 8 createUser,
8 doubleFollow, 9 doubleFollow,
9 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
@@ -95,7 +96,7 @@ describe('Test stats (excluding redundancy)', function () {
95 expect(data.totalInstanceFollowers).to.equal(0) 96 expect(data.totalInstanceFollowers).to.equal(0)
96 }) 97 })
97 98
98 after(function () { 99 after(async function () {
99 killallServers(servers) 100 await cleanupTests(servers)
100 }) 101 })
101}) 102})
diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.ts
index 1b4e190f1..9d7eec8ca 100644
--- a/server/tests/api/server/tracker.ts
+++ b/server/tests/api/server/tracker.ts
@@ -2,8 +2,16 @@
2 2
3import * as magnetUtil from 'magnet-uri' 3import * as magnetUtil from 'magnet-uri'
4import 'mocha' 4import 'mocha'
5import { getVideo, killallServers, reRunServer, flushAndRunServer, ServerInfo, uploadVideo } from '../../../../shared/extra-utils' 5import {
6import { flushTests, setAccessTokensToServers } from '../../../../shared/extra-utils/index' 6 cleanupTests,
7 flushAndRunServer,
8 getVideo,
9 killallServers,
10 reRunServer,
11 ServerInfo,
12 uploadVideo
13} from '../../../../shared/extra-utils'
14import { setAccessTokensToServers } from '../../../../shared/extra-utils/index'
7import { VideoDetails } from '../../../../shared/models/videos' 15import { VideoDetails } from '../../../../shared/models/videos'
8import * as WebTorrent from 'webtorrent' 16import * as WebTorrent from 'webtorrent'
9 17
@@ -82,7 +90,7 @@ describe('Test tracker', function () {
82 }) 90 })
83 }) 91 })
84 92
85 after(function () { 93 after(async function () {
86 killallServers([ server ]) 94 await cleanupTests([ server ])
87 }) 95 })
88}) 96})
diff --git a/server/tests/api/users/blocklist.ts b/server/tests/api/users/blocklist.ts
index 34eabf2e6..fbc57e0ef 100644
--- a/server/tests/api/users/blocklist.ts
+++ b/server/tests/api/users/blocklist.ts
@@ -4,6 +4,7 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { AccountBlock, ServerBlock, Video } from '../../../../shared/index' 5import { AccountBlock, ServerBlock, Video } from '../../../../shared/index'
6import { 6import {
7 cleanupTests,
7 createUser, 8 createUser,
8 doubleFollow, 9 doubleFollow,
9 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
@@ -498,7 +499,7 @@ describe('Test blocklist', function () {
498 }) 499 })
499 }) 500 })
500 501
501 after(function () { 502 after(async function () {
502 killallServers(servers) 503 await cleanupTests(servers)
503 }) 504 })
504}) 505})
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts
index ee5abd6b7..48811e647 100644
--- a/server/tests/api/users/user-subscriptions.ts
+++ b/server/tests/api/users/user-subscriptions.ts
@@ -3,6 +3,7 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 cleanupTests,
6 createUser, 7 createUser,
7 doubleFollow, 8 doubleFollow,
8 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
@@ -368,7 +369,7 @@ describe('Test users subscriptions', function () {
368 } 369 }
369 }) 370 })
370 371
371 after(function () { 372 after(async function () {
372 killallServers(servers) 373 await cleanupTests(servers)
373 }) 374 })
374}) 375})
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index 7097d90d1..9a971adb3 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -5,7 +5,7 @@ import 'mocha'
5import { Account } from '../../../../shared/models/actors' 5import { Account } from '../../../../shared/models/actors'
6import { 6import {
7 checkTmpIsEmpty, 7 checkTmpIsEmpty,
8 checkVideoFilesWereRemoved, 8 checkVideoFilesWereRemoved, cleanupTests,
9 createUser, 9 createUser,
10 doubleFollow, 10 doubleFollow,
11 flushAndRunMultipleServers, 11 flushAndRunMultipleServers,
@@ -235,7 +235,7 @@ describe('Test users with multiple servers', function () {
235 } 235 }
236 }) 236 })
237 237
238 after(function () { 238 after(async function () {
239 killallServers(servers) 239 await cleanupTests(servers)
240 }) 240 })
241}) 241})
diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts
index 295caae97..514acf2e7 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'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 registerUser, flushTests, getUserInformation, getMyUserInformation, killallServers, 6 registerUser, flushTests, getUserInformation, getMyUserInformation, killallServers,
7 userLogin, login, flushAndRunServer, ServerInfo, verifyEmail, updateCustomSubConfig, wait 7 userLogin, login, flushAndRunServer, ServerInfo, verifyEmail, updateCustomSubConfig, wait, cleanupTests
8} from '../../../../shared/extra-utils' 8} from '../../../../shared/extra-utils'
9import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' 9import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
10import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' 10import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
@@ -120,8 +120,9 @@ describe('Test users account verification', function () {
120 await userLogin(server, user2) 120 await userLogin(server, user2)
121 }) 121 })
122 122
123 after(function () { 123 after(async function () {
124 MockSmtpServer.Instance.kill() 124 MockSmtpServer.Instance.kill()
125 killallServers([ server ]) 125
126 await cleanupTests([ server ])
126 }) 127 })
127}) 128})
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 8efff12ad..e7291740b 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -5,9 +5,10 @@ import 'mocha'
5import { User, UserRole } from '../../../../shared/index' 5import { User, UserRole } from '../../../../shared/index'
6import { 6import {
7 blockUser, 7 blockUser,
8 cleanupTests,
8 createUser, 9 createUser,
9 deleteMe, 10 deleteMe,
10 flushTests, 11 flushAndRunServer,
11 getAccountRatings, 12 getAccountRatings,
12 getBlacklistedVideosList, 13 getBlacklistedVideosList,
13 getMyUserInformation, 14 getMyUserInformation,
@@ -17,14 +18,12 @@ import {
17 getUsersList, 18 getUsersList,
18 getUsersListPaginationAndSort, 19 getUsersListPaginationAndSort,
19 getVideosList, 20 getVideosList,
20 killallServers,
21 login, 21 login,
22 makePutBodyRequest, 22 makePutBodyRequest,
23 rateVideo, 23 rateVideo,
24 registerUser, 24 registerUser,
25 removeUser, 25 removeUser,
26 removeVideo, 26 removeVideo,
27 flushAndRunServer,
28 ServerInfo, 27 ServerInfo,
29 testImage, 28 testImage,
30 unblockUser, 29 unblockUser,
@@ -677,7 +676,7 @@ describe('Test users', function () {
677 }) 676 })
678 }) 677 })
679 678
680 after(function () { 679 after(async function () {
681 killallServers([ server ]) 680 await cleanupTests([ server ])
682 }) 681 })
683}) 682})
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 50b231555..68c1e9a8d 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -9,7 +9,7 @@ import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/
9import { 9import {
10 addVideoChannel, 10 addVideoChannel,
11 checkTmpIsEmpty, 11 checkTmpIsEmpty,
12 checkVideoFilesWereRemoved, 12 checkVideoFilesWereRemoved, cleanupTests,
13 completeVideoCheck, 13 completeVideoCheck,
14 createUser, 14 createUser,
15 dateIsValid, 15 dateIsValid,
@@ -1029,7 +1029,7 @@ describe('Test multiple servers', function () {
1029 }) 1029 })
1030 }) 1030 })
1031 1031
1032 after(function () { 1032 after(async function () {
1033 killallServers(servers) 1033 await cleanupTests(servers)
1034 }) 1034 })
1035}) 1035})
diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts
index 1397347d1..e9ad947b2 100644
--- a/server/tests/api/videos/services.ts
+++ b/server/tests/api/videos/services.ts
@@ -2,16 +2,8 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import { getOEmbed, getVideosList, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils/index'
6 flushTests, 6import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
7 getOEmbed,
8 getVideosList,
9 killallServers,
10 ServerInfo,
11 setAccessTokensToServers,
12 uploadVideo
13} from '../../../../shared/extra-utils/index'
14import { flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
15 7
16const expect = chai.expect 8const expect = chai.expect
17 9
@@ -74,7 +66,7 @@ describe('Test services', function () {
74 expect(res.body).to.not.have.property('thumbnail_height') 66 expect(res.body).to.not.have.property('thumbnail_height')
75 }) 67 })
76 68
77 after(function () { 69 after(async function () {
78 killallServers([ server ]) 70 await cleanupTests([ server ])
79 }) 71 })
80}) 72})
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index db2a3779f..1f366b642 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -6,8 +6,9 @@ import 'mocha'
6import { VideoPrivacy } from '../../../../shared/models/videos' 6import { VideoPrivacy } from '../../../../shared/models/videos'
7import { 7import {
8 checkVideoFilesWereRemoved, 8 checkVideoFilesWereRemoved,
9 cleanupTests,
9 completeVideoCheck, 10 completeVideoCheck,
10 flushTests, 11 flushAndRunServer,
11 getVideo, 12 getVideo,
12 getVideoCategories, 13 getVideoCategories,
13 getVideoLanguages, 14 getVideoLanguages,
@@ -17,10 +18,8 @@ import {
17 getVideosListPagination, 18 getVideosListPagination,
18 getVideosListSort, 19 getVideosListSort,
19 getVideosWithFilters, 20 getVideosWithFilters,
20 killallServers,
21 rateVideo, 21 rateVideo,
22 removeVideo, 22 removeVideo,
23 flushAndRunServer,
24 ServerInfo, 23 ServerInfo,
25 setAccessTokensToServers, 24 setAccessTokensToServers,
26 testImage, 25 testImage,
@@ -424,7 +423,7 @@ describe('Test a single server', function () {
424 expect(video.dislikes).to.equal(1) 423 expect(video.dislikes).to.equal(1)
425 }) 424 })
426 425
427 after(function () { 426 after(async function () {
428 killallServers([ server ]) 427 await cleanupTests([ server ])
429 }) 428 })
430}) 429})
diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts
index 06bb31348..7318497d5 100644
--- a/server/tests/api/videos/video-abuse.ts
+++ b/server/tests/api/videos/video-abuse.ts
@@ -4,6 +4,7 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { VideoAbuse, VideoAbuseState } from '../../../../shared/models/videos' 5import { VideoAbuse, VideoAbuseState } from '../../../../shared/models/videos'
6import { 6import {
7 cleanupTests,
7 deleteVideoAbuse, 8 deleteVideoAbuse,
8 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
9 getVideoAbusesList, 10 getVideoAbusesList,
@@ -172,7 +173,7 @@ describe('Test video abuses', function () {
172 expect(res.body.data.length).to.equal(0) 173 expect(res.body.data.length).to.equal(0)
173 }) 174 })
174 175
175 after(function () { 176 after(async function () {
176 killallServers(servers) 177 await cleanupTests(servers)
177 }) 178 })
178}) 179})
diff --git a/server/tests/api/videos/video-blacklist.ts b/server/tests/api/videos/video-blacklist.ts
index cb15d1a52..e907bbdc0 100644
--- a/server/tests/api/videos/video-blacklist.ts
+++ b/server/tests/api/videos/video-blacklist.ts
@@ -4,7 +4,7 @@ import * as chai from 'chai'
4import { orderBy } from 'lodash' 4import { orderBy } from 'lodash'
5import 'mocha' 5import 'mocha'
6import { 6import {
7 addVideoToBlacklist, 7 addVideoToBlacklist, cleanupTests,
8 createUser, 8 createUser,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 getBlacklistedVideosList, 10 getBlacklistedVideosList,
@@ -425,7 +425,7 @@ describe('Test video blacklist', function () {
425 }) 425 })
426 }) 426 })
427 427
428 after(function () { 428 after(async function () {
429 killallServers(servers) 429 await cleanupTests(servers)
430 }) 430 })
431}) 431})
diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts
index c6f59762a..5e13f5949 100644
--- a/server/tests/api/videos/video-captions.ts
+++ b/server/tests/api/videos/video-captions.ts
@@ -3,7 +3,7 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 checkVideoFilesWereRemoved, 6 checkVideoFilesWereRemoved, cleanupTests,
7 doubleFollow, 7 doubleFollow,
8 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
9 removeVideo, 9 removeVideo,
@@ -195,7 +195,7 @@ describe('Test video captions', function () {
195 await checkVideoFilesWereRemoved(videoUUID, 1) 195 await checkVideoFilesWereRemoved(videoUUID, 1)
196 }) 196 })
197 197
198 after(function () { 198 after(async function () {
199 killallServers(servers) 199 await cleanupTests(servers)
200 }) 200 })
201}) 201})
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index db1220677..1c0327d40 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -4,7 +4,7 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 acceptChangeOwnership, 6 acceptChangeOwnership,
7 changeVideoOwnership, 7 changeVideoOwnership, cleanupTests,
8 createUser, 8 createUser,
9 doubleFollow, 9 doubleFollow,
10 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
@@ -297,7 +297,7 @@ describe('Test video change ownership - quota too small', function () {
297 await acceptChangeOwnership(server.url, secondUserAccessToken, lastRequestChangeOwnershipId, channelId, 403) 297 await acceptChangeOwnership(server.url, secondUserAccessToken, lastRequestChangeOwnershipId, channelId, 403)
298 }) 298 })
299 299
300 after(function () { 300 after(async function () {
301 killallServers([server]) 301 await cleanupTests([ server ])
302 }) 302 })
303}) 303})
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 60b84e443..345e96f43 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -4,6 +4,7 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { User, Video } from '../../../../shared/index' 5import { User, Video } from '../../../../shared/index'
6import { 6import {
7 cleanupTests,
7 createUser, 8 createUser,
8 doubleFollow, 9 doubleFollow,
9 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
@@ -277,7 +278,7 @@ describe('Test video channels', function () {
277 } 278 }
278 }) 279 })
279 280
280 after(function () { 281 after(async function () {
281 killallServers(servers) 282 await cleanupTests(servers)
282 }) 283 })
283}) 284})
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts
index 50224ee47..22fd8c058 100644
--- a/server/tests/api/videos/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -3,11 +3,9 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' 5import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
6import { testImage } from '../../../../shared/extra-utils' 6import { cleanupTests, testImage } from '../../../../shared/extra-utils'
7import { 7import {
8 dateIsValid, 8 dateIsValid,
9 flushTests,
10 killallServers,
11 flushAndRunServer, 9 flushAndRunServer,
12 ServerInfo, 10 ServerInfo,
13 setAccessTokensToServers, 11 setAccessTokensToServers,
@@ -199,7 +197,7 @@ describe('Test video comments', function () {
199 expect(res.body.data[1].totalReplies).to.equal(0) 197 expect(res.body.data[1].totalReplies).to.equal(0)
200 }) 198 })
201 199
202 after(function () { 200 after(async function () {
203 killallServers([ server ]) 201 await cleanupTests([ server ])
204 }) 202 })
205}) 203})
diff --git a/server/tests/api/videos/video-description.ts b/server/tests/api/videos/video-description.ts
index 333d539f4..db4d278bf 100644
--- a/server/tests/api/videos/video-description.ts
+++ b/server/tests/api/videos/video-description.ts
@@ -3,6 +3,7 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 cleanupTests,
6 flushAndRunMultipleServers, 7 flushAndRunMultipleServers,
7 getVideo, 8 getVideo,
8 getVideoDescription, 9 getVideoDescription,
@@ -99,7 +100,7 @@ describe('Test video description', function () {
99 } 100 }
100 }) 101 })
101 102
102 after(function () { 103 after(async function () {
103 killallServers(servers) 104 await cleanupTests(servers)
104 }) 105 })
105}) 106})
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts
index 0ac84a656..22031c18b 100644
--- a/server/tests/api/videos/video-hls.ts
+++ b/server/tests/api/videos/video-hls.ts
@@ -5,7 +5,7 @@ import 'mocha'
5import { 5import {
6 checkDirectoryIsEmpty, 6 checkDirectoryIsEmpty,
7 checkSegmentHash, 7 checkSegmentHash,
8 checkTmpIsEmpty, 8 checkTmpIsEmpty, cleanupTests,
9 doubleFollow, 9 doubleFollow,
10 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
11 flushTests, 11 flushTests,
@@ -128,7 +128,7 @@ describe('Test HLS videos', function () {
128 } 128 }
129 }) 129 })
130 130
131 after(function () { 131 after(async function () {
132 killallServers(servers) 132 await cleanupTests(servers)
133 }) 133 })
134}) 134})
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index 49a28e207..1233ed6eb 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -4,6 +4,7 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { VideoDetails, VideoImport, VideoPrivacy } from '../../../../shared/models/videos' 5import { VideoDetails, VideoImport, VideoPrivacy } from '../../../../shared/models/videos'
6import { 6import {
7 cleanupTests,
7 doubleFollow, 8 doubleFollow,
8 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
9 getMyUserInformation, 10 getMyUserInformation,
@@ -241,7 +242,7 @@ describe('Test video imports', function () {
241 } 242 }
242 }) 243 })
243 244
244 after(function () { 245 after(async function () {
245 killallServers(servers) 246 await cleanupTests(servers)
246 }) 247 })
247}) 248})
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index 811705212..ad6a4b43f 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -2,25 +2,18 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import { cleanupTests, getVideosList, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils/index'
6 flushTests,
7 getVideosList,
8 killallServers,
9 ServerInfo,
10 setAccessTokensToServers,
11 uploadVideo
12} from '../../../../shared/extra-utils/index'
13import { userLogin } from '../../../../shared/extra-utils/users/login' 6import { userLogin } from '../../../../shared/extra-utils/users/login'
14import { createUser } from '../../../../shared/extra-utils/users/users' 7import { createUser } from '../../../../shared/extra-utils/users/users'
15import { getMyVideos } from '../../../../shared/extra-utils/videos/videos' 8import { getMyVideos } from '../../../../shared/extra-utils/videos/videos'
16import { 9import {
10 flushAndRunServer,
17 getAccountVideos, 11 getAccountVideos,
18 getConfig, 12 getConfig,
19 getCustomConfig, 13 getCustomConfig,
20 getMyUserInformation, 14 getMyUserInformation,
21 getVideoChannelVideos, 15 getVideoChannelVideos,
22 getVideosListWithToken, 16 getVideosListWithToken,
23 flushAndRunServer,
24 searchVideo, 17 searchVideo,
25 searchVideoWithToken, 18 searchVideoWithToken,
26 updateCustomConfig, 19 updateCustomConfig,
@@ -241,7 +234,7 @@ describe('Test video NSFW policy', function () {
241 }) 234 })
242 }) 235 })
243 236
244 after(function () { 237 after(async function () {
245 killallServers([ server ]) 238 await cleanupTests([ server ])
246 }) 239 })
247}) 240})
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index ea349f09b..928568299 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -5,7 +5,7 @@ import 'mocha'
5import { 5import {
6 addVideoChannel, 6 addVideoChannel,
7 addVideoInPlaylist, 7 addVideoInPlaylist,
8 checkPlaylistFilesWereRemoved, 8 checkPlaylistFilesWereRemoved, cleanupTests,
9 createUser, 9 createUser,
10 createVideoPlaylist, 10 createVideoPlaylist,
11 deleteVideoChannel, 11 deleteVideoChannel,
@@ -860,7 +860,7 @@ describe('Test video playlists', function () {
860 } 860 }
861 }) 861 })
862 862
863 after(function () { 863 after(async function () {
864 killallServers(servers) 864 await cleanupTests(servers)
865 }) 865 })
866}) 866})
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts
index a823993b2..ef1cf0f07 100644
--- a/server/tests/api/videos/video-privacy.ts
+++ b/server/tests/api/videos/video-privacy.ts
@@ -4,6 +4,7 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' 5import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
6import { 6import {
7 cleanupTests,
7 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
8 getVideosList, 9 getVideosList,
9 killallServers, 10 killallServers,
@@ -152,7 +153,7 @@ describe('Test video privacy', function () {
152 } 153 }
153 }) 154 })
154 155
155 after(function () { 156 after(async function () {
156 killallServers(servers) 157 await cleanupTests(servers)
157 }) 158 })
158}) 159})
diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.ts
index d7301a137..64f657780 100644
--- a/server/tests/api/videos/video-schedule-update.ts
+++ b/server/tests/api/videos/video-schedule-update.ts
@@ -4,6 +4,7 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { VideoPrivacy } from '../../../../shared/models/videos' 5import { VideoPrivacy } from '../../../../shared/models/videos'
6import { 6import {
7 cleanupTests,
7 doubleFollow, 8 doubleFollow,
8 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
9 getMyVideos, 10 getMyVideos,
@@ -165,7 +166,7 @@ describe('Test video update scheduler', function () {
165 } 166 }
166 }) 167 })
167 168
168 after(function () { 169 after(async function () {
169 killallServers(servers) 170 await cleanupTests(servers)
170 }) 171 })
171}) 172})
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 92888f137..3cd43e99b 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -6,7 +6,7 @@ import { omit } from 'lodash'
6import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' 6import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos'
7import { audio, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' 7import { audio, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
8import { 8import {
9 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath, cleanupTests,
10 doubleFollow, 10 doubleFollow,
11 flushAndRunMultipleServers, 11 flushAndRunMultipleServers,
12 generateHighBitrateVideo, 12 generateHighBitrateVideo,
@@ -349,7 +349,7 @@ describe('Test video transcoding', function () {
349 } 349 }
350 }) 350 })
351 351
352 after(function () { 352 after(async function () {
353 killallServers(servers) 353 await cleanupTests(servers)
354 }) 354 })
355}) 355})
diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts
index 179610595..e1e65260f 100644
--- a/server/tests/api/videos/videos-filter.ts
+++ b/server/tests/api/videos/videos-filter.ts
@@ -3,6 +3,7 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 cleanupTests,
6 createUser, 7 createUser,
7 doubleFollow, 8 doubleFollow,
8 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
@@ -119,7 +120,7 @@ describe('Test videos filter validator', function () {
119 }) 120 })
120 }) 121 })
121 122
122 after(function () { 123 after(async function () {
123 killallServers(servers) 124 await cleanupTests(servers)
124 }) 125 })
125}) 126})
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts
index 2a904c659..c7e55c1ab 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -3,12 +3,13 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 cleanupTests,
6 createUser, 7 createUser,
7 flushTests, 8 flushAndRunServer,
8 getVideosListWithToken, 9 getVideosListWithToken,
9 getVideoWithToken, 10 getVideoWithToken,
10 killallServers, reRunServer, 11 killallServers,
11 flushAndRunServer, 12 reRunServer,
12 searchVideoWithToken, 13 searchVideoWithToken,
13 ServerInfo, 14 ServerInfo,
14 setAccessTokensToServers, 15 setAccessTokensToServers,
@@ -220,7 +221,7 @@ describe('Test videos history', function () {
220 expect(res.body.total).to.equal(0) 221 expect(res.body.total).to.equal(0)
221 }) 222 })
222 223
223 after(function () { 224 after(async function () {
224 killallServers([ server ]) 225 await cleanupTests([ server ])
225 }) 226 })
226}) 227})
diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts
index c63725d71..975a5c87a 100644
--- a/server/tests/api/videos/videos-overview.ts
+++ b/server/tests/api/videos/videos-overview.ts
@@ -2,7 +2,7 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { flushAndRunServer, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils' 5import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils'
6import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' 6import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
7import { VideosOverview } from '../../../../shared/models/overviews' 7import { VideosOverview } from '../../../../shared/models/overviews'
8 8
@@ -87,7 +87,7 @@ describe('Test a videos overview', function () {
87 expect(overview.channels[0].channel.name).to.equal('root_channel') 87 expect(overview.channels[0].channel.name).to.equal('root_channel')
88 }) 88 })
89 89
90 after(function () { 90 after(async function () {
91 killallServers([ server ]) 91 await cleanupTests([ server ])
92 }) 92 })
93}) 93})
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts
index 80cecdd23..c21d46d56 100644
--- a/server/tests/api/videos/videos-views-cleaner.ts
+++ b/server/tests/api/videos/videos-views-cleaner.ts
@@ -10,7 +10,7 @@ import {
10 flushAndRunServer, 10 flushAndRunServer,
11 ServerInfo, 11 ServerInfo,
12 setAccessTokensToServers, 12 setAccessTokensToServers,
13 uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs 13 uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests
14} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
15import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' 15import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
16import { VideosOverview } from '../../../../shared/models/overviews' 16import { VideosOverview } from '../../../../shared/models/overviews'
@@ -100,7 +100,7 @@ describe('Test video views cleaner', function () {
100 } 100 }
101 }) 101 })
102 102
103 after(function () { 103 after(async function () {
104 killallServers(servers) 104 await cleanupTests(servers)
105 }) 105 })
106}) 106})
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts
index 191d4b460..0d378c1aa 100644
--- a/server/tests/cli/create-import-video-file-job.ts
+++ b/server/tests/cli/create-import-video-file-job.ts
@@ -4,6 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { VideoDetails, VideoFile } from '../../../shared/models/videos' 5import { VideoDetails, VideoFile } from '../../../shared/models/videos'
6import { 6import {
7 cleanupTests,
7 doubleFollow, 8 doubleFollow,
8 execCLI, 9 execCLI,
9 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
@@ -130,7 +131,7 @@ describe('Test create import video jobs', function () {
130 } 131 }
131 }) 132 })
132 133
133 after(function () { 134 after(async function () {
134 killallServers(servers) 135 await cleanupTests(servers)
135 }) 136 })
136}) 137})
diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts
index 61c310bc3..1c0e10066 100644
--- a/server/tests/cli/create-transcoding-job.ts
+++ b/server/tests/cli/create-transcoding-job.ts
@@ -4,6 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { VideoDetails } from '../../../shared/models/videos' 5import { VideoDetails } from '../../../shared/models/videos'
6import { 6import {
7 cleanupTests,
7 doubleFollow, 8 doubleFollow,
8 execCLI, 9 execCLI,
9 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
@@ -124,7 +125,7 @@ describe('Test create transcoding jobs', function () {
124 } 125 }
125 }) 126 })
126 127
127 after(function () { 128 after(async function () {
128 killallServers(servers) 129 await cleanupTests(servers)
129 }) 130 })
130}) 131})
diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts
index 14625f8c0..5e12c0089 100644
--- a/server/tests/cli/optimize-old-videos.ts
+++ b/server/tests/cli/optimize-old-videos.ts
@@ -4,6 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { getMaxBitrate, Video, VideoDetails, VideoResolution } from '../../../shared/models/videos' 5import { getMaxBitrate, Video, VideoDetails, VideoResolution } from '../../../shared/models/videos'
6import { 6import {
7 cleanupTests,
7 doubleFollow, 8 doubleFollow,
8 execCLI, 9 execCLI,
9 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
@@ -112,7 +113,7 @@ describe('Test optimize old videos', function () {
112 } 113 }
113 }) 114 })
114 115
115 after(function () { 116 after(async function () {
116 killallServers(servers) 117 await cleanupTests(servers)
117 }) 118 })
118}) 119})
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts
index 0c11945e0..80bbc98d5 100644
--- a/server/tests/cli/peertube.ts
+++ b/server/tests/cli/peertube.ts
@@ -10,7 +10,7 @@ import {
10 killallServers, 10 killallServers,
11 flushAndRunServer, 11 flushAndRunServer,
12 ServerInfo, 12 ServerInfo,
13 setAccessTokensToServers 13 setAccessTokensToServers, cleanupTests
14} from '../../../shared/extra-utils' 14} from '../../../shared/extra-utils'
15 15
16describe('Test CLI wrapper', function () { 16describe('Test CLI wrapper', function () {
@@ -46,6 +46,6 @@ describe('Test CLI wrapper', function () {
46 46
47 await execCLI(cmd + ` auth del ${server.url}`) 47 await execCLI(cmd + ` auth del ${server.url}`)
48 48
49 killallServers([ server ]) 49 await cleanupTests([ server ])
50 }) 50 })
51}) 51})
diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts
index 1d6423814..6abb6738f 100644
--- a/server/tests/cli/reset-password.ts
+++ b/server/tests/cli/reset-password.ts
@@ -1,13 +1,12 @@
1import 'mocha' 1import 'mocha'
2 2
3import { 3import {
4 cleanupTests,
4 createUser, 5 createUser,
5 execCLI, 6 execCLI,
6 flushTests, 7 flushAndRunServer,
7 getEnvCli, 8 getEnvCli,
8 killallServers,
9 login, 9 login,
10 flushAndRunServer,
11 ServerInfo, 10 ServerInfo,
12 setAccessTokensToServers 11 setAccessTokensToServers
13} from '../../../shared/extra-utils' 12} from '../../../shared/extra-utils'
@@ -32,7 +31,7 @@ describe('Test reset password scripts', function () {
32 await login(server.url, server.client, { username: 'user_1', password: 'coucou' }, 200) 31 await login(server.url, server.client, { username: 'user_1', password: 'coucou' }, 200)
33 }) 32 })
34 33
35 after(function () { 34 after(async function () {
36 killallServers([ server ]) 35 await cleanupTests([ server ])
37 }) 36 })
38}) 37})
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts
index dd594779b..55c43b32f 100644
--- a/server/tests/cli/update-host.ts
+++ b/server/tests/cli/update-host.ts
@@ -7,17 +7,17 @@ import { waitJobs } from '../../../shared/extra-utils/server/jobs'
7import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments' 7import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
8import { 8import {
9 addVideoChannel, 9 addVideoChannel,
10 cleanupTests,
10 createUser, 11 createUser,
11 execCLI, 12 execCLI,
12 flushTests, 13 flushAndRunServer,
13 getEnvCli, 14 getEnvCli,
14 getVideo, 15 getVideo,
15 getVideoChannelsList, 16 getVideoChannelsList,
16 getVideosList, 17 getVideosList,
17 killallServers, 18 killallServers,
18 makeActivityPubGetRequest, 19 makeActivityPubGetRequest,
19 parseTorrentVideo, 20 parseTorrentVideo, reRunServer,
20 flushAndRunServer,
21 ServerInfo, 21 ServerInfo,
22 setAccessTokensToServers, 22 setAccessTokensToServers,
23 uploadVideo 23 uploadVideo
@@ -70,7 +70,7 @@ describe('Test update host scripts', function () {
70 70
71 killallServers([ server ]) 71 killallServers([ server ])
72 // Run server with standard configuration 72 // Run server with standard configuration
73 server = await flushAndRunServer(2) 73 await reRunServer(server)
74 74
75 const env = getEnvCli(server) 75 const env = getEnvCli(server)
76 await execCLI(`${env} npm run update-host`) 76 await execCLI(`${env} npm run update-host`)
@@ -146,7 +146,7 @@ describe('Test update host scripts', function () {
146 } 146 }
147 }) 147 })
148 148
149 after(function () { 149 after(async function () {
150 killallServers([ server ]) 150 await cleanupTests([ server ])
151 }) 151 })
152}) 152})
diff --git a/server/tests/client.ts b/server/tests/client.ts
index cdf0ce2ce..778dcd08e 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -4,12 +4,11 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import * as request from 'supertest' 5import * as request from 'supertest'
6import { 6import {
7 flushTests, 7 cleanupTests,
8 flushAndRunServer,
8 getCustomConfig, 9 getCustomConfig,
9 getVideosList, 10 getVideosList,
10 killallServers,
11 makeHTMLRequest, 11 makeHTMLRequest,
12 flushAndRunServer,
13 ServerInfo, 12 ServerInfo,
14 serverLogin, 13 serverLogin,
15 updateCustomConfig, 14 updateCustomConfig,
@@ -145,7 +144,7 @@ describe('Test a client controllers', function () {
145 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }') 144 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
146 }) 145 })
147 146
148 after(function () { 147 after(async function () {
149 killallServers([ server ]) 148 await cleanupTests([ server ])
150 }) 149 })
151}) 150})
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts
index fc6543474..0dcdf09cf 100644
--- a/server/tests/feeds/feeds.ts
+++ b/server/tests/feeds/feeds.ts
@@ -3,6 +3,7 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 cleanupTests,
6 createUser, 7 createUser,
7 doubleFollow, 8 doubleFollow,
8 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
@@ -207,7 +208,7 @@ describe('Test syndication feeds', () => {
207 }) 208 })
208 }) 209 })
209 210
210 after(function () { 211 after(async function () {
211 killallServers(servers) 212 await cleanupTests(servers)
212 }) 213 })
213}) 214})
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts
index d5c7d9dd4..ed406e1bc 100644
--- a/server/tests/misc-endpoints.ts
+++ b/server/tests/misc-endpoints.ts
@@ -4,11 +4,10 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { 5import {
6 addVideoChannel, 6 addVideoChannel,
7 cleanupTests,
7 createUser, 8 createUser,
8 flushTests,
9 killallServers,
10 makeGetRequest,
11 flushAndRunServer, 9 flushAndRunServer,
10 makeGetRequest,
12 ServerInfo, 11 ServerInfo,
13 setAccessTokensToServers, 12 setAccessTokensToServers,
14 uploadVideo 13 uploadVideo
@@ -171,7 +170,7 @@ describe('Test misc endpoints', function () {
171 }) 170 })
172 }) 171 })
173 172
174 after(function () { 173 after(async function () {
175 killallServers([ server ]) 174 await cleanupTests([ server ])
176 }) 175 })
177}) 176})