diff options
Diffstat (limited to 'packages/tests/src/peertube-runner')
-rw-r--r-- | packages/tests/src/peertube-runner/client-cli.ts | 76 | ||||
-rw-r--r-- | packages/tests/src/peertube-runner/index.ts | 4 | ||||
-rw-r--r-- | packages/tests/src/peertube-runner/live-transcoding.ts | 200 | ||||
-rw-r--r-- | packages/tests/src/peertube-runner/studio-transcoding.ts | 127 | ||||
-rw-r--r-- | packages/tests/src/peertube-runner/vod-transcoding.ts | 349 |
5 files changed, 756 insertions, 0 deletions
diff --git a/packages/tests/src/peertube-runner/client-cli.ts b/packages/tests/src/peertube-runner/client-cli.ts new file mode 100644 index 000000000..814b7f13a --- /dev/null +++ b/packages/tests/src/peertube-runner/client-cli.ts | |||
@@ -0,0 +1,76 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { PeerTubeRunnerProcess } from '@tests/shared/peertube-runner-process.js' | ||
5 | import { | ||
6 | cleanupTests, | ||
7 | createSingleServer, | ||
8 | PeerTubeServer, | ||
9 | setAccessTokensToServers, | ||
10 | setDefaultVideoChannel | ||
11 | } from '@peertube/peertube-server-commands' | ||
12 | |||
13 | describe('Test peertube-runner program client CLI', function () { | ||
14 | let server: PeerTubeServer | ||
15 | let peertubeRunner: PeerTubeRunnerProcess | ||
16 | |||
17 | before(async function () { | ||
18 | this.timeout(120_000) | ||
19 | |||
20 | server = await createSingleServer(1) | ||
21 | |||
22 | await setAccessTokensToServers([ server ]) | ||
23 | await setDefaultVideoChannel([ server ]) | ||
24 | |||
25 | await server.config.enableRemoteTranscoding() | ||
26 | |||
27 | peertubeRunner = new PeerTubeRunnerProcess(server) | ||
28 | await peertubeRunner.runServer() | ||
29 | }) | ||
30 | |||
31 | it('Should not have PeerTube instance listed', async function () { | ||
32 | const data = await peertubeRunner.listRegisteredPeerTubeInstances() | ||
33 | |||
34 | expect(data).to.not.contain(server.url) | ||
35 | }) | ||
36 | |||
37 | it('Should register a new PeerTube instance', async function () { | ||
38 | const registrationToken = await server.runnerRegistrationTokens.getFirstRegistrationToken() | ||
39 | |||
40 | await peertubeRunner.registerPeerTubeInstance({ | ||
41 | registrationToken, | ||
42 | runnerName: 'my super runner', | ||
43 | runnerDescription: 'super description' | ||
44 | }) | ||
45 | }) | ||
46 | |||
47 | it('Should list this new PeerTube instance', async function () { | ||
48 | const data = await peertubeRunner.listRegisteredPeerTubeInstances() | ||
49 | |||
50 | expect(data).to.contain(server.url) | ||
51 | expect(data).to.contain('my super runner') | ||
52 | expect(data).to.contain('super description') | ||
53 | }) | ||
54 | |||
55 | it('Should still have the configuration after a restart', async function () { | ||
56 | peertubeRunner.kill() | ||
57 | |||
58 | await peertubeRunner.runServer() | ||
59 | }) | ||
60 | |||
61 | it('Should unregister the PeerTube instance', async function () { | ||
62 | await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'my super runner' }) | ||
63 | }) | ||
64 | |||
65 | it('Should not have PeerTube instance listed', async function () { | ||
66 | const data = await peertubeRunner.listRegisteredPeerTubeInstances() | ||
67 | |||
68 | expect(data).to.not.contain(server.url) | ||
69 | }) | ||
70 | |||
71 | after(async function () { | ||
72 | peertubeRunner.kill() | ||
73 | |||
74 | await cleanupTests([ server ]) | ||
75 | }) | ||
76 | }) | ||
diff --git a/packages/tests/src/peertube-runner/index.ts b/packages/tests/src/peertube-runner/index.ts new file mode 100644 index 000000000..29f21694f --- /dev/null +++ b/packages/tests/src/peertube-runner/index.ts | |||
@@ -0,0 +1,4 @@ | |||
1 | export * from './client-cli.js' | ||
2 | export * from './live-transcoding.js' | ||
3 | export * from './studio-transcoding.js' | ||
4 | export * from './vod-transcoding.js' | ||
diff --git a/packages/tests/src/peertube-runner/live-transcoding.ts b/packages/tests/src/peertube-runner/live-transcoding.ts new file mode 100644 index 000000000..9351bc5e2 --- /dev/null +++ b/packages/tests/src/peertube-runner/live-transcoding.ts | |||
@@ -0,0 +1,200 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | import { expect } from 'chai' | ||
3 | import { wait } from '@peertube/peertube-core-utils' | ||
4 | import { HttpStatusCode, VideoPrivacy } from '@peertube/peertube-models' | ||
5 | import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' | ||
6 | import { | ||
7 | cleanupTests, | ||
8 | createMultipleServers, | ||
9 | doubleFollow, | ||
10 | findExternalSavedVideo, | ||
11 | makeRawRequest, | ||
12 | ObjectStorageCommand, | ||
13 | PeerTubeServer, | ||
14 | setAccessTokensToServers, | ||
15 | setDefaultVideoChannel, | ||
16 | stopFfmpeg, | ||
17 | waitJobs, | ||
18 | waitUntilLivePublishedOnAllServers, | ||
19 | waitUntilLiveWaitingOnAllServers | ||
20 | } from '@peertube/peertube-server-commands' | ||
21 | import { expectStartWith } from '@tests/shared/checks.js' | ||
22 | import { checkPeerTubeRunnerCacheIsEmpty } from '@tests/shared/directories.js' | ||
23 | import { testLiveVideoResolutions } from '@tests/shared/live.js' | ||
24 | import { PeerTubeRunnerProcess } from '@tests/shared/peertube-runner-process.js' | ||
25 | import { SQLCommand } from '@tests/shared/sql-command.js' | ||
26 | |||
27 | describe('Test Live transcoding in peertube-runner program', function () { | ||
28 | let servers: PeerTubeServer[] = [] | ||
29 | let peertubeRunner: PeerTubeRunnerProcess | ||
30 | let sqlCommandServer1: SQLCommand | ||
31 | |||
32 | function runSuite (options: { | ||
33 | objectStorage?: ObjectStorageCommand | ||
34 | } = {}) { | ||
35 | const { objectStorage } = options | ||
36 | |||
37 | it('Should enable transcoding without additional resolutions', async function () { | ||
38 | this.timeout(120000) | ||
39 | |||
40 | const { video } = await servers[0].live.quickCreate({ permanentLive: true, saveReplay: false, privacy: VideoPrivacy.PUBLIC }) | ||
41 | |||
42 | const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: video.uuid }) | ||
43 | await waitUntilLivePublishedOnAllServers(servers, video.uuid) | ||
44 | await waitJobs(servers) | ||
45 | |||
46 | await testLiveVideoResolutions({ | ||
47 | originServer: servers[0], | ||
48 | sqlCommand: sqlCommandServer1, | ||
49 | servers, | ||
50 | liveVideoId: video.uuid, | ||
51 | resolutions: [ 720, 480, 360, 240, 144 ], | ||
52 | objectStorage, | ||
53 | transcoded: true | ||
54 | }) | ||
55 | |||
56 | await stopFfmpeg(ffmpegCommand) | ||
57 | |||
58 | await waitUntilLiveWaitingOnAllServers(servers, video.uuid) | ||
59 | await servers[0].videos.remove({ id: video.id }) | ||
60 | }) | ||
61 | |||
62 | it('Should transcode audio only RTMP stream', async function () { | ||
63 | this.timeout(120000) | ||
64 | |||
65 | const { video } = await servers[0].live.quickCreate({ permanentLive: true, saveReplay: false, privacy: VideoPrivacy.UNLISTED }) | ||
66 | |||
67 | const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: video.uuid, fixtureName: 'video_short_no_audio.mp4' }) | ||
68 | await waitUntilLivePublishedOnAllServers(servers, video.uuid) | ||
69 | await waitJobs(servers) | ||
70 | |||
71 | await stopFfmpeg(ffmpegCommand) | ||
72 | |||
73 | await waitUntilLiveWaitingOnAllServers(servers, video.uuid) | ||
74 | await servers[0].videos.remove({ id: video.id }) | ||
75 | }) | ||
76 | |||
77 | it('Should save a replay', async function () { | ||
78 | this.timeout(240000) | ||
79 | |||
80 | const { video } = await servers[0].live.quickCreate({ permanentLive: true, saveReplay: true }) | ||
81 | |||
82 | const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: video.uuid }) | ||
83 | await waitUntilLivePublishedOnAllServers(servers, video.uuid) | ||
84 | |||
85 | await testLiveVideoResolutions({ | ||
86 | originServer: servers[0], | ||
87 | sqlCommand: sqlCommandServer1, | ||
88 | servers, | ||
89 | liveVideoId: video.uuid, | ||
90 | resolutions: [ 720, 480, 360, 240, 144 ], | ||
91 | objectStorage, | ||
92 | transcoded: true | ||
93 | }) | ||
94 | |||
95 | await stopFfmpeg(ffmpegCommand) | ||
96 | |||
97 | await waitUntilLiveWaitingOnAllServers(servers, video.uuid) | ||
98 | await waitJobs(servers) | ||
99 | |||
100 | const session = await servers[0].live.findLatestSession({ videoId: video.uuid }) | ||
101 | expect(session.endingProcessed).to.be.true | ||
102 | expect(session.endDate).to.exist | ||
103 | expect(session.saveReplay).to.be.true | ||
104 | |||
105 | const videoLiveDetails = await servers[0].videos.get({ id: video.uuid }) | ||
106 | const replay = await findExternalSavedVideo(servers[0], videoLiveDetails) | ||
107 | |||
108 | for (const server of servers) { | ||
109 | const video = await server.videos.get({ id: replay.uuid }) | ||
110 | |||
111 | expect(video.files).to.have.lengthOf(0) | ||
112 | expect(video.streamingPlaylists).to.have.lengthOf(1) | ||
113 | |||
114 | const files = video.streamingPlaylists[0].files | ||
115 | expect(files).to.have.lengthOf(5) | ||
116 | |||
117 | for (const file of files) { | ||
118 | if (objectStorage) { | ||
119 | expectStartWith(file.fileUrl, objectStorage.getMockPlaylistBaseUrl()) | ||
120 | } | ||
121 | |||
122 | await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) | ||
123 | } | ||
124 | } | ||
125 | }) | ||
126 | } | ||
127 | |||
128 | before(async function () { | ||
129 | this.timeout(120_000) | ||
130 | |||
131 | servers = await createMultipleServers(2) | ||
132 | |||
133 | await setAccessTokensToServers(servers) | ||
134 | await setDefaultVideoChannel(servers) | ||
135 | |||
136 | await doubleFollow(servers[0], servers[1]) | ||
137 | |||
138 | sqlCommandServer1 = new SQLCommand(servers[0]) | ||
139 | |||
140 | await servers[0].config.enableRemoteTranscoding() | ||
141 | await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true }) | ||
142 | await servers[0].config.enableLive({ allowReplay: true, resolutions: 'max', transcoding: true }) | ||
143 | |||
144 | const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken() | ||
145 | |||
146 | peertubeRunner = new PeerTubeRunnerProcess(servers[0]) | ||
147 | await peertubeRunner.runServer() | ||
148 | await peertubeRunner.registerPeerTubeInstance({ registrationToken, runnerName: 'runner' }) | ||
149 | }) | ||
150 | |||
151 | describe('With lives on local filesystem storage', function () { | ||
152 | |||
153 | before(async function () { | ||
154 | await servers[0].config.enableTranscoding({ webVideo: true, hls: false, with0p: true }) | ||
155 | }) | ||
156 | |||
157 | runSuite() | ||
158 | }) | ||
159 | |||
160 | describe('With lives on object storage', function () { | ||
161 | if (areMockObjectStorageTestsDisabled()) return | ||
162 | |||
163 | const objectStorage = new ObjectStorageCommand() | ||
164 | |||
165 | before(async function () { | ||
166 | await objectStorage.prepareDefaultMockBuckets() | ||
167 | |||
168 | await servers[0].kill() | ||
169 | |||
170 | await servers[0].run(objectStorage.getDefaultMockConfig()) | ||
171 | |||
172 | // Wait for peertube runner socket reconnection | ||
173 | await wait(1500) | ||
174 | }) | ||
175 | |||
176 | runSuite({ objectStorage }) | ||
177 | |||
178 | after(async function () { | ||
179 | await objectStorage.cleanupMock() | ||
180 | }) | ||
181 | }) | ||
182 | |||
183 | describe('Check cleanup', function () { | ||
184 | |||
185 | it('Should have an empty cache directory', async function () { | ||
186 | await checkPeerTubeRunnerCacheIsEmpty(peertubeRunner) | ||
187 | }) | ||
188 | }) | ||
189 | |||
190 | after(async function () { | ||
191 | if (peertubeRunner) { | ||
192 | await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' }) | ||
193 | peertubeRunner.kill() | ||
194 | } | ||
195 | |||
196 | if (sqlCommandServer1) await sqlCommandServer1.cleanup() | ||
197 | |||
198 | await cleanupTests(servers) | ||
199 | }) | ||
200 | }) | ||
diff --git a/packages/tests/src/peertube-runner/studio-transcoding.ts b/packages/tests/src/peertube-runner/studio-transcoding.ts new file mode 100644 index 000000000..50e61091a --- /dev/null +++ b/packages/tests/src/peertube-runner/studio-transcoding.ts | |||
@@ -0,0 +1,127 @@ | |||
1 | |||
2 | import { expect } from 'chai' | ||
3 | import { getAllFiles, wait } from '@peertube/peertube-core-utils' | ||
4 | import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' | ||
5 | import { | ||
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | ObjectStorageCommand, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers, | ||
12 | setDefaultVideoChannel, | ||
13 | VideoStudioCommand, | ||
14 | waitJobs | ||
15 | } from '@peertube/peertube-server-commands' | ||
16 | import { expectStartWith, checkVideoDuration } from '@tests/shared/checks.js' | ||
17 | import { checkPeerTubeRunnerCacheIsEmpty } from '@tests/shared/directories.js' | ||
18 | import { PeerTubeRunnerProcess } from '@tests/shared/peertube-runner-process.js' | ||
19 | |||
20 | describe('Test studio transcoding in peertube-runner program', function () { | ||
21 | let servers: PeerTubeServer[] = [] | ||
22 | let peertubeRunner: PeerTubeRunnerProcess | ||
23 | |||
24 | function runSuite (options: { | ||
25 | objectStorage?: ObjectStorageCommand | ||
26 | } = {}) { | ||
27 | const { objectStorage } = options | ||
28 | |||
29 | it('Should run a complex studio transcoding', async function () { | ||
30 | this.timeout(120000) | ||
31 | |||
32 | const { uuid } = await servers[0].videos.quickUpload({ name: 'mp4', fixture: 'video_short.mp4' }) | ||
33 | await waitJobs(servers) | ||
34 | |||
35 | const video = await servers[0].videos.get({ id: uuid }) | ||
36 | const oldFileUrls = getAllFiles(video).map(f => f.fileUrl) | ||
37 | |||
38 | await servers[0].videoStudio.createEditionTasks({ videoId: uuid, tasks: VideoStudioCommand.getComplexTask() }) | ||
39 | await waitJobs(servers, { runnerJobs: true }) | ||
40 | |||
41 | for (const server of servers) { | ||
42 | const video = await server.videos.get({ id: uuid }) | ||
43 | const files = getAllFiles(video) | ||
44 | |||
45 | for (const f of files) { | ||
46 | expect(oldFileUrls).to.not.include(f.fileUrl) | ||
47 | } | ||
48 | |||
49 | if (objectStorage) { | ||
50 | for (const webVideoFile of video.files) { | ||
51 | expectStartWith(webVideoFile.fileUrl, objectStorage.getMockWebVideosBaseUrl()) | ||
52 | } | ||
53 | |||
54 | for (const hlsFile of video.streamingPlaylists[0].files) { | ||
55 | expectStartWith(hlsFile.fileUrl, objectStorage.getMockPlaylistBaseUrl()) | ||
56 | } | ||
57 | } | ||
58 | |||
59 | await checkVideoDuration(server, uuid, 9) | ||
60 | } | ||
61 | }) | ||
62 | } | ||
63 | |||
64 | before(async function () { | ||
65 | this.timeout(120_000) | ||
66 | |||
67 | servers = await createMultipleServers(2) | ||
68 | |||
69 | await setAccessTokensToServers(servers) | ||
70 | await setDefaultVideoChannel(servers) | ||
71 | |||
72 | await doubleFollow(servers[0], servers[1]) | ||
73 | |||
74 | await servers[0].config.enableTranscoding({ hls: true, webVideo: true }) | ||
75 | await servers[0].config.enableStudio() | ||
76 | await servers[0].config.enableRemoteStudio() | ||
77 | |||
78 | const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken() | ||
79 | |||
80 | peertubeRunner = new PeerTubeRunnerProcess(servers[0]) | ||
81 | await peertubeRunner.runServer() | ||
82 | await peertubeRunner.registerPeerTubeInstance({ registrationToken, runnerName: 'runner' }) | ||
83 | }) | ||
84 | |||
85 | describe('With videos on local filesystem storage', function () { | ||
86 | runSuite() | ||
87 | }) | ||
88 | |||
89 | describe('With videos on object storage', function () { | ||
90 | if (areMockObjectStorageTestsDisabled()) return | ||
91 | |||
92 | const objectStorage = new ObjectStorageCommand() | ||
93 | |||
94 | before(async function () { | ||
95 | await objectStorage.prepareDefaultMockBuckets() | ||
96 | |||
97 | await servers[0].kill() | ||
98 | |||
99 | await servers[0].run(objectStorage.getDefaultMockConfig()) | ||
100 | |||
101 | // Wait for peertube runner socket reconnection | ||
102 | await wait(1500) | ||
103 | }) | ||
104 | |||
105 | runSuite({ objectStorage }) | ||
106 | |||
107 | after(async function () { | ||
108 | await objectStorage.cleanupMock() | ||
109 | }) | ||
110 | }) | ||
111 | |||
112 | describe('Check cleanup', function () { | ||
113 | |||
114 | it('Should have an empty cache directory', async function () { | ||
115 | await checkPeerTubeRunnerCacheIsEmpty(peertubeRunner) | ||
116 | }) | ||
117 | }) | ||
118 | |||
119 | after(async function () { | ||
120 | if (peertubeRunner) { | ||
121 | await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' }) | ||
122 | peertubeRunner.kill() | ||
123 | } | ||
124 | |||
125 | await cleanupTests(servers) | ||
126 | }) | ||
127 | }) | ||
diff --git a/packages/tests/src/peertube-runner/vod-transcoding.ts b/packages/tests/src/peertube-runner/vod-transcoding.ts new file mode 100644 index 000000000..ff5cefe36 --- /dev/null +++ b/packages/tests/src/peertube-runner/vod-transcoding.ts | |||
@@ -0,0 +1,349 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | import { expect } from 'chai' | ||
3 | import { getAllFiles, wait } from '@peertube/peertube-core-utils' | ||
4 | import { VideoPrivacy } from '@peertube/peertube-models' | ||
5 | import { areMockObjectStorageTestsDisabled } from '@peertube/peertube-node-utils' | ||
6 | import { | ||
7 | cleanupTests, | ||
8 | createMultipleServers, | ||
9 | doubleFollow, | ||
10 | ObjectStorageCommand, | ||
11 | PeerTubeServer, | ||
12 | setAccessTokensToServers, | ||
13 | setDefaultVideoChannel, | ||
14 | waitJobs | ||
15 | } from '@peertube/peertube-server-commands' | ||
16 | import { checkPeerTubeRunnerCacheIsEmpty } from '@tests/shared/directories.js' | ||
17 | import { PeerTubeRunnerProcess } from '@tests/shared/peertube-runner-process.js' | ||
18 | import { completeCheckHlsPlaylist } from '@tests/shared/streaming-playlists.js' | ||
19 | import { completeWebVideoFilesCheck } from '@tests/shared/videos.js' | ||
20 | |||
21 | describe('Test VOD transcoding in peertube-runner program', function () { | ||
22 | let servers: PeerTubeServer[] = [] | ||
23 | let peertubeRunner: PeerTubeRunnerProcess | ||
24 | |||
25 | function runSuite (options: { | ||
26 | webVideoEnabled: boolean | ||
27 | hlsEnabled: boolean | ||
28 | objectStorage?: ObjectStorageCommand | ||
29 | }) { | ||
30 | const { webVideoEnabled, hlsEnabled, objectStorage } = options | ||
31 | |||
32 | const objectStorageBaseUrlWebVideo = objectStorage | ||
33 | ? objectStorage.getMockWebVideosBaseUrl() | ||
34 | : undefined | ||
35 | |||
36 | const objectStorageBaseUrlHLS = objectStorage | ||
37 | ? objectStorage.getMockPlaylistBaseUrl() | ||
38 | : undefined | ||
39 | |||
40 | it('Should upload a classic video mp4 and transcode it', async function () { | ||
41 | this.timeout(120000) | ||
42 | |||
43 | const { uuid } = await servers[0].videos.quickUpload({ name: 'mp4', fixture: 'video_short.mp4' }) | ||
44 | |||
45 | await waitJobs(servers, { runnerJobs: true }) | ||
46 | |||
47 | for (const server of servers) { | ||
48 | if (webVideoEnabled) { | ||
49 | await completeWebVideoFilesCheck({ | ||
50 | server, | ||
51 | originServer: servers[0], | ||
52 | fixture: 'video_short.mp4', | ||
53 | videoUUID: uuid, | ||
54 | objectStorageBaseUrl: objectStorageBaseUrlWebVideo, | ||
55 | files: [ | ||
56 | { resolution: 0 }, | ||
57 | { resolution: 144 }, | ||
58 | { resolution: 240 }, | ||
59 | { resolution: 360 }, | ||
60 | { resolution: 480 }, | ||
61 | { resolution: 720 } | ||
62 | ] | ||
63 | }) | ||
64 | } | ||
65 | |||
66 | if (hlsEnabled) { | ||
67 | await completeCheckHlsPlaylist({ | ||
68 | hlsOnly: !webVideoEnabled, | ||
69 | servers, | ||
70 | videoUUID: uuid, | ||
71 | objectStorageBaseUrl: objectStorageBaseUrlHLS, | ||
72 | resolutions: [ 720, 480, 360, 240, 144, 0 ] | ||
73 | }) | ||
74 | } | ||
75 | } | ||
76 | }) | ||
77 | |||
78 | it('Should upload a webm video and transcode it', async function () { | ||
79 | this.timeout(120000) | ||
80 | |||
81 | const { uuid } = await servers[0].videos.quickUpload({ name: 'mp4', fixture: 'video_short.webm' }) | ||
82 | |||
83 | await waitJobs(servers, { runnerJobs: true }) | ||
84 | |||
85 | for (const server of servers) { | ||
86 | if (webVideoEnabled) { | ||
87 | await completeWebVideoFilesCheck({ | ||
88 | server, | ||
89 | originServer: servers[0], | ||
90 | fixture: 'video_short.webm', | ||
91 | videoUUID: uuid, | ||
92 | objectStorageBaseUrl: objectStorageBaseUrlWebVideo, | ||
93 | files: [ | ||
94 | { resolution: 0 }, | ||
95 | { resolution: 144 }, | ||
96 | { resolution: 240 }, | ||
97 | { resolution: 360 }, | ||
98 | { resolution: 480 }, | ||
99 | { resolution: 720 } | ||
100 | ] | ||
101 | }) | ||
102 | } | ||
103 | |||
104 | if (hlsEnabled) { | ||
105 | await completeCheckHlsPlaylist({ | ||
106 | hlsOnly: !webVideoEnabled, | ||
107 | servers, | ||
108 | videoUUID: uuid, | ||
109 | objectStorageBaseUrl: objectStorageBaseUrlHLS, | ||
110 | resolutions: [ 720, 480, 360, 240, 144, 0 ] | ||
111 | }) | ||
112 | } | ||
113 | } | ||
114 | }) | ||
115 | |||
116 | it('Should upload an audio only video and transcode it', async function () { | ||
117 | this.timeout(120000) | ||
118 | |||
119 | const attributes = { name: 'audio_without_preview', fixture: 'sample.ogg' } | ||
120 | const { uuid } = await servers[0].videos.upload({ attributes, mode: 'resumable' }) | ||
121 | |||
122 | await waitJobs(servers, { runnerJobs: true }) | ||
123 | |||
124 | for (const server of servers) { | ||
125 | if (webVideoEnabled) { | ||
126 | await completeWebVideoFilesCheck({ | ||
127 | server, | ||
128 | originServer: servers[0], | ||
129 | fixture: 'sample.ogg', | ||
130 | videoUUID: uuid, | ||
131 | objectStorageBaseUrl: objectStorageBaseUrlWebVideo, | ||
132 | files: [ | ||
133 | { resolution: 0 }, | ||
134 | { resolution: 144 }, | ||
135 | { resolution: 240 }, | ||
136 | { resolution: 360 }, | ||
137 | { resolution: 480 } | ||
138 | ] | ||
139 | }) | ||
140 | } | ||
141 | |||
142 | if (hlsEnabled) { | ||
143 | await completeCheckHlsPlaylist({ | ||
144 | hlsOnly: !webVideoEnabled, | ||
145 | servers, | ||
146 | videoUUID: uuid, | ||
147 | objectStorageBaseUrl: objectStorageBaseUrlHLS, | ||
148 | resolutions: [ 480, 360, 240, 144, 0 ] | ||
149 | }) | ||
150 | } | ||
151 | } | ||
152 | }) | ||
153 | |||
154 | it('Should upload a private video and transcode it', async function () { | ||
155 | this.timeout(120000) | ||
156 | |||
157 | const { uuid } = await servers[0].videos.quickUpload({ name: 'mp4', fixture: 'video_short.mp4', privacy: VideoPrivacy.PRIVATE }) | ||
158 | |||
159 | await waitJobs(servers, { runnerJobs: true }) | ||
160 | |||
161 | if (webVideoEnabled) { | ||
162 | await completeWebVideoFilesCheck({ | ||
163 | server: servers[0], | ||
164 | originServer: servers[0], | ||
165 | fixture: 'video_short.mp4', | ||
166 | videoUUID: uuid, | ||
167 | objectStorageBaseUrl: objectStorageBaseUrlWebVideo, | ||
168 | files: [ | ||
169 | { resolution: 0 }, | ||
170 | { resolution: 144 }, | ||
171 | { resolution: 240 }, | ||
172 | { resolution: 360 }, | ||
173 | { resolution: 480 }, | ||
174 | { resolution: 720 } | ||
175 | ] | ||
176 | }) | ||
177 | } | ||
178 | |||
179 | if (hlsEnabled) { | ||
180 | await completeCheckHlsPlaylist({ | ||
181 | hlsOnly: !webVideoEnabled, | ||
182 | servers: [ servers[0] ], | ||
183 | videoUUID: uuid, | ||
184 | objectStorageBaseUrl: objectStorageBaseUrlHLS, | ||
185 | resolutions: [ 720, 480, 360, 240, 144, 0 ] | ||
186 | }) | ||
187 | } | ||
188 | }) | ||
189 | |||
190 | it('Should transcode videos on manual run', async function () { | ||
191 | this.timeout(120000) | ||
192 | |||
193 | await servers[0].config.disableTranscoding() | ||
194 | |||
195 | const { uuid } = await servers[0].videos.quickUpload({ name: 'manual transcoding', fixture: 'video_short.mp4' }) | ||
196 | await waitJobs(servers, { runnerJobs: true }) | ||
197 | |||
198 | { | ||
199 | const video = await servers[0].videos.get({ id: uuid }) | ||
200 | expect(getAllFiles(video)).to.have.lengthOf(1) | ||
201 | } | ||
202 | |||
203 | await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true }) | ||
204 | |||
205 | await servers[0].videos.runTranscoding({ transcodingType: 'web-video', videoId: uuid }) | ||
206 | await waitJobs(servers, { runnerJobs: true }) | ||
207 | |||
208 | await completeWebVideoFilesCheck({ | ||
209 | server: servers[0], | ||
210 | originServer: servers[0], | ||
211 | fixture: 'video_short.mp4', | ||
212 | videoUUID: uuid, | ||
213 | objectStorageBaseUrl: objectStorageBaseUrlWebVideo, | ||
214 | files: [ | ||
215 | { resolution: 0 }, | ||
216 | { resolution: 144 }, | ||
217 | { resolution: 240 }, | ||
218 | { resolution: 360 }, | ||
219 | { resolution: 480 }, | ||
220 | { resolution: 720 } | ||
221 | ] | ||
222 | }) | ||
223 | |||
224 | await servers[0].videos.runTranscoding({ transcodingType: 'hls', videoId: uuid }) | ||
225 | await waitJobs(servers, { runnerJobs: true }) | ||
226 | |||
227 | await completeCheckHlsPlaylist({ | ||
228 | hlsOnly: false, | ||
229 | servers: [ servers[0] ], | ||
230 | videoUUID: uuid, | ||
231 | objectStorageBaseUrl: objectStorageBaseUrlHLS, | ||
232 | resolutions: [ 720, 480, 360, 240, 144, 0 ] | ||
233 | }) | ||
234 | }) | ||
235 | } | ||
236 | |||
237 | before(async function () { | ||
238 | this.timeout(120_000) | ||
239 | |||
240 | servers = await createMultipleServers(2) | ||
241 | |||
242 | await setAccessTokensToServers(servers) | ||
243 | await setDefaultVideoChannel(servers) | ||
244 | |||
245 | await doubleFollow(servers[0], servers[1]) | ||
246 | |||
247 | await servers[0].config.enableRemoteTranscoding() | ||
248 | |||
249 | const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken() | ||
250 | |||
251 | peertubeRunner = new PeerTubeRunnerProcess(servers[0]) | ||
252 | await peertubeRunner.runServer() | ||
253 | await peertubeRunner.registerPeerTubeInstance({ registrationToken, runnerName: 'runner' }) | ||
254 | }) | ||
255 | |||
256 | describe('With videos on local filesystem storage', function () { | ||
257 | |||
258 | describe('Web video only enabled', function () { | ||
259 | |||
260 | before(async function () { | ||
261 | await servers[0].config.enableTranscoding({ webVideo: true, hls: false, with0p: true }) | ||
262 | }) | ||
263 | |||
264 | runSuite({ webVideoEnabled: true, hlsEnabled: false }) | ||
265 | }) | ||
266 | |||
267 | describe('HLS videos only enabled', function () { | ||
268 | |||
269 | before(async function () { | ||
270 | await servers[0].config.enableTranscoding({ webVideo: false, hls: true, with0p: true }) | ||
271 | }) | ||
272 | |||
273 | runSuite({ webVideoEnabled: false, hlsEnabled: true }) | ||
274 | }) | ||
275 | |||
276 | describe('Web video & HLS enabled', function () { | ||
277 | |||
278 | before(async function () { | ||
279 | await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true }) | ||
280 | }) | ||
281 | |||
282 | runSuite({ webVideoEnabled: true, hlsEnabled: true }) | ||
283 | }) | ||
284 | }) | ||
285 | |||
286 | describe('With videos on object storage', function () { | ||
287 | if (areMockObjectStorageTestsDisabled()) return | ||
288 | |||
289 | const objectStorage = new ObjectStorageCommand() | ||
290 | |||
291 | before(async function () { | ||
292 | await objectStorage.prepareDefaultMockBuckets() | ||
293 | |||
294 | await servers[0].kill() | ||
295 | |||
296 | await servers[0].run(objectStorage.getDefaultMockConfig()) | ||
297 | |||
298 | // Wait for peertube runner socket reconnection | ||
299 | await wait(1500) | ||
300 | }) | ||
301 | |||
302 | describe('Web video only enabled', function () { | ||
303 | |||
304 | before(async function () { | ||
305 | await servers[0].config.enableTranscoding({ webVideo: true, hls: false, with0p: true }) | ||
306 | }) | ||
307 | |||
308 | runSuite({ webVideoEnabled: true, hlsEnabled: false, objectStorage }) | ||
309 | }) | ||
310 | |||
311 | describe('HLS videos only enabled', function () { | ||
312 | |||
313 | before(async function () { | ||
314 | await servers[0].config.enableTranscoding({ webVideo: false, hls: true, with0p: true }) | ||
315 | }) | ||
316 | |||
317 | runSuite({ webVideoEnabled: false, hlsEnabled: true, objectStorage }) | ||
318 | }) | ||
319 | |||
320 | describe('Web video & HLS enabled', function () { | ||
321 | |||
322 | before(async function () { | ||
323 | await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true }) | ||
324 | }) | ||
325 | |||
326 | runSuite({ webVideoEnabled: true, hlsEnabled: true, objectStorage }) | ||
327 | }) | ||
328 | |||
329 | after(async function () { | ||
330 | await objectStorage.cleanupMock() | ||
331 | }) | ||
332 | }) | ||
333 | |||
334 | describe('Check cleanup', function () { | ||
335 | |||
336 | it('Should have an empty cache directory', async function () { | ||
337 | await checkPeerTubeRunnerCacheIsEmpty(peertubeRunner) | ||
338 | }) | ||
339 | }) | ||
340 | |||
341 | after(async function () { | ||
342 | if (peertubeRunner) { | ||
343 | await peertubeRunner.unregisterPeerTubeInstance({ runnerName: 'runner' }) | ||
344 | peertubeRunner.kill() | ||
345 | } | ||
346 | |||
347 | await cleanupTests(servers) | ||
348 | }) | ||
349 | }) | ||