X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Flive%2Flive.ts;h=f9b0d257bc846c9863663e6b8dbef143358afb13;hb=a687879e94fa5d3ecdd76bec3d94d0e1698ee913;hp=0a7ae8536da87ef839381b10cb9a0a0423d53044;hpb=bbae45c32ea41ba4926b291fac5f594c94d5aa9d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index 0a7ae8536..f9b0d257b 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts @@ -2,9 +2,9 @@ import { expect } from 'chai' import { basename, join } from 'path' -import { ffprobePromise, getVideoStream } from '@server/helpers/ffmpeg' -import { testImage, testVideoResolutions } from '@server/tests/shared' +import { SQLCommand, testImage, testLiveVideoResolutions } from '@server/tests/shared' import { getAllFiles, wait } from '@shared/core-utils' +import { ffprobePromise, getVideoStream } from '@shared/ffmpeg' import { HttpStatusCode, LiveVideo, @@ -21,6 +21,7 @@ import { doubleFollow, killallServers, LiveCommand, + makeGetRequest, makeRawRequest, PeerTubeServer, sendRTMPStream, @@ -86,6 +87,7 @@ describe('Test live', function () { commentsEnabled: false, downloadEnabled: false, saveReplay: true, + replaySettings: { privacy: VideoPrivacy.PUBLIC }, latencyMode: LiveVideoLatencyMode.SMALL_LATENCY, privacy: VideoPrivacy.PUBLIC, previewfile: 'video_short1-preview.webm.jpg', @@ -127,6 +129,9 @@ describe('Test live', function () { if (server.url === servers[0].url) { expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live') expect(live.streamKey).to.not.be.empty + + expect(live.replaySettings).to.exist + expect(live.replaySettings.privacy).to.equal(VideoPrivacy.PUBLIC) } else { expect(live.rtmpUrl).to.not.exist expect(live.streamKey).to.not.exist @@ -157,8 +162,8 @@ describe('Test live', function () { expect(video.privacy.id).to.equal(VideoPrivacy.UNLISTED) expect(video.nsfw).to.be.true - await makeRawRequest(server.url + video.thumbnailPath, HttpStatusCode.OK_200) - await makeRawRequest(server.url + video.previewPath, HttpStatusCode.OK_200) + await makeGetRequest({ url: server.url, path: video.thumbnailPath, expectedStatus: HttpStatusCode.OK_200 }) + await makeGetRequest({ url: server.url, path: video.previewPath, expectedStatus: HttpStatusCode.OK_200 }) } }) @@ -195,6 +200,7 @@ describe('Test live', function () { } expect(live.saveReplay).to.be.false + expect(live.replaySettings).to.not.exist expect(live.latencyMode).to.equal(LiveVideoLatencyMode.DEFAULT) } }) @@ -359,13 +365,17 @@ describe('Test live', function () { describe('Live transcoding', function () { let liveVideoId: string + let sqlCommandServer1: SQLCommand async function createLiveWrapper (saveReplay: boolean) { const liveAttributes = { name: 'live video', channelId: servers[0].store.channel.id, privacy: VideoPrivacy.PUBLIC, - saveReplay + saveReplay, + replaySettings: saveReplay + ? { privacy: VideoPrivacy.PUBLIC } + : undefined } const { uuid } = await commands[0].create({ fields: liveAttributes }) @@ -398,6 +408,8 @@ describe('Test live', function () { before(async function () { await updateConf([]) + + sqlCommandServer1 = new SQLCommand(servers[0]) }) it('Should enable transcoding without additional resolutions', async function () { @@ -409,8 +421,9 @@ describe('Test live', function () { await waitUntilLivePublishedOnAllServers(servers, liveVideoId) await waitJobs(servers) - await testVideoResolutions({ + await testLiveVideoResolutions({ originServer: servers[0], + sqlCommand: sqlCommandServer1, servers, liveVideoId, resolutions: [ 720 ], @@ -444,8 +457,9 @@ describe('Test live', function () { await waitUntilLivePublishedOnAllServers(servers, liveVideoId) await waitJobs(servers) - await testVideoResolutions({ + await testLiveVideoResolutions({ originServer: servers[0], + sqlCommand: sqlCommandServer1, servers, liveVideoId, resolutions: resolutions.concat([ 720 ]), @@ -496,8 +510,9 @@ describe('Test live', function () { await waitUntilLivePublishedOnAllServers(servers, liveVideoId) await waitJobs(servers) - await testVideoResolutions({ + await testLiveVideoResolutions({ originServer: servers[0], + sqlCommand: sqlCommandServer1, servers, liveVideoId, resolutions, @@ -519,7 +534,7 @@ describe('Test live', function () { } const minBitrateLimits = { - 720: 5000 * 1000, + 720: 4800 * 1000, 360: 1000 * 1000, 240: 550 * 1000 } @@ -532,8 +547,8 @@ describe('Test live', function () { expect(video.files).to.have.lengthOf(0) const hlsPlaylist = video.streamingPlaylists.find(s => s.type === VideoStreamingPlaylistType.HLS) - await makeRawRequest(hlsPlaylist.playlistUrl, HttpStatusCode.OK_200) - await makeRawRequest(hlsPlaylist.segmentsSha256Url, HttpStatusCode.OK_200) + await makeRawRequest({ url: hlsPlaylist.playlistUrl, expectedStatus: HttpStatusCode.OK_200 }) + await makeRawRequest({ url: hlsPlaylist.segmentsSha256Url, expectedStatus: HttpStatusCode.OK_200 }) // We should have generated random filenames expect(basename(hlsPlaylist.playlistUrl)).to.not.equal('master.m3u8') @@ -564,8 +579,8 @@ describe('Test live', function () { expect(probe.format.bit_rate).to.be.below(maxBitrateLimits[videoStream.height]) expect(probe.format.bit_rate).to.be.at.least(minBitrateLimits[videoStream.height]) - await makeRawRequest(file.torrentUrl, HttpStatusCode.OK_200) - await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200) + await makeRawRequest({ url: file.torrentUrl, expectedStatus: HttpStatusCode.OK_200 }) + await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) } } }) @@ -592,8 +607,9 @@ describe('Test live', function () { await waitUntilLivePublishedOnAllServers(servers, liveVideoId) await waitJobs(servers) - await testVideoResolutions({ + await testLiveVideoResolutions({ originServer: servers[0], + sqlCommand: sqlCommandServer1, servers, liveVideoId, resolutions, @@ -628,8 +644,9 @@ describe('Test live', function () { await waitUntilLivePublishedOnAllServers(servers, liveVideoId) await waitJobs(servers) - await testVideoResolutions({ + await testLiveVideoResolutions({ originServer: servers[0], + sqlCommand: sqlCommandServer1, servers, liveVideoId, resolutions: [ 720 ], @@ -652,6 +669,10 @@ describe('Test live', function () { expect(hlsFiles[0].resolution.id).to.equal(720) }) + + after(async function () { + await sqlCommandServer1.cleanup() + }) }) describe('After a server restart', function () { @@ -669,6 +690,9 @@ describe('Test live', function () { channelId: servers[0].store.channel.id, privacy: VideoPrivacy.PUBLIC, saveReplay: options.saveReplay, + replaySettings: options.saveReplay + ? { privacy: VideoPrivacy.PUBLIC } + : undefined, permanentLive: options.permanent }