Try to fix travis
This commit is contained in:
parent
86ebdf8c46
commit
42e1ec25ec
|
@ -6,9 +6,27 @@ import { join } from 'path'
|
||||||
import { UserRole, VideoImport, VideoImportState } from '../../../../shared'
|
import { UserRole, VideoImport, VideoImportState } from '../../../../shared'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest,
|
blockUser,
|
||||||
makePostBodyRequest, makeUploadRequest, makePutBodyRequest, registerUser, removeUser, flushAndRunServer, ServerInfo, setAccessTokensToServers,
|
createUser,
|
||||||
updateUser, uploadVideo, userLogin, deleteMe, unblockUser, blockUser
|
deleteMe,
|
||||||
|
flushAndRunServer,
|
||||||
|
getMyUserInformation,
|
||||||
|
getMyUserVideoRating,
|
||||||
|
getUsersList,
|
||||||
|
immutableAssign,
|
||||||
|
killallServers,
|
||||||
|
makeGetRequest,
|
||||||
|
makePostBodyRequest,
|
||||||
|
makePutBodyRequest,
|
||||||
|
makeUploadRequest,
|
||||||
|
registerUser,
|
||||||
|
removeUser,
|
||||||
|
ServerInfo,
|
||||||
|
setAccessTokensToServers,
|
||||||
|
unblockUser,
|
||||||
|
updateUser,
|
||||||
|
uploadVideo,
|
||||||
|
userLogin
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import {
|
import {
|
||||||
checkBadCountPagination,
|
checkBadCountPagination,
|
||||||
|
|
|
@ -4,8 +4,15 @@ import * as chai from 'chai'
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import {
|
import {
|
||||||
createUser,
|
createUser,
|
||||||
flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePostBodyRequest, flushAndRunServer, ServerInfo, setAccessTokensToServers,
|
flushAndRunServer,
|
||||||
uploadVideo, userLogin
|
killallServers,
|
||||||
|
makeDeleteRequest,
|
||||||
|
makeGetRequest,
|
||||||
|
makePostBodyRequest,
|
||||||
|
ServerInfo,
|
||||||
|
setAccessTokensToServers,
|
||||||
|
uploadVideo,
|
||||||
|
userLogin
|
||||||
} from '../../../../shared/extra-utils'
|
} from '../../../../shared/extra-utils'
|
||||||
import {
|
import {
|
||||||
checkBadCountPagination,
|
checkBadCountPagination,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import { flushTests, killallServers, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils'
|
import { flushAndRunServer, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils'
|
||||||
import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
|
import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
|
||||||
import { VideosOverview } from '../../../../shared/models/overviews'
|
import { VideosOverview } from '../../../../shared/models/overviews'
|
||||||
|
|
||||||
|
|
|
@ -87,12 +87,14 @@ function randomServer () {
|
||||||
return Math.floor(Math.random() * (high - low) + low)
|
return Math.floor(Math.random() * (high - low) + low)
|
||||||
}
|
}
|
||||||
|
|
||||||
function flushAndRunServer (serverNumber: number, configOverrideArg?: Object, args = []) {
|
async function flushAndRunServer (serverNumber: number, configOverrideArg?: Object, args = []) {
|
||||||
const parallel = process.env.MOCHA_PARALLEL === 'true'
|
const parallel = process.env.MOCHA_PARALLEL === 'true'
|
||||||
|
|
||||||
const internalServerNumber = parallel ? randomServer() : serverNumber
|
const internalServerNumber = parallel ? randomServer() : serverNumber
|
||||||
const port = 9000 + internalServerNumber
|
const port = 9000 + internalServerNumber
|
||||||
|
|
||||||
|
await flushTests(serverNumber)
|
||||||
|
|
||||||
const server: ServerInfo = {
|
const server: ServerInfo = {
|
||||||
app: null,
|
app: null,
|
||||||
port,
|
port,
|
||||||
|
@ -175,45 +177,41 @@ function flushAndRunServer (serverNumber: number, configOverrideArg?: Object, ar
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise<ServerInfo>(res => {
|
return new Promise<ServerInfo>(res => {
|
||||||
flushTests(internalServerNumber)
|
server.app = fork(join(root(), 'dist', 'server.js'), args, options)
|
||||||
.then(() => {
|
server.app.stdout.on('data', function onStdout (data) {
|
||||||
|
let dontContinue = false
|
||||||
|
|
||||||
server.app = fork(join(root(), 'dist', 'server.js'), args, options)
|
// Capture things if we want to
|
||||||
server.app.stdout.on('data', function onStdout (data) {
|
for (const key of Object.keys(regexps)) {
|
||||||
let dontContinue = false
|
const regexp = regexps[ key ]
|
||||||
|
const matches = data.toString().match(regexp)
|
||||||
|
if (matches !== null) {
|
||||||
|
if (key === 'client_id') server.client.id = matches[ 1 ]
|
||||||
|
else if (key === 'client_secret') server.client.secret = matches[ 1 ]
|
||||||
|
else if (key === 'user_username') server.user.username = matches[ 1 ]
|
||||||
|
else if (key === 'user_password') server.user.password = matches[ 1 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Capture things if we want to
|
// Check if all required sentences are here
|
||||||
for (const key of Object.keys(regexps)) {
|
for (const key of Object.keys(serverRunString)) {
|
||||||
const regexp = regexps[ key ]
|
if (data.toString().indexOf(key) !== -1) serverRunString[ key ] = true
|
||||||
const matches = data.toString().match(regexp)
|
if (serverRunString[ key ] === false) dontContinue = true
|
||||||
if (matches !== null) {
|
}
|
||||||
if (key === 'client_id') server.client.id = matches[ 1 ]
|
|
||||||
else if (key === 'client_secret') server.client.secret = matches[ 1 ]
|
|
||||||
else if (key === 'user_username') server.user.username = matches[ 1 ]
|
|
||||||
else if (key === 'user_password') server.user.password = matches[ 1 ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if all required sentences are here
|
// If no, there is maybe one thing not already initialized (client/user credentials generation...)
|
||||||
for (const key of Object.keys(serverRunString)) {
|
if (dontContinue === true) return
|
||||||
if (data.toString().indexOf(key) !== -1) serverRunString[ key ] = true
|
|
||||||
if (serverRunString[ key ] === false) dontContinue = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// If no, there is maybe one thing not already initialized (client/user credentials generation...)
|
server.app.stdout.removeListener('data', onStdout)
|
||||||
if (dontContinue === true) return
|
|
||||||
|
|
||||||
server.app.stdout.removeListener('data', onStdout)
|
process.on('exit', () => {
|
||||||
|
try {
|
||||||
process.on('exit', () => {
|
process.kill(server.app.pid)
|
||||||
try {
|
} catch { /* empty */ }
|
||||||
process.kill(server.app.pid)
|
|
||||||
} catch { /* empty */ }
|
|
||||||
})
|
|
||||||
|
|
||||||
res(server)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
res(server)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue