diff options
Diffstat (limited to 'shared/server-commands/server')
-rw-r--r-- | shared/server-commands/server/jobs.ts | 9 | ||||
-rw-r--r-- | shared/server-commands/server/object-storage-command.ts | 105 | ||||
-rw-r--r-- | shared/server-commands/server/server.ts | 48 |
3 files changed, 125 insertions, 37 deletions
diff --git a/shared/server-commands/server/jobs.ts b/shared/server-commands/server/jobs.ts index fc65a873b..e1d6cdff4 100644 --- a/shared/server-commands/server/jobs.ts +++ b/shared/server-commands/server/jobs.ts | |||
@@ -4,7 +4,14 @@ import { wait } from '@shared/core-utils' | |||
4 | import { JobState, JobType } from '../../models' | 4 | import { JobState, JobType } from '../../models' |
5 | import { PeerTubeServer } from './server' | 5 | import { PeerTubeServer } from './server' |
6 | 6 | ||
7 | async function waitJobs (serversArg: PeerTubeServer[] | PeerTubeServer, skipDelayed = false) { | 7 | async function waitJobs ( |
8 | serversArg: PeerTubeServer[] | PeerTubeServer, | ||
9 | options: { | ||
10 | skipDelayed?: boolean // default false | ||
11 | } = {} | ||
12 | ) { | ||
13 | const { skipDelayed = false } = options | ||
14 | |||
8 | const pendingJobWait = process.env.NODE_PENDING_JOB_WAIT | 15 | const pendingJobWait = process.env.NODE_PENDING_JOB_WAIT |
9 | ? parseInt(process.env.NODE_PENDING_JOB_WAIT, 10) | 16 | ? parseInt(process.env.NODE_PENDING_JOB_WAIT, 10) |
10 | : 250 | 17 | : 250 |
diff --git a/shared/server-commands/server/object-storage-command.ts b/shared/server-commands/server/object-storage-command.ts index b4de8f4cb..a1fe4f0f7 100644 --- a/shared/server-commands/server/object-storage-command.ts +++ b/shared/server-commands/server/object-storage-command.ts | |||
@@ -4,74 +4,135 @@ import { makePostBodyRequest } from '../requests' | |||
4 | import { AbstractCommand } from '../shared' | 4 | import { AbstractCommand } from '../shared' |
5 | 5 | ||
6 | export class ObjectStorageCommand extends AbstractCommand { | 6 | export class ObjectStorageCommand extends AbstractCommand { |
7 | static readonly DEFAULT_PLAYLIST_BUCKET = 'streaming-playlists' | 7 | static readonly DEFAULT_PLAYLIST_MOCK_BUCKET = 'streaming-playlists' |
8 | static readonly DEFAULT_WEBTORRENT_BUCKET = 'videos' | 8 | static readonly DEFAULT_WEBTORRENT_MOCK_BUCKET = 'videos' |
9 | 9 | ||
10 | static getDefaultConfig () { | 10 | static readonly DEFAULT_SCALEWAY_BUCKET = 'peertube-ci-test' |
11 | |||
12 | // --------------------------------------------------------------------------- | ||
13 | |||
14 | static getDefaultMockConfig () { | ||
11 | return { | 15 | return { |
12 | object_storage: { | 16 | object_storage: { |
13 | enabled: true, | 17 | enabled: true, |
14 | endpoint: 'http://' + this.getEndpointHost(), | 18 | endpoint: 'http://' + this.getMockEndpointHost(), |
15 | region: this.getRegion(), | 19 | region: this.getMockRegion(), |
16 | 20 | ||
17 | credentials: this.getCredentialsConfig(), | 21 | credentials: this.getMockCredentialsConfig(), |
18 | 22 | ||
19 | streaming_playlists: { | 23 | streaming_playlists: { |
20 | bucket_name: this.DEFAULT_PLAYLIST_BUCKET | 24 | bucket_name: this.DEFAULT_PLAYLIST_MOCK_BUCKET |
21 | }, | 25 | }, |
22 | 26 | ||
23 | videos: { | 27 | videos: { |
24 | bucket_name: this.DEFAULT_WEBTORRENT_BUCKET | 28 | bucket_name: this.DEFAULT_WEBTORRENT_MOCK_BUCKET |
25 | } | 29 | } |
26 | } | 30 | } |
27 | } | 31 | } |
28 | } | 32 | } |
29 | 33 | ||
30 | static getCredentialsConfig () { | 34 | static getMockCredentialsConfig () { |
31 | return { | 35 | return { |
32 | access_key_id: 'AKIAIOSFODNN7EXAMPLE', | 36 | access_key_id: 'AKIAIOSFODNN7EXAMPLE', |
33 | secret_access_key: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' | 37 | secret_access_key: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' |
34 | } | 38 | } |
35 | } | 39 | } |
36 | 40 | ||
37 | static getEndpointHost () { | 41 | static getMockEndpointHost () { |
38 | return 'localhost:9444' | 42 | return 'localhost:9444' |
39 | } | 43 | } |
40 | 44 | ||
41 | static getRegion () { | 45 | static getMockRegion () { |
42 | return 'us-east-1' | 46 | return 'us-east-1' |
43 | } | 47 | } |
44 | 48 | ||
45 | static getWebTorrentBaseUrl () { | 49 | static getMockWebTorrentBaseUrl () { |
46 | return `http://${this.DEFAULT_WEBTORRENT_BUCKET}.${this.getEndpointHost()}/` | 50 | return `http://${this.DEFAULT_WEBTORRENT_MOCK_BUCKET}.${this.getMockEndpointHost()}/` |
47 | } | 51 | } |
48 | 52 | ||
49 | static getPlaylistBaseUrl () { | 53 | static getMockPlaylistBaseUrl () { |
50 | return `http://${this.DEFAULT_PLAYLIST_BUCKET}.${this.getEndpointHost()}/` | 54 | return `http://${this.DEFAULT_PLAYLIST_MOCK_BUCKET}.${this.getMockEndpointHost()}/` |
51 | } | 55 | } |
52 | 56 | ||
53 | static async prepareDefaultBuckets () { | 57 | static async prepareDefaultMockBuckets () { |
54 | await this.createBucket(this.DEFAULT_PLAYLIST_BUCKET) | 58 | await this.createMockBucket(this.DEFAULT_PLAYLIST_MOCK_BUCKET) |
55 | await this.createBucket(this.DEFAULT_WEBTORRENT_BUCKET) | 59 | await this.createMockBucket(this.DEFAULT_WEBTORRENT_MOCK_BUCKET) |
56 | } | 60 | } |
57 | 61 | ||
58 | static async createBucket (name: string) { | 62 | static async createMockBucket (name: string) { |
59 | await makePostBodyRequest({ | 63 | await makePostBodyRequest({ |
60 | url: this.getEndpointHost(), | 64 | url: this.getMockEndpointHost(), |
61 | path: '/ui/' + name + '?delete', | 65 | path: '/ui/' + name + '?delete', |
62 | expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307 | 66 | expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307 |
63 | }) | 67 | }) |
64 | 68 | ||
65 | await makePostBodyRequest({ | 69 | await makePostBodyRequest({ |
66 | url: this.getEndpointHost(), | 70 | url: this.getMockEndpointHost(), |
67 | path: '/ui/' + name + '?create', | 71 | path: '/ui/' + name + '?create', |
68 | expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307 | 72 | expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307 |
69 | }) | 73 | }) |
70 | 74 | ||
71 | await makePostBodyRequest({ | 75 | await makePostBodyRequest({ |
72 | url: this.getEndpointHost(), | 76 | url: this.getMockEndpointHost(), |
73 | path: '/ui/' + name + '?make-public', | 77 | path: '/ui/' + name + '?make-public', |
74 | expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307 | 78 | expectedStatus: HttpStatusCode.TEMPORARY_REDIRECT_307 |
75 | }) | 79 | }) |
76 | } | 80 | } |
81 | |||
82 | // --------------------------------------------------------------------------- | ||
83 | |||
84 | static getDefaultScalewayConfig (options: { | ||
85 | serverNumber: number | ||
86 | enablePrivateProxy?: boolean // default true | ||
87 | privateACL?: 'private' | 'public-read' // default 'private' | ||
88 | }) { | ||
89 | const { serverNumber, enablePrivateProxy = true, privateACL = 'private' } = options | ||
90 | |||
91 | return { | ||
92 | object_storage: { | ||
93 | enabled: true, | ||
94 | endpoint: this.getScalewayEndpointHost(), | ||
95 | region: this.getScalewayRegion(), | ||
96 | |||
97 | credentials: this.getScalewayCredentialsConfig(), | ||
98 | |||
99 | upload_acl: { | ||
100 | private: privateACL | ||
101 | }, | ||
102 | |||
103 | proxy: { | ||
104 | proxify_private_files: enablePrivateProxy | ||
105 | }, | ||
106 | |||
107 | streaming_playlists: { | ||
108 | bucket_name: this.DEFAULT_SCALEWAY_BUCKET, | ||
109 | prefix: `test:server-${serverNumber}-streaming-playlists:` | ||
110 | }, | ||
111 | |||
112 | videos: { | ||
113 | bucket_name: this.DEFAULT_SCALEWAY_BUCKET, | ||
114 | prefix: `test:server-${serverNumber}-videos:` | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | |||
120 | static getScalewayCredentialsConfig () { | ||
121 | return { | ||
122 | access_key_id: process.env.OBJECT_STORAGE_SCALEWAY_KEY_ID, | ||
123 | secret_access_key: process.env.OBJECT_STORAGE_SCALEWAY_ACCESS_KEY | ||
124 | } | ||
125 | } | ||
126 | |||
127 | static getScalewayEndpointHost () { | ||
128 | return 's3.fr-par.scw.cloud' | ||
129 | } | ||
130 | |||
131 | static getScalewayRegion () { | ||
132 | return 'fr-par' | ||
133 | } | ||
134 | |||
135 | static getScalewayBaseUrl () { | ||
136 | return `https://${this.DEFAULT_SCALEWAY_BUCKET}.${this.getScalewayEndpointHost()}/` | ||
137 | } | ||
77 | } | 138 | } |
diff --git a/shared/server-commands/server/server.ts b/shared/server-commands/server/server.ts index 2b4c9c9f8..c062e6986 100644 --- a/shared/server-commands/server/server.ts +++ b/shared/server-commands/server/server.ts | |||
@@ -13,7 +13,15 @@ import { AbusesCommand } from '../moderation' | |||
13 | import { OverviewsCommand } from '../overviews' | 13 | import { OverviewsCommand } from '../overviews' |
14 | import { SearchCommand } from '../search' | 14 | import { SearchCommand } from '../search' |
15 | import { SocketIOCommand } from '../socket' | 15 | import { SocketIOCommand } from '../socket' |
16 | import { AccountsCommand, BlocklistCommand, LoginCommand, NotificationsCommand, SubscriptionsCommand, UsersCommand } from '../users' | 16 | import { |
17 | AccountsCommand, | ||
18 | BlocklistCommand, | ||
19 | LoginCommand, | ||
20 | NotificationsCommand, | ||
21 | SubscriptionsCommand, | ||
22 | TwoFactorCommand, | ||
23 | UsersCommand | ||
24 | } from '../users' | ||
17 | import { | 25 | import { |
18 | BlacklistCommand, | 26 | BlacklistCommand, |
19 | CaptionsCommand, | 27 | CaptionsCommand, |
@@ -28,6 +36,7 @@ import { | |||
28 | StreamingPlaylistsCommand, | 36 | StreamingPlaylistsCommand, |
29 | VideosCommand, | 37 | VideosCommand, |
30 | VideoStudioCommand, | 38 | VideoStudioCommand, |
39 | VideoTokenCommand, | ||
31 | ViewsCommand | 40 | ViewsCommand |
32 | } from '../videos' | 41 | } from '../videos' |
33 | import { CommentsCommand } from '../videos/comments-command' | 42 | import { CommentsCommand } from '../videos/comments-command' |
@@ -136,6 +145,8 @@ export class PeerTubeServer { | |||
136 | videos?: VideosCommand | 145 | videos?: VideosCommand |
137 | videoStats?: VideoStatsCommand | 146 | videoStats?: VideoStatsCommand |
138 | views?: ViewsCommand | 147 | views?: ViewsCommand |
148 | twoFactor?: TwoFactorCommand | ||
149 | videoToken?: VideoTokenCommand | ||
139 | 150 | ||
140 | constructor (options: { serverNumber: number } | { url: string }) { | 151 | constructor (options: { serverNumber: number } | { url: string }) { |
141 | if ((options as any).url) { | 152 | if ((options as any).url) { |
@@ -182,6 +193,12 @@ export class PeerTubeServer { | |||
182 | this.port = parseInt(parsed.port) | 193 | this.port = parseInt(parsed.port) |
183 | } | 194 | } |
184 | 195 | ||
196 | getDirectoryPath (directoryName: string) { | ||
197 | const testDirectory = 'test' + this.internalServerNumber | ||
198 | |||
199 | return join(root(), testDirectory, directoryName) | ||
200 | } | ||
201 | |||
185 | async flushAndRun (configOverride?: Object, options: RunServerOptions = {}) { | 202 | async flushAndRun (configOverride?: Object, options: RunServerOptions = {}) { |
186 | await ServersCommand.flushTests(this.internalServerNumber) | 203 | await ServersCommand.flushTests(this.internalServerNumber) |
187 | 204 | ||
@@ -341,19 +358,20 @@ export class PeerTubeServer { | |||
341 | suffix: '_test' + this.internalServerNumber | 358 | suffix: '_test' + this.internalServerNumber |
342 | }, | 359 | }, |
343 | storage: { | 360 | storage: { |
344 | tmp: `test${this.internalServerNumber}/tmp/`, | 361 | tmp: this.getDirectoryPath('tmp') + '/', |
345 | bin: `test${this.internalServerNumber}/bin/`, | 362 | bin: this.getDirectoryPath('bin') + '/', |
346 | avatars: `test${this.internalServerNumber}/avatars/`, | 363 | avatars: this.getDirectoryPath('avatars') + '/', |
347 | videos: `test${this.internalServerNumber}/videos/`, | 364 | videos: this.getDirectoryPath('videos') + '/', |
348 | streaming_playlists: `test${this.internalServerNumber}/streaming-playlists/`, | 365 | streaming_playlists: this.getDirectoryPath('streaming-playlists') + '/', |
349 | redundancy: `test${this.internalServerNumber}/redundancy/`, | 366 | redundancy: this.getDirectoryPath('redundancy') + '/', |
350 | logs: `test${this.internalServerNumber}/logs/`, | 367 | logs: this.getDirectoryPath('logs') + '/', |
351 | previews: `test${this.internalServerNumber}/previews/`, | 368 | previews: this.getDirectoryPath('previews') + '/', |
352 | thumbnails: `test${this.internalServerNumber}/thumbnails/`, | 369 | thumbnails: this.getDirectoryPath('thumbnails') + '/', |
353 | torrents: `test${this.internalServerNumber}/torrents/`, | 370 | torrents: this.getDirectoryPath('torrents') + '/', |
354 | captions: `test${this.internalServerNumber}/captions/`, | 371 | captions: this.getDirectoryPath('captions') + '/', |
355 | cache: `test${this.internalServerNumber}/cache/`, | 372 | cache: this.getDirectoryPath('cache') + '/', |
356 | plugins: `test${this.internalServerNumber}/plugins/` | 373 | plugins: this.getDirectoryPath('plugins') + '/', |
374 | well_known: this.getDirectoryPath('well-known') + '/' | ||
357 | }, | 375 | }, |
358 | admin: { | 376 | admin: { |
359 | email: `admin${this.internalServerNumber}@example.com` | 377 | email: `admin${this.internalServerNumber}@example.com` |
@@ -410,5 +428,7 @@ export class PeerTubeServer { | |||
410 | this.videoStudio = new VideoStudioCommand(this) | 428 | this.videoStudio = new VideoStudioCommand(this) |
411 | this.videoStats = new VideoStatsCommand(this) | 429 | this.videoStats = new VideoStatsCommand(this) |
412 | this.views = new ViewsCommand(this) | 430 | this.views = new ViewsCommand(this) |
431 | this.twoFactor = new TwoFactorCommand(this) | ||
432 | this.videoToken = new VideoTokenCommand(this) | ||
413 | } | 433 | } |
414 | } | 434 | } |