aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli/create-transcoding-job.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-21 15:51:30 +0200
committerChocobozzz <me@florianbigard.com>2021-07-21 15:51:30 +0200
commita24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch)
treea54b0f6c921ba83a6e909cd0ced325b2d4b8863c /server/tests/cli/create-transcoding-job.ts
parent5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff)
parentc63830f15403ac4e750829f27d8bbbdc9a59282c (diff)
downloadPeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz
PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst
PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip
Merge branch 'next' into develop
Diffstat (limited to 'server/tests/cli/create-transcoding-job.ts')
-rw-r--r--server/tests/cli/create-transcoding-job.ts110
1 files changed, 43 insertions, 67 deletions
diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts
index 5bc1687cd..df787ccdc 100644
--- a/server/tests/cli/create-transcoding-job.ts
+++ b/server/tests/cli/create-transcoding-job.ts
@@ -2,26 +2,19 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { VideoDetails } from '../../../shared/models/videos'
6import { 5import {
7 cleanupTests, 6 cleanupTests,
7 createMultipleServers,
8 doubleFollow, 8 doubleFollow,
9 execCLI, 9 PeerTubeServer,
10 flushAndRunMultipleServers,
11 getEnvCli,
12 getVideo,
13 getVideosList,
14 ServerInfo,
15 setAccessTokensToServers, 10 setAccessTokensToServers,
16 updateCustomSubConfig, 11 waitJobs
17 uploadVideo
18} from '../../../shared/extra-utils' 12} from '../../../shared/extra-utils'
19import { waitJobs } from '../../../shared/extra-utils/server/jobs'
20 13
21const expect = chai.expect 14const expect = chai.expect
22 15
23describe('Test create transcoding jobs', function () { 16describe('Test create transcoding jobs', function () {
24 let servers: ServerInfo[] = [] 17 let servers: PeerTubeServer[] = []
25 const videosUUID: string[] = [] 18 const videosUUID: string[] = []
26 19
27 const config = { 20 const config = {
@@ -46,16 +39,16 @@ describe('Test create transcoding jobs', function () {
46 this.timeout(60000) 39 this.timeout(60000)
47 40
48 // Run server 2 to have transcoding enabled 41 // Run server 2 to have transcoding enabled
49 servers = await flushAndRunMultipleServers(2) 42 servers = await createMultipleServers(2)
50 await setAccessTokensToServers(servers) 43 await setAccessTokensToServers(servers)
51 44
52 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) 45 await servers[0].config.updateCustomSubConfig({ newConfig: config })
53 46
54 await doubleFollow(servers[0], servers[1]) 47 await doubleFollow(servers[0], servers[1])
55 48
56 for (let i = 1; i <= 5; i++) { 49 for (let i = 1; i <= 5; i++) {
57 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' + i }) 50 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' + i } })
58 videosUUID.push(res.body.video.uuid) 51 videosUUID.push(uuid)
59 } 52 }
60 53
61 await waitJobs(servers) 54 await waitJobs(servers)
@@ -65,13 +58,11 @@ describe('Test create transcoding jobs', function () {
65 this.timeout(30000) 58 this.timeout(30000)
66 59
67 for (const server of servers) { 60 for (const server of servers) {
68 const res = await getVideosList(server.url) 61 const { data } = await server.videos.list()
69 const videos = res.body.data 62 expect(data).to.have.lengthOf(videosUUID.length)
70 expect(videos).to.have.lengthOf(videosUUID.length)
71 63
72 for (const video of videos) { 64 for (const video of data) {
73 const res2 = await getVideo(server.url, video.uuid) 65 const videoDetail = await server.videos.get({ id: video.uuid })
74 const videoDetail: VideoDetails = res2.body
75 expect(videoDetail.files).to.have.lengthOf(1) 66 expect(videoDetail.files).to.have.lengthOf(1)
76 expect(videoDetail.streamingPlaylists).to.have.lengthOf(0) 67 expect(videoDetail.streamingPlaylists).to.have.lengthOf(0)
77 } 68 }
@@ -81,20 +72,16 @@ describe('Test create transcoding jobs', function () {
81 it('Should run a transcoding job on video 2', async function () { 72 it('Should run a transcoding job on video 2', async function () {
82 this.timeout(60000) 73 this.timeout(60000)
83 74
84 const env = getEnvCli(servers[0]) 75 await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`)
85 await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[1]}`)
86
87 await waitJobs(servers) 76 await waitJobs(servers)
88 77
89 for (const server of servers) { 78 for (const server of servers) {
90 const res = await getVideosList(server.url) 79 const { data } = await server.videos.list()
91 const videos = res.body.data
92 80
93 let infoHashes: { [id: number]: string } 81 let infoHashes: { [id: number]: string }
94 82
95 for (const video of videos) { 83 for (const video of data) {
96 const res2 = await getVideo(server.url, video.uuid) 84 const videoDetail = await server.videos.get({ id: video.uuid })
97 const videoDetail: VideoDetails = res2.body
98 85
99 if (video.uuid === videosUUID[1]) { 86 if (video.uuid === videosUUID[1]) {
100 expect(videoDetail.files).to.have.lengthOf(4) 87 expect(videoDetail.files).to.have.lengthOf(4)
@@ -123,43 +110,38 @@ describe('Test create transcoding jobs', function () {
123 it('Should run a transcoding job on video 1 with resolution', async function () { 110 it('Should run a transcoding job on video 1 with resolution', async function () {
124 this.timeout(60000) 111 this.timeout(60000)
125 112
126 const env = getEnvCli(servers[0]) 113 await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`)
127 await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`)
128 114
129 await waitJobs(servers) 115 await waitJobs(servers)
130 116
131 for (const server of servers) { 117 for (const server of servers) {
132 const res = await getVideosList(server.url) 118 const { data } = await server.videos.list()
133 const videos = res.body.data 119 expect(data).to.have.lengthOf(videosUUID.length)
134 expect(videos).to.have.lengthOf(videosUUID.length)
135 120
136 const res2 = await getVideo(server.url, videosUUID[0]) 121 const videoDetails = await server.videos.get({ id: videosUUID[0] })
137 const videoDetail: VideoDetails = res2.body
138 122
139 expect(videoDetail.files).to.have.lengthOf(2) 123 expect(videoDetails.files).to.have.lengthOf(2)
140 expect(videoDetail.files[0].resolution.id).to.equal(720) 124 expect(videoDetails.files[0].resolution.id).to.equal(720)
141 expect(videoDetail.files[1].resolution.id).to.equal(480) 125 expect(videoDetails.files[1].resolution.id).to.equal(480)
142 126
143 expect(videoDetail.streamingPlaylists).to.have.lengthOf(0) 127 expect(videoDetails.streamingPlaylists).to.have.lengthOf(0)
144 } 128 }
145 }) 129 })
146 130
147 it('Should generate an HLS resolution', async function () { 131 it('Should generate an HLS resolution', async function () {
148 this.timeout(120000) 132 this.timeout(120000)
149 133
150 const env = getEnvCli(servers[0]) 134 await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
151 await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
152 135
153 await waitJobs(servers) 136 await waitJobs(servers)
154 137
155 for (const server of servers) { 138 for (const server of servers) {
156 const res = await getVideo(server.url, videosUUID[2]) 139 const videoDetails = await server.videos.get({ id: videosUUID[2] })
157 const videoDetail: VideoDetails = res.body
158 140
159 expect(videoDetail.files).to.have.lengthOf(1) 141 expect(videoDetails.files).to.have.lengthOf(1)
160 expect(videoDetail.streamingPlaylists).to.have.lengthOf(1) 142 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
161 143
162 const files = videoDetail.streamingPlaylists[0].files 144 const files = videoDetails.streamingPlaylists[0].files
163 expect(files).to.have.lengthOf(1) 145 expect(files).to.have.lengthOf(1)
164 expect(files[0].resolution.id).to.equal(480) 146 expect(files[0].resolution.id).to.equal(480)
165 } 147 }
@@ -168,16 +150,14 @@ describe('Test create transcoding jobs', function () {
168 it('Should not duplicate an HLS resolution', async function () { 150 it('Should not duplicate an HLS resolution', async function () {
169 this.timeout(120000) 151 this.timeout(120000)
170 152
171 const env = getEnvCli(servers[0]) 153 await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
172 await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
173 154
174 await waitJobs(servers) 155 await waitJobs(servers)
175 156
176 for (const server of servers) { 157 for (const server of servers) {
177 const res = await getVideo(server.url, videosUUID[2]) 158 const videoDetails = await server.videos.get({ id: videosUUID[2] })
178 const videoDetail: VideoDetails = res.body
179 159
180 const files = videoDetail.streamingPlaylists[0].files 160 const files = videoDetails.streamingPlaylists[0].files
181 expect(files).to.have.lengthOf(1) 161 expect(files).to.have.lengthOf(1)
182 expect(files[0].resolution.id).to.equal(480) 162 expect(files[0].resolution.id).to.equal(480)
183 } 163 }
@@ -186,19 +166,17 @@ describe('Test create transcoding jobs', function () {
186 it('Should generate all HLS resolutions', async function () { 166 it('Should generate all HLS resolutions', async function () {
187 this.timeout(120000) 167 this.timeout(120000)
188 168
189 const env = getEnvCli(servers[0]) 169 await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`)
190 await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`)
191 170
192 await waitJobs(servers) 171 await waitJobs(servers)
193 172
194 for (const server of servers) { 173 for (const server of servers) {
195 const res = await getVideo(server.url, videosUUID[3]) 174 const videoDetails = await server.videos.get({ id: videosUUID[3] })
196 const videoDetail: VideoDetails = res.body
197 175
198 expect(videoDetail.files).to.have.lengthOf(1) 176 expect(videoDetails.files).to.have.lengthOf(1)
199 expect(videoDetail.streamingPlaylists).to.have.lengthOf(1) 177 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
200 178
201 const files = videoDetail.streamingPlaylists[0].files 179 const files = videoDetails.streamingPlaylists[0].files
202 expect(files).to.have.lengthOf(4) 180 expect(files).to.have.lengthOf(4)
203 } 181 }
204 }) 182 })
@@ -207,20 +185,18 @@ describe('Test create transcoding jobs', function () {
207 this.timeout(120000) 185 this.timeout(120000)
208 186
209 config.transcoding.hls.enabled = true 187 config.transcoding.hls.enabled = true
210 await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) 188 await servers[0].config.updateCustomSubConfig({ newConfig: config })
211 189
212 const env = getEnvCli(servers[0]) 190 await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`)
213 await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[4]}`)
214 191
215 await waitJobs(servers) 192 await waitJobs(servers)
216 193
217 for (const server of servers) { 194 for (const server of servers) {
218 const res = await getVideo(server.url, videosUUID[4]) 195 const videoDetails = await server.videos.get({ id: videosUUID[4] })
219 const videoDetail: VideoDetails = res.body
220 196
221 expect(videoDetail.files).to.have.lengthOf(4) 197 expect(videoDetails.files).to.have.lengthOf(4)
222 expect(videoDetail.streamingPlaylists).to.have.lengthOf(1) 198 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
223 expect(videoDetail.streamingPlaylists[0].files).to.have.lengthOf(4) 199 expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(4)
224 } 200 }
225 }) 201 })
226 202