]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/multiple-servers.ts
Remove resumable cache after upload success
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / multiple-servers.ts
index 89d84230779e10ccef6c2d4171339a5c48eb1fef..9c255c1c55ef0a74ddb92801e0dbba4af758d96d 100644 (file)
@@ -2,30 +2,30 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import * as request from 'supertest'
-import { HttpStatusCode } from '@shared/core-utils'
+import request from 'supertest'
 import {
   buildAbsoluteFixturePath,
   checkTmpIsEmpty,
   checkVideoFilesWereRemoved,
   cleanupTests,
   completeVideoCheck,
+  createMultipleServers,
   dateIsValid,
   doubleFollow,
-  flushAndRunMultipleServers,
-  ServerInfo,
+  PeerTubeServer,
+  saveVideoInServers,
   setAccessTokensToServers,
   testImage,
   wait,
   waitJobs,
   webtorrentAdd
 } from '@shared/extra-utils'
-import { VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
+import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
 
 const expect = chai.expect
 
 describe('Test multiple servers', function () {
-  let servers: ServerInfo[] = []
+  let servers: PeerTubeServer[] = []
   const toRemove = []
   let videoUUID = ''
   let videoChannelId: number
@@ -33,7 +33,7 @@ describe('Test multiple servers', function () {
   before(async function () {
     this.timeout(120000)
 
-    servers = await flushAndRunMultipleServers(3)
+    servers = await createMultipleServers(3)
 
     // Get the access tokens
     await setAccessTokensToServers(servers)
@@ -349,7 +349,7 @@ describe('Test multiple servers', function () {
 
   describe('It should list local videos', function () {
     it('Should list only local videos on server 1', async function () {
-      const { data, total } = await servers[0].videos.list({ filter: 'local' })
+      const { data, total } = await servers[0].videos.list({ isLocal: true })
 
       expect(total).to.equal(1)
       expect(data).to.be.an('array')
@@ -358,7 +358,7 @@ describe('Test multiple servers', function () {
     })
 
     it('Should list only local videos on server 2', async function () {
-      const { data, total } = await servers[1].videos.list({ filter: 'local' })
+      const { data, total } = await servers[1].videos.list({ isLocal: true })
 
       expect(total).to.equal(1)
       expect(data).to.be.an('array')
@@ -367,7 +367,7 @@ describe('Test multiple servers', function () {
     })
 
     it('Should list only local videos on server 3', async function () {
-      const { data, total } = await servers[2].videos.list({ filter: 'local' })
+      const { data, total } = await servers[2].videos.list({ isLocal: true })
 
       expect(total).to.equal(2)
       expect(data).to.be.an('array')
@@ -662,19 +662,19 @@ describe('Test multiple servers', function () {
       }
     })
 
-    it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
-      this.timeout(10000)
+    it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', async function () {
+      this.timeout(30000)
 
-      await servers[2].videos.remove({ id: toRemove[0].id })
-      await servers[2].videos.remove({ id: toRemove[1].id })
+      for (const id of [ toRemove[0].id, toRemove[1].id ]) {
+        await saveVideoInServers(servers, id)
 
-      await waitJobs(servers)
-    })
+        await servers[2].videos.remove({ id })
 
-    it('Should not have files of videos 3 and 3-2 on each server', async function () {
-      for (const server of servers) {
-        await checkVideoFilesWereRemoved(toRemove[0].uuid, server)
-        await checkVideoFilesWereRemoved(toRemove[1].uuid, server)
+        await waitJobs(servers)
+
+        for (const server of servers) {
+          await checkVideoFilesWereRemoved({ server, video: server.store.videoDetails })
+        }
       }
     })