All API tests in parallel

This commit is contained in:
Chocobozzz 2019-04-26 08:50:52 +02:00
parent 7243f84db0
commit 48f07b4a40
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
34 changed files with 286 additions and 222 deletions

View File

@ -23,13 +23,13 @@ elif [ "$1" = "api-1" ]; then
sh ./server/tests/api/travis-1.sh
elif [ "$1" = "api-2" ]; then
npm run build:server
mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-2.ts
sh ./server/tests/api/travis-2.sh
elif [ "$1" = "api-3" ]; then
npm run build:server
mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-3.ts
sh ./server/tests/api/travis-3.sh
elif [ "$1" = "api-4" ]; then
npm run build:server
mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/index-4.ts
sh ./server/tests/api/travis-4.sh
elif [ "$1" = "lint" ]; then
npm run tslint -- --project ./tsconfig.json -c ./tslint.json server.ts "server/**/*.ts" "shared/**/*.ts"

View File

@ -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.body
expect(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.body
expect(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)
})
})

View File

@ -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.uuid
await 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)
})

View File

@ -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 refresh
await 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)
})
})

View File

@ -3,9 +3,9 @@
import 'mocha'
import {
cleanupTests,
closeAllSequelize,
flushAndRunMultipleServers,
flushTests,
killallServers,
ServerInfo,
setActorField
@ -18,18 +18,26 @@ import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-u
const 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)
})

View File

@ -1,2 +0,0 @@
import './server'
import './users'

View File

@ -1 +0,0 @@
import './videos'

View File

@ -1,2 +0,0 @@
import './redundancy'
import './activitypub'

View File

@ -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'

View File

@ -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('admin1@example.com')
expect(data.admin.email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(data.contactForm.enabled).to.be.true
expect(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('superadmin1@example.com')
// We override admin email in parallel tests, so skip this exception
if (parallelTests() === false) {
expect(data.admin.email).to.equal('superadmin1@example.com')
}
expect(data.contactForm.enabled).to.be.false
expect(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 () {

View File

@ -54,7 +54,7 @@ describe('Test contact form', function () {
expect(email['from'][0]['address']).equal('test-admin@localhost')
expect(email['from'][0]['name']).equal('toto@example.com')
expect(email['to'][0]['address']).equal('admin1@example.com')
expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com')
expect(email['subject']).contains('Contact form')
expect(email['text']).contains('my super message')
})

View File

@ -37,15 +37,17 @@ describe('Test emails', function () {
username: 'user_1',
password: 'super_password'
}
let emailPort: number
before(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('admin1@example.com')
expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com')
expect(email['subject']).contains('abuse')
expect(email['text']).contains(videoUUID)
})

View File

@ -29,7 +29,7 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc
const follow = res.body.data[0] as ActorFollow
expect(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 = 'acc
const follow = res.body.data[0] as ActorFollow
expect(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')
}
}

View File

@ -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.data
expect(res.body.total).to.equal(1)

View File

@ -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: any
before(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 tokens
await setAccessTokensToServers(servers)
})

View File

@ -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 ])

View File

@ -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 $checkParamFiles

View File

@ -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 $usersFiles

View File

@ -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 \
$videosFiles

View File

@ -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 $activitypubFiles

View File

@ -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.body
expect(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.body
expect(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)

View File

@ -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 Account
expect(rootServer1List).not.to.be.undefined
const resAccount = await getAccount(server.url, rootServer1List.name + '@' + rootServer1List.host)
const rootServer1Get = resAccount.body as Account
expect(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 Account
expect(accountDeleted).not.to.be.undefined
const 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 VideoChannel
expect(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 Account
expect(accountDeleted).to.be.undefined
const 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 VideoChannel
expect(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)
}
})

View File

@ -316,7 +316,7 @@ describe('Test users', function () {
const rootUser = users[ 1 ]
expect(rootUser.username).to.equal('root')
expect(rootUser.email).to.equal('admin1@example.com')
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('admin1@example.com')
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('admin1@example.com')
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')

View File

@ -109,7 +109,7 @@ describe('Test multiple servers', function () {
// All servers should have this video
let publishedAt: string = null
for (const server of servers) {
const isLocal = server.url === 'http://localhost:' + servers[0].port
const isLocal = server.port === servers[0].port
const checkAttributes = {
name: 'my super name for server 1',
category: 5,

View File

@ -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 () {

View File

@ -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)
})
})

View File

@ -41,7 +41,7 @@ describe('Test video channels', function () {
let videoUUID: string
before(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].port
const 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].port
const 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].port
const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5)
expect(res2.body.total).to.equal(1)

View File

@ -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.text
expect(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)

View File

@ -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)
}
})

View File

@ -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)
})
})

View File

@ -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' + internalServerNumber
const username = 'peertube'
const password = 'peertube'
const host = 'localhost'
@ -18,37 +19,37 @@ function getSequelize (serverNumber: number) {
logging: false
})
sequelizes[serverNumber] = seq
sequelizes[internalServerNumber] = seq
return 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:disable
const 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 ]
}
}
}

View File

@ -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.internalServerNumber
const directoryPath = join(root(), testDirectory, directory)

View File

@ -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' + internalServerNumber
for (const directory of directories) {
const directoryPath = join(root(), testDirectory, directory)

View File

@ -568,8 +568,8 @@ async function completeVideoCheck (
expect(file).not.to.be.undefined
let 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.magnetUri
expect(file.magnetUri).to.have.lengthOf.above(2)