]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/redundancy/redundancy.ts
Merge branch 'release/3.3.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / api / redundancy / redundancy.ts
index 77ea2278e6218e31113f01920465f41c7191426e..a6559d304f775006807a0baa162522e37f416ffb 100644 (file)
@@ -5,31 +5,29 @@ import * as chai from 'chai'
 import { readdir } from 'fs-extra'
 import * as magnetUtil from 'magnet-uri'
 import { join } from 'path'
-import { HttpStatusCode } from '@shared/core-utils'
 import {
   checkSegmentHash,
   checkVideoFilesWereRemoved,
   cleanupTests,
+  createMultipleServers,
   doubleFollow,
-  flushAndRunMultipleServers,
   killallServers,
   makeGetRequest,
-  reRunServer,
+  PeerTubeServer,
   root,
-  ServerInfo,
   setAccessTokensToServers,
   wait,
   waitJobs
 } from '@shared/extra-utils'
-import { VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '@shared/models'
+import { HttpStatusCode, VideoPrivacy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '@shared/models'
 
 const expect = chai.expect
 
-let servers: ServerInfo[] = []
+let servers: PeerTubeServer[] = []
 let video1Server2UUID: string
 let video1Server2Id: number
 
-function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: number } }, baseWebseeds: string[], server: ServerInfo) {
+function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: number } }, baseWebseeds: string[], server: PeerTubeServer) {
   const parsed = magnetUtil.decode(file.magnetUri)
 
   for (const ws of baseWebseeds) {
@@ -40,7 +38,7 @@ function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: numbe
   expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length)
 }
 
-async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, additionalParams: any = {}, withWebtorrent = true) {
+async function createSingleServers (strategy: VideoRedundancyStrategy | null, additionalParams: any = {}, withWebtorrent = true) {
   const strategies: any[] = []
 
   if (strategy !== null) {
@@ -72,7 +70,7 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, add
     }
   }
 
-  servers = await flushAndRunMultipleServers(3, config)
+  servers = await createMultipleServers(3, config)
 
   // Get the access tokens
   await setAccessTokensToServers(servers)
@@ -130,13 +128,13 @@ async function check2Webseeds (videoUUID?: string) {
 
       await makeGetRequest({
         url: servers[0].url,
-        statusCodeExpected: HttpStatusCode.OK_200,
+        expectedStatus: HttpStatusCode.OK_200,
         path: '/static/redundancy/' + `${videoUUID}-${file.resolution.id}.mp4`,
         contentType: null
       })
       await makeGetRequest({
         url: servers[1].url,
-        statusCodeExpected: HttpStatusCode.OK_200,
+        expectedStatus: HttpStatusCode.OK_200,
         path: `/static/webseed/${videoUUID}-${file.resolution.id}.mp4`,
         contentType: null
       })
@@ -288,7 +286,7 @@ describe('Test videos redundancy', function () {
     before(function () {
       this.timeout(120000)
 
-      return flushAndRunServers(strategy)
+      return createSingleServers(strategy)
     })
 
     it('Should have 1 webseed on the first video', async function () {
@@ -338,7 +336,7 @@ describe('Test videos redundancy', function () {
     before(function () {
       this.timeout(120000)
 
-      return flushAndRunServers(strategy)
+      return createSingleServers(strategy)
     })
 
     it('Should have 1 webseed on the first video', async function () {
@@ -388,7 +386,7 @@ describe('Test videos redundancy', function () {
     before(function () {
       this.timeout(120000)
 
-      return flushAndRunServers(strategy, { min_views: 3 })
+      return createSingleServers(strategy, { min_views: 3 })
     })
 
     it('Should have 1 webseed on the first video', async function () {
@@ -458,7 +456,7 @@ describe('Test videos redundancy', function () {
     before(async function () {
       this.timeout(120000)
 
-      await flushAndRunServers(strategy, { min_views: 3 }, false)
+      await createSingleServers(strategy, { min_views: 3 }, false)
     })
 
     it('Should have 0 playlist redundancy on the first video', async function () {
@@ -519,7 +517,7 @@ describe('Test videos redundancy', function () {
     before(function () {
       this.timeout(120000)
 
-      return flushAndRunServers(null)
+      return createSingleServers(null)
     })
 
     it('Should have 1 webseed on the first video', async function () {
@@ -575,7 +573,7 @@ describe('Test videos redundancy', function () {
   describe('Test expiration', function () {
     const strategy = 'recently-added'
 
-    async function checkContains (servers: ServerInfo[], str: string) {
+    async function checkContains (servers: PeerTubeServer[], str: string) {
       for (const server of servers) {
         const video = await server.videos.get({ id: video1Server2UUID })
 
@@ -585,7 +583,7 @@ describe('Test videos redundancy', function () {
       }
     }
 
-    async function checkNotContains (servers: ServerInfo[], str: string) {
+    async function checkNotContains (servers: PeerTubeServer[], str: string) {
       for (const server of servers) {
         const video = await server.videos.get({ id: video1Server2UUID })
 
@@ -598,7 +596,7 @@ describe('Test videos redundancy', function () {
     before(async function () {
       this.timeout(120000)
 
-      await flushAndRunServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
+      await createSingleServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
 
       await enableRedundancyOnServer1()
     })
@@ -640,7 +638,7 @@ describe('Test videos redundancy', function () {
     before(async function () {
       this.timeout(120000)
 
-      await flushAndRunServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
+      await createSingleServers(strategy, { min_lifetime: '7 seconds', min_views: 0 })
 
       await enableRedundancyOnServer1()
 
@@ -691,7 +689,7 @@ describe('Test videos redundancy', function () {
       await waitJobs(servers)
 
       await killallServers([ servers[0] ])
-      await reRunServer(servers[0], {
+      await servers[0].run({
         redundancy: {
           videos: {
             check_interval: '1 second',