diff options
Diffstat (limited to 'server/tests/api/live/live-views.ts')
-rw-r--r-- | server/tests/api/live/live-views.ts | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/server/tests/api/live/live-views.ts b/server/tests/api/live/live-views.ts index a44d21ffa..5e3a79c64 100644 --- a/server/tests/api/live/live-views.ts +++ b/server/tests/api/live/live-views.ts | |||
@@ -3,20 +3,15 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FfmpegCommand } from 'fluent-ffmpeg' | 5 | import { FfmpegCommand } from 'fluent-ffmpeg' |
6 | import { VideoDetails, VideoPrivacy } from '@shared/models' | 6 | import { VideoPrivacy } from '@shared/models' |
7 | import { | 7 | import { |
8 | cleanupTests, | 8 | cleanupTests, |
9 | createLive, | 9 | createMultipleServers, |
10 | doubleFollow, | 10 | doubleFollow, |
11 | flushAndRunMultipleServers, | 11 | PeerTubeServer, |
12 | getVideo, | ||
13 | sendRTMPStreamInVideo, | ||
14 | ServerInfo, | ||
15 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
16 | setDefaultVideoChannel, | 13 | setDefaultVideoChannel, |
17 | stopFfmpeg, | 14 | stopFfmpeg, |
18 | updateCustomSubConfig, | ||
19 | viewVideo, | ||
20 | wait, | 15 | wait, |
21 | waitJobs, | 16 | waitJobs, |
22 | waitUntilLivePublishedOnAllServers | 17 | waitUntilLivePublishedOnAllServers |
@@ -25,23 +20,25 @@ import { | |||
25 | const expect = chai.expect | 20 | const expect = chai.expect |
26 | 21 | ||
27 | describe('Test live', function () { | 22 | describe('Test live', function () { |
28 | let servers: ServerInfo[] = [] | 23 | let servers: PeerTubeServer[] = [] |
29 | 24 | ||
30 | before(async function () { | 25 | before(async function () { |
31 | this.timeout(120000) | 26 | this.timeout(120000) |
32 | 27 | ||
33 | servers = await flushAndRunMultipleServers(2) | 28 | servers = await createMultipleServers(2) |
34 | 29 | ||
35 | // Get the access tokens | 30 | // Get the access tokens |
36 | await setAccessTokensToServers(servers) | 31 | await setAccessTokensToServers(servers) |
37 | await setDefaultVideoChannel(servers) | 32 | await setDefaultVideoChannel(servers) |
38 | 33 | ||
39 | await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { | 34 | await servers[0].config.updateCustomSubConfig({ |
40 | live: { | 35 | newConfig: { |
41 | enabled: true, | 36 | live: { |
42 | allowReplay: true, | 37 | enabled: true, |
43 | transcoding: { | 38 | allowReplay: true, |
44 | enabled: false | 39 | transcoding: { |
40 | enabled: false | ||
41 | } | ||
45 | } | 42 | } |
46 | } | 43 | } |
47 | }) | 44 | }) |
@@ -56,9 +53,7 @@ describe('Test live', function () { | |||
56 | 53 | ||
57 | async function countViews (expected: number) { | 54 | async function countViews (expected: number) { |
58 | for (const server of servers) { | 55 | for (const server of servers) { |
59 | const res = await getVideo(server.url, liveVideoId) | 56 | const video = await server.videos.get({ id: liveVideoId }) |
60 | const video: VideoDetails = res.body | ||
61 | |||
62 | expect(video.views).to.equal(expected) | 57 | expect(video.views).to.equal(expected) |
63 | } | 58 | } |
64 | } | 59 | } |
@@ -68,14 +63,14 @@ describe('Test live', function () { | |||
68 | 63 | ||
69 | const liveAttributes = { | 64 | const liveAttributes = { |
70 | name: 'live video', | 65 | name: 'live video', |
71 | channelId: servers[0].videoChannel.id, | 66 | channelId: servers[0].store.channel.id, |
72 | privacy: VideoPrivacy.PUBLIC | 67 | privacy: VideoPrivacy.PUBLIC |
73 | } | 68 | } |
74 | 69 | ||
75 | const res = await createLive(servers[0].url, servers[0].accessToken, liveAttributes) | 70 | const live = await servers[0].live.create({ fields: liveAttributes }) |
76 | liveVideoId = res.body.video.uuid | 71 | liveVideoId = live.uuid |
77 | 72 | ||
78 | command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId) | 73 | command = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoId }) |
79 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) | 74 | await waitUntilLivePublishedOnAllServers(servers, liveVideoId) |
80 | await waitJobs(servers) | 75 | await waitJobs(servers) |
81 | }) | 76 | }) |
@@ -87,8 +82,8 @@ describe('Test live', function () { | |||
87 | it('Should view a live twice and display 1 view', async function () { | 82 | it('Should view a live twice and display 1 view', async function () { |
88 | this.timeout(30000) | 83 | this.timeout(30000) |
89 | 84 | ||
90 | await viewVideo(servers[0].url, liveVideoId) | 85 | await servers[0].videos.view({ id: liveVideoId }) |
91 | await viewVideo(servers[0].url, liveVideoId) | 86 | await servers[0].videos.view({ id: liveVideoId }) |
92 | 87 | ||
93 | await wait(7000) | 88 | await wait(7000) |
94 | 89 | ||
@@ -109,9 +104,9 @@ describe('Test live', function () { | |||
109 | it('Should view a live on a remote and on local and display 2 views', async function () { | 104 | it('Should view a live on a remote and on local and display 2 views', async function () { |
110 | this.timeout(30000) | 105 | this.timeout(30000) |
111 | 106 | ||
112 | await viewVideo(servers[0].url, liveVideoId) | 107 | await servers[0].videos.view({ id: liveVideoId }) |
113 | await viewVideo(servers[1].url, liveVideoId) | 108 | await servers[1].videos.view({ id: liveVideoId }) |
114 | await viewVideo(servers[1].url, liveVideoId) | 109 | await servers[1].videos.view({ id: liveVideoId }) |
115 | 110 | ||
116 | await wait(7000) | 111 | await wait(7000) |
117 | await waitJobs(servers) | 112 | await waitJobs(servers) |