]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/live/live-rtmps.ts
Remove low timeouts
[github/Chocobozzz/PeerTube.git] / server / tests / api / live / live-rtmps.ts
1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3 import { expect } from 'chai'
4 import { buildAbsoluteFixturePath } from '@shared/core-utils'
5 import { VideoPrivacy } from '@shared/models'
6 import {
7 cleanupTests,
8 createSingleServer,
9 PeerTubeServer,
10 sendRTMPStream,
11 setAccessTokensToServers,
12 setDefaultVideoChannel,
13 stopFfmpeg,
14 testFfmpegStreamError,
15 waitUntilLivePublishedOnAllServers
16 } from '@shared/server-commands'
17
18 describe('Test live RTMPS', function () {
19 let server: PeerTubeServer
20 let rtmpUrl: string
21 let rtmpsUrl: string
22
23 async function createLiveWrapper () {
24 const liveAttributes = {
25 name: 'live',
26 channelId: server.store.channel.id,
27 privacy: VideoPrivacy.PUBLIC,
28 saveReplay: false
29 }
30
31 const { uuid } = await server.live.create({ fields: liveAttributes })
32
33 const live = await server.live.get({ videoId: uuid })
34 const video = await server.videos.get({ id: uuid })
35
36 return Object.assign(video, live)
37 }
38
39 before(async function () {
40 this.timeout(120000)
41
42 server = await createSingleServer(1)
43
44 // Get the access tokens
45 await setAccessTokensToServers([ server ])
46 await setDefaultVideoChannel([ server ])
47
48 await server.config.updateCustomSubConfig({
49 newConfig: {
50 live: {
51 enabled: true,
52 allowReplay: true,
53 transcoding: {
54 enabled: false
55 }
56 }
57 }
58 })
59
60 rtmpUrl = 'rtmp://' + server.hostname + ':' + server.rtmpPort + '/live'
61 rtmpsUrl = 'rtmps://' + server.hostname + ':' + server.rtmpsPort + '/live'
62 })
63
64 it('Should enable RTMPS endpoint only', async function () {
65 this.timeout(240000)
66
67 await server.kill()
68 await server.run({
69 live: {
70 rtmp: {
71 enabled: false
72 },
73 rtmps: {
74 enabled: true,
75 port: server.rtmpsPort,
76 key_file: buildAbsoluteFixturePath('rtmps.key'),
77 cert_file: buildAbsoluteFixturePath('rtmps.cert')
78 }
79 }
80 })
81
82 {
83 const liveVideo = await createLiveWrapper()
84
85 expect(liveVideo.rtmpUrl).to.not.exist
86 expect(liveVideo.rtmpsUrl).to.equal(rtmpsUrl)
87
88 const command = sendRTMPStream({ rtmpBaseUrl: rtmpUrl, streamKey: liveVideo.streamKey })
89 await testFfmpegStreamError(command, true)
90 }
91
92 {
93 const liveVideo = await createLiveWrapper()
94
95 const command = sendRTMPStream({ rtmpBaseUrl: rtmpsUrl, streamKey: liveVideo.streamKey })
96 await waitUntilLivePublishedOnAllServers([ server ], liveVideo.uuid)
97 await stopFfmpeg(command)
98 }
99 })
100
101 it('Should enable both RTMP and RTMPS', async function () {
102 this.timeout(240000)
103
104 await server.kill()
105 await server.run({
106 live: {
107 rtmp: {
108 enabled: true,
109 port: server.rtmpPort
110 },
111 rtmps: {
112 enabled: true,
113 port: server.rtmpsPort,
114 key_file: buildAbsoluteFixturePath('rtmps.key'),
115 cert_file: buildAbsoluteFixturePath('rtmps.cert')
116 }
117 }
118 })
119
120 {
121 const liveVideo = await createLiveWrapper()
122
123 expect(liveVideo.rtmpUrl).to.equal(rtmpUrl)
124 expect(liveVideo.rtmpsUrl).to.equal(rtmpsUrl)
125
126 const command = sendRTMPStream({ rtmpBaseUrl: rtmpUrl, streamKey: liveVideo.streamKey })
127 await waitUntilLivePublishedOnAllServers([ server ], liveVideo.uuid)
128 await stopFfmpeg(command)
129 }
130
131 {
132 const liveVideo = await createLiveWrapper()
133
134 const command = sendRTMPStream({ rtmpBaseUrl: rtmpsUrl, streamKey: liveVideo.streamKey })
135 await waitUntilLivePublishedOnAllServers([ server ], liveVideo.uuid)
136 await stopFfmpeg(command)
137 }
138 })
139
140 after(async function () {
141 await cleanupTests([ server ])
142 })
143 })