Speed up activity pub http requests

This commit is contained in:
Chocobozzz
2017-11-17 11:35:10 +01:00
parent 1b3989b096
commit afffe98839
26 changed files with 517 additions and 437 deletions

View File

@@ -10,4 +10,3 @@ import './video-blacklist-management'
import './video-description'
import './video-privacy'
import './services'
import './request-schedulers'

View File

@@ -113,7 +113,7 @@ describe('Test multiple pods', function () {
expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ])
expect(dateIsValid(video.createdAt)).to.be.true
expect(dateIsValid(video.updatedAt)).to.be.true
expect(video.author).to.equal('root')
expect(video.account).to.equal('root')
const res2 = await getVideo(server.url, video.uuid)
const videoDetails = res2.body
@@ -202,7 +202,7 @@ describe('Test multiple pods', function () {
expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ])
expect(dateIsValid(video.createdAt)).to.be.true
expect(dateIsValid(video.updatedAt)).to.be.true
expect(video.author).to.equal('user1')
expect(video.account).to.equal('user1')
if (server.url !== 'http://localhost:9002') {
expect(video.isLocal).to.be.false
@@ -696,7 +696,7 @@ describe('Test multiple pods', function () {
expect(baseVideo.licence).to.equal(video.licence)
expect(baseVideo.category).to.equal(video.category)
expect(baseVideo.nsfw).to.equal(video.nsfw)
expect(baseVideo.author).to.equal(video.author)
expect(baseVideo.author).to.equal(video.account)
expect(baseVideo.tags).to.deep.equal(video.tags)
}
})

View File

@@ -1,82 +0,0 @@
/* tslint:disable:no-unused-expression */
import 'mocha'
import * as chai from 'chai'
const expect = chai.expect
import {
ServerInfo,
flushTests,
uploadVideo,
makeFriends,
wait,
setAccessTokensToServers,
flushAndRunMultipleServers,
getRequestsStats,
killallServers
} from '../utils'
describe('Test requests schedulers stats', function () {
const requestSchedulerNames = [ 'requestScheduler', 'requestVideoQaduScheduler', 'requestVideoEventScheduler' ]
let servers: ServerInfo[] = []
function uploadVideoWrapper (server: ServerInfo) {
const videoAttributes = {
tags: [ 'tag1', 'tag2' ]
}
return uploadVideo(server.url, server.accessToken, videoAttributes)
}
// ---------------------------------------------------------------
before(async function () {
this.timeout(120000)
servers = await flushAndRunMultipleServers(2)
await setAccessTokensToServers(servers)
await makeFriends(servers[0].url, servers[0].accessToken)
})
it('Should have a correct timer', async function () {
const server = servers[0]
const res = await getRequestsStats(server)
const requestSchedulers = res.body
for (const requestSchedulerName of requestSchedulerNames) {
const requestScheduler = requestSchedulers[requestSchedulerName]
expect(requestScheduler.remainingMilliSeconds).to.be.at.least(0)
expect(requestScheduler.remainingMilliSeconds).to.be.at.most(10000)
}
})
it('Should have the correct total request', async function () {
this.timeout(15000)
const server = servers[0]
// Ensure the requests of pod 1 won't be made
servers[1].app.kill()
await uploadVideoWrapper(server)
await wait(1000)
const res = await getRequestsStats(server)
const requestSchedulers = res.body
const requestScheduler = requestSchedulers.requestScheduler
expect(requestScheduler.totalRequests).to.equal(3)
})
after(async function () {
// Server 1 has already been killed
killallServers([ servers[0] ])
if (this['ok']) {
await flushTests()
}
})
})

View File

@@ -14,6 +14,7 @@ import {
getOEmbed
} from '../utils'
import { runServer } from '../utils/servers'
import { Video } from '../../../client/src/app/videos/shared/video.model'
describe('Test services', function () {
let server: ServerInfo = null
@@ -46,7 +47,7 @@ describe('Test services', function () {
expect(res.body.html).to.equal(expectedHtml)
expect(res.body.title).to.equal(server.video.name)
expect(res.body.author_name).to.equal(server.video.author)
expect(res.body.author_name).to.equal(server.video.account)
expect(res.body.width).to.equal(560)
expect(res.body.height).to.equal(315)
expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
@@ -66,7 +67,7 @@ describe('Test services', function () {
expect(res.body.html).to.equal(expectedHtml)
expect(res.body.title).to.equal(server.video.name)
expect(res.body.author_name).to.equal(server.video.author)
expect(res.body.author_name).to.equal(server.video.account)
expect(res.body.height).to.equal(50)
expect(res.body.width).to.equal(50)
expect(res.body).to.not.have.property('thumbnail_url')

View File

@@ -125,8 +125,8 @@ describe('Test a single pod', function () {
expect(video.languageLabel).to.equal('Mandarin')
expect(video.nsfw).to.be.ok
expect(video.description).to.equal('my super description')
expect(video.podHost).to.equal('localhost:9001')
expect(video.author).to.equal('root')
expect(video.serverHost).to.equal('localhost:9001')
expect(video.account).to.equal('root')
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
expect(dateIsValid(video.createdAt)).to.be.true
@@ -174,8 +174,8 @@ describe('Test a single pod', function () {
expect(video.languageLabel).to.equal('Mandarin')
expect(video.nsfw).to.be.ok
expect(video.description).to.equal('my super description')
expect(video.podHost).to.equal('localhost:9001')
expect(video.author).to.equal('root')
expect(video.serverHost).to.equal('localhost:9001')
expect(video.account).to.equal('root')
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
expect(dateIsValid(video.createdAt)).to.be.true
@@ -237,8 +237,8 @@ describe('Test a single pod', function () {
expect(video.languageLabel).to.equal('Mandarin')
expect(video.nsfw).to.be.ok
expect(video.description).to.equal('my super description')
expect(video.podHost).to.equal('localhost:9001')
expect(video.author).to.equal('root')
expect(video.serverHost).to.equal('localhost:9001')
expect(video.account).to.equal('root')
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
expect(dateIsValid(video.createdAt)).to.be.true
@@ -249,7 +249,7 @@ describe('Test a single pod', function () {
})
// Not implemented yet
// it('Should search the video by podHost', async function () {
// it('Should search the video by serverHost', async function () {
// const res = await videosUtils.searchVideo(server.url, '9001', 'host')
// expect(res.body.total).to.equal(1)
@@ -259,7 +259,7 @@ describe('Test a single pod', function () {
// const video = res.body.data[0]
// expect(video.name).to.equal('my super name')
// expect(video.description).to.equal('my super description')
// expect(video.podHost).to.equal('localhost:9001')
// expect(video.serverHost).to.equal('localhost:9001')
// expect(video.author).to.equal('root')
// expect(video.isLocal).to.be.true
// expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
@@ -291,8 +291,8 @@ describe('Test a single pod', function () {
expect(video.languageLabel).to.equal('Mandarin')
expect(video.nsfw).to.be.ok
expect(video.description).to.equal('my super description')
expect(video.podHost).to.equal('localhost:9001')
expect(video.author).to.equal('root')
expect(video.serverHost).to.equal('localhost:9001')
expect(video.account).to.equal('root')
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
expect(dateIsValid(video.createdAt)).to.be.true
@@ -311,7 +311,7 @@ describe('Test a single pod', function () {
})
it('Should not find a search by author', async function () {
const res = await searchVideo(server.url, 'hello', 'author')
const res = await searchVideo(server.url, 'hello', 'account')
expect(res.body.total).to.equal(0)
expect(res.body.data).to.be.an('array')
@@ -352,7 +352,7 @@ describe('Test a single pod', function () {
'video_short1.webm', 'video_short2.webm', 'video_short3.webm'
]
const tasks: Promise<any>[] = []
// const tasks: Promise<any>[] = []
for (const video of videos) {
const videoAttributes = {
name: video + ' name',
@@ -366,10 +366,13 @@ describe('Test a single pod', function () {
}
const p = uploadVideo(server.url, server.accessToken, videoAttributes)
tasks.push(p)
await p
}
await Promise.all(tasks)
// FIXME: concurrent uploads does not work :(
// tasks.push(p)
// }
//
// await Promise.all(tasks)
})
it('Should have the correct durations', async function () {
@@ -462,7 +465,7 @@ describe('Test a single pod', function () {
})
it('Should search all the root author videos', async function () {
const res = await searchVideoWithPagination(server.url, 'root', 'author', 0, 15)
const res = await searchVideoWithPagination(server.url, 'root', 'account', 0, 15)
const videos = res.body.data
expect(res.body.total).to.equal(6)
@@ -550,8 +553,8 @@ describe('Test a single pod', function () {
expect(video.languageLabel).to.equal('Arabic')
expect(video.nsfw).to.be.ok
expect(video.description).to.equal('my super description updated')
expect(video.podHost).to.equal('localhost:9001')
expect(video.author).to.equal('root')
expect(video.serverHost).to.equal('localhost:9001')
expect(video.account).to.equal('root')
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
expect(dateIsValid(video.createdAt)).to.be.true
@@ -599,8 +602,8 @@ describe('Test a single pod', function () {
expect(video.languageLabel).to.equal('Arabic')
expect(video.nsfw).to.be.ok
expect(video.description).to.equal('my super description updated')
expect(video.podHost).to.equal('localhost:9001')
expect(video.author).to.equal('root')
expect(video.serverHost).to.equal('localhost:9001')
expect(video.account).to.equal('root')
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ])
expect(dateIsValid(video.createdAt)).to.be.true
@@ -639,8 +642,8 @@ describe('Test a single pod', function () {
expect(video.languageLabel).to.equal('Arabic')
expect(video.nsfw).to.be.ok
expect(video.description).to.equal('hello everybody')
expect(video.podHost).to.equal('localhost:9001')
expect(video.author).to.equal('root')
expect(video.serverHost).to.equal('localhost:9001')
expect(video.account).to.equal('root')
expect(video.isLocal).to.be.true
expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ])
expect(dateIsValid(video.createdAt)).to.be.true

View File

@@ -1,38 +1,36 @@
/* tslint:disable:no-unused-expression */
import 'mocha'
import * as chai from 'chai'
const expect = chai.expect
import 'mocha'
import { UserRole } from '../../../shared'
import {
ServerInfo,
flushTests,
runServer,
login,
uploadVideo,
makeFriends,
quitFriends,
getVideosList,
rateVideo,
getUserVideoRating,
removeVideo,
makePutBodyRequest,
createUser,
loginAndGetAccessToken,
flushTests,
getBlacklistedVideosList,
getMyUserInformation,
getUserInformation,
getUsersList,
getUsersListPaginationAndSort,
updateUser,
updateMyUser,
getUserVideoRating,
getVideosList,
killallServers,
login,
loginAndGetAccessToken,
makePutBodyRequest,
rateVideo,
registerUser,
removeUser,
killallServers,
getUserInformation,
getBlacklistedVideosList
removeVideo,
runServer,
ServerInfo,
updateMyUser,
updateUser,
uploadVideo
} from '../utils'
import { UserRole } from '../../../shared'
import { follow } from '../utils/follows'
import { getMyVideos } from '../utils/videos'
const expect = chai.expect
describe('Test users', function () {
let server: ServerInfo
let accessToken: string
@@ -57,28 +55,36 @@ describe('Test users', function () {
const client = { id: 'client', secret: server.client.secret }
const res = await login(server.url, client, server.user, 400)
expect(res.body.error).to.equal('invalid_client')
expect(res.body.error)
.to
.equal('invalid_client')
})
it('Should not login with an invalid client secret', async function () {
const client = { id: server.client.id, secret: 'coucou' }
const res = await login(server.url, client, server.user, 400)
expect(res.body.error).to.equal('invalid_client')
expect(res.body.error)
.to
.equal('invalid_client')
})
it('Should not login with an invalid username', async function () {
const user = { username: 'captain crochet', password: server.user.password }
const res = await login(server.url, server.client, user, 400)
expect(res.body.error).to.equal('invalid_grant')
expect(res.body.error)
.to
.equal('invalid_grant')
})
it('Should not login with an invalid password', async function () {
const user = { username: server.user.username, password: 'mew_three' }
const res = await login(server.url, server.client, user, 400)
expect(res.body.error).to.equal('invalid_grant')
expect(res.body.error)
.to
.equal('invalid_grant')
})
it('Should not be able to upload a video', async function () {
@@ -88,15 +94,12 @@ describe('Test users', function () {
await uploadVideo(server.url, accessToken, videoAttributes, 401)
})
it('Should not be able to make friends', async function () {
it('Should not be able to follow', async function () {
accessToken = 'my_super_token'
await makeFriends(server.url, accessToken, 401)
await follow(server.url, [ 'http://example.com' ], accessToken, 401)
})
it('Should not be able to quit friends', async function () {
accessToken = 'my_super_token'
await quitFriends(server.url, accessToken, 401)
})
it('Should not be able to unfollow')
it('Should be able to login', async function () {
const res = await login(server.url, server.client, server.user, 200)
@@ -108,9 +111,11 @@ describe('Test users', function () {
const videoAttributes = {}
await uploadVideo(server.url, accessToken, videoAttributes, 204)
const res = await getVideosList(server.url)
const video = res.body.data[0]
const video = res.body.data[ 0 ]
expect(video.author).to.equal('root')
expect(video.account)
.to
.equal('root')
videoId = video.id
})
@@ -124,8 +129,12 @@ describe('Test users', function () {
const res = await getUserVideoRating(server.url, accessToken, videoId)
const rating = res.body
expect(rating.videoId).to.equal(videoId)
expect(rating.rating).to.equal('like')
expect(rating.videoId)
.to
.equal(videoId)
expect(rating.rating)
.to
.equal('like')
})
it('Should not be able to remove the video with an incorrect token', async function () {
@@ -187,12 +196,23 @@ describe('Test users', function () {
const res = await getMyUserInformation(server.url, accessTokenUser)
const user = res.body
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('user_1@example.com')
expect(user.username)
.to
.equal('user_1')
expect(user.email)
.to
.equal('user_1@example.com')
expect(user.displayNSFW).to.be.false
expect(user.videoQuota).to.equal(2 * 1024 * 1024)
expect(user.roleLabel).to.equal('User')
expect(user.id).to.be.a('number')
expect(user.videoQuota)
.to
.equal(2 * 1024 * 1024)
expect(user.roleLabel)
.to
.equal('User')
expect(user.id)
.to
.be
.a('number')
})
it('Should be able to upload a video with this user', async function () {
@@ -206,12 +226,19 @@ describe('Test users', function () {
it('Should be able to list my videos', async function () {
const res = await getMyVideos(server.url, accessTokenUser, 0, 5)
expect(res.body.total).to.equal(1)
expect(res.body.total)
.to
.equal(1)
const videos = res.body.data
expect(videos).to.have.lengthOf(1)
expect(videos)
.to
.have
.lengthOf(1)
expect(videos[0].name).to.equal('super user video')
expect(videos[ 0 ].name)
.to
.equal('super user video')
})
it('Should list all the users', async function () {
@@ -220,18 +247,33 @@ describe('Test users', function () {
const total = result.total
const users = result.data
expect(total).to.equal(2)
expect(users).to.be.an('array')
expect(users.length).to.equal(2)
expect(total)
.to
.equal(2)
expect(users)
.to
.be
.an('array')
expect(users.length)
.to
.equal(2)
const user = users[0]
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('user_1@example.com')
const user = users[ 0 ]
expect(user.username)
.to
.equal('user_1')
expect(user.email)
.to
.equal('user_1@example.com')
expect(user.displayNSFW).to.be.false
const rootUser = users[1]
expect(rootUser.username).to.equal('root')
expect(rootUser.email).to.equal('admin1@example.com')
const rootUser = users[ 1 ]
expect(rootUser.username)
.to
.equal('root')
expect(rootUser.email)
.to
.equal('admin1@example.com')
expect(rootUser.displayNSFW).to.be.false
userId = user.id
@@ -244,13 +286,23 @@ describe('Test users', function () {
const total = result.total
const users = result.data
expect(total).to.equal(2)
expect(users.length).to.equal(1)
expect(total)
.to
.equal(2)
expect(users.length)
.to
.equal(1)
const user = users[0]
expect(user.username).to.equal('root')
expect(user.email).to.equal('admin1@example.com')
expect(user.roleLabel).to.equal('Administrator')
const user = users[ 0 ]
expect(user.username)
.to
.equal('root')
expect(user.email)
.to
.equal('admin1@example.com')
expect(user.roleLabel)
.to
.equal('Administrator')
expect(user.displayNSFW).to.be.false
})
@@ -260,12 +312,20 @@ describe('Test users', function () {
const total = result.total
const users = result.data
expect(total).to.equal(2)
expect(users.length).to.equal(1)
expect(total)
.to
.equal(2)
expect(users.length)
.to
.equal(1)
const user = users[0]
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('user_1@example.com')
const user = users[ 0 ]
expect(user.username)
.to
.equal('user_1')
expect(user.email)
.to
.equal('user_1@example.com')
expect(user.displayNSFW).to.be.false
})
@@ -275,12 +335,20 @@ describe('Test users', function () {
const total = result.total
const users = result.data
expect(total).to.equal(2)
expect(users.length).to.equal(1)
expect(total)
.to
.equal(2)
expect(users.length)
.to
.equal(1)
const user = users[0]
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('user_1@example.com')
const user = users[ 0 ]
expect(user.username)
.to
.equal('user_1')
expect(user.email)
.to
.equal('user_1@example.com')
expect(user.displayNSFW).to.be.false
})
@@ -290,16 +358,28 @@ describe('Test users', function () {
const total = result.total
const users = result.data
expect(total).to.equal(2)
expect(users.length).to.equal(2)
expect(total)
.to
.equal(2)
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].displayNSFW).to.be.false
expect(users[ 0 ].username)
.to
.equal('root')
expect(users[ 0 ].email)
.to
.equal('admin1@example.com')
expect(users[ 0 ].displayNSFW).to.be.false
expect(users[1].username).to.equal('user_1')
expect(users[1].email).to.equal('user_1@example.com')
expect(users[1].displayNSFW).to.be.false
expect(users[ 1 ].username)
.to
.equal('user_1')
expect(users[ 1 ].email)
.to
.equal('user_1@example.com')
expect(users[ 1 ].displayNSFW).to.be.false
})
it('Should update my password', async function () {
@@ -315,11 +395,20 @@ describe('Test users', function () {
const res = await getMyUserInformation(server.url, accessTokenUser)
const user = res.body
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('user_1@example.com')
expect(user.username)
.to
.equal('user_1')
expect(user.email)
.to
.equal('user_1@example.com')
expect(user.displayNSFW).to.be.ok
expect(user.videoQuota).to.equal(2 * 1024 * 1024)
expect(user.id).to.be.a('number')
expect(user.videoQuota)
.to
.equal(2 * 1024 * 1024)
expect(user.id)
.to
.be
.a('number')
})
it('Should be able to change the email display attribute', async function () {
@@ -328,11 +417,20 @@ describe('Test users', function () {
const res = await getMyUserInformation(server.url, accessTokenUser)
const user = res.body
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('updated@example.com')
expect(user.username)
.to
.equal('user_1')
expect(user.email)
.to
.equal('updated@example.com')
expect(user.displayNSFW).to.be.ok
expect(user.videoQuota).to.equal(2 * 1024 * 1024)
expect(user.id).to.be.a('number')
expect(user.videoQuota)
.to
.equal(2 * 1024 * 1024)
expect(user.id)
.to
.be
.a('number')
})
it('Should be able to update another user', async function () {
@@ -341,12 +439,23 @@ describe('Test users', function () {
const res = await getUserInformation(server.url, accessToken, userId)
const user = res.body
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('updated2@example.com')
expect(user.username)
.to
.equal('user_1')
expect(user.email)
.to
.equal('updated2@example.com')
expect(user.displayNSFW).to.be.ok
expect(user.videoQuota).to.equal(42)
expect(user.roleLabel).to.equal('Moderator')
expect(user.id).to.be.a('number')
expect(user.videoQuota)
.to
.equal(42)
expect(user.roleLabel)
.to
.equal('Moderator')
expect(user.id)
.to
.be
.a('number')
})
it('Should not be able to delete a user by a moderator', async function () {
@@ -369,10 +478,14 @@ describe('Test users', function () {
it('Should not have videos of this user', async function () {
const res = await getVideosList(server.url)
expect(res.body.total).to.equal(1)
expect(res.body.total)
.to
.equal(1)
const video = res.body.data[0]
expect(video.author).to.equal('root')
const video = res.body.data[ 0 ]
expect(video.account)
.to
.equal('root')
})
it('Should register a new user', async function () {
@@ -392,14 +505,16 @@ describe('Test users', function () {
const res = await getMyUserInformation(server.url, accessToken)
const user = res.body
expect(user.videoQuota).to.equal(5 * 1024 * 1024)
expect(user.videoQuota)
.to
.equal(5 * 1024 * 1024)
})
after(async function () {
killallServers([ server ])
// Keep the logs if the test failed
if (this['ok']) {
if (this[ 'ok' ]) {
await flushTests()
}
})

View File

@@ -1,22 +1,22 @@
/* tslint:disable:no-unused-expression */
import 'mocha'
import * as chai from 'chai'
const expect = chai.expect
import 'mocha'
import {
ServerInfo,
flushAndRunMultipleServers,
uploadVideo,
makeFriends,
getVideosList,
wait,
setAccessTokensToServers,
flushTests,
getVideoAbusesList,
reportVideoAbuse,
getVideosList,
killallServers,
flushTests
reportVideoAbuse,
ServerInfo,
setAccessTokensToServers,
uploadVideo,
wait
} from '../utils'
import { doubleFollow } from '../utils/follows'
const expect = chai.expect
describe('Test video abuses', function () {
let servers: ServerInfo[] = []
@@ -30,32 +30,32 @@ describe('Test video abuses', function () {
// Get the access tokens
await setAccessTokensToServers(servers)
// Pod 1 makes friend with pod 2
await makeFriends(servers[0].url, servers[0].accessToken)
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
// Upload some videos on each pods
// Upload some videos on each servers
const video1Attributes = {
name: 'my super name for pod 1',
description: 'my super description for pod 1'
name: 'my super name for server 1',
description: 'my super description for server 1'
}
await uploadVideo(servers[0].url, servers[0].accessToken, video1Attributes)
const video2Attributes = {
name: 'my super name for pod 2',
description: 'my super description for pod 2'
name: 'my super name for server 2',
description: 'my super description for server 2'
}
await uploadVideo(servers[1].url, servers[1].accessToken, video2Attributes)
// Wait videos propagation
await wait(22000)
await wait(25000)
const res = await getVideosList(servers[0].url)
const videos = res.body.data
expect(videos.length).to.equal(2)
servers[0].video = videos.find(video => video.name === 'my super name for pod 1')
servers[1].video = videos.find(video => video.name === 'my super name for pod 2')
servers[0].video = videos.find(video => video.name === 'my super name for server 1')
servers[1].video = videos.find(video => video.name === 'my super name for server 2')
})
it('Should not have video abuses', async function () {
@@ -72,11 +72,11 @@ describe('Test video abuses', function () {
const reason = 'my super bad reason'
await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[0].video.id, reason)
// We wait requests propagation, even if the pod 1 is not supposed to make a request to pod 2
// We wait requests propagation, even if the server 1 is not supposed to make a request to server 2
await wait(11000)
})
it('Should have 1 video abuses on pod 1 and 0 on pod 2', async function () {
it('Should have 1 video abuses on server 1 and 0 on server 2', async function () {
const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken)
expect(res1.body.total).to.equal(1)
@@ -86,7 +86,7 @@ describe('Test video abuses', function () {
const abuse = res1.body.data[0]
expect(abuse.reason).to.equal('my super bad reason')
expect(abuse.reporterUsername).to.equal('root')
expect(abuse.reporterPodHost).to.equal('localhost:9001')
expect(abuse.reporterServerHost).to.equal('localhost:9001')
expect(abuse.videoId).to.equal(servers[0].video.id)
const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken)
@@ -96,16 +96,16 @@ describe('Test video abuses', function () {
})
it('Should report abuse on a remote video', async function () {
this.timeout(15000)
this.timeout(25000)
const reason = 'my super bad reason 2'
await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[1].video.id, reason)
// We wait requests propagation
await wait(11000)
await wait(15000)
})
it('Should have 2 video abuse on pod 1 and 1 on pod 2', async function () {
it('Should have 2 video abuse on server 1 and 1 on server 2', async function () {
const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken)
expect(res1.body.total).to.equal(2)
expect(res1.body.data).to.be.an('array')
@@ -114,13 +114,13 @@ describe('Test video abuses', function () {
const abuse1 = res1.body.data[0]
expect(abuse1.reason).to.equal('my super bad reason')
expect(abuse1.reporterUsername).to.equal('root')
expect(abuse1.reporterPodHost).to.equal('localhost:9001')
expect(abuse1.reporterServerHost).to.equal('localhost:9001')
expect(abuse1.videoId).to.equal(servers[0].video.id)
const abuse2 = res1.body.data[1]
expect(abuse2.reason).to.equal('my super bad reason 2')
expect(abuse2.reporterUsername).to.equal('root')
expect(abuse2.reporterPodHost).to.equal('localhost:9001')
expect(abuse2.reporterServerHost).to.equal('localhost:9001')
expect(abuse2.videoId).to.equal(servers[1].video.id)
const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken)
@@ -131,7 +131,7 @@ describe('Test video abuses', function () {
const abuse3 = res2.body.data[0]
expect(abuse3.reason).to.equal('my super bad reason 2')
expect(abuse3.reporterUsername).to.equal('root')
expect(abuse3.reporterPodHost).to.equal('localhost:9001')
expect(abuse3.reporterServerHost).to.equal('localhost:9001')
})
after(async function () {