From 6403a6bd019a30848f0e9b5f6e7b9734229ab0f1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 May 2023 13:33:27 +0200 Subject: peertube runner tests in parallel --- server/tests/api/videos/single-server.ts | 2 +- server/tests/peertube-runner/client-cli.ts | 5 ++-- server/tests/peertube-runner/live-transcoding.ts | 8 +++---- server/tests/peertube-runner/studio-transcoding.ts | 6 ++--- server/tests/peertube-runner/vod-transcoding.ts | 6 ++--- server/tests/shared/peertube-runner-process.ts | 27 ++++++++++++---------- 6 files changed, 28 insertions(+), 26 deletions(-) (limited to 'server/tests') diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index 9fd52933f..b44e1bc37 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts @@ -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', diff --git a/server/tests/peertube-runner/client-cli.ts b/server/tests/peertube-runner/client-cli.ts index ff70e599f..cc8136c4a 100644 --- a/server/tests/peertube-runner/client-cli.ts +++ b/server/tests/peertube-runner/client-cli.ts @@ -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 () { diff --git a/server/tests/peertube-runner/live-transcoding.ts b/server/tests/peertube-runner/live-transcoding.ts index 13a4cb4e9..c56f4cd84 100644 --- a/server/tests/peertube-runner/live-transcoding.ts +++ b/server/tests/peertube-runner/live-transcoding.ts @@ -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() } diff --git a/server/tests/peertube-runner/studio-transcoding.ts b/server/tests/peertube-runner/studio-transcoding.ts index e20cc9041..f60b83dbd 100644 --- a/server/tests/peertube-runner/studio-transcoding.ts +++ b/server/tests/peertube-runner/studio-transcoding.ts @@ -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() } diff --git a/server/tests/peertube-runner/vod-transcoding.ts b/server/tests/peertube-runner/vod-transcoding.ts index d7e2df095..02d839339 100644 --- a/server/tests/peertube-runner/vod-transcoding.ts +++ b/server/tests/peertube-runner/vod-transcoding.ts @@ -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() } diff --git a/server/tests/shared/peertube-runner-process.ts b/server/tests/shared/peertube-runner-process.ts index 84e2dc6df..6ad2cd116 100644 --- a/server/tests/shared/peertube-runner-process.ts +++ b/server/tests/shared/peertube-runner-process.ts @@ -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((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 ] + } } -- cgit v1.2.3