diff options
Diffstat (limited to 'server/tests/cli/peertube.ts')
-rw-r--r-- | server/tests/cli/peertube.ts | 84 |
1 files changed, 81 insertions, 3 deletions
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index b8c0b1f79..27fbde02d 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
@@ -7,14 +7,17 @@ import { | |||
7 | buildAbsoluteFixturePath, | 7 | buildAbsoluteFixturePath, |
8 | cleanupTests, | 8 | cleanupTests, |
9 | createUser, | 9 | createUser, |
10 | doubleFollow, | ||
10 | execCLI, | 11 | execCLI, |
11 | flushAndRunServer, | 12 | flushAndRunServer, |
12 | getEnvCli, | 13 | getEnvCli, |
14 | getLocalIdByUUID, | ||
13 | getVideo, | 15 | getVideo, |
14 | getVideosList, | 16 | getVideosList, |
15 | getVideosListWithToken, removeVideo, | 17 | removeVideo, |
16 | ServerInfo, | 18 | ServerInfo, |
17 | setAccessTokensToServers, | 19 | setAccessTokensToServers, |
20 | uploadVideoAndGetId, | ||
18 | userLogin, | 21 | userLogin, |
19 | waitJobs | 22 | waitJobs |
20 | } from '../../../shared/extra-utils' | 23 | } from '../../../shared/extra-utils' |
@@ -101,7 +104,7 @@ describe('Test CLI wrapper', function () { | |||
101 | 104 | ||
102 | const videos: Video[] = res.body.data | 105 | const videos: Video[] = res.body.data |
103 | 106 | ||
104 | const video: VideoDetails = (await getVideo(server.url, videos[ 0 ].uuid)).body | 107 | const video: VideoDetails = (await getVideo(server.url, videos[0].uuid)).body |
105 | 108 | ||
106 | expect(video.name).to.equal('test upload') | 109 | expect(video.name).to.equal('test upload') |
107 | expect(video.support).to.equal('support_text') | 110 | expect(video.support).to.equal('support_text') |
@@ -210,6 +213,81 @@ describe('Test CLI wrapper', function () { | |||
210 | }) | 213 | }) |
211 | }) | 214 | }) |
212 | 215 | ||
216 | describe('Manage video redundancies', function () { | ||
217 | let anotherServer: ServerInfo | ||
218 | let video1Server2: number | ||
219 | let servers: ServerInfo[] | ||
220 | |||
221 | before(async function () { | ||
222 | this.timeout(120000) | ||
223 | |||
224 | anotherServer = await flushAndRunServer(2) | ||
225 | await setAccessTokensToServers([ anotherServer ]) | ||
226 | |||
227 | await doubleFollow(server, anotherServer) | ||
228 | |||
229 | servers = [ server, anotherServer ] | ||
230 | await waitJobs(servers) | ||
231 | |||
232 | const uuid = (await uploadVideoAndGetId({ server: anotherServer, videoName: 'super video' })).uuid | ||
233 | await waitJobs(servers) | ||
234 | |||
235 | video1Server2 = await getLocalIdByUUID(server.url, uuid) | ||
236 | }) | ||
237 | |||
238 | it('Should add a redundancy', async function () { | ||
239 | this.timeout(60000) | ||
240 | |||
241 | const env = getEnvCli(server) | ||
242 | |||
243 | const params = `add --video ${video1Server2}` | ||
244 | |||
245 | await execCLI(`${env} ${cmd} redundancy ${params}`) | ||
246 | |||
247 | await waitJobs(servers) | ||
248 | }) | ||
249 | |||
250 | it('Should list redundancies', async function () { | ||
251 | this.timeout(60000) | ||
252 | |||
253 | { | ||
254 | const env = getEnvCli(server) | ||
255 | |||
256 | const params = 'list-my-redundancies' | ||
257 | const stdout = await execCLI(`${env} ${cmd} redundancy ${params}`) | ||
258 | |||
259 | expect(stdout).to.contain('super video') | ||
260 | expect(stdout).to.contain(`localhost:${server.port}`) | ||
261 | } | ||
262 | }) | ||
263 | |||
264 | it('Should remove a redundancy', async function () { | ||
265 | this.timeout(60000) | ||
266 | |||
267 | const env = getEnvCli(server) | ||
268 | |||
269 | const params = `remove --video ${video1Server2}` | ||
270 | |||
271 | await execCLI(`${env} ${cmd} redundancy ${params}`) | ||
272 | |||
273 | await waitJobs(servers) | ||
274 | |||
275 | { | ||
276 | const env = getEnvCli(server) | ||
277 | const params = 'list-my-redundancies' | ||
278 | const stdout = await execCLI(`${env} ${cmd} redundancy ${params}`) | ||
279 | |||
280 | expect(stdout).to.not.contain('super video') | ||
281 | } | ||
282 | }) | ||
283 | |||
284 | after(async function () { | ||
285 | this.timeout(10000) | ||
286 | |||
287 | await cleanupTests([ anotherServer ]) | ||
288 | }) | ||
289 | }) | ||
290 | |||
213 | after(async function () { | 291 | after(async function () { |
214 | this.timeout(10000) | 292 | this.timeout(10000) |
215 | 293 | ||