X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Flive%2Flive-permanent.ts;h=f07d4cfecc7936b0df884abf4bd3da323ae45bdf;hb=9f430a53be016f8db2736d5d8111282660b50f4c;hp=6f4915a6b4b6a634af1c0124f9457369d7481c98;hpb=04aed76711909507e74905bde3a7fa024d3585c9;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts index 6f4915a6b..f07d4cfec 100644 --- a/server/tests/api/live/live-permanent.ts +++ b/server/tests/api/live/live-permanent.ts @@ -2,14 +2,13 @@ import 'mocha' import * as chai from 'chai' -import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models' +import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' import { cleanupTests, ConfigCommand, + createMultipleServers, doubleFollow, - flushAndRunMultipleServers, - getVideo, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel, stopFfmpeg, @@ -20,33 +19,33 @@ import { const expect = chai.expect describe('Permanent live', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] let videoUUID: string async function createLiveWrapper (permanentLive: boolean) { const attributes: LiveVideoCreate = { - channelId: servers[0].videoChannel.id, + channelId: servers[0].store.channel.id, privacy: VideoPrivacy.PUBLIC, name: 'my super live', saveReplay: false, permanentLive } - const { uuid } = await servers[0].liveCommand.create({ fields: attributes }) + const { uuid } = await servers[0].live.create({ fields: attributes }) return uuid } async function checkVideoState (videoId: string, state: VideoState) { for (const server of servers) { - const res = await getVideo(server.url, videoId) - expect((res.body as VideoDetails).state.id).to.equal(state) + const video = await server.videos.get({ id: videoId }) + expect(video.state.id).to.equal(state) } } before(async function () { this.timeout(120000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) // Get the access tokens await setAccessTokensToServers(servers) @@ -55,7 +54,7 @@ describe('Permanent live', function () { // Server 1 and server 2 follow each other await doubleFollow(servers[0], servers[1]) - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { live: { enabled: true, @@ -76,14 +75,14 @@ describe('Permanent live', function () { const videoUUID = await createLiveWrapper(false) { - const live = await servers[0].liveCommand.get({ videoId: videoUUID }) + const live = await servers[0].live.get({ videoId: videoUUID }) expect(live.permanentLive).to.be.false } - await servers[0].liveCommand.update({ videoId: videoUUID, fields: { permanentLive: true } }) + await servers[0].live.update({ videoId: videoUUID, fields: { permanentLive: true } }) { - const live = await servers[0].liveCommand.get({ videoId: videoUUID }) + const live = await servers[0].live.get({ videoId: videoUUID }) expect(live.permanentLive).to.be.true } }) @@ -93,7 +92,7 @@ describe('Permanent live', function () { videoUUID = await createLiveWrapper(true) - const live = await servers[0].liveCommand.get({ videoId: videoUUID }) + const live = await servers[0].live.get({ videoId: videoUUID }) expect(live.permanentLive).to.be.true await waitJobs(servers) @@ -102,16 +101,16 @@ describe('Permanent live', function () { it('Should stream into this permanent live', async function () { this.timeout(120000) - const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID }) + const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID }) for (const server of servers) { - await server.liveCommand.waitUntilPublished({ videoId: videoUUID }) + await server.live.waitUntilPublished({ videoId: videoUUID }) } await checkVideoState(videoUUID, VideoState.PUBLISHED) await stopFfmpeg(ffmpegCommand) - await servers[0].liveCommand.waitUntilWaiting({ videoId: videoUUID }) + await servers[0].live.waitUntilWaiting({ videoId: videoUUID }) await waitJobs(servers) }) @@ -123,9 +122,7 @@ describe('Permanent live', function () { await waitJobs(servers) for (const server of servers) { - const res = await getVideo(server.url, videoUUID) - - const videoDetails = res.body as VideoDetails + const videoDetails = await server.videos.get({ id: videoUUID }) expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) } }) @@ -139,7 +136,7 @@ describe('Permanent live', function () { it('Should be able to stream again in the permanent live', async function () { this.timeout(20000) - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { live: { enabled: true, @@ -153,15 +150,15 @@ describe('Permanent live', function () { } }) - const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID }) + const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID }) for (const server of servers) { - await server.liveCommand.waitUntilPublished({ videoId: videoUUID }) + await server.live.waitUntilPublished({ videoId: videoUUID }) } await checkVideoState(videoUUID, VideoState.PUBLISHED) - const count = await servers[0].liveCommand.countPlaylists({ videoUUID }) + const count = await servers[0].live.countPlaylists({ videoUUID }) // master playlist and 720p playlist expect(count).to.equal(2)