]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/object-storage/live.ts
Feature/Add replay privacy (#5692)
[github/Chocobozzz/PeerTube.git] / server / tests / api / object-storage / live.ts
index 7e16b4c890483bde7560bf37f35d39b5a45a358e..588e0a8d7b81cc5c37f659612206d3eb79aadf07 100644 (file)
@@ -1,8 +1,8 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import { expect } from 'chai'
-import { expectStartWith, testVideoResolutions } from '@server/tests/shared'
-import { areObjectStorageTestsDisabled } from '@shared/core-utils'
+import { expectStartWith, MockObjectStorageProxy, testVideoResolutions } from '@server/tests/shared'
+import { areMockObjectStorageTestsDisabled } from '@shared/core-utils'
 import { HttpStatusCode, LiveVideoCreate, VideoPrivacy } from '@shared/models'
 import {
   createMultipleServers,
@@ -27,6 +27,7 @@ async function createLive (server: PeerTubeServer, permanent: boolean) {
     privacy: VideoPrivacy.PUBLIC,
     name: 'my super live',
     saveReplay: true,
+    replaySettings: { privacy: VideoPrivacy.PUBLIC },
     permanentLive: permanent
   }
 
@@ -46,9 +47,9 @@ async function checkFilesExist (servers: PeerTubeServer[], videoUUID: string, nu
     expect(files).to.have.lengthOf(numberOfFiles)
 
     for (const file of files) {
-      expectStartWith(file.fileUrl, ObjectStorageCommand.getPlaylistBaseUrl())
+      expectStartWith(file.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl())
 
-      await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
+      await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
     }
   }
 }
@@ -75,16 +76,16 @@ async function checkFilesCleanup (server: PeerTubeServer, videoUUID: string, res
 }
 
 describe('Object storage for lives', function () {
-  if (areObjectStorageTestsDisabled()) return
+  if (areMockObjectStorageTestsDisabled()) return
 
   let servers: PeerTubeServer[]
 
   before(async function () {
     this.timeout(120000)
 
-    await ObjectStorageCommand.prepareDefaultBuckets()
+    await ObjectStorageCommand.prepareDefaultMockBuckets()
 
-    servers = await createMultipleServers(2, ObjectStorageCommand.getDefaultConfig())
+    servers = await createMultipleServers(2, ObjectStorageCommand.getDefaultMockConfig())
 
     await setAccessTokensToServers(servers)
     await setDefaultVideoChannel(servers)
@@ -93,7 +94,7 @@ describe('Object storage for lives', function () {
     await servers[0].config.enableTranscoding()
   })
 
-  describe('Without live transcoding', async function () {
+  describe('Without live transcoding', function () {
     let videoUUID: string
 
     before(async function () {
@@ -134,7 +135,7 @@ describe('Object storage for lives', function () {
     })
   })
 
-  describe('With live transcoding', async function () {
+  describe('With live transcoding', function () {
     const resolutions = [ 720, 480, 360, 240, 144 ]
 
     before(async function () {
@@ -223,6 +224,62 @@ describe('Object storage for lives', function () {
     })
   })
 
+  describe('With object storage base url', function () {
+    const mockObjectStorageProxy = new MockObjectStorageProxy()
+    let baseMockUrl: string
+
+    before(async function () {
+      this.timeout(120000)
+
+      const port = await mockObjectStorageProxy.initialize()
+      baseMockUrl = `http://127.0.0.1:${port}/streaming-playlists`
+
+      await ObjectStorageCommand.createMockBucket('streaming-playlists')
+
+      const config = {
+        object_storage: {
+          enabled: true,
+          endpoint: 'http://' + ObjectStorageCommand.getMockEndpointHost(),
+          region: ObjectStorageCommand.getMockRegion(),
+
+          credentials: ObjectStorageCommand.getMockCredentialsConfig(),
+
+          streaming_playlists: {
+            bucket_name: 'streaming-playlists',
+            prefix: '',
+            base_url: baseMockUrl
+          }
+        }
+      }
+
+      await servers[0].kill()
+      await servers[0].run(config)
+
+      await servers[0].config.enableLive({ transcoding: true, resolutions: 'min' })
+    })
+
+    it('Should publish a live and replace the base url', async function () {
+      this.timeout(240000)
+
+      const videoUUIDPermanent = await createLive(servers[0], true)
+
+      const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUIDPermanent })
+      await waitUntilLivePublishedOnAllServers(servers, videoUUIDPermanent)
+
+      await testVideoResolutions({
+        originServer: servers[0],
+        servers,
+        liveVideoId: videoUUIDPermanent,
+        resolutions: [ 720 ],
+        transcoded: true,
+        objectStorage: true,
+        objectStorageBaseUrl: baseMockUrl
+      })
+
+      await stopFfmpeg(ffmpegCommand)
+    })
+  })
+
   after(async function () {
     await killallServers(servers)
   })