]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/live/live-permanent.ts
Introduce live command
[github/Chocobozzz/PeerTube.git] / server / tests / api / live / live-permanent.ts
index d52e8c7e4b898acbbebce83918a2bb1417ff044a..a0f70dfdb3dcb365c09334156b971829eb6b136b 100644 (file)
@@ -5,29 +5,21 @@ import * as chai from 'chai'
 import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models'
 import {
   cleanupTests,
-  createLive,
+  ConfigCommand,
   doubleFollow,
   flushAndRunMultipleServers,
-  getCustomConfigResolutions,
-  getLive,
-  getPlaylistsCount,
   getVideo,
-  sendRTMPStreamInVideo,
   ServerInfo,
   setAccessTokensToServers,
   setDefaultVideoChannel,
   stopFfmpeg,
-  updateCustomSubConfig,
-  updateLive,
   wait,
-  waitJobs,
-  waitUntilLivePublished,
-  waitUntilLiveWaiting
+  waitJobs
 } from '../../../../shared/extra-utils'
 
 const expect = chai.expect
 
-describe('Permenant live', function () {
+describe('Permanent live', function () {
   let servers: ServerInfo[] = []
   let videoUUID: string
 
@@ -40,8 +32,8 @@ describe('Permenant live', function () {
       permanentLive
     }
 
-    const res = await createLive(servers[0].url, servers[0].accessToken, attributes)
-    return res.body.video.uuid
+    const { uuid } = await servers[0].liveCommand.createLive({ fields: attributes })
+    return uuid
   }
 
   async function checkVideoState (videoId: string, state: VideoState) {
@@ -63,14 +55,16 @@ describe('Permenant live', function () {
     // Server 1 and server 2 follow each other
     await doubleFollow(servers[0], servers[1])
 
-    await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
-      live: {
-        enabled: true,
-        allowReplay: true,
-        maxDuration: -1,
-        transcoding: {
+    await servers[0].configCommand.updateCustomSubConfig({
+      newConfig: {
+        live: {
           enabled: true,
-          resolutions: getCustomConfigResolutions(true)
+          allowReplay: true,
+          maxDuration: -1,
+          transcoding: {
+            enabled: true,
+            resolutions: ConfigCommand.getCustomConfigResolutions(true)
+          }
         }
       }
     })
@@ -82,15 +76,15 @@ describe('Permenant live', function () {
     const videoUUID = await createLiveWrapper(false)
 
     {
-      const res = await getLive(servers[0].url, servers[0].accessToken, videoUUID)
-      expect(res.body.permanentLive).to.be.false
+      const live = await servers[0].liveCommand.getLive({ videoId: videoUUID })
+      expect(live.permanentLive).to.be.false
     }
 
-    await updateLive(servers[0].url, servers[0].accessToken, videoUUID, { permanentLive: true })
+    await servers[0].liveCommand.updateLive({ videoId: videoUUID, fields: { permanentLive: true } })
 
     {
-      const res = await getLive(servers[0].url, servers[0].accessToken, videoUUID)
-      expect(res.body.permanentLive).to.be.true
+      const live = await servers[0].liveCommand.getLive({ videoId: videoUUID })
+      expect(live.permanentLive).to.be.true
     }
   })
 
@@ -99,25 +93,25 @@ describe('Permenant live', function () {
 
     videoUUID = await createLiveWrapper(true)
 
-    const res = await getLive(servers[0].url, servers[0].accessToken, videoUUID)
-    expect(res.body.permanentLive).to.be.true
+    const live = await servers[0].liveCommand.getLive({ videoId: videoUUID })
+    expect(live.permanentLive).to.be.true
 
     await waitJobs(servers)
   })
 
   it('Should stream into this permanent live', async function () {
-    this.timeout(60000)
+    this.timeout(120000)
 
-    const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID)
+    const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID })
 
     for (const server of servers) {
-      await waitUntilLivePublished(server.url, server.accessToken, videoUUID)
+      await server.liveCommand.waitUntilLivePublished({ videoId: videoUUID })
     }
 
     await checkVideoState(videoUUID, VideoState.PUBLISHED)
 
-    await stopFfmpeg(command)
-    await waitUntilLiveWaiting(servers[0].url, servers[0].accessToken, videoUUID)
+    await stopFfmpeg(ffmpegCommand)
+    await servers[0].liveCommand.waitUntilLiveWaiting({ videoId: videoUUID })
 
     await waitJobs(servers)
   })
@@ -145,31 +139,33 @@ describe('Permenant live', function () {
   it('Should be able to stream again in the permanent live', async function () {
     this.timeout(20000)
 
-    await updateCustomSubConfig(servers[0].url, servers[0].accessToken, {
-      live: {
-        enabled: true,
-        allowReplay: true,
-        maxDuration: -1,
-        transcoding: {
+    await servers[0].configCommand.updateCustomSubConfig({
+      newConfig: {
+        live: {
           enabled: true,
-          resolutions: getCustomConfigResolutions(false)
+          allowReplay: true,
+          maxDuration: -1,
+          transcoding: {
+            enabled: true,
+            resolutions: ConfigCommand.getCustomConfigResolutions(false)
+          }
         }
       }
     })
 
-    const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, videoUUID)
+    const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID })
 
     for (const server of servers) {
-      await waitUntilLivePublished(server.url, server.accessToken, videoUUID)
+      await server.liveCommand.waitUntilLivePublished({ videoId: videoUUID })
     }
 
     await checkVideoState(videoUUID, VideoState.PUBLISHED)
 
-    const count = await getPlaylistsCount(servers[0], videoUUID)
+    const count = await servers[0].liveCommand.getPlaylistsCount({ videoUUID })
     // master playlist and 720p playlist
     expect(count).to.equal(2)
 
-    await stopFfmpeg(command)
+    await stopFfmpeg(ffmpegCommand)
   })
 
   after(async function () {