ActivityPub-federated video streaming platform using P2P directly in your web browser
All API tests in parallel
Chocobozzz48f07b4a4091
diff --git a/scripts/travis.sh b/scripts/travis.shindex 67d8b5d7e9..772d3906ae 100755--- a/scripts/travis.sh+++ b/scripts/travis.sh@@ -23,13 +23,13 @@ elif [ "$1" = "api-1" ]; thensh ./server/tests/api/travis-1.shelif [ "$1" = "api-2" ]; thennpm run build:server- mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-2.ts+ sh ./server/tests/api/travis-2.shelif [ "$1" = "api-3" ]; thennpm run build:server- mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-3.ts+ sh ./server/tests/api/travis-3.shelif [ "$1" = "api-4" ]; thennpm run build:server- mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-4.ts+ sh ./server/tests/api/travis-4.shelif [ "$1" = "lint" ]; thennpm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts"diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.tsindex edf588c166..34c6be49be 100644--- a/server/tests/api/activitypub/client.ts+++ b/server/tests/api/activitypub/client.ts@@ -3,6 +3,7 @@import * as chai from 'chai'import 'mocha'import {+ cleanupTests,doubleFollow,flushAndRunMultipleServers,flushTests,@@ -39,7 +40,7 @@ describe('Test activitypub', function () {const object = res.bodyexpect(object.type).to.equal('Person')- expect(object.id).to.equal('http://localhost:9001/accounts/root')+ expect(object.id).to.equal('http://localhost:' + servers[0].port + '/accounts/root')expect(object.name).to.equal('root')expect(object.preferredUsername).to.equal('root')})@@ -49,17 +50,17 @@ describe('Test activitypub', function () {const object = res.bodyexpect(object.type).to.equal('Video')- expect(object.id).to.equal('http://localhost:9001/videos/watch/' + videoUUID)+ expect(object.id).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)expect(object.name).to.equal('video')})it('Should redirect to the origin video object', async function () {const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, 302)- expect(res.header.location).to.equal('http://localhost:9001/videos/watch/' + videoUUID)+ expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)})- after(function () {- killallServers(servers)+ after(async function () {+ await cleanupTests(servers)})})diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.tsindex 7240bb0fb4..3a1c0d3212 100644--- a/server/tests/api/activitypub/fetch.ts+++ b/server/tests/api/activitypub/fetch.ts@@ -3,6 +3,7 @@import 'mocha'import {+ cleanupTests,closeAllSequelize,createUser,doubleFollow,@@ -48,8 +49,16 @@ describe('Test ActivityPub fetcher', function () {const badVideoUUID = res.body.video.uuidawait uploadVideo(servers[0].url, userAccessToken, { name: 'video user' })- await setActorField(1, 'http://localhost:9001/accounts/user1', 'url', 'http://localhost:9002/accounts/user1')- await setVideoField(1, badVideoUUID, 'url', 'http://localhost:9003/videos/watch/' + badVideoUUID)+ {+ const to = 'http://localhost:' + servers[0].port + '/accounts/user1'+ const value = 'http://localhost:' + servers[1].port + '/accounts/user1'+ await setActorField(servers[0].internalServerNumber, to, 'url', value)+ }++ {+ const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + badVideoUUID+ await setVideoField(servers[0].internalServerNumber, badVideoUUID, 'url', value)+ }})it('Should add only the video with a valid actor URL', async function () {@@ -78,7 +87,9 @@ describe('Test ActivityPub fetcher', function () {})after(async function () {- killallServers(servers)+ this.timeout(10000)++ await cleanupTests(servers)await closeAllSequelize(servers)})diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.tsindex 9be9aa495b..921ee874c7 100644--- a/server/tests/api/activitypub/refresher.ts+++ b/server/tests/api/activitypub/refresher.ts@@ -2,13 +2,14 @@import 'mocha'import {+ cleanupTests, closeAllSequelize,createVideoPlaylist,doubleFollow,flushAndRunMultipleServers,generateUserAccessToken,getVideo,getVideoPlaylist,- killallServers, rateVideo,+ killallServers,reRunServer,ServerInfo,setAccessTokensToServers,@@ -48,26 +49,26 @@ describe('Test AP refresher', function () {}{- const a1 = await generateUserAccessToken(servers[1], 'user1')- await uploadVideo(servers[1].url, a1, { name: 'video4' })+ const a1 = await generateUserAccessToken(servers[ 1 ], 'user1')+ await uploadVideo(servers[ 1 ].url, a1, { name: 'video4' })- const a2 = await generateUserAccessToken(servers[1], 'user2')- await uploadVideo(servers[1].url, a2, { name: 'video5' })+ const a2 = await generateUserAccessToken(servers[ 1 ], 'user2')+ await uploadVideo(servers[ 1 ].url, a2, { name: 'video5' })}{- const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }- const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs })+ const playlistAttrs = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[ 1 ].videoChannel.id }+ const res = await createVideoPlaylist({ url: servers[ 1 ].url, token: servers[ 1 ].accessToken, playlistAttrs })playlistUUID1 = res.body.videoPlaylist.uuid}{- const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }- const res = await createVideoPlaylist({ url: servers[1].url, token: servers[1].accessToken, playlistAttrs })+ const playlistAttrs = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[ 1 ].videoChannel.id }+ const res = await createVideoPlaylist({ url: servers[ 1 ].url, token: servers[ 1 ].accessToken, playlistAttrs })playlistUUID2 = res.body.videoPlaylist.uuid}- await doubleFollow(servers[0], servers[1])+ await doubleFollow(servers[ 0 ], servers[ 1 ])})describe('Videos refresher', function () {@@ -78,7 +79,7 @@ describe('Test AP refresher', function () {await wait(10000)// Change UUID so the remote server returns a 404- await setVideoField(2, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')+ await setVideoField(servers[ 1 ].internalServerNumber, videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')await getVideo(servers[ 0 ].url, videoUUID1)await getVideo(servers[ 0 ].url, videoUUID2)@@ -94,7 +95,7 @@ describe('Test AP refresher', function () {killallServers([ servers[ 1 ] ])- await setVideoField(2, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')+ await setVideoField(servers[ 1 ].internalServerNumber, videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')// Video will need a refreshawait wait(10000)@@ -121,15 +122,16 @@ describe('Test AP refresher', function () {await wait(10000)// Change actor name so the remote server returns a 404- await setActorField(2, 'http://localhost:9002/accounts/user2', 'preferredUsername', 'toto')+ const to = 'http://localhost:' + servers[ 1 ].port + '/accounts/user2'+ await setActorField(servers[ 1 ].internalServerNumber, to, 'preferredUsername', 'toto')- await getAccount(servers[ 0 ].url, 'user1@localhost:9002')- await getAccount(servers[ 0 ].url, 'user2@localhost:9002')+ await getAccount(servers[ 0 ].url, 'user1@localhost:' + servers[ 1 ].port)+ await getAccount(servers[ 0 ].url, 'user2@localhost:' + servers[ 1 ].port)await waitJobs(servers)- await getAccount(servers[ 0 ].url, 'user1@localhost:9002', 200)- await getAccount(servers[ 0 ].url, 'user2@localhost:9002', 404)+ await getAccount(servers[ 0 ].url, 'user1@localhost:' + servers[ 1 ].port, 200)+ await getAccount(servers[ 0 ].url, 'user2@localhost:' + servers[ 1 ].port, 404)})})@@ -141,7 +143,7 @@ describe('Test AP refresher', function () {await wait(10000)// Change UUID so the remote server returns a 404- await setPlaylistField(2, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')+ await setPlaylistField(servers[ 1 ].internalServerNumber, playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')await getVideoPlaylist(servers[ 0 ].url, playlistUUID1)await getVideoPlaylist(servers[ 0 ].url, playlistUUID2)@@ -153,7 +155,11 @@ describe('Test AP refresher', function () {})})- after(function () {- killallServers(servers)+ after(async function () {+ this.timeout(10000)++ await cleanupTests(servers)++ await closeAllSequelize(servers)})})diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.tsindex 11e6859bfb..dc960c5c34 100644--- a/server/tests/api/activitypub/security.ts+++ b/server/tests/api/activitypub/security.ts@@ -3,9 +3,9 @@import 'mocha'import {+ cleanupTests,closeAllSequelize,flushAndRunMultipleServers,- flushTests,killallServers,ServerInfo,setActorField@@ -18,18 +18,26 @@ import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-uconst expect = chai.expect-function setKeysOfServer2 (serverNumber: number, publicKey: string, privateKey: string) {+function setKeysOfServer (onServer: ServerInfo, ofServer: ServerInfo, publicKey: string, privateKey: string) {return Promise.all([- setActorField(serverNumber, 'http://localhost:9002/accounts/peertube', 'publicKey', publicKey),- setActorField(serverNumber, 'http://localhost:9002/accounts/peertube', 'privateKey', privateKey)+ setActorField(onServer.internalServerNumber, 'http://localhost:' + ofServer.port + '/accounts/peertube', 'publicKey', publicKey),+ setActorField(onServer.internalServerNumber, 'http://localhost:' + ofServer.port + '/accounts/peertube', 'privateKey', privateKey)])}-function setKeysOfServer3 (serverNumber: number, publicKey: string, privateKey: string) {- return Promise.all([- setActorField(serverNumber, 'http://localhost:9003/accounts/peertube', 'publicKey', publicKey),- setActorField(serverNumber, 'http://localhost:9003/accounts/peertube', 'privateKey', privateKey)- ])+function getAnnounceWithoutContext (server2: ServerInfo) {+ const json = require('./json/peertube/announce-without-context.json')+ const result: typeof json = {}++ for (const key of Object.keys(json)) {+ if (Array.isArray(json[key])) {+ result[key] = json[key].map(v => v.replace(':9002', `:${server2.port}`))+ } else {+ result[ key ] = json[ key ].replace(':9002', `:${server2.port}`)+ }+ }++ return result}describe('Test ActivityPub security', function () {@@ -38,13 +46,13 @@ describe('Test ActivityPub security', function () {const keys = require('./json/peertube/keys.json')const invalidKeys = require('./json/peertube/invalid-keys.json')- const baseHttpSignature = {+ const baseHttpSignature = () => ({algorithm: HTTP_SIGNATURE.ALGORITHM,authorizationHeaderName: HTTP_SIGNATURE.HEADER_NAME,- keyId: 'acct:peertube@localhost:9002',+ keyId: 'acct:peertube@localhost:' + servers[1].port,key: keys.privateKey,headers: HTTP_SIGNATURE.HEADERS_TO_SIGN- }+ })// ---------------------------------------------------------------@@ -55,56 +63,56 @@ describe('Test ActivityPub security', function () {url = servers[0].url + '/inbox'- await setKeysOfServer2(1, keys.publicKey, keys.privateKey)+ await setKeysOfServer(servers[0], servers[1], keys.publicKey, keys.privateKey)- const to = { url: 'http://localhost:9001/accounts/peertube' }- const by = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey }+ const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' }+ const by = { url: 'http://localhost:' + servers[1].port + '/accounts/peertube', privateKey: keys.privateKey }await makeFollowRequest(to, by)})describe('When checking HTTP signature', function () {it('Should fail with an invalid digest', async function () {- const body = activityPubContextify(require('./json/peertube/announce-without-context.json'))+ const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))const headers = {Digest: buildDigest({ hello: 'coucou' })}- const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers)+ const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)expect(response.statusCode).to.equal(403)})it('Should fail with an invalid date', async function () {- const body = activityPubContextify(require('./json/peertube/announce-without-context.json'))+ const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))const headers = buildGlobalHeaders(body)headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT'- const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers)+ const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)expect(response.statusCode).to.equal(403)})it('Should fail with bad keys', async function () {- await setKeysOfServer2(1, invalidKeys.publicKey, invalidKeys.privateKey)- await setKeysOfServer2(2, invalidKeys.publicKey, invalidKeys.privateKey)+ await setKeysOfServer(servers[0], servers[1], invalidKeys.publicKey, invalidKeys.privateKey)+ await setKeysOfServer(servers[1], servers[1], invalidKeys.publicKey, invalidKeys.privateKey)- const body = activityPubContextify(require('./json/peertube/announce-without-context.json'))+ const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))const headers = buildGlobalHeaders(body)- const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers)+ const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)expect(response.statusCode).to.equal(403)})it('Should succeed with a valid HTTP signature', async function () {- await setKeysOfServer2(1, keys.publicKey, keys.privateKey)- await setKeysOfServer2(2, keys.publicKey, keys.privateKey)+ await setKeysOfServer(servers[0], servers[1], keys.publicKey, keys.privateKey)+ await setKeysOfServer(servers[1], servers[1], keys.publicKey, keys.privateKey)- const body = activityPubContextify(require('./json/peertube/announce-without-context.json'))+ const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))const headers = buildGlobalHeaders(body)- const { response } = await makePOSTAPRequest(url, body, baseHttpSignature, headers)+ const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)expect(response.statusCode).to.equal(204)})@@ -112,28 +120,28 @@ describe('Test ActivityPub security', function () {describe('When checking Linked Data Signature', function () {before(async () => {- await setKeysOfServer3(3, keys.publicKey, keys.privateKey)+ await setKeysOfServer(servers[2], servers[2], keys.publicKey, keys.privateKey)- const to = { url: 'http://localhost:9001/accounts/peertube' }- const by = { url: 'http://localhost:9003/accounts/peertube', privateKey: keys.privateKey }+ const to = { url: 'http://localhost:' + servers[0].port + '/accounts/peertube' }+ const by = { url: 'http://localhost:' + servers[2].port + '/accounts/peertube', privateKey: keys.privateKey }await makeFollowRequest(to, by)})it('Should fail with bad keys', async function () {this.timeout(10000)- await setKeysOfServer3(1, invalidKeys.publicKey, invalidKeys.privateKey)- await setKeysOfServer3(3, invalidKeys.publicKey, invalidKeys.privateKey)+ await setKeysOfServer(servers[0], servers[2], invalidKeys.publicKey, invalidKeys.privateKey)+ await setKeysOfServer(servers[2], servers[2], invalidKeys.publicKey, invalidKeys.privateKey)- const body = require('./json/peertube/announce-without-context.json')- body.actor = 'http://localhost:9003/accounts/peertube'+ const body = getAnnounceWithoutContext(servers[1])+ body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'- const signer: any = { privateKey: invalidKeys.privateKey, url: 'http://localhost:9003/accounts/peertube' }+ const signer: any = { privateKey: invalidKeys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }const signedBody = await buildSignedActivity(signer, body)const headers = buildGlobalHeaders(signedBody)- const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers)+ const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)expect(response.statusCode).to.equal(403)})@@ -141,20 +149,20 @@ describe('Test ActivityPub security', function () {it('Should fail with an altered body', async function () {this.timeout(10000)- await setKeysOfServer3(1, keys.publicKey, keys.privateKey)- await setKeysOfServer3(3, keys.publicKey, keys.privateKey)+ await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey)+ await setKeysOfServer(servers[0], servers[2], keys.publicKey, keys.privateKey)- const body = require('./json/peertube/announce-without-context.json')- body.actor = 'http://localhost:9003/accounts/peertube'+ const body = getAnnounceWithoutContext(servers[1])+ body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'- const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:9003/accounts/peertube' }+ const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }const signedBody = await buildSignedActivity(signer, body)- signedBody.actor = 'http://localhost:9003/account/peertube'+ signedBody.actor = 'http://localhost:' + servers[2].port + '/account/peertube'const headers = buildGlobalHeaders(signedBody)- const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers)+ const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)expect(response.statusCode).to.equal(403)})@@ -162,22 +170,24 @@ describe('Test ActivityPub security', function () {it('Should succeed with a valid signature', async function () {this.timeout(10000)- const body = require('./json/peertube/announce-without-context.json')- body.actor = 'http://localhost:9003/accounts/peertube'+ const body = getAnnounceWithoutContext(servers[1])+ body.actor = 'http://localhost:' + servers[2].port + '/accounts/peertube'- const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:9003/accounts/peertube' }+ const signer: any = { privateKey: keys.privateKey, url: 'http://localhost:' + servers[2].port + '/accounts/peertube' }const signedBody = await buildSignedActivity(signer, body)const headers = buildGlobalHeaders(signedBody)- const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature, headers)+ const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)expect(response.statusCode).to.equal(204)})})after(async function () {- killallServers(servers)+ this.timeout(10000)++ await cleanupTests(servers)await closeAllSequelize(servers)})diff --git a/server/tests/api/index-2.ts b/server/tests/api/index-2.tsdeleted file mode 100644index ed93faa910..0000000000--- a/server/tests/api/index-2.ts+++ /dev/null@@ -1,2 +0,0 @@-import './server'-import './users'diff --git a/server/tests/api/index-3.ts b/server/tests/api/index-3.tsdeleted file mode 100644index 39823b82c3..0000000000--- a/server/tests/api/index-3.ts+++ /dev/null@@ -1 +0,0 @@-import './videos'diff --git a/server/tests/api/index-4.ts b/server/tests/api/index-4.tsdeleted file mode 100644index 7d8be2b3d1..0000000000--- a/server/tests/api/index-4.ts+++ /dev/null@@ -1,2 +0,0 @@-import './redundancy'-import './activitypub'diff --git a/server/tests/api/index.ts b/server/tests/api/index.tsindex bc140f860e..bac77ab2e9 100644--- a/server/tests/api/index.ts+++ b/server/tests/api/index.ts@@ -1,5 +1,9 @@// Order of the tests we want to execute-import './index-1'-import './index-2'-import './index-3'-import './index-4'+import './activitypub'+import './check-params'+import './notifications'+import './redundancy'+import './search'+import './server'+import './users'+import './videos'diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.tsindex c0d11914bf..ca389b7b6b 100644--- a/server/tests/api/server/config.ts+++ b/server/tests/api/server/config.ts@@ -11,9 +11,9 @@ import {getAbout,getConfig,getCustomConfig,- killallServers,+ killallServers, parallelTests,registerUser,- reRunServer,+ reRunServer, ServerInfo,setAccessTokensToServers,updateCustomConfig} from '../../../../shared/extra-utils'@@ -21,7 +21,7 @@ import { ServerConfig } from '../../../../shared/models'const expect = chai.expect-function checkInitialConfig (data: CustomConfig) {+function checkInitialConfig (server: ServerInfo, data: CustomConfig) {expect(data.instance.name).to.equal('PeerTube')expect(data.instance.shortDescription).to.equal('PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' +@@ -45,7 +45,7 @@ function checkInitialConfig (data: CustomConfig) {expect(data.signup.limit).to.equal(4)expect(data.signup.requiresEmailVerification).to.be.false- expect(data.admin.email).to.equal('[email protected]')+ expect(data.admin.email).to.equal('admin' + server.internalServerNumber + '@example.com')expect(data.contactForm.enabled).to.be.trueexpect(data.user.videoQuota).to.equal(5242880)@@ -89,7 +89,11 @@ function checkUpdatedConfig (data: CustomConfig) {expect(data.signup.limit).to.equal(5)expect(data.signup.requiresEmailVerification).to.be.false- expect(data.admin.email).to.equal('[email protected]')+ // We override admin email in parallel tests, so skip this exception+ if (parallelTests() === false) {+ expect(data.admin.email).to.equal('[email protected]')+ }+expect(data.contactForm.enabled).to.be.falseexpect(data.user.videoQuota).to.equal(5242881)@@ -118,6 +122,7 @@ describe('Test config', function () {before(async function () {this.timeout(30000)+server = await flushAndRunServer(1)await setAccessTokensToServers([ server ])})@@ -160,7 +165,7 @@ describe('Test config', function () {const res = await getCustomConfig(server.url, server.accessToken)const data = res.body as CustomConfig- checkInitialConfig(data)+ checkInitialConfig(server, data)})it('Should update the customized configuration', async function () {@@ -297,7 +302,7 @@ describe('Test config', function () {const res = await getCustomConfig(server.url, server.accessToken)const data = res.body- checkInitialConfig(data)+ checkInitialConfig(server, data)})after(async function () {diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.tsindex 0a1c49ef50..87e55060ca 100644--- a/server/tests/api/server/contact-form.ts+++ b/server/tests/api/server/contact-form.ts@@ -54,7 +54,7 @@ describe('Test contact form', function () {expect(email['from'][0]['address']).equal('test-admin@localhost')expect(email['from'][0]['name']).equal('[email protected]')- expect(email['to'][0]['address']).equal('[email protected]')+ expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com')expect(email['subject']).contains('Contact form')expect(email['text']).contains('my super message')})diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.tsindex 9ccb1c36fd..5929a3adbe 100644--- a/server/tests/api/server/email.ts+++ b/server/tests/api/server/email.ts@@ -37,15 +37,17 @@ describe('Test emails', function () {username: 'user_1',password: 'super_password'}+ let emailPort: numberbefore(async function () {this.timeout(30000)- await MockSmtpServer.Instance.collectEmails(emails)+ emailPort = await MockSmtpServer.Instance.collectEmails(emails)const overrideConfig = {smtp: {- hostname: 'localhost'+ hostname: 'localhost',+ port: emailPort}}server = await flushAndRunServer(1, overrideConfig)@@ -134,7 +136,7 @@ describe('Test emails', function () {expect(email['from'][0]['name']).equal('localhost:' + server.port)expect(email['from'][0]['address']).equal('test-admin@localhost')- expect(email['to'][0]['address']).equal('[email protected]')+ expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com')expect(email['subject']).contains('abuse')expect(email['text']).contains(videoUUID)})diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.tsindex fc20f8961d..a82acdb34a 100644--- a/server/tests/api/server/follows-moderation.ts+++ b/server/tests/api/server/follows-moderation.ts@@ -29,7 +29,7 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'accconst follow = res.body.data[0] as ActorFollowexpect(follow.state).to.equal(state)- expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + 'accounts/peertube')+ expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube')expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')}@@ -39,7 +39,7 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'accconst follow = res.body.data[0] as ActorFollowexpect(follow.state).to.equal(state)- expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + 'accounts/peertube')+ expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + '/accounts/peertube')expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube')}}diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.tsindex d4155667f4..e8d6f5138f 100644--- a/server/tests/api/server/follows.ts+++ b/server/tests/api/server/follows.ts@@ -141,7 +141,7 @@ describe('Test follows', function () {it('Should search followers on server 2', async function () {{- const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', '9001')+ const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', servers[0].port + '')const follows = res.body.dataexpect(res.body.total).to.equal(1)diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.tsindex 9a8bc08f9b..068654d8c4 100644--- a/server/tests/api/server/handle-down.ts+++ b/server/tests/api/server/handle-down.ts@@ -60,48 +60,50 @@ describe('Test handle downs', function () {privacy: VideoPrivacy.UNLISTED})- const checkAttributes = {- name: 'my super name for server 1',- category: 5,- licence: 4,- language: 'ja',- nsfw: true,- description: 'my super description for server 1',- support: 'my super support text for server 1',- account: {- name: 'root',- host: 'localhost:' + servers[0].port- },- isLocal: false,- duration: 10,- tags: [ 'tag1p1', 'tag2p1' ],- privacy: VideoPrivacy.PUBLIC,- commentsEnabled: true,- downloadEnabled: true,- channel: {- name: 'root_channel',- displayName: 'Main root channel',- description: '',- isLocal: false- },- fixture: 'video_short1.webm',- files: [- {- resolution: 720,- size: 572456- }- ]- }-- const unlistedCheckAttributes = immutableAssign(checkAttributes, {- privacy: VideoPrivacy.UNLISTED- })+ let checkAttributes: any+ let unlistedCheckAttributes: anybefore(async function () {this.timeout(30000)servers = await flushAndRunMultipleServers(3)+ checkAttributes = {+ name: 'my super name for server 1',+ category: 5,+ licence: 4,+ language: 'ja',+ nsfw: true,+ description: 'my super description for server 1',+ support: 'my super support text for server 1',+ account: {+ name: 'root',+ host: 'localhost:' + servers[0].port+ },+ isLocal: false,+ duration: 10,+ tags: [ 'tag1p1', 'tag2p1' ],+ privacy: VideoPrivacy.PUBLIC,+ commentsEnabled: true,+ downloadEnabled: true,+ channel: {+ name: 'root_channel',+ displayName: 'Main root channel',+ description: '',+ isLocal: false+ },+ fixture: 'video_short1.webm',+ files: [+ {+ resolution: 720,+ size: 572456+ }+ ]+ }+ unlistedCheckAttributes = immutableAssign(checkAttributes, {+ privacy: VideoPrivacy.UNLISTED+ })+// Get the access tokensawait setAccessTokensToServers(servers)})diff --git a/server/tests/api/server/logs.ts b/server/tests/api/server/logs.tsindex 3644fa0d30..68f4421993 100644--- a/server/tests/api/server/logs.ts+++ b/server/tests/api/server/logs.ts@@ -45,7 +45,7 @@ describe('Test logs', function () {})it('Should get logs with an end date', async function () {- this.timeout(10000)+ this.timeout(20000)await uploadVideo(server.url, server.accessToken, { name: 'video 3' })await waitJobs([ server ])diff --git a/server/tests/api/travis-1.sh b/server/tests/api/travis-1.shindex 0673bb2bfd..f7332795c2 100644--- a/server/tests/api/travis-1.sh+++ b/server/tests/api/travis-1.sh@@ -2,9 +2,9 @@set -eu+checkParamFiles=$(find server/tests/api/check-params -type f | grep -v index.ts | xargs echo)notificationsFiles=$(find server/tests/api/notifications -type f | grep -v index.ts | xargs echo)searchFiles=$(find server/tests/api/search -type f | grep -v index.ts | xargs echo)-checkParamFiles=$(find server/tests/api/check-params -type f | grep -v index.ts | xargs echo)-MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 4 --timeout 5000 --exit --require ts-node/register --bail \+MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 3 --timeout 5000 --exit --require ts-node/register --bail \$notificationsFiles $searchFiles $checkParamFilesdiff --git a/server/tests/api/travis-2.sh b/server/tests/api/travis-2.shnew file mode 100644index 0000000000..abeb481444--- /dev/null+++ b/server/tests/api/travis-2.sh@@ -0,0 +1,9 @@+#!/usr/bin/env sh++set -eu++serverFiles=$(find server/tests/api/server -type f | grep -v index.ts | xargs echo)+usersFiles=$(find server/tests/api/users -type f | grep -v index.ts | xargs echo)++MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 3 --timeout 5000 --exit --require ts-node/register --bail \+ $serverFiles $usersFilesdiff --git a/server/tests/api/travis-3.sh b/server/tests/api/travis-3.shnew file mode 100644index 0000000000..81e6c2e4b2--- /dev/null+++ b/server/tests/api/travis-3.sh@@ -0,0 +1,8 @@+#!/usr/bin/env sh++set -eu++videosFiles=$(find server/tests/api/videos -type f | grep -v index.ts | xargs echo)++MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 3 --timeout 5000 --exit --require ts-node/register --bail \+ $videosFilesdiff --git a/server/tests/api/travis-4.sh b/server/tests/api/travis-4.shnew file mode 100644index 0000000000..24bf5b71c8--- /dev/null+++ b/server/tests/api/travis-4.sh@@ -0,0 +1,9 @@+#!/usr/bin/env sh++set -eu++redundancyFiles=$(find server/tests/api/redundancy -type f | grep -v index.ts | xargs echo)+activitypubFiles=$(find server/tests/api/activitypub -type f | grep -v index.ts | xargs echo)++MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 3 --timeout 5000 --exit --require ts-node/register --bail \+ $redundancyFiles $activitypubFilesdiff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.tsindex 48811e647d..c8a89d6be4 100644--- a/server/tests/api/users/user-subscriptions.ts+++ b/server/tests/api/users/user-subscriptions.ts@@ -71,8 +71,8 @@ describe('Test users subscriptions', function () {it('User of server 1 should follow user of server 3 and root of server 1', async function () {this.timeout(60000)- await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003')- await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001')+ await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port)+ await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port)await waitJobs(servers)@@ -116,22 +116,22 @@ describe('Test users subscriptions', function () {it('Should get subscription', async function () {{- const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'user3_channel@localhost:9003')+ const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'user3_channel@localhost:' + servers[2].port)const videoChannel: VideoChannel = res.bodyexpect(videoChannel.name).to.equal('user3_channel')- expect(videoChannel.host).to.equal('localhost:9003')+ expect(videoChannel.host).to.equal('localhost:' + servers[2].port)expect(videoChannel.displayName).to.equal('Main user3 channel')expect(videoChannel.followingCount).to.equal(0)expect(videoChannel.followersCount).to.equal(1)}{- const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'root_channel@localhost:9001')+ const res = await getUserSubscription(servers[ 0 ].url, users[ 0 ].accessToken, 'root_channel@localhost:' + servers[0].port)const videoChannel: VideoChannel = res.bodyexpect(videoChannel.name).to.equal('root_channel')- expect(videoChannel.host).to.equal('localhost:9001')+ expect(videoChannel.host).to.equal('localhost:' + servers[0].port)expect(videoChannel.displayName).to.equal('Main root channel')expect(videoChannel.followingCount).to.equal(0)expect(videoChannel.followersCount).to.equal(1)@@ -140,19 +140,19 @@ describe('Test users subscriptions', function () {it('Should return the existing subscriptions', async function () {const uris = [- 'user3_channel@localhost:9003',- 'root2_channel@localhost:9001',- 'root_channel@localhost:9001',- 'user3_channel@localhost:9001'+ 'user3_channel@localhost:' + servers[2].port,+ 'root2_channel@localhost:' + servers[0].port,+ 'root_channel@localhost:' + servers[0].port,+ 'user3_channel@localhost:' + servers[0].port]const res = await areSubscriptionsExist(servers[ 0 ].url, users[ 0 ].accessToken, uris)const body = res.body- expect(body['user3_channel@localhost:9003']).to.be.true- expect(body['root2_channel@localhost:9001']).to.be.false- expect(body['root_channel@localhost:9001']).to.be.true- expect(body['user3_channel@localhost:9001']).to.be.false+ expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true+ expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false+ expect(body['root_channel@localhost:' + servers[0].port]).to.be.true+ expect(body['user3_channel@localhost:' + servers[0].port]).to.be.false})it('Should list subscription videos', async function () {@@ -291,7 +291,7 @@ describe('Test users subscriptions', function () {it('Should remove user of server 3 subscription', async function () {this.timeout(30000)- await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003')+ await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port)await waitJobs(servers)})@@ -312,7 +312,7 @@ describe('Test users subscriptions', function () {it('Should remove the root subscription and not display the videos anymore', async function () {this.timeout(30000)- await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:9001')+ await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port)await waitJobs(servers)@@ -340,7 +340,7 @@ describe('Test users subscriptions', function () {it('Should follow user of server 3 again', async function () {this.timeout(60000)- await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:9003')+ await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port)await waitJobs(servers)diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.tsindex 9a971adb39..988fdad3f9 100644--- a/server/tests/api/users/users-multiple-servers.ts+++ b/server/tests/api/users/users-multiple-servers.ts@@ -151,13 +151,13 @@ describe('Test users with multiple servers', function () {for (const server of servers) {const resAccounts = await getAccountsList(server.url, '-createdAt')- const rootServer1List = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:9001') as Account+ const rootServer1List = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port) as Accountexpect(rootServer1List).not.to.be.undefinedconst resAccount = await getAccount(server.url, rootServer1List.name + '@' + rootServer1List.host)const rootServer1Get = resAccount.body as Accountexpect(rootServer1Get.name).to.equal('root')- expect(rootServer1Get.host).to.equal('localhost:9001')+ expect(rootServer1Get.host).to.equal('localhost:' + servers[0].port)expect(rootServer1Get.displayName).to.equal('my super display name')expect(rootServer1Get.description).to.equal('my super description updated')@@ -188,12 +188,12 @@ describe('Test users with multiple servers', function () {for (const server of servers) {const resAccounts = await getAccountsList(server.url, '-createdAt')- const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account+ const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) as Accountexpect(accountDeleted).not.to.be.undefinedconst resVideoChannels = await getVideoChannelsList(server.url, 0, 10)const videoChannelDeleted = resVideoChannels.body.data.find(a => {- return a.displayName === 'Main user1 channel' && a.host === 'localhost:9001'+ return a.displayName === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port}) as VideoChannelexpect(videoChannelDeleted).not.to.be.undefined}@@ -205,12 +205,12 @@ describe('Test users with multiple servers', function () {for (const server of servers) {const resAccounts = await getAccountsList(server.url, '-createdAt')- const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:9001') as Account+ const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) as Accountexpect(accountDeleted).to.be.undefinedconst resVideoChannels = await getVideoChannelsList(server.url, 0, 10)const videoChannelDeleted = resVideoChannels.body.data.find(a => {- return a.name === 'Main user1 channel' && a.host === 'localhost:9001'+ return a.name === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port}) as VideoChannelexpect(videoChannelDeleted).to.be.undefined}@@ -218,14 +218,14 @@ describe('Test users with multiple servers', function () {it('Should not have actor files', async () => {for (const server of servers) {- await checkActorFilesWereRemoved(userAccountUUID, server.serverNumber)- await checkActorFilesWereRemoved(userVideoChannelUUID, server.serverNumber)+ await checkActorFilesWereRemoved(userAccountUUID, server.internalServerNumber)+ await checkActorFilesWereRemoved(userVideoChannelUUID, server.internalServerNumber)}})it('Should not have video files', async () => {for (const server of servers) {- await checkVideoFilesWereRemoved(videoUUID, server.serverNumber)+ await checkVideoFilesWereRemoved(videoUUID, server.internalServerNumber)}})diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.tsindex c8e32f3f55..c1a24b8387 100644--- a/server/tests/api/users/users.ts+++ b/server/tests/api/users/users.ts@@ -316,7 +316,7 @@ describe('Test users', function () {const rootUser = users[ 1 ]expect(rootUser.username).to.equal('root')- expect(rootUser.email).to.equal('[email protected]')+ expect(rootUser.email).to.equal('admin' + server.internalServerNumber + '@example.com')expect(user.nsfwPolicy).to.equal('display')userId = user.id@@ -334,7 +334,7 @@ describe('Test users', function () {const user = users[ 0 ]expect(user.username).to.equal('root')- expect(user.email).to.equal('[email protected]')+ expect(user.email).to.equal('admin' + server.internalServerNumber + '@example.com')expect(user.roleLabel).to.equal('Administrator')expect(user.nsfwPolicy).to.equal('display')})@@ -379,7 +379,7 @@ describe('Test users', function () {expect(users.length).to.equal(2)expect(users[ 0 ].username).to.equal('root')- expect(users[ 0 ].email).to.equal('[email protected]')+ expect(users[ 0 ].email).to.equal('admin' + server.internalServerNumber + '@example.com')expect(users[ 0 ].nsfwPolicy).to.equal('display')expect(users[ 1 ].username).to.equal('user_1')diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.tsindex 89904759a6..09b4612005 100644--- a/server/tests/api/videos/multiple-servers.ts+++ b/server/tests/api/videos/multiple-servers.ts@@ -109,7 +109,7 @@ describe('Test multiple servers', function () {// All servers should have this videolet publishedAt: string = nullfor (const server of servers) {- const isLocal = server.url === 'http://localhost:' + servers[0].port+ const isLocal = server.port === servers[0].portconst checkAttributes = {name: 'my super name for server 1',category: 5,diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.tsindex b0412f4dfb..d8f394ac74 100644--- a/server/tests/api/videos/single-server.ts+++ b/server/tests/api/videos/single-server.ts@@ -37,7 +37,7 @@ describe('Test a single server', function () {let videoUUID = ''let videosListBase: any[] = null- const getCheckAttributes = {+ const getCheckAttributes = () => ({name: 'my super name',category: 2,licence: 6,@@ -68,9 +68,9 @@ describe('Test a single server', function () {size: 218910}]- }+ })- const updateCheckAttributes = {+ const updateCheckAttributes = () => ({name: 'my super video updated',category: 4,licence: 2,@@ -101,7 +101,7 @@ describe('Test a single server', function () {size: 292677}]- }+ })before(async function () {this.timeout(30000)@@ -182,7 +182,7 @@ describe('Test a single server', function () {expect(res.body.data.length).to.equal(1)const video = res.body.data[0]- await completeVideoCheck(server.url, video, getCheckAttributes)+ await completeVideoCheck(server.url, video, getCheckAttributes())})it('Should get the video by UUID', async function () {@@ -191,7 +191,7 @@ describe('Test a single server', function () {const res = await getVideo(server.url, videoUUID)const video = res.body- await completeVideoCheck(server.url, video, getCheckAttributes)+ await completeVideoCheck(server.url, video, getCheckAttributes())})it('Should have the views updated', async function () {@@ -376,7 +376,7 @@ describe('Test a single server', function () {const res = await getVideo(server.url, videoId)const video = res.body- await completeVideoCheck(server.url, video, updateCheckAttributes)+ await completeVideoCheck(server.url, video, updateCheckAttributes())})it('Should update only the tags of a video', async function () {@@ -388,7 +388,7 @@ describe('Test a single server', function () {const res = await getVideo(server.url, videoId)const video = res.body- await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes))+ await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes(), attributes))})it('Should update only the description of a video', async function () {@@ -400,7 +400,8 @@ describe('Test a single server', function () {const res = await getVideo(server.url, videoId)const video = res.body- await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes))+ const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes)+ await completeVideoCheck(server.url, video, expectedAttributes)})it('Should like a video', async function () {diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.tsindex 1c0327d408..3a3add71b0 100644--- a/server/tests/api/videos/video-change-ownership.ts+++ b/server/tests/api/videos/video-change-ownership.ts@@ -4,7 +4,8 @@ import * as chai from 'chai'import 'mocha'import {acceptChangeOwnership,- changeVideoOwnership, cleanupTests,+ changeVideoOwnership,+ cleanupTests,createUser,doubleFollow,flushAndRunMultipleServers,@@ -13,7 +14,6 @@ import {getVideo,getVideoChangeOwnershipList,getVideosList,- killallServers,refuseChangeOwnership,ServerInfo,setAccessTokensToServers,@@ -203,8 +203,8 @@ describe('Test video change ownership - nominal', function () {}})- after(function () {- killallServers(servers)+ after(async function () {+ await cleanupTests(servers)})})diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.tsindex f091484049..41fe3be5cf 100644--- a/server/tests/api/videos/video-channels.ts+++ b/server/tests/api/videos/video-channels.ts@@ -41,7 +41,7 @@ describe('Test video channels', function () {let videoUUID: stringbefore(async function () {- this.timeout(30000)+ this.timeout(60000)servers = await flushAndRunMultipleServers(2)@@ -213,7 +213,7 @@ describe('Test video channels', function () {this.timeout(10000)for (const server of servers) {- const channelURI = 'second_video_channel@localhost:' + server.port+ const channelURI = 'second_video_channel@localhost:' + servers[0].portconst res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)expect(res1.body.total).to.equal(1)expect(res1.body.data).to.be.an('array')@@ -234,11 +234,11 @@ describe('Test video channels', function () {this.timeout(10000)for (const server of servers) {- const secondChannelURI = 'second_video_channel@localhost:' + server.port+ const secondChannelURI = 'second_video_channel@localhost:' + servers[0].portconst res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5)expect(res1.body.total).to.equal(0)- const channelURI = 'root_channel@localhost:' + server.port+ const channelURI = 'root_channel@localhost:' + servers[0].portconst res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)expect(res2.body.total).to.equal(1)diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.tsindex 4565d0ebe6..504c50dee0 100644--- a/server/tests/api/videos/video-hls.ts+++ b/server/tests/api/videos/video-hls.ts@@ -50,7 +50,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) {{for (const resolution of resolutions) {- const res2 = await getPlaylist(`http://localhost:${server.port}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`)+ const res2 = await getPlaylist(`http://localhost:${servers[0].port}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`)const subPlaylist = res2.textexpect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`)@@ -58,7 +58,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) {}{- const baseUrl = 'http://localhost:' + server.port + '/static/streaming-playlists/hls'+ const baseUrl = 'http://localhost:' + servers[0].port + '/static/streaming-playlists/hls'for (const resolution of resolutions) {await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist)diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.tsindex e4d817ff8b..83a2f3d4d8 100644--- a/server/tests/api/videos/video-playlists.ts+++ b/server/tests/api/videos/video-playlists.ts@@ -358,7 +358,7 @@ describe('Test video playlists', function () {for (const server of servers) {const results = [- await getAccountPlaylistsList(server.url, 'root@localhost:9002', 0, 5, '-createdAt'),+ await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'),await getVideoPlaylistsList(server.url, 0, 2, '-createdAt')]@@ -757,7 +757,7 @@ describe('Test video playlists', function () {this.timeout(30000)for (const server of servers) {- await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.serverNumber)+ await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.internalServerNumber)}})diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.tsindex c21d46d569..fbddd40f49 100644--- a/server/tests/api/videos/videos-views-cleaner.ts+++ b/server/tests/api/videos/videos-views-cleaner.ts@@ -10,7 +10,7 @@ import {flushAndRunServer,ServerInfo,setAccessTokensToServers,- uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests+ uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests, closeAllSequelize} from '../../../../shared/extra-utils'import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'import { VideosOverview } from '../../../../shared/models/overviews'@@ -58,14 +58,14 @@ describe('Test video views cleaner', function () {{for (const server of servers) {- const total = await countVideoViewsOf(server.serverNumber, videoIdServer1)+ const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1)expect(total).to.equal(2)}}{for (const server of servers) {- const total = await countVideoViewsOf(server.serverNumber, videoIdServer2)+ const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer2)expect(total).to.equal(2)}}@@ -74,8 +74,6 @@ describe('Test video views cleaner', function () {it('Should clean old video views', async function () {this.timeout(50000)- this.timeout(50000)-killallServers([ servers[0] ])await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } })@@ -86,21 +84,23 @@ describe('Test video views cleaner', function () {{for (const server of servers) {- const total = await countVideoViewsOf(server.serverNumber, videoIdServer1)+ const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1)expect(total).to.equal(2)}}{- const totalServer1 = await countVideoViewsOf(servers[0].serverNumber, videoIdServer2)+ const totalServer1 = await countVideoViewsOf(servers[0].internalServerNumber, videoIdServer2)expect(totalServer1).to.equal(0)- const totalServer2 = await countVideoViewsOf(servers[1].serverNumber, videoIdServer2)+ const totalServer2 = await countVideoViewsOf(servers[1].internalServerNumber, videoIdServer2)expect(totalServer2).to.equal(2)}})after(async function () {+ await closeAllSequelize(servers)+await cleanupTests(servers)})})diff --git a/shared/extra-utils/miscs/sql.ts b/shared/extra-utils/miscs/sql.tsindex 3cfae5c23b..34477cb78b 100644--- a/shared/extra-utils/miscs/sql.ts+++ b/shared/extra-utils/miscs/sql.ts@@ -1,11 +1,12 @@import { QueryTypes, Sequelize } from 'sequelize'+import { ServerInfo } from '../server/servers'let sequelizes: { [ id: number ]: Sequelize } = {}-function getSequelize (serverNumber: number) {- if (sequelizes[serverNumber]) return sequelizes[serverNumber]+function getSequelize (internalServerNumber: number) {+ if (sequelizes[internalServerNumber]) return sequelizes[internalServerNumber]- const dbname = 'peertube_test' + serverNumber+ const dbname = 'peertube_test' + internalServerNumberconst username = 'peertube'const password = 'peertube'const host = 'localhost'@@ -18,37 +19,37 @@ function getSequelize (serverNumber: number) {logging: false})- sequelizes[serverNumber] = seq+ sequelizes[internalServerNumber] = seqreturn seq}-function setActorField (serverNumber: number, to: string, field: string, value: string) {- const seq = getSequelize(serverNumber)+function setActorField (internalServerNumber: number, to: string, field: string, value: string) {+ const seq = getSequelize(internalServerNumber)const options = { type: QueryTypes.UPDATE }return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options)}-function setVideoField (serverNumber: number, uuid: string, field: string, value: string) {- const seq = getSequelize(serverNumber)+function setVideoField (internalServerNumber: number, uuid: string, field: string, value: string) {+ const seq = getSequelize(internalServerNumber)const options = { type: QueryTypes.UPDATE }return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)}-function setPlaylistField (serverNumber: number, uuid: string, field: string, value: string) {- const seq = getSequelize(serverNumber)+function setPlaylistField (internalServerNumber: number, uuid: string, field: string, value: string) {+ const seq = getSequelize(internalServerNumber)const options = { type: QueryTypes.UPDATE }return seq.query(`UPDATE "videoPlaylist" SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)}-async function countVideoViewsOf (serverNumber: number, uuid: string) {- const seq = getSequelize(serverNumber)+async function countVideoViewsOf (internalServerNumber: number, uuid: string) {+ const seq = getSequelize(internalServerNumber)// tslint:disableconst query = `SELECT SUM("videoView"."views") AS "total" FROM "videoView" INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'`@@ -62,11 +63,11 @@ async function countVideoViewsOf (serverNumber: number, uuid: string) {return parseInt(total + '', 10)}-async function closeAllSequelize (servers: any[]) {- for (let i = 1; i <= servers.length; i++) {- if (sequelizes[ i ]) {- await sequelizes[ i ].close()- delete sequelizes[ i ]+async function closeAllSequelize (servers: ServerInfo[]) {+ for (const server of servers) {+ if (sequelizes[ server.internalServerNumber ]) {+ await sequelizes[ server.internalServerNumber ].close()+ delete sequelizes[ server.internalServerNumber ]}}}diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.tsindex 3992735e10..4c7d6862ae 100644--- a/shared/extra-utils/server/servers.ts+++ b/shared/extra-utils/server/servers.ts@@ -246,7 +246,7 @@ async function checkTmpIsEmpty (server: ServerInfo) {}async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) {- const testDirectory = 'test' + server.serverNumber+ const testDirectory = 'test' + server.internalServerNumberconst directoryPath = join(root(), testDirectory, directory)diff --git a/shared/extra-utils/videos/video-playlists.ts b/shared/extra-utils/videos/video-playlists.tsindex 4d110a1312..fd62bef199 100644--- a/shared/extra-utils/videos/video-playlists.ts+++ b/shared/extra-utils/videos/video-playlists.ts@@ -252,10 +252,10 @@ function reorderVideosPlaylist (options: {async function checkPlaylistFilesWereRemoved (playlistUUID: string,- serverNumber: number,+ internalServerNumber: number,directories = [ 'thumbnails' ]) {- const testDirectory = 'test' + serverNumber+ const testDirectory = 'test' + internalServerNumberfor (const directory of directories) {const directoryPath = join(root(), testDirectory, directory)diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.tsindex b5a07b792d..b64de24707 100644--- a/shared/extra-utils/videos/videos.ts+++ b/shared/extra-utils/videos/videos.ts@@ -568,8 +568,8 @@ async function completeVideoCheck (expect(file).not.to.be.undefinedlet extension = extname(attributes.fixture)- // Transcoding enabled on server 2, extension will always be .mp4- if (attributes.account.host === 'localhost:9002') extension = '.mp4'+ // Transcoding enabled: extension will always be .mp4+ if (attributes.files.length > 1) extension = '.mp4'const magnetUri = file.magnetUriexpect(file.magnetUri).to.have.lengthOf.above(2)