diff options
Diffstat (limited to 'server/tests/cli/create-import-video-file-job.ts')
-rw-r--r-- | server/tests/cli/create-import-video-file-job.ts | 70 |
1 files changed, 31 insertions, 39 deletions
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts index 49758ff56..bddcff5e7 100644 --- a/server/tests/cli/create-import-video-file-job.ts +++ b/server/tests/cli/create-import-video-file-job.ts | |||
@@ -2,21 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { VideoFile } from '@shared/models/videos/video-file.model' | 5 | import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' |
6 | import { | 6 | import { VideoFile } from '@shared/models' |
7 | cleanupTests, | ||
8 | doubleFollow, | ||
9 | execCLI, | ||
10 | flushAndRunMultipleServers, | ||
11 | getEnvCli, | ||
12 | getVideo, | ||
13 | getVideosList, | ||
14 | ServerInfo, | ||
15 | setAccessTokensToServers, | ||
16 | uploadVideo | ||
17 | } from '../../../shared/extra-utils' | ||
18 | import { waitJobs } from '../../../shared/extra-utils/server/jobs' | ||
19 | import { VideoDetails } from '../../../shared/models/videos' | ||
20 | 7 | ||
21 | const expect = chai.expect | 8 | const expect = chai.expect |
22 | 9 | ||
@@ -33,7 +20,7 @@ function assertVideoProperties (video: VideoFile, resolution: number, extname: s | |||
33 | describe('Test create import video jobs', function () { | 20 | describe('Test create import video jobs', function () { |
34 | this.timeout(60000) | 21 | this.timeout(60000) |
35 | 22 | ||
36 | let servers: ServerInfo[] = [] | 23 | let servers: PeerTubeServer[] = [] |
37 | let video1UUID: string | 24 | let video1UUID: string |
38 | let video2UUID: string | 25 | let video2UUID: string |
39 | 26 | ||
@@ -41,56 +28,61 @@ describe('Test create import video jobs', function () { | |||
41 | this.timeout(90000) | 28 | this.timeout(90000) |
42 | 29 | ||
43 | // Run server 2 to have transcoding enabled | 30 | // Run server 2 to have transcoding enabled |
44 | servers = await flushAndRunMultipleServers(2) | 31 | servers = await createMultipleServers(2) |
45 | await setAccessTokensToServers(servers) | 32 | await setAccessTokensToServers(servers) |
46 | 33 | ||
47 | await doubleFollow(servers[0], servers[1]) | 34 | await doubleFollow(servers[0], servers[1]) |
48 | 35 | ||
49 | // Upload two videos for our needs | 36 | // Upload two videos for our needs |
50 | const res1 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' }) | 37 | { |
51 | video1UUID = res1.body.video.uuid | 38 | const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video1' } }) |
52 | const res2 = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' }) | 39 | video1UUID = uuid |
53 | video2UUID = res2.body.video.uuid | 40 | } |
41 | |||
42 | { | ||
43 | const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video2' } }) | ||
44 | video2UUID = uuid | ||
45 | } | ||
54 | 46 | ||
55 | // Transcoding | 47 | // Transcoding |
56 | await waitJobs(servers) | 48 | await waitJobs(servers) |
57 | }) | 49 | }) |
58 | 50 | ||
59 | it('Should run a import job on video 1 with a lower resolution', async function () { | 51 | it('Should run a import job on video 1 with a lower resolution', async function () { |
60 | const env = getEnvCli(servers[0]) | 52 | const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm` |
61 | await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`) | 53 | await servers[0].cli.execWithEnv(command) |
62 | 54 | ||
63 | await waitJobs(servers) | 55 | await waitJobs(servers) |
64 | 56 | ||
65 | for (const server of servers) { | 57 | for (const server of servers) { |
66 | const { data: videos } = (await getVideosList(server.url)).body | 58 | const { data: videos } = await server.videos.list() |
67 | expect(videos).to.have.lengthOf(2) | 59 | expect(videos).to.have.lengthOf(2) |
68 | 60 | ||
69 | const video = videos.find(({ uuid }) => uuid === video1UUID) | 61 | const video = videos.find(({ uuid }) => uuid === video1UUID) |
70 | const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body | 62 | const videoDetails = await server.videos.get({ id: video.uuid }) |
71 | 63 | ||
72 | expect(videoDetail.files).to.have.lengthOf(2) | 64 | expect(videoDetails.files).to.have.lengthOf(2) |
73 | const [ originalVideo, transcodedVideo ] = videoDetail.files | 65 | const [ originalVideo, transcodedVideo ] = videoDetails.files |
74 | assertVideoProperties(originalVideo, 720, 'webm', 218910) | 66 | assertVideoProperties(originalVideo, 720, 'webm', 218910) |
75 | assertVideoProperties(transcodedVideo, 480, 'webm', 69217) | 67 | assertVideoProperties(transcodedVideo, 480, 'webm', 69217) |
76 | } | 68 | } |
77 | }) | 69 | }) |
78 | 70 | ||
79 | it('Should run a import job on video 2 with the same resolution and a different extension', async function () { | 71 | it('Should run a import job on video 2 with the same resolution and a different extension', async function () { |
80 | const env = getEnvCli(servers[1]) | 72 | const command = `npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv` |
81 | await execCLI(`${env} npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`) | 73 | await servers[1].cli.execWithEnv(command) |
82 | 74 | ||
83 | await waitJobs(servers) | 75 | await waitJobs(servers) |
84 | 76 | ||
85 | for (const server of servers) { | 77 | for (const server of servers) { |
86 | const { data: videos } = (await getVideosList(server.url)).body | 78 | const { data: videos } = await server.videos.list() |
87 | expect(videos).to.have.lengthOf(2) | 79 | expect(videos).to.have.lengthOf(2) |
88 | 80 | ||
89 | const video = videos.find(({ uuid }) => uuid === video2UUID) | 81 | const video = videos.find(({ uuid }) => uuid === video2UUID) |
90 | const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body | 82 | const videoDetails = await server.videos.get({ id: video.uuid }) |
91 | 83 | ||
92 | expect(videoDetail.files).to.have.lengthOf(4) | 84 | expect(videoDetails.files).to.have.lengthOf(4) |
93 | const [ originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240 ] = videoDetail.files | 85 | const [ originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240 ] = videoDetails.files |
94 | assertVideoProperties(originalVideo, 720, 'ogv', 140849) | 86 | assertVideoProperties(originalVideo, 720, 'ogv', 140849) |
95 | assertVideoProperties(transcodedVideo420, 480, 'mp4') | 87 | assertVideoProperties(transcodedVideo420, 480, 'mp4') |
96 | assertVideoProperties(transcodedVideo320, 360, 'mp4') | 88 | assertVideoProperties(transcodedVideo320, 360, 'mp4') |
@@ -99,20 +91,20 @@ describe('Test create import video jobs', function () { | |||
99 | }) | 91 | }) |
100 | 92 | ||
101 | it('Should run a import job on video 2 with the same resolution and the same extension', async function () { | 93 | it('Should run a import job on video 2 with the same resolution and the same extension', async function () { |
102 | const env = getEnvCli(servers[0]) | 94 | const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm` |
103 | await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`) | 95 | await servers[0].cli.execWithEnv(command) |
104 | 96 | ||
105 | await waitJobs(servers) | 97 | await waitJobs(servers) |
106 | 98 | ||
107 | for (const server of servers) { | 99 | for (const server of servers) { |
108 | const { data: videos } = (await getVideosList(server.url)).body | 100 | const { data: videos } = await server.videos.list() |
109 | expect(videos).to.have.lengthOf(2) | 101 | expect(videos).to.have.lengthOf(2) |
110 | 102 | ||
111 | const video = videos.find(({ uuid }) => uuid === video1UUID) | 103 | const video = videos.find(({ uuid }) => uuid === video1UUID) |
112 | const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body | 104 | const videoDetails = await server.videos.get({ id: video.uuid }) |
113 | 105 | ||
114 | expect(videoDetail.files).to.have.lengthOf(2) | 106 | expect(videoDetails.files).to.have.lengthOf(2) |
115 | const [ video720, video480 ] = videoDetail.files | 107 | const [ video720, video480 ] = videoDetails.files |
116 | assertVideoProperties(video720, 720, 'webm', 942961) | 108 | assertVideoProperties(video720, 720, 'webm', 942961) |
117 | assertVideoProperties(video480, 480, 'webm', 69217) | 109 | assertVideoProperties(video480, 480, 'webm', 69217) |
118 | } | 110 | } |