- ubuntu-toolchain-r-test
packages:
- g++-4.9
- postgresql: "9.4"
+ postgresql: "9.6"
cache:
directories:
import {
createUser, flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePutBodyRequest, flushAndRunServer, ServerInfo,
- setAccessTokensToServers, userLogin, immutableAssign
+ setAccessTokensToServers, userLogin, immutableAssign, cleanupTests
} from '../../../../shared/extra-utils'
describe('Test config API validators', function () {
})
it('Should fail if email disabled and signup requires email verification', async function () {
- // opposite scenario - succcess when enable enabled - covered via tests/api/users/user-verification.ts
+ // opposite scenario - success when enable enabled - covered via tests/api/users/user-verification.ts
const newUpdateParams = immutableAssign(updateParams, {
signup: {
enabled: true,
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
reRunServer,
flushAndRunServer,
ServerInfo,
- setAccessTokensToServers
+ setAccessTokensToServers, cleanupTests
} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
fromEmail: 'toto@example.com',
body: 'Hello, how are you?'
}
+ let emailPort: number
// ---------------------------------------------------------------
before(async function () {
this.timeout(60000)
- await MockSmtpServer.Instance.collectEmails(emails)
+ emailPort = await MockSmtpServer.Instance.collectEmails(emails)
// Email is disabled
server = await flushAndRunServer(1)
killallServers([ server ])
// Contact form is disabled
- await reRunServer(server, { smtp: { hostname: 'localhost' }, contact_form: { enabled: false } })
+ await reRunServer(server, { smtp: { hostname: 'localhost', port: emailPort }, contact_form: { enabled: false } })
await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 409 }))
})
killallServers([ server ])
// Email & contact form enabled
- await reRunServer(server, { smtp: { hostname: 'localhost' } })
+ await reRunServer(server, { smtp: { hostname: 'localhost', port: emailPort } })
await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromEmail: 'badEmail' }))
await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromEmail: 'badEmail@' }))
await sendContactForm(immutableAssign(defaultBody, { url: server.url }))
})
- after(function () {
+ after(async function () {
MockSmtpServer.Instance.kill()
- killallServers([ server ])
+
+ // await cleanupTests([ server ])
})
})
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
- userLogin
+ userLogin, cleanupTests
} from '../../../../shared/extra-utils'
import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import {
- createUser, flushTests, killallServers, makeDeleteRequest, makePostBodyRequest, flushAndRunServer, ServerInfo, setAccessTokensToServers,
+ cleanupTests,
+ createUser,
+ flushAndRunServer,
+ makeDeleteRequest,
+ makePostBodyRequest,
+ ServerInfo,
+ setAccessTokensToServers,
userLogin
} from '../../../../shared/extra-utils'
import {
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
- userLogin
+ userLogin,
+ cleanupTests
} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
- userLogin
+ userLogin,
+ cleanupTests
} from '../../../../shared/extra-utils'
import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import {
+ cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
it('Should fail with an invalid token', async function () {
await makePutBodyRequest({
url: servers[0].url,
- path: path + '/localhost:9002',
+ path: path + '/localhost:' + servers[1].port,
fields: { redundancyAllowed: true },
token: 'fake_token',
statusCodeExpected: 401
it('Should fail if the user is not an administrator', async function () {
await makePutBodyRequest({
url: servers[0].url,
- path: path + '/localhost:9002',
+ path: path + '/localhost:' + servers[1].port,
fields: { redundancyAllowed: true },
token: userAccessToken,
statusCodeExpected: 403
it('Should fail without de redundancyAllowed param', async function () {
await makePutBodyRequest({
url: servers[0].url,
- path: path + '/localhost:9002',
+ path: path + '/localhost:' + servers[1].port,
fields: { blabla: true },
token: servers[0].accessToken,
statusCodeExpected: 400
it('Should succeed with the correct parameters', async function () {
await makePutBodyRequest({
url: servers[0].url,
- path: path + '/localhost:9002',
+ path: path + '/localhost:' + servers[1].port,
fields: { redundancyAllowed: true },
token: servers[0].accessToken,
statusCodeExpected: 204
})
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import 'mocha'
-import { flushTests, immutableAssign, killallServers, makeGetRequest, flushAndRunServer, ServerInfo } from '../../../../shared/extra-utils'
+import { cleanupTests, flushAndRunServer, immutableAssign, makeGetRequest, ServerInfo } from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
checkBadSortPagination,
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import {
- flushTests,
- killallServers,
- makeGetRequest,
+ cleanupTests,
flushAndRunServer,
+ makeGetRequest,
ServerInfo,
setAccessTokensToServers,
uploadVideo
})
it('Should fail with an invalid video id', async function () {
- const embedUrl = 'http://localhost:9001/videos/watch/blabla'
+ const embedUrl = `http://localhost:${server.port}/videos/watch/blabla`
await checkParamEmbed(server, embedUrl)
})
it('Should fail with an unknown video', async function () {
- const embedUrl = 'http://localhost:9001/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c'
+ const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c`
await checkParamEmbed(server, embedUrl, 404)
})
it('Should fail with an invalid path', async function () {
- const embedUrl = 'http://localhost:9001/videos/watchs/' + server.video.uuid
+ const embedUrl = `http://localhost:${server.port}/videos/watchs/${server.video.uuid}`
await checkParamEmbed(server, embedUrl)
})
it('Should fail with an invalid max height', async function () {
- const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
await checkParamEmbed(server, embedUrl, 400, { maxheight: 'hello' })
})
it('Should fail with an invalid max width', async function () {
- const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
await checkParamEmbed(server, embedUrl, 400, { maxwidth: 'hello' })
})
it('Should fail with an invalid format', async function () {
- const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
await checkParamEmbed(server, embedUrl, 400, { format: 'blabla' })
})
it('Should fail with a non supported format', async function () {
- const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
await checkParamEmbed(server, embedUrl, 501, { format: 'xml' })
})
it('Should succeed with the correct params', async function () {
- const embedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
const query = {
format: 'json',
maxheight: 400,
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import * as io from 'socket.io-client'
import {
- flushTests,
+ cleanupTests,
+ flushAndRunServer,
immutableAssign,
- killallServers,
makeGetRequest,
makePostBodyRequest,
makePutBodyRequest,
- flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
wait
describe('When connecting to my notification socket', function () {
it('Should fail with no token', function (next) {
- const socket = io('http://localhost:9001/user-notifications', { reconnection: false })
+ const socket = io(`http://localhost:${server.port}/user-notifications`, { reconnection: false })
socket.on('error', () => {
socket.removeListener('error', this)
})
it('Should fail with an invalid token', function (next) {
- const socket = io('http://localhost:9001/user-notifications', {
+ const socket = io(`http://localhost:${server.port}/user-notifications`, {
query: { accessToken: 'bad_access_token' },
reconnection: false
})
})
it('Should success with the correct token', function (next) {
- const socket = io('http://localhost:9001/user-notifications', {
+ const socket = io(`http://localhost:${server.port}/user-notifications`, {
query: { accessToken: server.accessToken },
reconnection: false
})
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import {
+ cleanupTests,
createUser,
- flushTests,
- killallServers,
+ flushAndRunServer,
makeDeleteRequest,
makeGetRequest,
makePostBodyRequest,
- flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
userLogin
await makePostBodyRequest({
url: server.url,
path,
- fields: { uri: 'user1_channel@localhost:9001' },
+ fields: { uri: 'user1_channel@localhost:' + server.port },
statusCodeExpected: 401
})
})
url: server.url,
path,
token: server.accessToken,
- fields: { uri: 'user1_channel@localhost:9001' },
+ fields: { uri: 'user1_channel@localhost:' + server.port },
statusCodeExpected: 204
})
it('Should fail with a non authenticated user', async function () {
await makeGetRequest({
url: server.url,
- path: path + '/user1_channel@localhost:9001',
+ path: path + '/user1_channel@localhost:' + server.port,
statusCodeExpected: 401
})
})
it('Should fail with an unknown subscription', async function () {
await makeGetRequest({
url: server.url,
- path: path + '/root1@localhost:9001',
+ path: path + '/root1@localhost:' + server.port,
token: server.accessToken,
statusCodeExpected: 404
})
it('Should succeed with the correct parameters', async function () {
await makeGetRequest({
url: server.url,
- path: path + '/user1_channel@localhost:9001',
+ path: path + '/user1_channel@localhost:' + server.port,
token: server.accessToken,
statusCodeExpected: 200
})
await makeGetRequest({
url: server.url,
path: existPath,
- query: { 'uris[]': 'coucou@localhost:9001' },
+ query: { 'uris[]': 'coucou@localhost:' + server.port },
token: server.accessToken,
statusCodeExpected: 200
})
it('Should fail with a non authenticated user', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/user1_channel@localhost:9001',
+ path: path + '/user1_channel@localhost:' + server.port,
statusCodeExpected: 401
})
})
it('Should fail with an unknown subscription', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/root1@localhost:9001',
+ path: path + '/root1@localhost:' + server.port,
token: server.accessToken,
statusCodeExpected: 404
})
it('Should succeed with the correct parameters', async function () {
await makeDeleteRequest({
url: server.url,
- path: path + '/user1_channel@localhost:9001',
+ path: path + '/user1_channel@localhost:' + server.port,
token: server.accessToken,
statusCodeExpected: 204
})
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import {
blockUser,
+ cleanupTests,
createUser,
deleteMe,
flushAndRunServer,
getMyUserVideoRating,
getUsersList,
immutableAssign,
- killallServers,
makeGetRequest,
makePostBodyRequest,
makePutBodyRequest,
})
it('Should fail if we register a user with the same email', async function () {
- const fields = immutableAssign(baseCorrectParams, { email: 'admin1@example.com' })
+ const fields = immutableAssign(baseCorrectParams, { email: 'admin' + server.internalServerNumber + '@example.com' })
await makePostBodyRequest({
url: server.url,
})
})
- after(function () {
- killallServers([ server, serverWithRegistrationDisabled ])
+ after(async function () {
+ await cleanupTests([ server, serverWithRegistrationDisabled ])
})
})
import 'mocha'
import {
+ cleanupTests,
createUser,
deleteVideoAbuse,
- flushTests,
- killallServers,
+ flushAndRunServer,
makeGetRequest,
makePostBodyRequest,
- flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
updateVideoAbuse,
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import {
+ cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
})
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import 'mocha'
import {
+ cleanupTests,
createUser,
- flushTests,
- killallServers,
+ flushAndRunServer,
makeDeleteRequest,
makeGetRequest,
makeUploadRequest,
- flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
uploadVideo,
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import { omit } from 'lodash'
import 'mocha'
import {
+ cleanupTests,
createUser,
deleteVideoChannel,
- flushTests,
+ flushAndRunServer,
getAccountVideoChannelsList,
- getMyUserInformation,
- getVideoChannelsList,
immutableAssign,
- killallServers,
makeGetRequest,
makePostBodyRequest,
makePutBodyRequest,
makeUploadRequest,
- flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
userLogin
checkBadSortPagination,
checkBadStartPagination
} from '../../../../shared/extra-utils/requests/check-api-params'
-import { User } from '../../../../shared/models/users'
import { join } from 'path'
const expect = chai.expect
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import * as chai from 'chai'
import 'mocha'
import {
+ cleanupTests,
createUser,
flushAndRunServer,
- killallServers,
makeDeleteRequest,
makeGetRequest,
makePostBodyRequest,
it('Should return conflict on comment thread add')
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import { join } from 'path'
import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
import {
+ cleanupTests,
createUser,
- flushTests,
+ flushAndRunServer,
getMyUserInformation,
immutableAssign,
- killallServers,
makeGetRequest,
makePostBodyRequest,
makeUploadRequest,
- flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
updateCustomSubConfig,
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import {
addVideoInPlaylist,
+ cleanupTests,
createVideoPlaylist,
deleteVideoPlaylist,
- flushTests,
+ flushAndRunServer,
generateUserAccessToken,
getAccountPlaylistsListWithToken,
getVideoPlaylist,
immutableAssign,
- killallServers,
makeGetRequest,
removeVideoFromPlaylist,
reorderVideosPlaylist,
- flushAndRunServer,
ServerInfo,
- setAccessTokensToServers, setDefaultVideoChannel,
+ setAccessTokensToServers,
+ setDefaultVideoChannel,
updateVideoPlaylist,
updateVideoPlaylistElement,
uploadVideoAndGetId
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import {
+ cleanupTests,
createUser,
createVideoPlaylist,
- flushTests,
- killallServers,
- makeGetRequest,
flushAndRunServer,
+ makeGetRequest,
ServerInfo,
- setAccessTokensToServers, setDefaultVideoChannel,
+ setAccessTokensToServers,
+ setDefaultVideoChannel,
userLogin
} from '../../../../shared/extra-utils'
import { UserRole } from '../../../../shared/models/users'
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import {
checkBadCountPagination,
checkBadStartPagination,
- flushTests,
- killallServers,
+ cleanupTests,
+ flushAndRunServer,
makeGetRequest,
makePostBodyRequest,
makePutBodyRequest,
- flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
uploadVideo
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import { join } from 'path'
import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
import {
- createUser, flushTests, getMyUserInformation, getVideo, getVideosList, immutableAssign, killallServers, makeDeleteRequest,
- makeGetRequest, makeUploadRequest, makePutBodyRequest, removeVideo, uploadVideo,
- flushAndRunServer, ServerInfo, setAccessTokensToServers, userLogin, updateCustomSubConfig
+ cleanupTests,
+ createUser,
+ flushAndRunServer,
+ getMyUserInformation,
+ getVideo,
+ getVideosList,
+ immutableAssign,
+ makeDeleteRequest,
+ makeGetRequest,
+ makePutBodyRequest,
+ makeUploadRequest,
+ removeVideo,
+ ServerInfo,
+ setAccessTokensToServers,
+ userLogin,
+ root
} from '../../../../shared/extra-utils'
import {
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination
} from '../../../../shared/extra-utils/requests/check-api-params'
-import { getAccountsList } from '../../../../shared/extra-utils/users/accounts'
const expect = chai.expect
describe('When adding a video', function () {
let baseCorrectParams
const baseCorrectAttaches = {
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.webm')
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.webm')
}
before(function () {
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
- it('Should fail without an incorrect input file', async function () {
+ it('Should fail with an incorrect input file', async function () {
const fields = baseCorrectParams
let attaches = {
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm')
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
attaches = {
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mkv')
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
})
it('Should fail with an incorrect thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'),
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
+ 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png'),
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
it('Should fail with a big thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'),
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
+ 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png'),
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
it('Should fail with an incorrect preview file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'),
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
+ 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png'),
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
it('Should fail with a big preview file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'),
- 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
+ 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png'),
+ 'videofile': join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
}
await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
{
const attaches = immutableAssign(baseCorrectAttaches, {
- videofile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mp4')
})
await makeUploadRequest({
{
const attaches = immutableAssign(baseCorrectAttaches, {
- videofile: join(__dirname, '..', '..', 'fixtures', 'video_short.ogv')
+ videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.ogv')
})
await makeUploadRequest({
it('Should fail with an incorrect thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
+ 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png')
}
await makeUploadRequest({
it('Should fail with a big thumbnail file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
+ 'thumbnailfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png')
}
await makeUploadRequest({
it('Should fail with an incorrect preview file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
+ 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar.png')
}
await makeUploadRequest({
it('Should fail with a big preview file', async function () {
const fields = baseCorrectParams
const attaches = {
- 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
+ 'previewfile': join(root(), 'server', 'tests', 'fixtures', 'avatar-big.png')
}
await makeUploadRequest({
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
userLogin,
wait,
getCustomConfig,
- updateCustomConfig, getVideoThreadComments, getVideoCommentThreads, follow
+ updateCustomConfig, getVideoThreadComments, getVideoCommentThreads, follow, cleanupTests
} from '../../../../shared/extra-utils'
import { killallServers, ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
})
})
- after(function () {
+ after(async function () {
MockSmtpServer.Instance.kill()
- killallServers(servers)
+ await cleanupTests(servers)
})
})
import { VideoDetails } from '../../../../shared/models/videos'
import {
checkSegmentHash,
- checkVideoFilesWereRemoved,
+ checkVideoFilesWereRemoved, cleanupTests,
doubleFollow,
flushAndRunMultipleServers,
getFollowingListPaginationAndSort,
expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length)
}
-async function runServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) {
+async function flushAndRunServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) {
const config = {
transcoding: {
hls: {
expect(server2.following.hostRedundancyAllowed).to.be.false
}
-async function cleanServers () {
- killallServers(servers)
-}
-
describe('Test videos redundancy', function () {
describe('With most-views strategy', function () {
before(function () {
this.timeout(120000)
- return runServers(strategy)
+ return flushAndRunServers(strategy)
})
it('Should have 1 webseed on the first video', async function () {
await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos', join('playlists', 'hls') ])
})
- after(function () {
- return cleanServers()
+ after(async function () {
+ return cleanupTests(servers)
})
})
before(function () {
this.timeout(120000)
- return runServers(strategy)
+ return flushAndRunServers(strategy)
})
it('Should have 1 webseed on the first video', async function () {
await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos' ])
})
- after(function () {
- return cleanServers()
+ after(async function () {
+ await cleanupTests(servers)
})
})
before(function () {
this.timeout(120000)
- return runServers(strategy, { min_views: 3 })
+ return flushAndRunServers(strategy, { min_views: 3 })
})
it('Should have 1 webseed on the first video', async function () {
}
})
- after(function () {
- return cleanServers()
+ after(async function () {
+ await cleanupTests(servers)
})
})
before(async function () {
this.timeout(120000)
- await runServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
+ await flushAndRunServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
await enableRedundancyOnServer1()
})
await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A9001')
})
- after(function () {
- return killallServers([ servers[1], servers[2] ])
+ after(async function () {
+ await cleanupTests(servers)
})
})
before(async function () {
this.timeout(120000)
- await runServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
+ await flushAndRunServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
await enableRedundancyOnServer1()
await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ join('redundancy', 'hls') ])
})
- after(function () {
- return cleanServers()
+ after(async function () {
+ await cleanupTests(servers)
})
})
})
import * as chai from 'chai'
import 'mocha'
import {
- addVideoChannel,
+ addVideoChannel, cleanupTests,
createUser,
deleteVideoChannel,
flushAndRunMultipleServers,
expect(res.body.data).to.have.lengthOf(0)
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
updateVideo,
uploadVideo,
wait,
- searchVideo
+ searchVideo, cleanupTests
} from '../../../../shared/extra-utils'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
import { Video, VideoPrivacy } from '../../../../shared/models/videos'
expect(res.body.data).to.have.lengthOf(0)
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
setAccessTokensToServers,
uploadVideo,
wait,
- immutableAssign
+ immutableAssign,
+ cleanupTests
} from '../../../../shared/extra-utils'
const expect = chai.expect
}
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import { About } from '../../../../shared/models/server/about.model'
import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
import {
+ cleanupTests,
deleteCustomConfig,
+ flushAndRunServer,
getAbout,
- killallServers,
- reRunServer,
- flushTests,
getConfig,
getCustomConfig,
+ killallServers,
registerUser,
- flushAndRunServer,
+ reRunServer,
setAccessTokensToServers,
updateCustomConfig
} from '../../../../shared/extra-utils'
checkInitialConfig(data)
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import * as chai from 'chai'
import 'mocha'
-import { flushTests, killallServers, flushAndRunServer, ServerInfo, setAccessTokensToServers, wait } from '../../../../shared/extra-utils'
+import {
+ flushTests,
+ killallServers,
+ flushAndRunServer,
+ ServerInfo,
+ setAccessTokensToServers,
+ wait,
+ cleanupTests
+} from '../../../../shared/extra-utils'
import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
import { sendContactForm } from '../../../../shared/extra-utils/server/contact-form'
})
})
- after(function () {
+ after(async function () {
MockSmtpServer.Instance.kill()
- killallServers([ server ])
+
+ await cleanupTests([ server ])
})
})
flushTests,
killallServers,
ServerInfo,
- setAccessTokensToServers
+ setAccessTokensToServers, cleanupTests
} from '../../../../shared/extra-utils'
import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
})
})
- after(function () {
+ after(async function () {
MockSmtpServer.Instance.kill()
- killallServers([ server ])
+
+ await cleanupTests([ server ])
})
})
killallServers,
ServerInfo,
setAccessTokensToServers,
- uploadVideo
+ uploadVideo, cleanupTests
} from '../../../../shared/extra-utils'
import { unfollow } from '../../../../shared/extra-utils/server/follows'
import { userLogin } from '../../../../shared/extra-utils/users/login'
})
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import 'mocha'
import {
- acceptFollower,
+ acceptFollower, cleanupTests,
flushAndRunMultipleServers,
killallServers,
ServerInfo,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import 'mocha'
import { Video, VideoPrivacy } from '../../../../shared/models/videos'
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
-import { completeVideoCheck } from '../../../../shared/extra-utils'
+import { cleanupTests, completeVideoCheck } from '../../../../shared/extra-utils'
import {
flushAndRunMultipleServers,
getVideosList,
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
import {
+ cleanupTests,
completeVideoCheck,
flushAndRunMultipleServers,
getVideo,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import 'mocha'
-import { killallServers, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
+import { cleanupTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
import { getJobsList, getJobsListPaginationAndSort, waitJobs } from '../../../../shared/extra-utils/server/jobs'
import { flushAndRunMultipleServers } from '../../../../shared/extra-utils/server/servers'
expect(dateIsValid(job.finishedOn)).to.be.true
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import 'mocha'
-import { flushTests, killallServers, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
+import {
+ flushTests,
+ killallServers,
+ flushAndRunServer,
+ ServerInfo,
+ setAccessTokensToServers,
+ cleanupTests
+} from '../../../../shared/extra-utils/index'
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
import { uploadVideo } from '../../../../shared/extra-utils/videos/videos'
import { getLogs } from '../../../../shared/extra-utils/logs/logs'
}
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import * as request from 'supertest'
-import {
- flushTests,
- killallServers,
- ServerInfo
-} from '../../../../shared/extra-utils'
-import { flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
+import { ServerInfo } from '../../../../shared/extra-utils'
+import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
describe('Start and stop server without web client routes', function () {
let server: ServerInfo
return req.expect(404)
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import * as chai from 'chai'
-import { About } from '../../../../shared/models/server/about.model'
-import { CustomConfig } from '../../../../shared/models/server/custom-config.model'
-import {
- deleteCustomConfig,
- getAbout,
- getVideo,
- killallServers,
- login,
- reRunServer,
- uploadVideo,
- userLogin,
- viewVideo,
- wait
-} from '../../../../shared/extra-utils'
-const expect = chai.expect
+import { cleanupTests, getVideo, uploadVideo, userLogin, viewVideo, wait } from '../../../../shared/extra-utils'
+import { flushAndRunServer, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
-import {
- getConfig,
- flushTests,
- flushAndRunServer,
- registerUser, getCustomConfig, setAccessTokensToServers, updateCustomConfig
-} from '../../../../shared/extra-utils/index'
+const expect = chai.expect
describe('Test application behind a reverse proxy', function () {
let server = null
await userLogin(server, user, 429)
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import { ServerStats } from '../../../../shared/models/server/server-stats.model'
import {
+ cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
expect(data.totalInstanceFollowers).to.equal(0)
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as magnetUtil from 'magnet-uri'
import 'mocha'
-import { getVideo, killallServers, reRunServer, flushAndRunServer, ServerInfo, uploadVideo } from '../../../../shared/extra-utils'
-import { flushTests, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
+import {
+ cleanupTests,
+ flushAndRunServer,
+ getVideo,
+ killallServers,
+ reRunServer,
+ ServerInfo,
+ uploadVideo
+} from '../../../../shared/extra-utils'
+import { setAccessTokensToServers } from '../../../../shared/extra-utils/index'
import { VideoDetails } from '../../../../shared/models/videos'
import * as WebTorrent from 'webtorrent'
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import { AccountBlock, ServerBlock, Video } from '../../../../shared/index'
import {
+ cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
})
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import 'mocha'
import {
+ cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import { Account } from '../../../../shared/models/actors'
import {
checkTmpIsEmpty,
- checkVideoFilesWereRemoved,
+ checkVideoFilesWereRemoved, cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import 'mocha'
import {
registerUser, flushTests, getUserInformation, getMyUserInformation, killallServers,
- userLogin, login, flushAndRunServer, ServerInfo, verifyEmail, updateCustomSubConfig, wait
+ userLogin, login, flushAndRunServer, ServerInfo, verifyEmail, updateCustomSubConfig, wait, cleanupTests
} from '../../../../shared/extra-utils'
import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
await userLogin(server, user2)
})
- after(function () {
+ after(async function () {
MockSmtpServer.Instance.kill()
- killallServers([ server ])
+
+ await cleanupTests([ server ])
})
})
import { User, UserRole } from '../../../../shared/index'
import {
blockUser,
+ cleanupTests,
createUser,
deleteMe,
- flushTests,
+ flushAndRunServer,
getAccountRatings,
getBlacklistedVideosList,
getMyUserInformation,
getUsersList,
getUsersListPaginationAndSort,
getVideosList,
- killallServers,
login,
makePutBodyRequest,
rateVideo,
registerUser,
removeUser,
removeVideo,
- flushAndRunServer,
ServerInfo,
testImage,
unblockUser,
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import {
addVideoChannel,
checkTmpIsEmpty,
- checkVideoFilesWereRemoved,
+ checkVideoFilesWereRemoved, cleanupTests,
completeVideoCheck,
createUser,
dateIsValid,
})
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import 'mocha'
-import {
- flushTests,
- getOEmbed,
- getVideosList,
- killallServers,
- ServerInfo,
- setAccessTokensToServers,
- uploadVideo
-} from '../../../../shared/extra-utils/index'
-import { flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
+import { getOEmbed, getVideosList, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils/index'
+import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
const expect = chai.expect
expect(res.body).to.not.have.property('thumbnail_height')
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import { VideoPrivacy } from '../../../../shared/models/videos'
import {
checkVideoFilesWereRemoved,
+ cleanupTests,
completeVideoCheck,
- flushTests,
+ flushAndRunServer,
getVideo,
getVideoCategories,
getVideoLanguages,
getVideosListPagination,
getVideosListSort,
getVideosWithFilters,
- killallServers,
rateVideo,
removeVideo,
- flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
testImage,
expect(video.dislikes).to.equal(1)
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import { VideoAbuse, VideoAbuseState } from '../../../../shared/models/videos'
import {
+ cleanupTests,
deleteVideoAbuse,
flushAndRunMultipleServers,
getVideoAbusesList,
expect(res.body.data.length).to.equal(0)
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import { orderBy } from 'lodash'
import 'mocha'
import {
- addVideoToBlacklist,
+ addVideoToBlacklist, cleanupTests,
createUser,
flushAndRunMultipleServers,
getBlacklistedVideosList,
})
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import 'mocha'
import {
- checkVideoFilesWereRemoved,
+ checkVideoFilesWereRemoved, cleanupTests,
doubleFollow,
flushAndRunMultipleServers,
removeVideo,
await checkVideoFilesWereRemoved(videoUUID, 1)
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import 'mocha'
import {
acceptChangeOwnership,
- changeVideoOwnership,
+ changeVideoOwnership, cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
await acceptChangeOwnership(server.url, secondUserAccessToken, lastRequestChangeOwnershipId, channelId, 403)
})
- after(function () {
- killallServers([server])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import 'mocha'
import { User, Video } from '../../../../shared/index'
import {
+ cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import 'mocha'
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
-import { testImage } from '../../../../shared/extra-utils'
+import { cleanupTests, testImage } from '../../../../shared/extra-utils'
import {
dateIsValid,
- flushTests,
- killallServers,
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
expect(res.body.data[1].totalReplies).to.equal(0)
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import * as chai from 'chai'
import 'mocha'
import {
+ cleanupTests,
flushAndRunMultipleServers,
getVideo,
getVideoDescription,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import {
checkDirectoryIsEmpty,
checkSegmentHash,
- checkTmpIsEmpty,
+ checkTmpIsEmpty, cleanupTests,
doubleFollow,
flushAndRunMultipleServers,
flushTests,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import 'mocha'
import { VideoDetails, VideoImport, VideoPrivacy } from '../../../../shared/models/videos'
import {
+ cleanupTests,
doubleFollow,
flushAndRunMultipleServers,
getMyUserInformation,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import 'mocha'
-import {
- flushTests,
- getVideosList,
- killallServers,
- ServerInfo,
- setAccessTokensToServers,
- uploadVideo
-} from '../../../../shared/extra-utils/index'
+import { cleanupTests, getVideosList, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils/index'
import { userLogin } from '../../../../shared/extra-utils/users/login'
import { createUser } from '../../../../shared/extra-utils/users/users'
import { getMyVideos } from '../../../../shared/extra-utils/videos/videos'
import {
+ flushAndRunServer,
getAccountVideos,
getConfig,
getCustomConfig,
getMyUserInformation,
getVideoChannelVideos,
getVideosListWithToken,
- flushAndRunServer,
searchVideo,
searchVideoWithToken,
updateCustomConfig,
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import {
addVideoChannel,
addVideoInPlaylist,
- checkPlaylistFilesWereRemoved,
+ checkPlaylistFilesWereRemoved, cleanupTests,
createUser,
createVideoPlaylist,
deleteVideoChannel,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import 'mocha'
import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
import {
+ cleanupTests,
flushAndRunMultipleServers,
getVideosList,
killallServers,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import 'mocha'
import { VideoPrivacy } from '../../../../shared/models/videos'
import {
+ cleanupTests,
doubleFollow,
flushAndRunMultipleServers,
getMyVideos,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos'
import { audio, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
import {
- buildAbsoluteFixturePath,
+ buildAbsoluteFixturePath, cleanupTests,
doubleFollow,
flushAndRunMultipleServers,
generateHighBitrateVideo,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import 'mocha'
import {
+ cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
})
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import 'mocha'
import {
+ cleanupTests,
createUser,
- flushTests,
+ flushAndRunServer,
getVideosListWithToken,
getVideoWithToken,
- killallServers, reRunServer,
- flushAndRunServer,
+ killallServers,
+ reRunServer,
searchVideoWithToken,
ServerInfo,
setAccessTokensToServers,
expect(res.body.total).to.equal(0)
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import * as chai from 'chai'
import 'mocha'
-import { flushAndRunServer, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils'
+import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils'
import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
import { VideosOverview } from '../../../../shared/models/overviews'
expect(overview.channels[0].channel.name).to.equal('root_channel')
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
flushAndRunServer,
ServerInfo,
setAccessTokensToServers,
- uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs
+ uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests
} from '../../../../shared/extra-utils'
import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
import { VideosOverview } from '../../../../shared/models/overviews'
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import { VideoDetails, VideoFile } from '../../../shared/models/videos'
import {
+ cleanupTests,
doubleFollow,
execCLI,
flushAndRunMultipleServers,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import { VideoDetails } from '../../../shared/models/videos'
import {
+ cleanupTests,
doubleFollow,
execCLI,
flushAndRunMultipleServers,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import { getMaxBitrate, Video, VideoDetails, VideoResolution } from '../../../shared/models/videos'
import {
+ cleanupTests,
doubleFollow,
execCLI,
flushAndRunMultipleServers,
}
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
killallServers,
flushAndRunServer,
ServerInfo,
- setAccessTokensToServers
+ setAccessTokensToServers, cleanupTests
} from '../../../shared/extra-utils'
describe('Test CLI wrapper', function () {
await execCLI(cmd + ` auth del ${server.url}`)
- killallServers([ server ])
+ await cleanupTests([ server ])
})
})
import 'mocha'
import {
+ cleanupTests,
createUser,
execCLI,
- flushTests,
+ flushAndRunServer,
getEnvCli,
- killallServers,
login,
- flushAndRunServer,
ServerInfo,
setAccessTokensToServers
} from '../../../shared/extra-utils'
await login(server.url, server.client, { username: 'user_1', password: 'coucou' }, 200)
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
import {
addVideoChannel,
+ cleanupTests,
createUser,
execCLI,
- flushTests,
+ flushAndRunServer,
getEnvCli,
getVideo,
getVideoChannelsList,
getVideosList,
killallServers,
makeActivityPubGetRequest,
- parseTorrentVideo,
- flushAndRunServer,
+ parseTorrentVideo, reRunServer,
ServerInfo,
setAccessTokensToServers,
uploadVideo
killallServers([ server ])
// Run server with standard configuration
- server = await flushAndRunServer(2)
+ await reRunServer(server)
const env = getEnvCli(server)
await execCLI(`${env} npm run update-host`)
}
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import * as chai from 'chai'
import * as request from 'supertest'
import {
- flushTests,
+ cleanupTests,
+ flushAndRunServer,
getCustomConfig,
getVideosList,
- killallServers,
makeHTMLRequest,
- flushAndRunServer,
ServerInfo,
serverLogin,
updateCustomConfig,
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }')
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
import * as chai from 'chai'
import 'mocha'
import {
+ cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
})
})
- after(function () {
- killallServers(servers)
+ after(async function () {
+ await cleanupTests(servers)
})
})
import * as chai from 'chai'
import {
addVideoChannel,
+ cleanupTests,
createUser,
- flushTests,
- killallServers,
- makeGetRequest,
flushAndRunServer,
+ makeGetRequest,
ServerInfo,
setAccessTokensToServers,
uploadVideo
})
})
- after(function () {
- killallServers([ server ])
+ after(async function () {
+ await cleanupTests([ server ])
})
})
--- /dev/null
+function randomInt (low: number, high: number) {
+ return Math.floor(Math.random() * (high - low) + low)
+}
+
+export {
+ randomInt
+}
if (msg.start) {
const maildev = new MailDev({
ip: '127.0.0.1',
- smtp: 1025,
+ smtp: msg.port,
disableWeb: true,
silent: true
})
-import { fork, ChildProcess } from 'child_process'
+import { ChildProcess, fork } from 'child_process'
+import { randomInt } from '../../core-utils/miscs/miscs'
+import { parallelTests } from '../server/servers'
class MockSmtpServer {
}
collectEmails (emailsCollection: object[]) {
- return new Promise((res, rej) => {
+ return new Promise<number>((res, rej) => {
+ const port = parallelTests() ? randomInt(1000, 2000) : 1025
+
if (this.started) {
this.emails = emailsCollection
return res()
// ensure maildev isn't started until
// unexpected exit can be reported to test runner
- this.emailChildProcess.send({ start: true })
+ this.emailChildProcess.send({ start: true, port })
this.emailChildProcess.on('exit', () => {
return rej(new Error('maildev exited unexpectedly, confirm port not in use'))
})
}
this.started = true
this.emails = emailsCollection
- return res()
+ return res(port)
})
})
}
import { ChildProcess, exec, fork } from 'child_process'
import { join } from 'path'
import { root, wait } from '../miscs/miscs'
-import { readdir, readFile } from 'fs-extra'
+import { copy, readdir, readFile, remove } from 'fs-extra'
import { existsSync } from 'fs'
import { expect } from 'chai'
import { VideoChannel } from '../../models/videos'
+import { randomInt } from '../../core-utils/miscs/miscs'
interface ServerInfo {
app: ChildProcess,
email?: string
}
+ customConfigFile?: string
+
accessToken?: string
videoChannel?: VideoChannel
videos?: { id: number, uuid: string }[]
}
+function parallelTests () {
+ return process.env.MOCHA_PARALLEL === 'true'
+}
+
function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) {
let apps = []
let i = 0
const low = 10
const high = 10000
- return Math.floor(Math.random() * (high - low) + low)
+ return randomInt(low, high)
}
async function flushAndRunServer (serverNumber: number, configOverride?: Object, args = []) {
- const parallel = process.env.MOCHA_PARALLEL === 'true'
+ const parallel = parallelTests()
const internalServerNumber = parallel ? randomServer() : serverNumber
const port = 9000 + internalServerNumber
- await flushTests(serverNumber)
+ await flushTests(internalServerNumber)
const server: ServerInfo = {
app: null,
port,
internalServerNumber,
parallel,
- serverNumber: internalServerNumber,
+ serverNumber,
url: `http://localhost:${port}`,
host: `localhost:${port}`,
client: {
return runServer(server, configOverride, args)
}
-function runServer (server: ServerInfo, configOverrideArg?: any, args = []) {
+async function runServer (server: ServerInfo, configOverrideArg?: any, args = []) {
// These actions are async so we need to be sure that they have both been done
const serverRunString = {
'Server listening': false
user_password: 'User password: (.+)'
}
- // Share the environment
- const env = Object.create(process.env)
- env['NODE_ENV'] = 'test'
- env['NODE_APP_INSTANCE'] = server.serverNumber.toString()
+ if (server.internalServerNumber !== server.serverNumber) {
+ const basePath = join(root(), 'config')
+
+ const tmpConfigFile = join(basePath, `test-${server.internalServerNumber}.yaml`)
+ await copy(join(basePath, `test-${server.serverNumber}.yaml`), tmpConfigFile)
+
+ server.customConfigFile = tmpConfigFile
+ }
- let configOverride: any = {}
+ const configOverride: any = {}
if (server.parallel) {
- configOverride = {
+ Object.assign(configOverride, {
listen: {
port: server.port
},
admin: {
email: `admin${server.internalServerNumber}@example.com`
}
- }
+ })
}
if (configOverrideArg !== undefined) {
Object.assign(configOverride, configOverrideArg)
}
+ // Share the environment
+ const env = Object.create(process.env)
+ env['NODE_ENV'] = 'test'
+ env['NODE_APP_INSTANCE'] = server.internalServerNumber.toString()
env['NODE_CONFIG'] = JSON.stringify(configOverride)
const options = {
silent: true,
- env: env,
+ env,
detached: true
}
function killallServers (servers: ServerInfo[]) {
for (const server of servers) {
+ if (!server.app) continue
+
process.kill(-server.app.pid)
+ server.app = null
}
}
if (server.parallel) {
p.push(flushTests(server.internalServerNumber))
}
+
+ if (server.customConfigFile) {
+ p.push(remove(server.customConfigFile))
+ }
}
return Promise.all(p)
checkDirectoryIsEmpty,
checkTmpIsEmpty,
ServerInfo,
+ parallelTests,
cleanupTests,
flushAndRunMultipleServers,
flushTests,