diff options
Diffstat (limited to 'server/tests/api/live/live-permanent.ts')
-rw-r--r-- | server/tests/api/live/live-permanent.ts | 99 |
1 files changed, 46 insertions, 53 deletions
diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts index 71b7d28a8..f07d4cfec 100644 --- a/server/tests/api/live/live-permanent.ts +++ b/server/tests/api/live/live-permanent.ts | |||
@@ -2,59 +2,50 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models' | 5 | import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createLive, | 8 | ConfigCommand, |
9 | createMultipleServers, | ||
9 | doubleFollow, | 10 | doubleFollow, |
10 | flushAndRunMultipleServers, | 11 | PeerTubeServer, |
11 | getCustomConfigResolutions, | ||
12 | getLive, | ||
13 | getPlaylistsCount, | ||
14 | getVideo, | ||
15 | sendRTMPStreamInVideo, | ||
16 | ServerInfo, | ||
17 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
18 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
19 | stopFfmpeg, | 14 | stopFfmpeg, |
20 | updateCustomSubConfig, | ||
21 | updateLive, | ||
22 | wait, | 15 | wait, |
23 | waitJobs, | 16 | waitJobs |
24 | waitUntilLivePublished, | ||
25 | waitUntilLiveWaiting | ||
26 | } from '../../../../shared/extra-utils' | 17 | } from '../../../../shared/extra-utils' |
27 | 18 | ||
28 | const expect = chai.expect | 19 | const expect = chai.expect |
29 | 20 | ||
30 | describe('Permanent live', function () { | 21 | describe('Permanent live', function () { |
31 | let servers: ServerInfo[] = [] | 22 | let servers: PeerTubeServer[] = [] |
32 | let videoUUID: string | 23 | let videoUUID: string |
33 | 24 | ||
34 | async function createLiveWrapper (permanentLive: boolean) { | 25 | async function createLiveWrapper (permanentLive: boolean) { |
35 | const attributes: LiveVideoCreate = { | 26 | const attributes: LiveVideoCreate = { |
36 | channelId: servers[0].videoChannel.id, | 27 | channelId: servers[0].store.channel.id, |
37 | privacy: VideoPrivacy.PUBLIC, | 28 | privacy: VideoPrivacy.PUBLIC, |
38 | name: 'my super live', | 29 | name: 'my super live', |
39 | saveReplay: false, | 30 | saveReplay: false, |
40 | permanentLive | 31 | permanentLive |
41 | } | 32 | } |
42 | 33 | ||
43 | const res = await createLive(servers[0].url, servers[0].accessToken, attributes) | 34 | const { uuid } = await servers[0].live.create({ fields: attributes }) |
44 | return res.body.video.uuid | 35 | return uuid |
45 | } | 36 | } |
46 | 37 | ||
47 | async function checkVideoState (videoId: string, state: VideoState) { | 38 | async function checkVideoState (videoId: string, state: VideoState) { |
48 | for (const server of servers) { | 39 | for (const server of servers) { |
49 | const res = await getVideo(server.url, videoId) | 40 | const video = await server.videos.get({ id: videoId }) |
50 | expect((res.body as VideoDetails).state.id).to.equal(state) | 41 | expect(video.state.id).to.equal(state) |
51 | } | 42 | } |
52 | } | 43 | } |
53 | 44 | ||
54 | before(async function () { | 45 | before(async function () { |
55 | this.timeout(120000) | 46 | this.timeout(120000) |
56 | 47 | ||
57 | servers = await flushAndRunMultipleServers(2) | 48 | servers = await createMultipleServers(2) |
58 | 49 | ||
59 | // Get the access tokens | 50 | // Get the access tokens |
60 | await setAccessTokensToServers(servers) | 51 | await setAccessTokensToServers(servers) |
@@ -63,14 +54,16 @@ describe('Permanent live', function () { | |||
63 | // Server 1 and server 2 follow each other | 54 | // Server 1 and server 2 follow each other |
64 | await doubleFollow(servers[0], servers[1]) | 55 | await doubleFollow(servers[0], servers[1]) |
65 | 56 | ||
66 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { | 57 | await servers[0].config.updateCustomSubConfig({ |
67 | live: { | 58 | newConfig: { |
68 | enabled: true, | 59 | live: { |
69 | allowReplay: true, | ||
70 | maxDuration: -1, | ||
71 | transcoding: { | ||
72 | enabled: true, | 60 | enabled: true, |
73 | resolutions: getCustomConfigResolutions(true) | 61 | allowReplay: true, |
62 | maxDuration: -1, | ||
63 | transcoding: { | ||
64 | enabled: true, | ||
65 | resolutions: ConfigCommand.getCustomConfigResolutions(true) | ||
66 | } | ||
74 | } | 67 | } |
75 | } | 68 | } |
76 | }) | 69 | }) |
@@ -82,15 +75,15 @@ describe('Permanent live', function () { | |||
82 | const videoUUID = await createLiveWrapper(false) | 75 | const videoUUID = await createLiveWrapper(false) |
83 | 76 | ||
84 | { | 77 | { |
85 | const res = await getLive(servers[0].url, servers[0].accessToken, videoUUID) | 78 | const live = await servers[0].live.get({ videoId: videoUUID }) |
86 | expect(res.body.permanentLive).to.be.false | 79 | expect(live.permanentLive).to.be.false |
87 | } | 80 | } |
88 | 81 | ||
89 | await updateLive(servers[0].url, servers[0].accessToken, videoUUID, { permanentLive: true }) | 82 | await servers[0].live.update({ videoId: videoUUID, fields: { permanentLive: true } }) |
90 | 83 | ||
91 | { | 84 | { |
92 | const res = await getLive(servers[0].url, servers[0].accessToken, videoUUID) | 85 | const live = await servers[0].live.get({ videoId: videoUUID }) |
93 | expect(res.body.permanentLive).to.be.true | 86 | expect(live.permanentLive).to.be.true |
94 | } | 87 | } |
95 | }) | 88 | }) |
96 | 89 | ||
@@ -99,8 +92,8 @@ describe('Permanent live', function () { | |||
99 | 92 | ||
100 | videoUUID = await createLiveWrapper(true) | 93 | videoUUID = await createLiveWrapper(true) |
101 | 94 | ||
102 | const res = await getLive(servers[0].url, servers[0].accessToken, videoUUID) | 95 | const live = await servers[0].live.get({ videoId: videoUUID }) |
103 | expect(res.body.permanentLive).to.be.true | 96 | expect(live.permanentLive).to.be.true |
104 | 97 | ||
105 | await waitJobs(servers) | 98 | await waitJobs(servers) |
106 | }) | 99 | }) |
@@ -108,16 +101,16 @@ describe('Permanent live', function () { | |||
108 | it('Should stream into this permanent live', async function () { | 101 | it('Should stream into this permanent live', async function () { |
109 | this.timeout(120000) | 102 | this.timeout(120000) |
110 | 103 | ||
111 | const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID) | 104 | const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID }) |
112 | 105 | ||
113 | for (const server of servers) { | 106 | for (const server of servers) { |
114 | await waitUntilLivePublished(server.url, server.accessToken, videoUUID) | 107 | await server.live.waitUntilPublished({ videoId: videoUUID }) |
115 | } | 108 | } |
116 | 109 | ||
117 | await checkVideoState(videoUUID, VideoState.PUBLISHED) | 110 | await checkVideoState(videoUUID, VideoState.PUBLISHED) |
118 | 111 | ||
119 | await stopFfmpeg(command) | 112 | await stopFfmpeg(ffmpegCommand) |
120 | await waitUntilLiveWaiting(servers[0].url, servers[0].accessToken, videoUUID) | 113 | await servers[0].live.waitUntilWaiting({ videoId: videoUUID }) |
121 | 114 | ||
122 | await waitJobs(servers) | 115 | await waitJobs(servers) |
123 | }) | 116 | }) |
@@ -129,9 +122,7 @@ describe('Permanent live', function () { | |||
129 | await waitJobs(servers) | 122 | await waitJobs(servers) |
130 | 123 | ||
131 | for (const server of servers) { | 124 | for (const server of servers) { |
132 | const res = await getVideo(server.url, videoUUID) | 125 | const videoDetails = await server.videos.get({ id: videoUUID }) |
133 | |||
134 | const videoDetails = res.body as VideoDetails | ||
135 | expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) | 126 | expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) |
136 | } | 127 | } |
137 | }) | 128 | }) |
@@ -145,31 +136,33 @@ describe('Permanent live', function () { | |||
145 | it('Should be able to stream again in the permanent live', async function () { | 136 | it('Should be able to stream again in the permanent live', async function () { |
146 | this.timeout(20000) | 137 | this.timeout(20000) |
147 | 138 | ||
148 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { | 139 | await servers[0].config.updateCustomSubConfig({ |
149 | live: { | 140 | newConfig: { |
150 | enabled: true, | 141 | live: { |
151 | allowReplay: true, | ||
152 | maxDuration: -1, | ||
153 | transcoding: { | ||
154 | enabled: true, | 142 | enabled: true, |
155 | resolutions: getCustomConfigResolutions(false) | 143 | allowReplay: true, |
144 | maxDuration: -1, | ||
145 | transcoding: { | ||
146 | enabled: true, | ||
147 | resolutions: ConfigCommand.getCustomConfigResolutions(false) | ||
148 | } | ||
156 | } | 149 | } |
157 | } | 150 | } |
158 | }) | 151 | }) |
159 | 152 | ||
160 | const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID) | 153 | const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID }) |
161 | 154 | ||
162 | for (const server of servers) { | 155 | for (const server of servers) { |
163 | await waitUntilLivePublished(server.url, server.accessToken, videoUUID) | 156 | await server.live.waitUntilPublished({ videoId: videoUUID }) |
164 | } | 157 | } |
165 | 158 | ||
166 | await checkVideoState(videoUUID, VideoState.PUBLISHED) | 159 | await checkVideoState(videoUUID, VideoState.PUBLISHED) |
167 | 160 | ||
168 | const count = await getPlaylistsCount(servers[0], videoUUID) | 161 | const count = await servers[0].live.countPlaylists({ videoUUID }) |
169 | // master playlist and 720p playlist | 162 | // master playlist and 720p playlist |
170 | expect(count).to.equal(2) | 163 | expect(count).to.equal(2) |
171 | 164 | ||
172 | await stopFfmpeg(command) | 165 | await stopFfmpeg(ffmpegCommand) |
173 | }) | 166 | }) |
174 | 167 | ||
175 | after(async function () { | 168 | after(async function () { |