diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-19 13:33:27 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-05-19 13:33:27 +0200 |
commit | 6403a6bd019a30848f0e9b5f6e7b9734229ab0f1 (patch) | |
tree | 8fb162cdb5e42ee6bb5a11acedb88218b12aa200 /server/tests/shared | |
parent | 30453cb5ba523020c488dfb7986a9848870393a5 (diff) | |
download | PeerTube-6403a6bd019a30848f0e9b5f6e7b9734229ab0f1.tar.gz PeerTube-6403a6bd019a30848f0e9b5f6e7b9734229ab0f1.tar.zst PeerTube-6403a6bd019a30848f0e9b5f6e7b9734229ab0f1.zip |
peertube runner tests in parallel
Diffstat (limited to 'server/tests/shared')
-rw-r--r-- | server/tests/shared/peertube-runner-process.ts | 27 |
1 files changed, 15 insertions, 12 deletions
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 | } |