diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-03 14:10:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-12-03 15:21:16 +0100 |
commit | bb4ba6d94c5051fdd665ebe63fffcc105778b8be (patch) | |
tree | d39302608c53e31395683bb5dd551eac6ced89f8 /server/tests | |
parent | 19b7ebfaa822b12f6da25ad2ba10398b3ef25ec6 (diff) | |
download | PeerTube-bb4ba6d94c5051fdd665ebe63fffcc105778b8be.tar.gz PeerTube-bb4ba6d94c5051fdd665ebe63fffcc105778b8be.tar.zst PeerTube-bb4ba6d94c5051fdd665ebe63fffcc105778b8be.zip |
Add permanent live support
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/check-params/live.ts | 15 | ||||
-rw-r--r-- | server/tests/api/live/index.ts | 1 | ||||
-rw-r--r-- | server/tests/api/live/live-permanent.ts | 190 |
3 files changed, 205 insertions, 1 deletions
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts index 2b2d1beec..055f2f295 100644 --- a/server/tests/api/check-params/live.ts +++ b/server/tests/api/check-params/live.ts | |||
@@ -84,7 +84,8 @@ describe('Test video lives API validator', function () { | |||
84 | tags: [ 'tag1', 'tag2' ], | 84 | tags: [ 'tag1', 'tag2' ], |
85 | privacy: VideoPrivacy.PUBLIC, | 85 | privacy: VideoPrivacy.PUBLIC, |
86 | channelId, | 86 | channelId, |
87 | saveReplay: false | 87 | saveReplay: false, |
88 | permanentLive: false | ||
88 | } | 89 | } |
89 | }) | 90 | }) |
90 | 91 | ||
@@ -211,6 +212,12 @@ describe('Test video lives API validator', function () { | |||
211 | await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) | 212 | await makeUploadRequest({ url: server.url, path, token: server.accessToken, fields, attaches }) |
212 | }) | 213 | }) |
213 | 214 | ||
215 | it('Should fail with save replay and permanent live set to true', async function () { | ||
216 | const fields = immutableAssign(baseCorrectParams, { saveReplay: true, permanentLive: true }) | ||
217 | |||
218 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
219 | }) | ||
220 | |||
214 | it('Should succeed with the correct parameters', async function () { | 221 | it('Should succeed with the correct parameters', async function () { |
215 | this.timeout(30000) | 222 | this.timeout(30000) |
216 | 223 | ||
@@ -372,6 +379,12 @@ describe('Test video lives API validator', function () { | |||
372 | await updateLive(server.url, server.accessToken, videoIdNotLive, {}, 404) | 379 | await updateLive(server.url, server.accessToken, videoIdNotLive, {}, 404) |
373 | }) | 380 | }) |
374 | 381 | ||
382 | it('Should fail with save replay and permanent live set to true', async function () { | ||
383 | const fields = { saveReplay: true, permanentLive: true } | ||
384 | |||
385 | await updateLive(server.url, server.accessToken, videoId, fields, 400) | ||
386 | }) | ||
387 | |||
375 | it('Should succeed with the correct params', async function () { | 388 | it('Should succeed with the correct params', async function () { |
376 | await updateLive(server.url, server.accessToken, videoId, { saveReplay: false }) | 389 | await updateLive(server.url, server.accessToken, videoId, { saveReplay: false }) |
377 | }) | 390 | }) |
diff --git a/server/tests/api/live/index.ts b/server/tests/api/live/index.ts index 32219969a..c733f564e 100644 --- a/server/tests/api/live/index.ts +++ b/server/tests/api/live/index.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import './live-constraints' | 1 | import './live-constraints' |
2 | import './live-permanent' | ||
2 | import './live-save-replay' | 3 | import './live-save-replay' |
3 | import './live' | 4 | import './live' |
diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts new file mode 100644 index 000000000..a64588ed7 --- /dev/null +++ b/server/tests/api/live/live-permanent.ts | |||
@@ -0,0 +1,190 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import 'mocha' | ||
4 | import * as chai from 'chai' | ||
5 | import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models' | ||
6 | import { | ||
7 | checkLiveCleanup, | ||
8 | cleanupTests, | ||
9 | createLive, | ||
10 | doubleFollow, | ||
11 | flushAndRunMultipleServers, | ||
12 | getLive, | ||
13 | getPlaylistsCount, | ||
14 | getVideo, | ||
15 | sendRTMPStreamInVideo, | ||
16 | ServerInfo, | ||
17 | setAccessTokensToServers, | ||
18 | setDefaultVideoChannel, | ||
19 | stopFfmpeg, | ||
20 | updateCustomSubConfig, | ||
21 | updateLive, | ||
22 | wait, | ||
23 | waitJobs, | ||
24 | waitUntilLiveStarts | ||
25 | } from '../../../../shared/extra-utils' | ||
26 | |||
27 | const expect = chai.expect | ||
28 | |||
29 | describe('Permenant live', function () { | ||
30 | let servers: ServerInfo[] = [] | ||
31 | let videoUUID: string | ||
32 | |||
33 | async function createLiveWrapper (permanentLive: boolean) { | ||
34 | const attributes: LiveVideoCreate = { | ||
35 | channelId: servers[0].videoChannel.id, | ||
36 | privacy: VideoPrivacy.PUBLIC, | ||
37 | name: 'my super live', | ||
38 | saveReplay: false, | ||
39 | permanentLive | ||
40 | } | ||
41 | |||
42 | const res = await createLive(servers[0].url, servers[0].accessToken, attributes) | ||
43 | return res.body.video.uuid | ||
44 | } | ||
45 | |||
46 | async function checkVideoState (videoId: string, state: VideoState) { | ||
47 | for (const server of servers) { | ||
48 | const res = await getVideo(server.url, videoId) | ||
49 | expect((res.body as VideoDetails).state.id).to.equal(state) | ||
50 | } | ||
51 | } | ||
52 | |||
53 | before(async function () { | ||
54 | this.timeout(120000) | ||
55 | |||
56 | servers = await flushAndRunMultipleServers(2) | ||
57 | |||
58 | // Get the access tokens | ||
59 | await setAccessTokensToServers(servers) | ||
60 | await setDefaultVideoChannel(servers) | ||
61 | |||
62 | // Server 1 and server 2 follow each other | ||
63 | await doubleFollow(servers[0], servers[1]) | ||
64 | |||
65 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { | ||
66 | live: { | ||
67 | enabled: true, | ||
68 | allowReplay: true, | ||
69 | maxDuration: null, | ||
70 | transcoding: { | ||
71 | enabled: true, | ||
72 | resolutions: { | ||
73 | '240p': true, | ||
74 | '360p': true, | ||
75 | '480p': true, | ||
76 | '720p': true, | ||
77 | '1080p': true, | ||
78 | '2160p': true | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | }) | ||
83 | }) | ||
84 | |||
85 | it('Should create a non permanent live and update it to be a permanent live', async function () { | ||
86 | this.timeout(20000) | ||
87 | |||
88 | const videoUUID = await createLiveWrapper(false) | ||
89 | |||
90 | { | ||
91 | const res = await getLive(servers[0].url, servers[0].accessToken, videoUUID) | ||
92 | expect(res.body.permanentLive).to.be.false | ||
93 | } | ||
94 | |||
95 | await updateLive(servers[0].url, servers[0].accessToken, videoUUID, { permanentLive: true }) | ||
96 | |||
97 | { | ||
98 | const res = await getLive(servers[0].url, servers[0].accessToken, videoUUID) | ||
99 | expect(res.body.permanentLive).to.be.true | ||
100 | } | ||
101 | }) | ||
102 | |||
103 | it('Should create a permanent live', async function () { | ||
104 | this.timeout(20000) | ||
105 | |||
106 | videoUUID = await createLiveWrapper(true) | ||
107 | |||
108 | const res = await getLive(servers[0].url, servers[0].accessToken, videoUUID) | ||
109 | expect(res.body.permanentLive).to.be.true | ||
110 | |||
111 | await waitJobs(servers) | ||
112 | }) | ||
113 | |||
114 | it('Should stream into this permanent live', async function () { | ||
115 | this.timeout(40000) | ||
116 | |||
117 | const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID) | ||
118 | |||
119 | for (const server of servers) { | ||
120 | await waitUntilLiveStarts(server.url, server.accessToken, videoUUID) | ||
121 | } | ||
122 | |||
123 | await checkVideoState(videoUUID, VideoState.PUBLISHED) | ||
124 | |||
125 | await stopFfmpeg(command) | ||
126 | |||
127 | await waitJobs(servers) | ||
128 | }) | ||
129 | |||
130 | it('Should not have cleaned up this live', async function () { | ||
131 | this.timeout(40000) | ||
132 | |||
133 | await wait(5000) | ||
134 | await waitJobs(servers) | ||
135 | |||
136 | for (const server of servers) { | ||
137 | const res = await getVideo(server.url, videoUUID) | ||
138 | |||
139 | const videoDetails = res.body as VideoDetails | ||
140 | expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) | ||
141 | } | ||
142 | }) | ||
143 | |||
144 | it('Should have set this live to waiting for live state', async function () { | ||
145 | this.timeout(20000) | ||
146 | |||
147 | await checkVideoState(videoUUID, VideoState.WAITING_FOR_LIVE) | ||
148 | }) | ||
149 | |||
150 | it('Should be able to stream again in the permanent live', async function () { | ||
151 | this.timeout(20000) | ||
152 | |||
153 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { | ||
154 | live: { | ||
155 | enabled: true, | ||
156 | allowReplay: true, | ||
157 | maxDuration: null, | ||
158 | transcoding: { | ||
159 | enabled: true, | ||
160 | resolutions: { | ||
161 | '240p': false, | ||
162 | '360p': false, | ||
163 | '480p': false, | ||
164 | '720p': false, | ||
165 | '1080p': false, | ||
166 | '2160p': false | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | }) | ||
171 | |||
172 | const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID) | ||
173 | |||
174 | for (const server of servers) { | ||
175 | await waitUntilLiveStarts(server.url, server.accessToken, videoUUID) | ||
176 | } | ||
177 | |||
178 | await checkVideoState(videoUUID, VideoState.PUBLISHED) | ||
179 | |||
180 | const count = await getPlaylistsCount(servers[0], videoUUID) | ||
181 | // master playlist and 720p playlist | ||
182 | expect(count).to.equal(2) | ||
183 | |||
184 | await stopFfmpeg(command) | ||
185 | }) | ||
186 | |||
187 | after(async function () { | ||
188 | await cleanupTests(servers) | ||
189 | }) | ||
190 | }) | ||