]>
Commit | Line | Data |
---|---|---|
1 | /* tslint:disable:no-unused-expression */ | |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
5 | import { VideoDetails, VideoFile } from '../../../shared/models/videos' | |
6 | const expect = chai.expect | |
7 | ||
8 | import { | |
9 | execCLI, | |
10 | flushTests, | |
11 | getEnvCli, | |
12 | getVideosList, | |
13 | killallServers, | |
14 | parseTorrentVideo, | |
15 | runServer, | |
16 | ServerInfo, | |
17 | setAccessTokensToServers, | |
18 | uploadVideo, | |
19 | wait, | |
20 | getVideo, flushAndRunMultipleServers, doubleFollow | |
21 | } from '../utils' | |
22 | ||
23 | function assertVideoProperties (video: VideoFile, resolution: number, extname: string) { | |
24 | expect(video).to.have.nested.property('resolution.id', resolution) | |
25 | expect(video).to.have.property('magnetUri').that.includes(`.${extname}`) | |
26 | expect(video).to.have.property('torrentUrl').that.includes(`-${resolution}.torrent`) | |
27 | expect(video).to.have.property('fileUrl').that.includes(`.${extname}`) | |
28 | expect(video).to.have.property('size').that.is.above(0) | |
29 | } | |
30 | ||
31 | describe('Test create import video jobs', function () { | |
32 | this.timeout(60000) | |
33 | ||
34 | let servers: ServerInfo[] = [] | |
35 | let video1UUID: string | |
36 | let video2UUID: string | |
37 | ||
38 | before(async function () { | |
39 | this.timeout(90000) | |
40 | await flushTests() | |
41 | ||
42 | // Run server 2 to have transcoding enabled | |
43 | servers = await flushAndRunMultipleServers(2) | |
44 | await setAccessTokensToServers(servers) | |
45 | ||
46 | await doubleFollow(servers[0], servers[1]) | |
47 | ||
48 | // Upload two videos for our needs | |
49 | const res1 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' }) | |
50 | video1UUID = res1.body.video.uuid | |
51 | const res2 = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' }) | |
52 | video2UUID = res2.body.video.uuid | |
53 | ||
54 | await wait(40000) | |
55 | }) | |
56 | ||
57 | it('Should run a import job on video 1 with a lower resolution', async function () { | |
58 | const env = getEnvCli(servers[0]) | |
59 | await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/api/fixtures/video_short-480.webm`) | |
60 | ||
61 | await wait(30000) | |
62 | ||
63 | for (const server of servers) { | |
64 | const { data: videos } = (await getVideosList(server.url)).body | |
65 | expect(videos).to.have.lengthOf(2) | |
66 | ||
67 | let infoHashes: { [ id: number ]: string } = {} | |
68 | ||
69 | const video = videos.find(({ uuid }) => uuid === video1UUID) | |
70 | const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body | |
71 | ||
72 | expect(videoDetail.files).to.have.lengthOf(2) | |
73 | const [originalVideo, transcodedVideo] = videoDetail.files | |
74 | assertVideoProperties(originalVideo, 720, 'webm') | |
75 | assertVideoProperties(transcodedVideo, 480, 'webm') | |
76 | } | |
77 | }) | |
78 | ||
79 | it('Should run a import job on video 2 with the same resolution', async function () { | |
80 | const env = getEnvCli(servers[1]) | |
81 | await execCLI(`${env} npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/api/fixtures/video_short.ogv`) | |
82 | ||
83 | await wait(30000) | |
84 | ||
85 | for (const server of servers.reverse()) { | |
86 | const { data: videos } = (await getVideosList(server.url)).body | |
87 | expect(videos).to.have.lengthOf(2) | |
88 | ||
89 | let infoHashes: { [ id: number ]: string } | |
90 | ||
91 | const video = videos.find(({ uuid }) => uuid === video2UUID) | |
92 | const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body | |
93 | ||
94 | expect(videoDetail.files).to.have.lengthOf(4) | |
95 | const [originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240] = videoDetail.files | |
96 | assertVideoProperties(originalVideo, 720, 'ogv') | |
97 | assertVideoProperties(transcodedVideo420, 480, 'mp4') | |
98 | assertVideoProperties(transcodedVideo320, 360, 'mp4') | |
99 | assertVideoProperties(transcodedVideo240, 240, 'mp4') | |
100 | } | |
101 | }) | |
102 | ||
103 | after(async function () { | |
104 | killallServers(servers) | |
105 | ||
106 | // Keep the logs if the test failed | |
107 | if (this['ok']) { | |
108 | await flushTests() | |
109 | } | |
110 | }) | |
111 | }) |