]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/multiple-servers.ts
Try parallel check params tests
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / multiple-servers.ts
index edc46a64452f2257b69d088d3eedce9ad1bed40e..68c1e9a8de3e531345f68d3f69c95cfb9548c0fa 100644 (file)
@@ -6,16 +6,17 @@ import { join } from 'path'
 import * as request from 'supertest'
 import { VideoPrivacy } from '../../../../shared/models/videos'
 import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
-
 import {
   addVideoChannel,
-  checkVideoFilesWereRemoved,
+  checkTmpIsEmpty,
+  checkVideoFilesWereRemoved, cleanupTests,
   completeVideoCheck,
   createUser,
   dateIsValid,
   doubleFollow,
   flushAndRunMultipleServers,
-  flushTests, getLocalVideos,
+  flushTests,
+  getLocalVideos,
   getVideo,
   getVideoChannelsList,
   getVideosList,
@@ -31,15 +32,15 @@ import {
   viewVideo,
   wait,
   webtorrentAdd
-} from '../../utils'
+} from '../../../../shared/extra-utils'
 import {
   addVideoCommentReply,
   addVideoCommentThread,
   deleteVideoComment,
   getVideoCommentThreads,
   getVideoThreadComments
-} from '../../utils/videos/video-comments'
-import { getAccountsList } from '../../utils/users/accounts'
+} from '../../../../shared/extra-utils/videos/video-comments'
+import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
 
 const expect = chai.expect
 
@@ -59,6 +60,7 @@ describe('Test multiple servers', function () {
 
     {
       const videoChannel = {
+        name: 'super_channel_name',
         displayName: 'my channel',
         description: 'super channel'
       }
@@ -96,13 +98,14 @@ describe('Test multiple servers', function () {
         nsfw: true,
         description: 'my super description for server 1',
         support: 'my super support text for server 1',
+        originallyPublishedAt: '2019-02-10T13:38:14.449Z',
         tags: [ 'tag1p1', 'tag2p1' ],
         channelId: videoChannelId,
         fixture: 'video_short1.webm'
       }
       await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
 
-      await wait(10000)
+      await waitJobs(servers)
 
       // All servers should have this video
       let publishedAt: string = null
@@ -116,6 +119,7 @@ describe('Test multiple servers', function () {
           nsfw: true,
           description: 'my super description for server 1',
           support: 'my super support text for server 1',
+          originallyPublishedAt: '2019-02-10T13:38:14.449Z',
           account: {
             name: 'root',
             host: 'localhost:9001'
@@ -126,8 +130,10 @@ describe('Test multiple servers', function () {
           tags: [ 'tag1p1', 'tag2p1' ],
           privacy: VideoPrivacy.PUBLIC,
           commentsEnabled: true,
+          downloadEnabled: true,
           channel: {
-            name: 'my channel',
+            displayName: 'my channel',
+            name: 'super_channel_name',
             description: 'super channel',
             isLocal
           },
@@ -158,7 +164,7 @@ describe('Test multiple servers', function () {
         username: 'user1',
         password: 'super_password'
       }
-      await createUser(servers[1].url, servers[1].accessToken, user.username, user.password)
+      await createUser({ url: servers[ 1 ].url, accessToken: servers[ 1 ].accessToken, username: user.username, password: user.password })
       const userAccessToken = await userLogin(servers[1], user)
 
       const videoAttributes = {
@@ -177,7 +183,7 @@ describe('Test multiple servers', function () {
       await uploadVideo(servers[1].url, userAccessToken, videoAttributes)
 
       // Transcoding
-      await wait(30000)
+      await waitJobs(servers)
 
       // All servers should have this video
       for (const server of servers) {
@@ -196,11 +202,13 @@ describe('Test multiple servers', function () {
           },
           isLocal,
           commentsEnabled: true,
+          downloadEnabled: true,
           duration: 5,
           tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
           privacy: VideoPrivacy.PUBLIC,
           channel: {
-            name: 'Default user1 channel',
+            displayName: 'Main user1 channel',
+            name: 'user1_channel',
             description: 'super channel',
             isLocal
           },
@@ -208,19 +216,19 @@ describe('Test multiple servers', function () {
           files: [
             {
               resolution: 240,
-              size: 190000
+              size: 187000
             },
             {
               resolution: 360,
-              size: 280000
+              size: 278000
             },
             {
               resolution: 480,
-              size: 390000
+              size: 383000
             },
             {
               resolution: 720,
-              size: 710000
+              size: 706000
             }
           ],
           thumbnailfile: 'thumbnail',
@@ -266,7 +274,7 @@ describe('Test multiple servers', function () {
       }
       await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
 
-      await wait(10000)
+      await waitJobs(servers)
 
       // All servers should have this video
       for (const server of servers) {
@@ -303,10 +311,12 @@ describe('Test multiple servers', function () {
           isLocal,
           duration: 5,
           commentsEnabled: true,
+          downloadEnabled: true,
           tags: [ 'tag1p3' ],
           privacy: VideoPrivacy.PUBLIC,
           channel: {
-            name: 'Default root channel',
+            displayName: 'Main root channel',
+            name: 'root_channel',
             description: '',
             isLocal
           },
@@ -333,12 +343,14 @@ describe('Test multiple servers', function () {
             host: 'localhost:9003'
           },
           commentsEnabled: true,
+          downloadEnabled: true,
           isLocal,
           duration: 5,
           tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
           privacy: VideoPrivacy.PUBLIC,
           channel: {
-            name: 'Default root channel',
+            displayName: 'Main root channel',
+            name: 'root_channel',
             description: '',
             isLocal
           },
@@ -487,7 +499,7 @@ describe('Test multiple servers', function () {
     })
 
     it('Should view multiple videos on owned servers', async function () {
-      this.timeout(15000)
+      this.timeout(30000)
 
       const tasks: Promise<any>[] = []
       await viewVideo(servers[2].url, localVideosServer3[0])
@@ -496,15 +508,18 @@ describe('Test multiple servers', function () {
       await viewVideo(servers[2].url, localVideosServer3[1])
 
       await Promise.all(tasks)
-      await wait(1500)
+      await waitJobs(servers)
 
       await viewVideo(servers[2].url, localVideosServer3[0])
 
-      await wait(1500)
+      await waitJobs(servers)
 
       await viewVideo(servers[2].url, localVideosServer3[0])
 
-      await wait(5000)
+      await waitJobs(servers)
+
+      // Wait the repeatable job
+      await wait(6000)
 
       for (const server of servers) {
         const res = await getVideosList(server.url)
@@ -519,7 +534,7 @@ describe('Test multiple servers', function () {
     })
 
     it('Should view multiple videos on each servers', async function () {
-      this.timeout(15000)
+      this.timeout(30000)
 
       const tasks: Promise<any>[] = []
       tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
@@ -535,7 +550,10 @@ describe('Test multiple servers', function () {
 
       await Promise.all(tasks)
 
-      await wait(10000)
+      await waitJobs(servers)
+
+      // Wait the repeatable job
+      await wait(8000)
 
       let baseVideos = null
 
@@ -561,18 +579,18 @@ describe('Test multiple servers', function () {
       this.timeout(20000)
 
       await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
-      await wait(200)
+      await wait(500)
       await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')
-      await wait(200)
+      await wait(500)
       await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
       await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')
-      await wait(200)
+      await wait(500)
       await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')
       await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')
-      await wait(200)
+      await wait(500)
       await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
 
-      await wait(10000)
+      await waitJobs(servers)
 
       let baseVideos = null
       for (const server of servers) {
@@ -609,12 +627,13 @@ describe('Test multiple servers', function () {
         support: 'my super support text updated',
         tags: [ 'tag_up_1', 'tag_up_2' ],
         thumbnailfile: 'thumbnail.jpg',
+        originallyPublishedAt: '2019-02-11T13:38:14.449Z',
         previewfile: 'preview.jpg'
       }
 
       await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
 
-      await wait(5000)
+      await waitJobs(servers)
     })
 
     it('Should have the video 3 updated on each server', async function () {
@@ -636,6 +655,7 @@ describe('Test multiple servers', function () {
           nsfw: true,
           description: 'my super description updated',
           support: 'my super support text updated',
+          originallyPublishedAt: '2019-02-11T13:38:14.449Z',
           account: {
             name: 'root',
             host: 'localhost:9003'
@@ -643,10 +663,12 @@ describe('Test multiple servers', function () {
           isLocal,
           duration: 5,
           commentsEnabled: true,
+          downloadEnabled: true,
           tags: [ 'tag_up_1', 'tag_up_2' ],
           privacy: VideoPrivacy.PUBLIC,
           channel: {
-            name: 'Default root channel',
+            displayName: 'Main root channel',
+            name: 'root_channel',
             description: '',
             isLocal
           },
@@ -670,7 +692,7 @@ describe('Test multiple servers', function () {
       await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
       await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)
 
-      await wait(5000)
+      await waitJobs(servers)
     })
 
     it('Should not have files of videos 3 and 3-2 on each server', async function () {
@@ -749,7 +771,7 @@ describe('Test multiple servers', function () {
         await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, text)
       }
 
-      await wait(5000)
+      await waitJobs(servers)
 
       {
         const res = await getVideoCommentThreads(servers[1].url, videoUUID, 0, 5)
@@ -759,7 +781,7 @@ describe('Test multiple servers', function () {
         await addVideoCommentReply(servers[ 1 ].url, servers[ 1 ].accessToken, videoUUID, threadId, text)
       }
 
-      await wait(5000)
+      await waitJobs(servers)
 
       {
         const res1 = await getVideoCommentThreads(servers[2].url, videoUUID, 0, 5)
@@ -775,7 +797,7 @@ describe('Test multiple servers', function () {
         await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, childCommentId, text2)
       }
 
-      await wait(5000)
+      await waitJobs(servers)
     })
 
     it('Should have these threads', async function () {
@@ -848,7 +870,7 @@ describe('Test multiple servers', function () {
 
       await deleteVideoComment(servers[2].url, servers[2].accessToken, videoUUID, childOfFirstChild.comment.id)
 
-      await wait(5000)
+      await waitJobs(servers)
     })
 
     it('Should not have this comment anymore', async function () {
@@ -877,7 +899,7 @@ describe('Test multiple servers', function () {
       const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
       await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
 
-      await wait(5000)
+      await waitJobs(servers)
     })
 
     it('Should have the thread comments deleted on other servers too', async function () {
@@ -901,20 +923,22 @@ describe('Test multiple servers', function () {
       }
     })
 
-    it('Should disable comments', async function () {
+    it('Should disable comments and download', async function () {
       this.timeout(20000)
 
       const attributes = {
-        commentsEnabled: false
+        commentsEnabled: false,
+        downloadEnabled: false
       }
 
       await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
 
-      await wait(5000)
+      await waitJobs(servers)
 
       for (const server of servers) {
         const res = await getVideo(server.url, videoUUID)
         expect(res.body.commentsEnabled).to.be.false
+        expect(res.body.downloadEnabled).to.be.false
 
         const text = 'my super forbidden comment'
         await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, 409)
@@ -941,7 +965,7 @@ describe('Test multiple servers', function () {
       await req.attach('videofile', filePath)
         .expect(200)
 
-      await wait(40000)
+      await waitJobs(servers)
 
       for (const server of servers) {
         const res = await getVideosList(server.url)
@@ -963,10 +987,12 @@ describe('Test multiple servers', function () {
           isLocal,
           duration: 5,
           commentsEnabled: false,
+          downloadEnabled: true,
           tags: [ ],
           privacy: VideoPrivacy.PUBLIC,
           channel: {
-            name: 'Default root channel',
+            displayName: 'Main root channel',
+            name: 'root_channel',
             description: '',
             isLocal
           },
@@ -974,19 +1000,19 @@ describe('Test multiple servers', function () {
           files: [
             {
               resolution: 720,
-              size: 40315
+              size: 72000
             },
             {
               resolution: 480,
-              size: 22808
+              size: 45000
             },
             {
               resolution: 360,
-              size: 18617
+              size: 34600
             },
             {
               resolution: 240,
-              size: 15217
+              size: 24770
             }
           ]
         }
@@ -995,12 +1021,15 @@ describe('Test multiple servers', function () {
     })
   })
 
-  after(async function () {
-    killallServers(servers)
+  describe('TMP directory', function () {
+    it('Should have an empty tmp directory', async function () {
+      for (const server of servers) {
+        await checkTmpIsEmpty(server)
+      }
+    })
+  })
 
-    // Keep the logs if the test failed
-    if (this['ok']) {
-      await flushTests()
-    }
+  after(async function () {
+    await cleanupTests(servers)
   })
 })