aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/live/live-permanent.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-08 10:18:40 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commit4f2199144e428c16460750305f737b890c1ac322 (patch)
treea19c5c0f254ab0b32d6c8838af33a1ba260e4877 /server/tests/api/live/live-permanent.ts
parent2c27e70471120c92e0bc8c8114141fbb31ff98ac (diff)
downloadPeerTube-4f2199144e428c16460750305f737b890c1ac322.tar.gz
PeerTube-4f2199144e428c16460750305f737b890c1ac322.tar.zst
PeerTube-4f2199144e428c16460750305f737b890c1ac322.zip
Introduce live command
Diffstat (limited to 'server/tests/api/live/live-permanent.ts')
-rw-r--r--server/tests/api/live/live-permanent.ts43
1 files changed, 18 insertions, 25 deletions
diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts
index b9e37c834..a0f70dfdb 100644
--- a/server/tests/api/live/live-permanent.ts
+++ b/server/tests/api/live/live-permanent.ts
@@ -6,22 +6,15 @@ import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 ConfigCommand, 8 ConfigCommand,
9 createLive,
10 doubleFollow, 9 doubleFollow,
11 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
12 getLive,
13 getPlaylistsCount,
14 getVideo, 11 getVideo,
15 sendRTMPStreamInVideo,
16 ServerInfo, 12 ServerInfo,
17 setAccessTokensToServers, 13 setAccessTokensToServers,
18 setDefaultVideoChannel, 14 setDefaultVideoChannel,
19 stopFfmpeg, 15 stopFfmpeg,
20 updateLive,
21 wait, 16 wait,
22 waitJobs, 17 waitJobs
23 waitUntilLivePublished,
24 waitUntilLiveWaiting
25} from '../../../../shared/extra-utils' 18} from '../../../../shared/extra-utils'
26 19
27const expect = chai.expect 20const expect = chai.expect
@@ -39,8 +32,8 @@ describe('Permanent live', function () {
39 permanentLive 32 permanentLive
40 } 33 }
41 34
42 const res = await createLive(servers[0].url, servers[0].accessToken, attributes) 35 const { uuid } = await servers[0].liveCommand.createLive({ fields: attributes })
43 return res.body.video.uuid 36 return uuid
44 } 37 }
45 38
46 async function checkVideoState (videoId: string, state: VideoState) { 39 async function checkVideoState (videoId: string, state: VideoState) {
@@ -83,15 +76,15 @@ describe('Permanent live', function () {
83 const videoUUID = await createLiveWrapper(false) 76 const videoUUID = await createLiveWrapper(false)
84 77
85 { 78 {
86 const res = await getLive(servers[0].url, servers[0].accessToken, videoUUID) 79 const live = await servers[0].liveCommand.getLive({ videoId: videoUUID })
87 expect(res.body.permanentLive).to.be.false 80 expect(live.permanentLive).to.be.false
88 } 81 }
89 82
90 await updateLive(servers[0].url, servers[0].accessToken, videoUUID, { permanentLive: true }) 83 await servers[0].liveCommand.updateLive({ videoId: videoUUID, fields: { permanentLive: true } })
91 84
92 { 85 {
93 const res = await getLive(servers[0].url, servers[0].accessToken, videoUUID) 86 const live = await servers[0].liveCommand.getLive({ videoId: videoUUID })
94 expect(res.body.permanentLive).to.be.true 87 expect(live.permanentLive).to.be.true
95 } 88 }
96 }) 89 })
97 90
@@ -100,8 +93,8 @@ describe('Permanent live', function () {
100 93
101 videoUUID = await createLiveWrapper(true) 94 videoUUID = await createLiveWrapper(true)
102 95
103 const res = await getLive(servers[0].url, servers[0].accessToken, videoUUID) 96 const live = await servers[0].liveCommand.getLive({ videoId: videoUUID })
104 expect(res.body.permanentLive).to.be.true 97 expect(live.permanentLive).to.be.true
105 98
106 await waitJobs(servers) 99 await waitJobs(servers)
107 }) 100 })
@@ -109,16 +102,16 @@ describe('Permanent live', function () {
109 it('Should stream into this permanent live', async function () { 102 it('Should stream into this permanent live', async function () {
110 this.timeout(120000) 103 this.timeout(120000)
111 104
112 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID) 105 const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID })
113 106
114 for (const server of servers) { 107 for (const server of servers) {
115 await waitUntilLivePublished(server.url, server.accessToken, videoUUID) 108 await server.liveCommand.waitUntilLivePublished({ videoId: videoUUID })
116 } 109 }
117 110
118 await checkVideoState(videoUUID, VideoState.PUBLISHED) 111 await checkVideoState(videoUUID, VideoState.PUBLISHED)
119 112
120 await stopFfmpeg(command) 113 await stopFfmpeg(ffmpegCommand)
121 await waitUntilLiveWaiting(servers[0].url, servers[0].accessToken, videoUUID) 114 await servers[0].liveCommand.waitUntilLiveWaiting({ videoId: videoUUID })
122 115
123 await waitJobs(servers) 116 await waitJobs(servers)
124 }) 117 })
@@ -160,19 +153,19 @@ describe('Permanent live', function () {
160 } 153 }
161 }) 154 })
162 155
163 const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID) 156 const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID })
164 157
165 for (const server of servers) { 158 for (const server of servers) {
166 await waitUntilLivePublished(server.url, server.accessToken, videoUUID) 159 await server.liveCommand.waitUntilLivePublished({ videoId: videoUUID })
167 } 160 }
168 161
169 await checkVideoState(videoUUID, VideoState.PUBLISHED) 162 await checkVideoState(videoUUID, VideoState.PUBLISHED)
170 163
171 const count = await getPlaylistsCount(servers[0], videoUUID) 164 const count = await servers[0].liveCommand.getPlaylistsCount({ videoUUID })
172 // master playlist and 720p playlist 165 // master playlist and 720p playlist
173 expect(count).to.equal(2) 166 expect(count).to.equal(2)
174 167
175 await stopFfmpeg(command) 168 await stopFfmpeg(ffmpegCommand)
176 }) 169 })
177 170
178 after(async function () { 171 after(async function () {