mirror of https://github.com/Chocobozzz/PeerTube
peertube runner tests in parallel
parent
30453cb5ba
commit
6403a6bd01
|
@ -112,7 +112,7 @@ export class ConfigManager {
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
isTestInstance () {
|
||||
return this.id === 'test'
|
||||
return typeof this.id === 'string' && this.id.match(/^test-\d$/)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -114,7 +114,8 @@ elif [ "$1" = "external-plugins" ]; then
|
|||
externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins)
|
||||
peertubeRunnerFiles=$(findTestFiles ./dist/server/tests/peertube-runner)
|
||||
|
||||
runTest "$1" 1 $externalPluginsFiles $peertubeRunnerFiles
|
||||
runTest "$1" 1 $externalPluginsFiles
|
||||
MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $peertubeRunnerFiles
|
||||
elif [ "$1" = "lint" ]; then
|
||||
npm run eslint -- --ext .ts "./server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts"
|
||||
npm run swagger-cli -- validate support/doc/api/openapi.yaml
|
||||
|
|
|
@ -213,7 +213,7 @@ describe('Test a single server', function () {
|
|||
})
|
||||
|
||||
it('Should upload 6 videos', async function () {
|
||||
this.timeout(50000)
|
||||
this.timeout(120000)
|
||||
|
||||
const videos = new Set([
|
||||
'video_short.mp4', 'video_short.ogv', 'video_short.webm',
|
||||
|
|
|
@ -18,7 +18,7 @@ describe('Test peertube-runner program client CLI', function () {
|
|||
|
||||
await server.config.enableRemoteTranscoding()
|
||||
|
||||
peertubeRunner = new PeerTubeRunnerProcess()
|
||||
peertubeRunner = new PeerTubeRunnerProcess(server)
|
||||
await peertubeRunner.runServer()
|
||||
})
|
||||
|
||||
|
@ -32,7 +32,6 @@ describe('Test peertube-runner program client CLI', function () {
|
|||
const registrationToken = await server.runnerRegistrationTokens.getFirstRegistrationToken()
|
||||
|
||||
await peertubeRunner.registerPeerTubeInstance({
|
||||
server,
|
||||
registrationToken,
|
||||
runnerName: 'my super runner',
|
||||
runnerDescription: 'super description'
|
||||
|
@ -54,7 +53,7 @@ describe('Test peertube-runner program client CLI', function () {
|
|||
})
|
||||
|
||||
it('Should unregister the PeerTube instance', async function () {
|
||||
await peertubeRunner.unregisterPeerTubeInstance({ server })
|
||||
await peertubeRunner.unregisterPeerTubeInstance()
|
||||
})
|
||||
|
||||
it('Should not have PeerTube instance listed', async function () {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { expect } from 'chai'
|
||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||
import { expect } from 'chai'
|
||||
import {
|
||||
checkPeerTubeRunnerCacheIsEmpty,
|
||||
expectStartWith,
|
||||
|
@ -144,9 +144,9 @@ describe('Test Live transcoding in peertube-runner program', function () {
|
|||
|
||||
const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken()
|
||||
|
||||
peertubeRunner = new PeerTubeRunnerProcess()
|
||||
peertubeRunner = new PeerTubeRunnerProcess(servers[0])
|
||||
await peertubeRunner.runServer()
|
||||
await peertubeRunner.registerPeerTubeInstance({ server: servers[0], registrationToken, runnerName: 'runner' })
|
||||
await peertubeRunner.registerPeerTubeInstance({ registrationToken, runnerName: 'runner' })
|
||||
})
|
||||
|
||||
describe('With lives on local filesystem storage', function () {
|
||||
|
@ -184,7 +184,7 @@ describe('Test Live transcoding in peertube-runner program', function () {
|
|||
|
||||
after(async function () {
|
||||
if (peertubeRunner) {
|
||||
await peertubeRunner.unregisterPeerTubeInstance({ server: servers[0] })
|
||||
await peertubeRunner.unregisterPeerTubeInstance()
|
||||
peertubeRunner.kill()
|
||||
}
|
||||
|
||||
|
|
|
@ -74,9 +74,9 @@ describe('Test studio transcoding in peertube-runner program', function () {
|
|||
|
||||
const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken()
|
||||
|
||||
peertubeRunner = new PeerTubeRunnerProcess()
|
||||
peertubeRunner = new PeerTubeRunnerProcess(servers[0])
|
||||
await peertubeRunner.runServer()
|
||||
await peertubeRunner.registerPeerTubeInstance({ server: servers[0], registrationToken, runnerName: 'runner' })
|
||||
await peertubeRunner.registerPeerTubeInstance({ registrationToken, runnerName: 'runner' })
|
||||
})
|
||||
|
||||
describe('With videos on local filesystem storage', function () {
|
||||
|
@ -109,7 +109,7 @@ describe('Test studio transcoding in peertube-runner program', function () {
|
|||
|
||||
after(async function () {
|
||||
if (peertubeRunner) {
|
||||
await peertubeRunner.unregisterPeerTubeInstance({ server: servers[0] })
|
||||
await peertubeRunner.unregisterPeerTubeInstance()
|
||||
peertubeRunner.kill()
|
||||
}
|
||||
|
||||
|
|
|
@ -249,9 +249,9 @@ describe('Test VOD transcoding in peertube-runner program', function () {
|
|||
|
||||
const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken()
|
||||
|
||||
peertubeRunner = new PeerTubeRunnerProcess()
|
||||
peertubeRunner = new PeerTubeRunnerProcess(servers[0])
|
||||
await peertubeRunner.runServer()
|
||||
await peertubeRunner.registerPeerTubeInstance({ server: servers[0], registrationToken, runnerName: 'runner' })
|
||||
await peertubeRunner.registerPeerTubeInstance({ registrationToken, runnerName: 'runner' })
|
||||
})
|
||||
|
||||
describe('With videos on local filesystem storage', function () {
|
||||
|
@ -335,7 +335,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {
|
|||
|
||||
after(async function () {
|
||||
if (peertubeRunner) {
|
||||
await peertubeRunner.unregisterPeerTubeInstance({ server: servers[0] })
|
||||
await peertubeRunner.unregisterPeerTubeInstance()
|
||||
peertubeRunner.kill()
|
||||
}
|
||||
|
||||
|
|
|
@ -7,13 +7,17 @@ import { PeerTubeServer } from '@shared/server-commands'
|
|||
export class PeerTubeRunnerProcess {
|
||||
private app?: ChildProcess
|
||||
|
||||
constructor (private readonly server: PeerTubeServer) {
|
||||
|
||||
}
|
||||
|
||||
runServer (options: {
|
||||
hideLogs?: boolean // default true
|
||||
} = {}) {
|
||||
const { hideLogs = true } = options
|
||||
|
||||
return new Promise<void>((res, rej) => {
|
||||
const args = [ 'server', '--verbose', '--id', 'test' ]
|
||||
const args = [ 'server', '--verbose', ...this.buildIdArg() ]
|
||||
|
||||
const forkOptions = {
|
||||
detached: false,
|
||||
|
@ -34,19 +38,18 @@ export class PeerTubeRunnerProcess {
|
|||
}
|
||||
|
||||
registerPeerTubeInstance (options: {
|
||||
server: PeerTubeServer
|
||||
registrationToken: string
|
||||
runnerName: string
|
||||
runnerDescription?: string
|
||||
}) {
|
||||
const { server, registrationToken, runnerName, runnerDescription } = options
|
||||
const { registrationToken, runnerName, runnerDescription } = options
|
||||
|
||||
const args = [
|
||||
'register',
|
||||
'--url', server.url,
|
||||
'--url', this.server.url,
|
||||
'--registration-token', registrationToken,
|
||||
'--runner-name', runnerName,
|
||||
'--id', 'test'
|
||||
...this.buildIdArg()
|
||||
]
|
||||
|
||||
if (runnerDescription) {
|
||||
|
@ -57,17 +60,13 @@ export class PeerTubeRunnerProcess {
|
|||
return execa.node(this.getRunnerPath(), args)
|
||||
}
|
||||
|
||||
unregisterPeerTubeInstance (options: {
|
||||
server: PeerTubeServer
|
||||
}) {
|
||||
const { server } = options
|
||||
|
||||
const args = [ 'unregister', '--url', server.url, '--id', 'test' ]
|
||||
unregisterPeerTubeInstance () {
|
||||
const args = [ 'unregister', '--url', this.server.url, ...this.buildIdArg() ]
|
||||
return execa.node(this.getRunnerPath(), args)
|
||||
}
|
||||
|
||||
async listRegisteredPeerTubeInstances () {
|
||||
const args = [ 'list-registered', '--id', 'test' ]
|
||||
const args = [ 'list-registered', ...this.buildIdArg() ]
|
||||
const { stdout } = await execa.node(this.getRunnerPath(), args)
|
||||
|
||||
return stdout
|
||||
|
@ -84,4 +83,8 @@ export class PeerTubeRunnerProcess {
|
|||
private getRunnerPath () {
|
||||
return join(root(), 'packages', 'peertube-runner', 'dist', 'peertube-runner.js')
|
||||
}
|
||||
|
||||
private buildIdArg () {
|
||||
return [ '--id', 'test-' + this.server.internalServerNumber ]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue