aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/cli')
-rw-r--r--server/tests/cli/create-import-video-file-job.ts52
-rw-r--r--server/tests/cli/create-transcoding-job.ts76
-rw-r--r--server/tests/cli/optimize-old-videos.ts47
-rw-r--r--server/tests/cli/peertube.ts41
-rw-r--r--server/tests/cli/prune-storage.ts5
-rw-r--r--server/tests/cli/regenerate-thumbnails.ts33
-rw-r--r--server/tests/cli/update-host.ts29
7 files changed, 116 insertions, 167 deletions
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts
index 8a23a94de..b1d9da242 100644
--- a/server/tests/cli/create-import-video-file-job.ts
+++ b/server/tests/cli/create-import-video-file-job.ts
@@ -2,19 +2,8 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { VideoFile } from '@shared/models/videos/video-file.model' 5import { cleanupTests, doubleFollow, flushAndRunMultipleServers, ServerInfo, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
6import { 6import { VideoFile } from '@shared/models'
7 cleanupTests,
8 doubleFollow,
9 flushAndRunMultipleServers,
10 getVideo,
11 getVideosList,
12 ServerInfo,
13 setAccessTokensToServers,
14 uploadVideo
15} from '../../../shared/extra-utils'
16import { waitJobs } from '../../../shared/extra-utils/server/jobs'
17import { VideoDetails } from '../../../shared/models/videos'
18 7
19const expect = chai.expect 8const expect = chai.expect
20 9
@@ -45,10 +34,15 @@ describe('Test create import video jobs', function () {
45 await doubleFollow(servers[0], servers[1]) 34 await doubleFollow(servers[0], servers[1])
46 35
47 // Upload two videos for our needs 36 // Upload two videos for our needs
48 const res1 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' }) 37 {
49 video1UUID = res1.body.video.uuid 38 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video1' } })
50 const res2 = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' }) 39 video1UUID = uuid
51 video2UUID = res2.body.video.uuid 40 }
41
42 {
43 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video2' } })
44 video2UUID = uuid
45 }
52 46
53 // Transcoding 47 // Transcoding
54 await waitJobs(servers) 48 await waitJobs(servers)
@@ -61,14 +55,14 @@ describe('Test create import video jobs', function () {
61 await waitJobs(servers) 55 await waitJobs(servers)
62 56
63 for (const server of servers) { 57 for (const server of servers) {
64 const { data: videos } = (await getVideosList(server.url)).body 58 const { data: videos } = await server.videosCommand.list()
65 expect(videos).to.have.lengthOf(2) 59 expect(videos).to.have.lengthOf(2)
66 60
67 const video = videos.find(({ uuid }) => uuid === video1UUID) 61 const video = videos.find(({ uuid }) => uuid === video1UUID)
68 const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body 62 const videoDetails = await server.videosCommand.get({ id: video.uuid })
69 63
70 expect(videoDetail.files).to.have.lengthOf(2) 64 expect(videoDetails.files).to.have.lengthOf(2)
71 const [ originalVideo, transcodedVideo ] = videoDetail.files 65 const [ originalVideo, transcodedVideo ] = videoDetails.files
72 assertVideoProperties(originalVideo, 720, 'webm', 218910) 66 assertVideoProperties(originalVideo, 720, 'webm', 218910)
73 assertVideoProperties(transcodedVideo, 480, 'webm', 69217) 67 assertVideoProperties(transcodedVideo, 480, 'webm', 69217)
74 } 68 }
@@ -81,14 +75,14 @@ describe('Test create import video jobs', function () {
81 await waitJobs(servers) 75 await waitJobs(servers)
82 76
83 for (const server of servers) { 77 for (const server of servers) {
84 const { data: videos } = (await getVideosList(server.url)).body 78 const { data: videos } = await server.videosCommand.list()
85 expect(videos).to.have.lengthOf(2) 79 expect(videos).to.have.lengthOf(2)
86 80
87 const video = videos.find(({ uuid }) => uuid === video2UUID) 81 const video = videos.find(({ uuid }) => uuid === video2UUID)
88 const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body 82 const videoDetails = await server.videosCommand.get({ id: video.uuid })
89 83
90 expect(videoDetail.files).to.have.lengthOf(4) 84 expect(videoDetails.files).to.have.lengthOf(4)
91 const [ originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240 ] = videoDetail.files 85 const [ originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240 ] = videoDetails.files
92 assertVideoProperties(originalVideo, 720, 'ogv', 140849) 86 assertVideoProperties(originalVideo, 720, 'ogv', 140849)
93 assertVideoProperties(transcodedVideo420, 480, 'mp4') 87 assertVideoProperties(transcodedVideo420, 480, 'mp4')
94 assertVideoProperties(transcodedVideo320, 360, 'mp4') 88 assertVideoProperties(transcodedVideo320, 360, 'mp4')
@@ -103,14 +97,14 @@ describe('Test create import video jobs', function () {
103 await waitJobs(servers) 97 await waitJobs(servers)
104 98
105 for (const server of servers) { 99 for (const server of servers) {
106 const { data: videos } = (await getVideosList(server.url)).body 100 const { data: videos } = await server.videosCommand.list()
107 expect(videos).to.have.lengthOf(2) 101 expect(videos).to.have.lengthOf(2)
108 102
109 const video = videos.find(({ uuid }) => uuid === video1UUID) 103 const video = videos.find(({ uuid }) => uuid === video1UUID)
110 const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body 104 const videoDetails = await server.videosCommand.get({ id: video.uuid })
111 105
112 expect(videoDetail.files).to.have.lengthOf(2) 106 expect(videoDetails.files).to.have.lengthOf(2)
113 const [ video720, video480 ] = videoDetail.files 107 const [ video720, video480 ] = videoDetails.files
114 assertVideoProperties(video720, 720, 'webm', 942961) 108 assertVideoProperties(video720, 720, 'webm', 942961)
115 assertVideoProperties(video480, 480, 'webm', 69217) 109 assertVideoProperties(video480, 480, 'webm', 69217)
116 } 110 }
diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts
index e3211882d..f629306e6 100644
--- a/server/tests/cli/create-transcoding-job.ts
+++ b/server/tests/cli/create-transcoding-job.ts
@@ -6,14 +6,10 @@ import {
6 cleanupTests, 6 cleanupTests,
7 doubleFollow, 7 doubleFollow,
8 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
9 getVideo,
10 getVideosList,
11 ServerInfo, 9 ServerInfo,
12 setAccessTokensToServers, 10 setAccessTokensToServers,
13 uploadVideo 11 waitJobs
14} from '../../../shared/extra-utils' 12} from '../../../shared/extra-utils'
15import { waitJobs } from '../../../shared/extra-utils/server/jobs'
16import { VideoDetails } from '../../../shared/models/videos'
17 13
18const expect = chai.expect 14const expect = chai.expect
19 15
@@ -51,8 +47,8 @@ describe('Test create transcoding jobs', function () {
51 await doubleFollow(servers[0], servers[1]) 47 await doubleFollow(servers[0], servers[1])
52 48
53 for (let i = 1; i <= 5; i++) { 49 for (let i = 1; i <= 5; i++) {
54 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' + i }) 50 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video' + i } })
55 videosUUID.push(res.body.video.uuid) 51 videosUUID.push(uuid)
56 } 52 }
57 53
58 await waitJobs(servers) 54 await waitJobs(servers)
@@ -62,13 +58,11 @@ describe('Test create transcoding jobs', function () {
62 this.timeout(30000) 58 this.timeout(30000)
63 59
64 for (const server of servers) { 60 for (const server of servers) {
65 const res = await getVideosList(server.url) 61 const { data } = await server.videosCommand.list()
66 const videos = res.body.data 62 expect(data).to.have.lengthOf(videosUUID.length)
67 expect(videos).to.have.lengthOf(videosUUID.length)
68 63
69 for (const video of videos) { 64 for (const video of data) {
70 const res2 = await getVideo(server.url, video.uuid) 65 const videoDetail = await server.videosCommand.get({ id: video.uuid })
71 const videoDetail: VideoDetails = res2.body
72 expect(videoDetail.files).to.have.lengthOf(1) 66 expect(videoDetail.files).to.have.lengthOf(1)
73 expect(videoDetail.streamingPlaylists).to.have.lengthOf(0) 67 expect(videoDetail.streamingPlaylists).to.have.lengthOf(0)
74 } 68 }
@@ -82,14 +76,12 @@ describe('Test create transcoding jobs', function () {
82 await waitJobs(servers) 76 await waitJobs(servers)
83 77
84 for (const server of servers) { 78 for (const server of servers) {
85 const res = await getVideosList(server.url) 79 const { data } = await server.videosCommand.list()
86 const videos = res.body.data
87 80
88 let infoHashes: { [id: number]: string } 81 let infoHashes: { [id: number]: string }
89 82
90 for (const video of videos) { 83 for (const video of data) {
91 const res2 = await getVideo(server.url, video.uuid) 84 const videoDetail = await server.videosCommand.get({ id: video.uuid })
92 const videoDetail: VideoDetails = res2.body
93 85
94 if (video.uuid === videosUUID[1]) { 86 if (video.uuid === videosUUID[1]) {
95 expect(videoDetail.files).to.have.lengthOf(4) 87 expect(videoDetail.files).to.have.lengthOf(4)
@@ -123,18 +115,16 @@ describe('Test create transcoding jobs', function () {
123 await waitJobs(servers) 115 await waitJobs(servers)
124 116
125 for (const server of servers) { 117 for (const server of servers) {
126 const res = await getVideosList(server.url) 118 const { data } = await server.videosCommand.list()
127 const videos = res.body.data 119 expect(data).to.have.lengthOf(videosUUID.length)
128 expect(videos).to.have.lengthOf(videosUUID.length)
129 120
130 const res2 = await getVideo(server.url, videosUUID[0]) 121 const videoDetails = await server.videosCommand.get({ id: videosUUID[0] })
131 const videoDetail: VideoDetails = res2.body
132 122
133 expect(videoDetail.files).to.have.lengthOf(2) 123 expect(videoDetails.files).to.have.lengthOf(2)
134 expect(videoDetail.files[0].resolution.id).to.equal(720) 124 expect(videoDetails.files[0].resolution.id).to.equal(720)
135 expect(videoDetail.files[1].resolution.id).to.equal(480) 125 expect(videoDetails.files[1].resolution.id).to.equal(480)
136 126
137 expect(videoDetail.streamingPlaylists).to.have.lengthOf(0) 127 expect(videoDetails.streamingPlaylists).to.have.lengthOf(0)
138 } 128 }
139 }) 129 })
140 130
@@ -146,13 +136,12 @@ describe('Test create transcoding jobs', function () {
146 await waitJobs(servers) 136 await waitJobs(servers)
147 137
148 for (const server of servers) { 138 for (const server of servers) {
149 const res = await getVideo(server.url, videosUUID[2]) 139 const videoDetails = await server.videosCommand.get({ id: videosUUID[2] })
150 const videoDetail: VideoDetails = res.body
151 140
152 expect(videoDetail.files).to.have.lengthOf(1) 141 expect(videoDetails.files).to.have.lengthOf(1)
153 expect(videoDetail.streamingPlaylists).to.have.lengthOf(1) 142 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
154 143
155 const files = videoDetail.streamingPlaylists[0].files 144 const files = videoDetails.streamingPlaylists[0].files
156 expect(files).to.have.lengthOf(1) 145 expect(files).to.have.lengthOf(1)
157 expect(files[0].resolution.id).to.equal(480) 146 expect(files[0].resolution.id).to.equal(480)
158 } 147 }
@@ -166,10 +155,9 @@ describe('Test create transcoding jobs', function () {
166 await waitJobs(servers) 155 await waitJobs(servers)
167 156
168 for (const server of servers) { 157 for (const server of servers) {
169 const res = await getVideo(server.url, videosUUID[2]) 158 const videoDetails = await server.videosCommand.get({ id: videosUUID[2] })
170 const videoDetail: VideoDetails = res.body
171 159
172 const files = videoDetail.streamingPlaylists[0].files 160 const files = videoDetails.streamingPlaylists[0].files
173 expect(files).to.have.lengthOf(1) 161 expect(files).to.have.lengthOf(1)
174 expect(files[0].resolution.id).to.equal(480) 162 expect(files[0].resolution.id).to.equal(480)
175 } 163 }
@@ -183,13 +171,12 @@ describe('Test create transcoding jobs', function () {
183 await waitJobs(servers) 171 await waitJobs(servers)
184 172
185 for (const server of servers) { 173 for (const server of servers) {
186 const res = await getVideo(server.url, videosUUID[3]) 174 const videoDetails = await server.videosCommand.get({ id: videosUUID[3] })
187 const videoDetail: VideoDetails = res.body
188 175
189 expect(videoDetail.files).to.have.lengthOf(1) 176 expect(videoDetails.files).to.have.lengthOf(1)
190 expect(videoDetail.streamingPlaylists).to.have.lengthOf(1) 177 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
191 178
192 const files = videoDetail.streamingPlaylists[0].files 179 const files = videoDetails.streamingPlaylists[0].files
193 expect(files).to.have.lengthOf(4) 180 expect(files).to.have.lengthOf(4)
194 } 181 }
195 }) 182 })
@@ -205,12 +192,11 @@ describe('Test create transcoding jobs', function () {
205 await waitJobs(servers) 192 await waitJobs(servers)
206 193
207 for (const server of servers) { 194 for (const server of servers) {
208 const res = await getVideo(server.url, videosUUID[4]) 195 const videoDetails = await server.videosCommand.get({ id: videosUUID[4] })
209 const videoDetail: VideoDetails = res.body
210 196
211 expect(videoDetail.files).to.have.lengthOf(4) 197 expect(videoDetails.files).to.have.lengthOf(4)
212 expect(videoDetail.streamingPlaylists).to.have.lengthOf(1) 198 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
213 expect(videoDetail.streamingPlaylists[0].files).to.have.lengthOf(4) 199 expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(4)
214 } 200 }
215 }) 201 })
216 202
diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts
index e369a3305..ef8603a33 100644
--- a/server/tests/cli/optimize-old-videos.ts
+++ b/server/tests/cli/optimize-old-videos.ts
@@ -8,16 +8,12 @@ import {
8 doubleFollow, 8 doubleFollow,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 generateHighBitrateVideo, 10 generateHighBitrateVideo,
11 getVideo,
12 getVideosList,
13 ServerInfo, 11 ServerInfo,
14 setAccessTokensToServers, 12 setAccessTokensToServers,
15 uploadVideo, 13 wait,
16 viewVideo, 14 waitJobs
17 wait 15} from '@shared/extra-utils'
18} from '../../../shared/extra-utils' 16import { getMaxBitrate, VideoResolution } from '@shared/models'
19import { waitJobs } from '../../../shared/extra-utils/server/jobs'
20import { getMaxBitrate, Video, VideoDetails, VideoResolution } from '../../../shared/models/videos'
21import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffprobe-utils' 17import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffprobe-utils'
22import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' 18import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants'
23 19
@@ -45,8 +41,8 @@ describe('Test optimize old videos', function () {
45 } 41 }
46 42
47 // Upload two videos for our needs 43 // Upload two videos for our needs
48 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1', fixture: tempFixturePath }) 44 await servers[0].videosCommand.upload({ attributes: { name: 'video1', fixture: tempFixturePath } })
49 await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2', fixture: tempFixturePath }) 45 await servers[0].videosCommand.upload({ attributes: { name: 'video2', fixture: tempFixturePath } })
50 46
51 await waitJobs(servers) 47 await waitJobs(servers)
52 }) 48 })
@@ -55,14 +51,12 @@ describe('Test optimize old videos', function () {
55 this.timeout(30000) 51 this.timeout(30000)
56 52
57 for (const server of servers) { 53 for (const server of servers) {
58 const res = await getVideosList(server.url) 54 const { data } = await server.videosCommand.list()
59 const videos = res.body.data 55 expect(data).to.have.lengthOf(2)
60 expect(videos).to.have.lengthOf(2) 56
61 57 for (const video of data) {
62 for (const video of videos) { 58 const videoDetails = await server.videosCommand.get({ id: video.uuid })
63 const res2 = await getVideo(server.url, video.uuid) 59 expect(videoDetails.files).to.have.lengthOf(1)
64 const videoDetail: VideoDetails = res2.body
65 expect(videoDetail.files).to.have.lengthOf(1)
66 } 60 }
67 } 61 }
68 }) 62 })
@@ -74,24 +68,21 @@ describe('Test optimize old videos', function () {
74 await waitJobs(servers) 68 await waitJobs(servers)
75 69
76 for (const server of servers) { 70 for (const server of servers) {
77 const res = await getVideosList(server.url) 71 const { data } = await server.videosCommand.list()
78 const videos: Video[] = res.body.data 72 expect(data).to.have.lengthOf(2)
79
80 expect(videos).to.have.lengthOf(2)
81 73
82 for (const video of videos) { 74 for (const video of data) {
83 await viewVideo(server.url, video.uuid) 75 await server.videosCommand.view({ id: video.uuid })
84 76
85 // Refresh video 77 // Refresh video
86 await waitJobs(servers) 78 await waitJobs(servers)
87 await wait(5000) 79 await wait(5000)
88 await waitJobs(servers) 80 await waitJobs(servers)
89 81
90 const res2 = await getVideo(server.url, video.uuid) 82 const videoDetails = await server.videosCommand.get({ id: video.uuid })
91 const videosDetails: VideoDetails = res2.body
92 83
93 expect(videosDetails.files).to.have.lengthOf(1) 84 expect(videoDetails.files).to.have.lengthOf(1)
94 const file = videosDetails.files[0] 85 const file = videoDetails.files[0]
95 86
96 expect(file.size).to.be.below(8000000) 87 expect(file.size).to.be.below(8000000)
97 88
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts
index a0c149ac0..fe5f63191 100644
--- a/server/tests/cli/peertube.ts
+++ b/server/tests/cli/peertube.ts
@@ -2,7 +2,6 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { Video, VideoDetails } from '../../../shared'
6import { 5import {
7 areHttpImportTestsDisabled, 6 areHttpImportTestsDisabled,
8 buildAbsoluteFixturePath, 7 buildAbsoluteFixturePath,
@@ -10,15 +9,10 @@ import {
10 CLICommand, 9 CLICommand,
11 doubleFollow, 10 doubleFollow,
12 flushAndRunServer, 11 flushAndRunServer,
13 getLocalIdByUUID,
14 getVideo,
15 getVideosList,
16 ImportsCommand, 12 ImportsCommand,
17 removeVideo,
18 ServerInfo, 13 ServerInfo,
19 setAccessTokensToServers, 14 setAccessTokensToServers,
20 testHelloWorldRegisteredSettings, 15 testHelloWorldRegisteredSettings,
21 uploadVideoAndGetId,
22 waitJobs 16 waitJobs
23} from '../../../shared/extra-utils' 17} from '../../../shared/extra-utils'
24 18
@@ -109,14 +103,10 @@ describe('Test CLI wrapper', function () {
109 }) 103 })
110 104
111 it('Should have the video uploaded', async function () { 105 it('Should have the video uploaded', async function () {
112 const res = await getVideosList(server.url) 106 const { total, data } = await server.videosCommand.list()
113 107 expect(total).to.equal(1)
114 expect(res.body.total).to.equal(1)
115
116 const videos: Video[] = res.body.data
117
118 const video: VideoDetails = (await getVideo(server.url, videos[0].uuid)).body
119 108
109 const video = await server.videosCommand.get({ id: data[0].uuid })
120 expect(video.name).to.equal('test upload') 110 expect(video.name).to.equal('test upload')
121 expect(video.support).to.equal('support_text') 111 expect(video.support).to.equal('support_text')
122 expect(video.channel.name).to.equal('user_channel') 112 expect(video.channel.name).to.equal('user_channel')
@@ -138,21 +128,19 @@ describe('Test CLI wrapper', function () {
138 128
139 await waitJobs([ server ]) 129 await waitJobs([ server ])
140 130
141 const res = await getVideosList(server.url) 131 const { total, data } = await server.videosCommand.list()
142 132 expect(total).to.equal(2)
143 expect(res.body.total).to.equal(2)
144 133
145 const videos: Video[] = res.body.data 134 const video = data.find(v => v.name === 'small video - youtube')
146 const video = videos.find(v => v.name === 'small video - youtube')
147 expect(video).to.not.be.undefined 135 expect(video).to.not.be.undefined
148 136
149 const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body 137 const videoDetails = await server.videosCommand.get({ id: video.id })
150 expect(videoDetails.channel.name).to.equal('user_channel') 138 expect(videoDetails.channel.name).to.equal('user_channel')
151 expect(videoDetails.support).to.equal('super support text') 139 expect(videoDetails.support).to.equal('super support text')
152 expect(videoDetails.nsfw).to.be.false 140 expect(videoDetails.nsfw).to.be.false
153 141
154 // So we can reimport it 142 // So we can reimport it
155 await removeVideo(server.url, userAccessToken, video.id) 143 await server.videosCommand.remove({ token: userAccessToken, id: video.id })
156 }) 144 })
157 145
158 it('Should import and override some imported attributes', async function () { 146 it('Should import and override some imported attributes', async function () {
@@ -167,14 +155,13 @@ describe('Test CLI wrapper', function () {
167 await waitJobs([ server ]) 155 await waitJobs([ server ])
168 156
169 { 157 {
170 const res = await getVideosList(server.url) 158 const { total, data } = await server.videosCommand.list()
171 expect(res.body.total).to.equal(2) 159 expect(total).to.equal(2)
172 160
173 const videos: Video[] = res.body.data 161 const video = data.find(v => v.name === 'toto')
174 const video = videos.find(v => v.name === 'toto')
175 expect(video).to.not.be.undefined 162 expect(video).to.not.be.undefined
176 163
177 const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body 164 const videoDetails = await server.videosCommand.get({ id: video.id })
178 expect(videoDetails.channel.name).to.equal('user_channel') 165 expect(videoDetails.channel.name).to.equal('user_channel')
179 expect(videoDetails.support).to.equal('support') 166 expect(videoDetails.support).to.equal('support')
180 expect(videoDetails.nsfw).to.be.true 167 expect(videoDetails.nsfw).to.be.true
@@ -238,10 +225,10 @@ describe('Test CLI wrapper', function () {
238 servers = [ server, anotherServer ] 225 servers = [ server, anotherServer ]
239 await waitJobs(servers) 226 await waitJobs(servers)
240 227
241 const uuid = (await uploadVideoAndGetId({ server: anotherServer, videoName: 'super video' })).uuid 228 const { uuid } = await anotherServer.videosCommand.quickUpload({ name: 'super video' })
242 await waitJobs(servers) 229 await waitJobs(servers)
243 230
244 video1Server2 = await getLocalIdByUUID(server.url, uuid) 231 video1Server2 = await server.videosCommand.getId({ uuid })
245 }) 232 })
246 233
247 it('Should add a redundancy', async function () { 234 it('Should add a redundancy', async function () {
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts
index b45049964..a4556312b 100644
--- a/server/tests/cli/prune-storage.ts
+++ b/server/tests/cli/prune-storage.ts
@@ -16,7 +16,6 @@ import {
16 ServerInfo, 16 ServerInfo,
17 setAccessTokensToServers, 17 setAccessTokensToServers,
18 setDefaultVideoChannel, 18 setDefaultVideoChannel,
19 uploadVideo,
20 wait, 19 wait,
21 waitJobs 20 waitJobs
22} from '@shared/extra-utils' 21} from '@shared/extra-utils'
@@ -69,8 +68,8 @@ describe('Test prune storage scripts', function () {
69 await setDefaultVideoChannel(servers) 68 await setDefaultVideoChannel(servers)
70 69
71 for (const server of servers) { 70 for (const server of servers) {
72 await uploadVideo(server.url, server.accessToken, { name: 'video 1' }) 71 await server.videosCommand.upload({ attributes: { name: 'video 1' } })
73 await uploadVideo(server.url, server.accessToken, { name: 'video 2' }) 72 await server.videosCommand.upload({ attributes: { name: 'video 2' } })
74 73
75 await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' }) 74 await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' })
76 75
diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts
index 68a4711b6..d59520783 100644
--- a/server/tests/cli/regenerate-thumbnails.ts
+++ b/server/tests/cli/regenerate-thumbnails.ts
@@ -2,29 +2,30 @@ import 'mocha'
2import { expect } from 'chai' 2import { expect } from 'chai'
3import { writeFile } from 'fs-extra' 3import { writeFile } from 'fs-extra'
4import { basename, join } from 'path' 4import { basename, join } from 'path'
5import { Video, VideoDetails } from '@shared/models' 5import { HttpStatusCode } from '@shared/core-utils'
6import { Video } from '@shared/models'
6import { 7import {
7 cleanupTests, 8 cleanupTests,
8 doubleFollow, 9 doubleFollow,
9 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
10 getVideo,
11 makeRawRequest, 11 makeRawRequest,
12 ServerInfo, 12 ServerInfo,
13 setAccessTokensToServers, 13 setAccessTokensToServers,
14 uploadVideoAndGetId,
15 waitJobs 14 waitJobs
16} from '../../../shared/extra-utils' 15} from '../../../shared/extra-utils'
17import { HttpStatusCode } from '@shared/core-utils'
18 16
19async function testThumbnail (server: ServerInfo, videoId: number | string) { 17async function testThumbnail (server: ServerInfo, videoId: number | string) {
20 const res = await getVideo(server.url, videoId) 18 const video = await server.videosCommand.get({ id: videoId })
21 const video: VideoDetails = res.body
22 19
23 const res1 = await makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200) 20 const requests = [
24 expect(res1.body).to.not.have.lengthOf(0) 21 makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200),
22 makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200)
23 ]
25 24
26 const res2 = await makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200) 25 for (const req of requests) {
27 expect(res2.body).to.not.have.lengthOf(0) 26 const res = await req
27 expect(res.body).to.not.have.lengthOf(0)
28 }
28} 29}
29 30
30describe('Test regenerate thumbnails script', function () { 31describe('Test regenerate thumbnails script', function () {
@@ -46,20 +47,20 @@ describe('Test regenerate thumbnails script', function () {
46 await doubleFollow(servers[0], servers[1]) 47 await doubleFollow(servers[0], servers[1])
47 48
48 { 49 {
49 const videoUUID1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).uuid 50 const videoUUID1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid
50 video1 = await (getVideo(servers[0].url, videoUUID1).then(res => res.body)) 51 video1 = await servers[0].videosCommand.get({ id: videoUUID1 })
51 52
52 thumbnail1Path = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(video1.thumbnailPath)) 53 thumbnail1Path = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(video1.thumbnailPath))
53 54
54 const videoUUID2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).uuid 55 const videoUUID2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid
55 video2 = await (getVideo(servers[0].url, videoUUID2).then(res => res.body)) 56 video2 = await servers[0].videosCommand.get({ id: videoUUID2 })
56 } 57 }
57 58
58 { 59 {
59 const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 3' })).uuid 60 const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'video 3' })).uuid
60 await waitJobs(servers) 61 await waitJobs(servers)
61 62
62 remoteVideo = await (getVideo(servers[0].url, videoUUID).then(res => res.body)) 63 remoteVideo = await servers[0].videosCommand.get({ id: videoUUID })
63 64
64 thumbnailRemotePath = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath)) 65 thumbnailRemotePath = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath))
65 } 66 }
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts
index b857fcf28..d90b4a64d 100644
--- a/server/tests/cli/update-host.ts
+++ b/server/tests/cli/update-host.ts
@@ -5,18 +5,14 @@ import { expect } from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 flushAndRunServer, 7 flushAndRunServer,
8 getVideo,
9 getVideosList,
10 killallServers, 8 killallServers,
11 makeActivityPubGetRequest, 9 makeActivityPubGetRequest,
12 parseTorrentVideo, 10 parseTorrentVideo,
13 reRunServer, 11 reRunServer,
14 ServerInfo, 12 ServerInfo,
15 setAccessTokensToServers, 13 setAccessTokensToServers,
16 uploadVideo,
17 waitJobs 14 waitJobs
18} from '@shared/extra-utils' 15} from '@shared/extra-utils'
19import { VideoDetails } from '@shared/models'
20 16
21describe('Test update host scripts', function () { 17describe('Test update host scripts', function () {
22 let server: ServerInfo 18 let server: ServerInfo
@@ -34,10 +30,8 @@ describe('Test update host scripts', function () {
34 await setAccessTokensToServers([ server ]) 30 await setAccessTokensToServers([ server ])
35 31
36 // Upload two videos for our needs 32 // Upload two videos for our needs
37 const videoAttributes = {} 33 const { uuid: video1UUID } = await server.videosCommand.upload()
38 const resVideo1 = await uploadVideo(server.url, server.accessToken, videoAttributes) 34 await server.videosCommand.upload()
39 const video1UUID = resVideo1.body.video.uuid
40 await uploadVideo(server.url, server.accessToken, videoAttributes)
41 35
42 // Create a user 36 // Create a user
43 await server.usersCommand.create({ username: 'toto', password: 'coucou' }) 37 await server.usersCommand.create({ username: 'toto', password: 'coucou' })
@@ -68,16 +62,15 @@ describe('Test update host scripts', function () {
68 }) 62 })
69 63
70 it('Should have updated videos url', async function () { 64 it('Should have updated videos url', async function () {
71 const res = await getVideosList(server.url) 65 const { total, data } = await server.videosCommand.list()
72 expect(res.body.total).to.equal(2) 66 expect(total).to.equal(2)
73 67
74 for (const video of res.body.data) { 68 for (const video of data) {
75 const { body } = await makeActivityPubGetRequest(server.url, '/videos/watch/' + video.uuid) 69 const { body } = await makeActivityPubGetRequest(server.url, '/videos/watch/' + video.uuid)
76 70
77 expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid) 71 expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid)
78 72
79 const res = await getVideo(server.url, video.uuid) 73 const videoDetails = await server.videosCommand.get({ id: video.uuid })
80 const videoDetails: VideoDetails = res.body
81 74
82 expect(videoDetails.trackerUrls[0]).to.include(server.host) 75 expect(videoDetails.trackerUrls[0]).to.include(server.host)
83 expect(videoDetails.streamingPlaylists[0].playlistUrl).to.include(server.host) 76 expect(videoDetails.streamingPlaylists[0].playlistUrl).to.include(server.host)
@@ -111,13 +104,11 @@ describe('Test update host scripts', function () {
111 it('Should have updated torrent hosts', async function () { 104 it('Should have updated torrent hosts', async function () {
112 this.timeout(30000) 105 this.timeout(30000)
113 106
114 const res = await getVideosList(server.url) 107 const { data } = await server.videosCommand.list()
115 const videos = res.body.data 108 expect(data).to.have.lengthOf(2)
116 expect(videos).to.have.lengthOf(2)
117 109
118 for (const video of videos) { 110 for (const video of data) {
119 const res2 = await getVideo(server.url, video.id) 111 const videoDetails = await server.videosCommand.get({ id: video.id })
120 const videoDetails: VideoDetails = res2.body
121 112
122 expect(videoDetails.files).to.have.lengthOf(4) 113 expect(videoDetails.files).to.have.lengthOf(4)
123 114