diff options
-rw-r--r-- | packages/peertube-runner/shared/config-manager.ts | 2 | ||||
-rwxr-xr-x | scripts/ci.sh | 3 | ||||
-rw-r--r-- | server/tests/api/videos/single-server.ts | 2 | ||||
-rw-r--r-- | server/tests/peertube-runner/client-cli.ts | 5 | ||||
-rw-r--r-- | server/tests/peertube-runner/live-transcoding.ts | 8 | ||||
-rw-r--r-- | server/tests/peertube-runner/studio-transcoding.ts | 6 | ||||
-rw-r--r-- | server/tests/peertube-runner/vod-transcoding.ts | 6 | ||||
-rw-r--r-- | server/tests/shared/peertube-runner-process.ts | 27 |
8 files changed, 31 insertions, 28 deletions
diff --git a/packages/peertube-runner/shared/config-manager.ts b/packages/peertube-runner/shared/config-manager.ts index 352bae1fa..548eeab85 100644 --- a/packages/peertube-runner/shared/config-manager.ts +++ b/packages/peertube-runner/shared/config-manager.ts | |||
@@ -112,7 +112,7 @@ export class ConfigManager { | |||
112 | // --------------------------------------------------------------------------- | 112 | // --------------------------------------------------------------------------- |
113 | 113 | ||
114 | isTestInstance () { | 114 | isTestInstance () { |
115 | return this.id === 'test' | 115 | return typeof this.id === 'string' && this.id.match(/^test-\d$/) |
116 | } | 116 | } |
117 | 117 | ||
118 | // --------------------------------------------------------------------------- | 118 | // --------------------------------------------------------------------------- |
diff --git a/scripts/ci.sh b/scripts/ci.sh index 7b2e5d347..9fb67f634 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh | |||
@@ -114,7 +114,8 @@ elif [ "$1" = "external-plugins" ]; then | |||
114 | externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins) | 114 | externalPluginsFiles=$(findTestFiles ./dist/server/tests/external-plugins) |
115 | peertubeRunnerFiles=$(findTestFiles ./dist/server/tests/peertube-runner) | 115 | peertubeRunnerFiles=$(findTestFiles ./dist/server/tests/peertube-runner) |
116 | 116 | ||
117 | runTest "$1" 1 $externalPluginsFiles $peertubeRunnerFiles | 117 | runTest "$1" 1 $externalPluginsFiles |
118 | MOCHA_PARALLEL=true runTest "$1" $((2*$speedFactor)) $peertubeRunnerFiles | ||
118 | elif [ "$1" = "lint" ]; then | 119 | elif [ "$1" = "lint" ]; then |
119 | npm run eslint -- --ext .ts "./server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts" | 120 | npm run eslint -- --ext .ts "./server/**/*.ts" "shared/**/*.ts" "scripts/**/*.ts" |
120 | npm run swagger-cli -- validate support/doc/api/openapi.yaml | 121 | npm run swagger-cli -- validate support/doc/api/openapi.yaml |
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 () { | |||
213 | }) | 213 | }) |
214 | 214 | ||
215 | it('Should upload 6 videos', async function () { | 215 | it('Should upload 6 videos', async function () { |
216 | this.timeout(50000) | 216 | this.timeout(120000) |
217 | 217 | ||
218 | const videos = new Set([ | 218 | const videos = new Set([ |
219 | 'video_short.mp4', 'video_short.ogv', 'video_short.webm', | 219 | '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 () { | |||
18 | 18 | ||
19 | await server.config.enableRemoteTranscoding() | 19 | await server.config.enableRemoteTranscoding() |
20 | 20 | ||
21 | peertubeRunner = new PeerTubeRunnerProcess() | 21 | peertubeRunner = new PeerTubeRunnerProcess(server) |
22 | await peertubeRunner.runServer() | 22 | await peertubeRunner.runServer() |
23 | }) | 23 | }) |
24 | 24 | ||
@@ -32,7 +32,6 @@ describe('Test peertube-runner program client CLI', function () { | |||
32 | const registrationToken = await server.runnerRegistrationTokens.getFirstRegistrationToken() | 32 | const registrationToken = await server.runnerRegistrationTokens.getFirstRegistrationToken() |
33 | 33 | ||
34 | await peertubeRunner.registerPeerTubeInstance({ | 34 | await peertubeRunner.registerPeerTubeInstance({ |
35 | server, | ||
36 | registrationToken, | 35 | registrationToken, |
37 | runnerName: 'my super runner', | 36 | runnerName: 'my super runner', |
38 | runnerDescription: 'super description' | 37 | runnerDescription: 'super description' |
@@ -54,7 +53,7 @@ describe('Test peertube-runner program client CLI', function () { | |||
54 | }) | 53 | }) |
55 | 54 | ||
56 | it('Should unregister the PeerTube instance', async function () { | 55 | it('Should unregister the PeerTube instance', async function () { |
57 | await peertubeRunner.unregisterPeerTubeInstance({ server }) | 56 | await peertubeRunner.unregisterPeerTubeInstance() |
58 | }) | 57 | }) |
59 | 58 | ||
60 | it('Should not have PeerTube instance listed', async function () { | 59 | 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 @@ | |||
1 | import { expect } from 'chai' | ||
2 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | import { expect } from 'chai' | ||
3 | import { | 3 | import { |
4 | checkPeerTubeRunnerCacheIsEmpty, | 4 | checkPeerTubeRunnerCacheIsEmpty, |
5 | expectStartWith, | 5 | expectStartWith, |
@@ -144,9 +144,9 @@ describe('Test Live transcoding in peertube-runner program', function () { | |||
144 | 144 | ||
145 | const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken() | 145 | const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken() |
146 | 146 | ||
147 | peertubeRunner = new PeerTubeRunnerProcess() | 147 | peertubeRunner = new PeerTubeRunnerProcess(servers[0]) |
148 | await peertubeRunner.runServer() | 148 | await peertubeRunner.runServer() |
149 | await peertubeRunner.registerPeerTubeInstance({ server: servers[0], registrationToken, runnerName: 'runner' }) | 149 | await peertubeRunner.registerPeerTubeInstance({ registrationToken, runnerName: 'runner' }) |
150 | }) | 150 | }) |
151 | 151 | ||
152 | describe('With lives on local filesystem storage', function () { | 152 | describe('With lives on local filesystem storage', function () { |
@@ -184,7 +184,7 @@ describe('Test Live transcoding in peertube-runner program', function () { | |||
184 | 184 | ||
185 | after(async function () { | 185 | after(async function () { |
186 | if (peertubeRunner) { | 186 | if (peertubeRunner) { |
187 | await peertubeRunner.unregisterPeerTubeInstance({ server: servers[0] }) | 187 | await peertubeRunner.unregisterPeerTubeInstance() |
188 | peertubeRunner.kill() | 188 | peertubeRunner.kill() |
189 | } | 189 | } |
190 | 190 | ||
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 () { | |||
74 | 74 | ||
75 | const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken() | 75 | const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken() |
76 | 76 | ||
77 | peertubeRunner = new PeerTubeRunnerProcess() | 77 | peertubeRunner = new PeerTubeRunnerProcess(servers[0]) |
78 | await peertubeRunner.runServer() | 78 | await peertubeRunner.runServer() |
79 | await peertubeRunner.registerPeerTubeInstance({ server: servers[0], registrationToken, runnerName: 'runner' }) | 79 | await peertubeRunner.registerPeerTubeInstance({ registrationToken, runnerName: 'runner' }) |
80 | }) | 80 | }) |
81 | 81 | ||
82 | describe('With videos on local filesystem storage', function () { | 82 | describe('With videos on local filesystem storage', function () { |
@@ -109,7 +109,7 @@ describe('Test studio transcoding in peertube-runner program', function () { | |||
109 | 109 | ||
110 | after(async function () { | 110 | after(async function () { |
111 | if (peertubeRunner) { | 111 | if (peertubeRunner) { |
112 | await peertubeRunner.unregisterPeerTubeInstance({ server: servers[0] }) | 112 | await peertubeRunner.unregisterPeerTubeInstance() |
113 | peertubeRunner.kill() | 113 | peertubeRunner.kill() |
114 | } | 114 | } |
115 | 115 | ||
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 () { | |||
249 | 249 | ||
250 | const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken() | 250 | const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken() |
251 | 251 | ||
252 | peertubeRunner = new PeerTubeRunnerProcess() | 252 | peertubeRunner = new PeerTubeRunnerProcess(servers[0]) |
253 | await peertubeRunner.runServer() | 253 | await peertubeRunner.runServer() |
254 | await peertubeRunner.registerPeerTubeInstance({ server: servers[0], registrationToken, runnerName: 'runner' }) | 254 | await peertubeRunner.registerPeerTubeInstance({ registrationToken, runnerName: 'runner' }) |
255 | }) | 255 | }) |
256 | 256 | ||
257 | describe('With videos on local filesystem storage', function () { | 257 | describe('With videos on local filesystem storage', function () { |
@@ -335,7 +335,7 @@ describe('Test VOD transcoding in peertube-runner program', function () { | |||
335 | 335 | ||
336 | after(async function () { | 336 | after(async function () { |
337 | if (peertubeRunner) { | 337 | if (peertubeRunner) { |
338 | await peertubeRunner.unregisterPeerTubeInstance({ server: servers[0] }) | 338 | await peertubeRunner.unregisterPeerTubeInstance() |
339 | peertubeRunner.kill() | 339 | peertubeRunner.kill() |
340 | } | 340 | } |
341 | 341 | ||
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' | |||
7 | export class PeerTubeRunnerProcess { | 7 | export class PeerTubeRunnerProcess { |
8 | private app?: ChildProcess | 8 | private app?: ChildProcess |
9 | 9 | ||
10 | constructor (private readonly server: PeerTubeServer) { | ||
11 | |||
12 | } | ||
13 | |||
10 | runServer (options: { | 14 | runServer (options: { |
11 | hideLogs?: boolean // default true | 15 | hideLogs?: boolean // default true |
12 | } = {}) { | 16 | } = {}) { |
13 | const { hideLogs = true } = options | 17 | const { hideLogs = true } = options |
14 | 18 | ||
15 | return new Promise<void>((res, rej) => { | 19 | return new Promise<void>((res, rej) => { |
16 | const args = [ 'server', '--verbose', '--id', 'test' ] | 20 | const args = [ 'server', '--verbose', ...this.buildIdArg() ] |
17 | 21 | ||
18 | const forkOptions = { | 22 | const forkOptions = { |
19 | detached: false, | 23 | detached: false, |
@@ -34,19 +38,18 @@ export class PeerTubeRunnerProcess { | |||
34 | } | 38 | } |
35 | 39 | ||
36 | registerPeerTubeInstance (options: { | 40 | registerPeerTubeInstance (options: { |
37 | server: PeerTubeServer | ||
38 | registrationToken: string | 41 | registrationToken: string |
39 | runnerName: string | 42 | runnerName: string |
40 | runnerDescription?: string | 43 | runnerDescription?: string |
41 | }) { | 44 | }) { |
42 | const { server, registrationToken, runnerName, runnerDescription } = options | 45 | const { registrationToken, runnerName, runnerDescription } = options |
43 | 46 | ||
44 | const args = [ | 47 | const args = [ |
45 | 'register', | 48 | 'register', |
46 | '--url', server.url, | 49 | '--url', this.server.url, |
47 | '--registration-token', registrationToken, | 50 | '--registration-token', registrationToken, |
48 | '--runner-name', runnerName, | 51 | '--runner-name', runnerName, |
49 | '--id', 'test' | 52 | ...this.buildIdArg() |
50 | ] | 53 | ] |
51 | 54 | ||
52 | if (runnerDescription) { | 55 | if (runnerDescription) { |
@@ -57,17 +60,13 @@ export class PeerTubeRunnerProcess { | |||
57 | return execa.node(this.getRunnerPath(), args) | 60 | return execa.node(this.getRunnerPath(), args) |
58 | } | 61 | } |
59 | 62 | ||
60 | unregisterPeerTubeInstance (options: { | 63 | unregisterPeerTubeInstance () { |
61 | server: PeerTubeServer | 64 | const args = [ 'unregister', '--url', this.server.url, ...this.buildIdArg() ] |
62 | }) { | ||
63 | const { server } = options | ||
64 | |||
65 | const args = [ 'unregister', '--url', server.url, '--id', 'test' ] | ||
66 | return execa.node(this.getRunnerPath(), args) | 65 | return execa.node(this.getRunnerPath(), args) |
67 | } | 66 | } |
68 | 67 | ||
69 | async listRegisteredPeerTubeInstances () { | 68 | async listRegisteredPeerTubeInstances () { |
70 | const args = [ 'list-registered', '--id', 'test' ] | 69 | const args = [ 'list-registered', ...this.buildIdArg() ] |
71 | const { stdout } = await execa.node(this.getRunnerPath(), args) | 70 | const { stdout } = await execa.node(this.getRunnerPath(), args) |
72 | 71 | ||
73 | return stdout | 72 | return stdout |
@@ -84,4 +83,8 @@ export class PeerTubeRunnerProcess { | |||
84 | private getRunnerPath () { | 83 | private getRunnerPath () { |
85 | return join(root(), 'packages', 'peertube-runner', 'dist', 'peertube-runner.js') | 84 | return join(root(), 'packages', 'peertube-runner', 'dist', 'peertube-runner.js') |
86 | } | 85 | } |
86 | |||
87 | private buildIdArg () { | ||
88 | return [ '--id', 'test-' + this.server.internalServerNumber ] | ||
89 | } | ||
87 | } | 90 | } |