aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-18 14:44:12 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-19 09:36:50 +0100
commitfae6e4da8f516a9d6c3bad9bf6f35811ccacbad8 (patch)
tree38df5942cb2fa6e5860c8e0e19471eb6b124e291 /server/tests/api
parent3f8ae0e4e4da90c964597e4b3e0724da5eaa1668 (diff)
downloadPeerTube-fae6e4da8f516a9d6c3bad9bf6f35811ccacbad8.tar.gz
PeerTube-fae6e4da8f516a9d6c3bad9bf6f35811ccacbad8.tar.zst
PeerTube-fae6e4da8f516a9d6c3bad9bf6f35811ccacbad8.zip
Try to speed up server tests
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/live/live-save-replay.ts29
-rw-r--r--server/tests/api/live/live.ts30
2 files changed, 36 insertions, 23 deletions
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index 757e11845..6dd6fb44e 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -4,6 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { FfmpegCommand } from 'fluent-ffmpeg' 5import { FfmpegCommand } from 'fluent-ffmpeg'
6import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models' 6import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models'
7import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
7import { 8import {
8 addVideoToBlacklist, 9 addVideoToBlacklist,
9 checkLiveCleanup, 10 checkLiveCleanup,
@@ -23,9 +24,9 @@ import {
23 updateCustomSubConfig, 24 updateCustomSubConfig,
24 updateVideo, 25 updateVideo,
25 waitJobs, 26 waitJobs,
27 waitUntilLiveEnded,
26 waitUntilLivePublished 28 waitUntilLivePublished
27} from '../../../../shared/extra-utils' 29} from '../../../../shared/extra-utils'
28import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
29 30
30const expect = chai.expect 31const expect = chai.expect
31 32
@@ -74,6 +75,12 @@ describe('Save replay setting', function () {
74 } 75 }
75 } 76 }
76 77
78 async function waitUntilLivePublishedOnAllServers (videoId: string) {
79 for (const server of servers) {
80 await waitUntilLivePublished(server.url, server.accessToken, videoId)
81 }
82 }
83
77 before(async function () { 84 before(async function () {
78 this.timeout(120000) 85 this.timeout(120000)
79 86
@@ -125,10 +132,11 @@ describe('Save replay setting', function () {
125 }) 132 })
126 133
127 it('Should correctly have updated the live and federated it when streaming in the live', async function () { 134 it('Should correctly have updated the live and federated it when streaming in the live', async function () {
128 this.timeout(20000) 135 this.timeout(30000)
129 136
130 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 137 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
131 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID) 138
139 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
132 140
133 await waitJobs(servers) 141 await waitJobs(servers)
134 142
@@ -141,6 +149,9 @@ describe('Save replay setting', function () {
141 149
142 await stopFfmpeg(ffmpegCommand) 150 await stopFfmpeg(ffmpegCommand)
143 151
152 for (const server of servers) {
153 await waitUntilLiveEnded(server.url, server.accessToken, liveVideoUUID)
154 }
144 await waitJobs(servers) 155 await waitJobs(servers)
145 156
146 // Live still exist, but cannot be played anymore 157 // Live still exist, but cannot be played anymore
@@ -159,7 +170,8 @@ describe('Save replay setting', function () {
159 liveVideoUUID = await createLiveWrapper(false) 170 liveVideoUUID = await createLiveWrapper(false)
160 171
161 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 172 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
162 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID) 173
174 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
163 175
164 await waitJobs(servers) 176 await waitJobs(servers)
165 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 177 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
@@ -185,7 +197,8 @@ describe('Save replay setting', function () {
185 liveVideoUUID = await createLiveWrapper(false) 197 liveVideoUUID = await createLiveWrapper(false)
186 198
187 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 199 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
188 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID) 200
201 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
189 202
190 await waitJobs(servers) 203 await waitJobs(servers)
191 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 204 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
@@ -219,7 +232,7 @@ describe('Save replay setting', function () {
219 this.timeout(20000) 232 this.timeout(20000)
220 233
221 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 234 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
222 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID) 235 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
223 236
224 await waitJobs(servers) 237 await waitJobs(servers)
225 238
@@ -262,7 +275,7 @@ describe('Save replay setting', function () {
262 liveVideoUUID = await createLiveWrapper(true) 275 liveVideoUUID = await createLiveWrapper(true)
263 276
264 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 277 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
265 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID) 278 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
266 279
267 await waitJobs(servers) 280 await waitJobs(servers)
268 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 281 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
@@ -288,7 +301,7 @@ describe('Save replay setting', function () {
288 liveVideoUUID = await createLiveWrapper(true) 301 liveVideoUUID = await createLiveWrapper(true)
289 302
290 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 303 ffmpegCommand = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
291 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID) 304 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
292 305
293 await waitJobs(servers) 306 await waitJobs(servers)
294 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 307 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index ff822f84d..19976ba8a 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -50,6 +50,12 @@ const expect = chai.expect
50describe('Test live', function () { 50describe('Test live', function () {
51 let servers: ServerInfo[] = [] 51 let servers: ServerInfo[] = []
52 52
53 async function waitUntilLivePublishedOnAllServers (videoId: string) {
54 for (const server of servers) {
55 await waitUntilLivePublished(server.url, server.accessToken, videoId)
56 }
57 }
58
53 before(async function () { 59 before(async function () {
54 this.timeout(120000) 60 this.timeout(120000)
55 61
@@ -390,7 +396,7 @@ describe('Test live', function () {
390 liveVideoId = await createLiveWrapper(false) 396 liveVideoId = await createLiveWrapper(false)
391 397
392 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId) 398 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
393 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId) 399 await waitUntilLivePublishedOnAllServers(liveVideoId)
394 await waitJobs(servers) 400 await waitJobs(servers)
395 401
396 await testVideoResolutions(liveVideoId, [ 720 ]) 402 await testVideoResolutions(liveVideoId, [ 720 ])
@@ -406,7 +412,7 @@ describe('Test live', function () {
406 liveVideoId = await createLiveWrapper(false) 412 liveVideoId = await createLiveWrapper(false)
407 413
408 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId) 414 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
409 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId) 415 await waitUntilLivePublishedOnAllServers(liveVideoId)
410 await waitJobs(servers) 416 await waitJobs(servers)
411 417
412 await testVideoResolutions(liveVideoId, resolutions) 418 await testVideoResolutions(liveVideoId, resolutions)
@@ -423,7 +429,7 @@ describe('Test live', function () {
423 liveVideoId = await createLiveWrapper(true) 429 liveVideoId = await createLiveWrapper(true)
424 430
425 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId, 'video_short2.webm') 431 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId, 'video_short2.webm')
426 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId) 432 await waitUntilLivePublishedOnAllServers(liveVideoId)
427 await waitJobs(servers) 433 await waitJobs(servers)
428 434
429 await testVideoResolutions(liveVideoId, resolutions) 435 await testVideoResolutions(liveVideoId, resolutions)
@@ -433,7 +439,7 @@ describe('Test live', function () {
433 439
434 await waitJobs(servers) 440 await waitJobs(servers)
435 441
436 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId) 442 await waitUntilLivePublishedOnAllServers(liveVideoId)
437 443
438 const bitrateLimits = { 444 const bitrateLimits = {
439 720: 5000 * 1000, // 60FPS 445 720: 5000 * 1000, // 60FPS
@@ -514,7 +520,7 @@ describe('Test live', function () {
514 liveVideoId = res.body.video.uuid 520 liveVideoId = res.body.video.uuid
515 521
516 command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId) 522 command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId)
517 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoId) 523 await waitUntilLivePublishedOnAllServers(liveVideoId)
518 await waitJobs(servers) 524 await waitJobs(servers)
519 }) 525 })
520 526
@@ -602,10 +608,7 @@ describe('Test live', function () {
602 608
603 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 609 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
604 610
605 for (const server of servers) { 611 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
606 await waitUntilLivePublished(server.url, server.accessToken, liveVideoUUID)
607 }
608
609 await waitJobs(servers) 612 await waitJobs(servers)
610 613
611 for (const stateChanges of [ localStateChanges, remoteStateChanges ]) { 614 for (const stateChanges of [ localStateChanges, remoteStateChanges ]) {
@@ -618,7 +621,6 @@ describe('Test live', function () {
618 for (const server of servers) { 621 for (const server of servers) {
619 await waitUntilLiveEnded(server.url, server.accessToken, liveVideoUUID) 622 await waitUntilLiveEnded(server.url, server.accessToken, liveVideoUUID)
620 } 623 }
621
622 await waitJobs(servers) 624 await waitJobs(servers)
623 625
624 for (const stateChanges of [ localStateChanges, remoteStateChanges ]) { 626 for (const stateChanges of [ localStateChanges, remoteStateChanges ]) {
@@ -654,10 +656,7 @@ describe('Test live', function () {
654 656
655 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 657 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
656 658
657 for (const server of servers) { 659 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
658 await waitUntilLivePublished(server.url, server.accessToken, liveVideoUUID)
659 }
660
661 await waitJobs(servers) 660 await waitJobs(servers)
662 661
663 expect(localLastVideoViews).to.equal(0) 662 expect(localLastVideoViews).to.equal(0)
@@ -691,7 +690,8 @@ describe('Test live', function () {
691 socket.emit('subscribe', { videoId }) 690 socket.emit('subscribe', { videoId })
692 691
693 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 692 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoUUID)
694 await waitUntilLivePublished(servers[0].url, servers[0].accessToken, liveVideoUUID) 693
694 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
695 await waitJobs(servers) 695 await waitJobs(servers)
696 696
697 expect(stateChanges).to.have.lengthOf(1) 697 expect(stateChanges).to.have.lengthOf(1)