aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-04 13:40:02 +0100
committerChocobozzz <chocobozzz@cpy.re>2022-03-09 09:23:10 +0100
commitf443a74649174b2f9347c158e30f8ac7aa3e958a (patch)
treee423bc4e2307477bda4341037b7fa04ad10adae6 /server/tests
parent01dd04cd5ab7b55d2a9af7d0ebf405bee9579b09 (diff)
downloadPeerTube-f443a74649174b2f9347c158e30f8ac7aa3e958a.tar.gz
PeerTube-f443a74649174b2f9347c158e30f8ac7aa3e958a.tar.zst
PeerTube-f443a74649174b2f9347c158e30f8ac7aa3e958a.zip
Add latency setting support
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/config.ts3
-rw-r--r--server/tests/api/check-params/live.ts32
-rw-r--r--server/tests/api/live/live.ts9
-rw-r--r--server/tests/api/server/config.ts5
4 files changed, 46 insertions, 3 deletions
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index ce067a892..900f642c2 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -125,6 +125,9 @@ describe('Test config API validators', function () {
125 enabled: true, 125 enabled: true,
126 126
127 allowReplay: false, 127 allowReplay: false,
128 latencySetting: {
129 enabled: false
130 },
128 maxDuration: 30, 131 maxDuration: 30,
129 maxInstanceLives: -1, 132 maxInstanceLives: -1,
130 maxUserLives: 50, 133 maxUserLives: 50,
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index 8aee6164c..b253f5e20 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { buildAbsoluteFixturePath } from '@shared/core-utils' 5import { buildAbsoluteFixturePath } from '@shared/core-utils'
6import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' 6import { HttpStatusCode, LiveVideoLatencyMode, VideoCreateResult, VideoPrivacy } from '@shared/models'
7import { 7import {
8 cleanupTests, 8 cleanupTests,
9 createSingleServer, 9 createSingleServer,
@@ -38,6 +38,9 @@ describe('Test video lives API validator', function () {
38 newConfig: { 38 newConfig: {
39 live: { 39 live: {
40 enabled: true, 40 enabled: true,
41 latencySetting: {
42 enabled: false
43 },
41 maxInstanceLives: 20, 44 maxInstanceLives: 20,
42 maxUserLives: 20, 45 maxUserLives: 20,
43 allowReplay: true 46 allowReplay: true
@@ -81,7 +84,8 @@ describe('Test video lives API validator', function () {
81 privacy: VideoPrivacy.PUBLIC, 84 privacy: VideoPrivacy.PUBLIC,
82 channelId, 85 channelId,
83 saveReplay: false, 86 saveReplay: false,
84 permanentLive: false 87 permanentLive: false,
88 latencyMode: LiveVideoLatencyMode.DEFAULT
85 } 89 }
86 }) 90 })
87 91
@@ -214,6 +218,18 @@ describe('Test video lives API validator', function () {
214 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 218 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
215 }) 219 })
216 220
221 it('Should fail with bad latency setting', async function () {
222 const fields = { ...baseCorrectParams, latencyMode: 42 }
223
224 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
225 })
226
227 it('Should fail to set latency if the server does not allow it', async function () {
228 const fields = { ...baseCorrectParams, latencyMode: LiveVideoLatencyMode.HIGH_LATENCY }
229
230 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
231 })
232
217 it('Should succeed with the correct parameters', async function () { 233 it('Should succeed with the correct parameters', async function () {
218 this.timeout(30000) 234 this.timeout(30000)
219 235
@@ -393,6 +409,18 @@ describe('Test video lives API validator', function () {
393 await command.update({ videoId: video.id, fields, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 409 await command.update({ videoId: video.id, fields, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
394 }) 410 })
395 411
412 it('Should fail with bad latency setting', async function () {
413 const fields = { latencyMode: 42 }
414
415 await command.update({ videoId: video.id, fields, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
416 })
417
418 it('Should fail to set latency if the server does not allow it', async function () {
419 const fields = { latencyMode: LiveVideoLatencyMode.HIGH_LATENCY }
420
421 await command.update({ videoId: video.id, fields, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
422 })
423
396 it('Should succeed with the correct params', async function () { 424 it('Should succeed with the correct params', async function () {
397 await command.update({ videoId: video.id, fields: { saveReplay: false } }) 425 await command.update({ videoId: video.id, fields: { saveReplay: false } })
398 await command.update({ videoId: video.uuid, fields: { saveReplay: false } }) 426 await command.update({ videoId: video.uuid, fields: { saveReplay: false } })
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index d756a02c1..aeb039696 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -10,6 +10,7 @@ import {
10 HttpStatusCode, 10 HttpStatusCode,
11 LiveVideo, 11 LiveVideo,
12 LiveVideoCreate, 12 LiveVideoCreate,
13 LiveVideoLatencyMode,
13 VideoDetails, 14 VideoDetails,
14 VideoPrivacy, 15 VideoPrivacy,
15 VideoState, 16 VideoState,
@@ -52,6 +53,9 @@ describe('Test live', function () {
52 live: { 53 live: {
53 enabled: true, 54 enabled: true,
54 allowReplay: true, 55 allowReplay: true,
56 latencySetting: {
57 enabled: true
58 },
55 transcoding: { 59 transcoding: {
56 enabled: false 60 enabled: false
57 } 61 }
@@ -85,6 +89,7 @@ describe('Test live', function () {
85 commentsEnabled: false, 89 commentsEnabled: false,
86 downloadEnabled: false, 90 downloadEnabled: false,
87 saveReplay: true, 91 saveReplay: true,
92 latencyMode: LiveVideoLatencyMode.SMALL_LATENCY,
88 privacy: VideoPrivacy.PUBLIC, 93 privacy: VideoPrivacy.PUBLIC,
89 previewfile: 'video_short1-preview.webm.jpg', 94 previewfile: 'video_short1-preview.webm.jpg',
90 thumbnailfile: 'video_short1.webm.jpg' 95 thumbnailfile: 'video_short1.webm.jpg'
@@ -131,6 +136,7 @@ describe('Test live', function () {
131 } 136 }
132 137
133 expect(live.saveReplay).to.be.true 138 expect(live.saveReplay).to.be.true
139 expect(live.latencyMode).to.equal(LiveVideoLatencyMode.SMALL_LATENCY)
134 } 140 }
135 }) 141 })
136 142
@@ -175,7 +181,7 @@ describe('Test live', function () {
175 it('Should update the live', async function () { 181 it('Should update the live', async function () {
176 this.timeout(10000) 182 this.timeout(10000)
177 183
178 await commands[0].update({ videoId: liveVideoUUID, fields: { saveReplay: false } }) 184 await commands[0].update({ videoId: liveVideoUUID, fields: { saveReplay: false, latencyMode: LiveVideoLatencyMode.DEFAULT } })
179 await waitJobs(servers) 185 await waitJobs(servers)
180 }) 186 })
181 187
@@ -192,6 +198,7 @@ describe('Test live', function () {
192 } 198 }
193 199
194 expect(live.saveReplay).to.be.false 200 expect(live.saveReplay).to.be.false
201 expect(live.latencyMode).to.equal(LiveVideoLatencyMode.DEFAULT)
195 } 202 }
196 }) 203 })
197 204
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index 565b2953a..5028b65e6 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -82,6 +82,7 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) {
82 82
83 expect(data.live.enabled).to.be.false 83 expect(data.live.enabled).to.be.false
84 expect(data.live.allowReplay).to.be.false 84 expect(data.live.allowReplay).to.be.false
85 expect(data.live.latencySetting.enabled).to.be.true
85 expect(data.live.maxDuration).to.equal(-1) 86 expect(data.live.maxDuration).to.equal(-1)
86 expect(data.live.maxInstanceLives).to.equal(20) 87 expect(data.live.maxInstanceLives).to.equal(20)
87 expect(data.live.maxUserLives).to.equal(3) 88 expect(data.live.maxUserLives).to.equal(3)
@@ -185,6 +186,7 @@ function checkUpdatedConfig (data: CustomConfig) {
185 186
186 expect(data.live.enabled).to.be.true 187 expect(data.live.enabled).to.be.true
187 expect(data.live.allowReplay).to.be.true 188 expect(data.live.allowReplay).to.be.true
189 expect(data.live.latencySetting.enabled).to.be.false
188 expect(data.live.maxDuration).to.equal(5000) 190 expect(data.live.maxDuration).to.equal(5000)
189 expect(data.live.maxInstanceLives).to.equal(-1) 191 expect(data.live.maxInstanceLives).to.equal(-1)
190 expect(data.live.maxUserLives).to.equal(10) 192 expect(data.live.maxUserLives).to.equal(10)
@@ -326,6 +328,9 @@ const newCustomConfig: CustomConfig = {
326 live: { 328 live: {
327 enabled: true, 329 enabled: true,
328 allowReplay: true, 330 allowReplay: true,
331 latencySetting: {
332 enabled: false
333 },
329 maxDuration: 5000, 334 maxDuration: 5000,
330 maxInstanceLives: -1, 335 maxInstanceLives: -1,
331 maxUserLives: 10, 336 maxUserLives: 10,