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.ts22
-rw-r--r--server/tests/cli/create-move-video-storage-job.ts25
2 files changed, 26 insertions, 21 deletions
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts
index 3ece4f2ec..edd727967 100644
--- a/server/tests/cli/create-import-video-file-job.ts
+++ b/server/tests/cli/create-import-video-file-job.ts
@@ -25,25 +25,27 @@ function assertVideoProperties (video: VideoFile, resolution: number, extname: s
25 if (size) expect(video.size).to.equal(size) 25 if (size) expect(video.size).to.equal(size)
26} 26}
27 27
28async function checkFiles (video: VideoDetails, objectStorage: boolean) { 28async function checkFiles (video: VideoDetails, objectStorage: ObjectStorageCommand) {
29 for (const file of video.files) { 29 for (const file of video.files) {
30 if (objectStorage) expectStartWith(file.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl()) 30 if (objectStorage) expectStartWith(file.fileUrl, objectStorage.getMockWebVideosBaseUrl())
31 31
32 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) 32 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
33 } 33 }
34} 34}
35 35
36function runTests (objectStorage: boolean) { 36function runTests (enableObjectStorage: boolean) {
37 let video1ShortId: string 37 let video1ShortId: string
38 let video2UUID: string 38 let video2UUID: string
39 39
40 let servers: PeerTubeServer[] = [] 40 let servers: PeerTubeServer[] = []
41 41
42 const objectStorage = new ObjectStorageCommand()
43
42 before(async function () { 44 before(async function () {
43 this.timeout(90000) 45 this.timeout(90000)
44 46
45 const config = objectStorage 47 const config = enableObjectStorage
46 ? ObjectStorageCommand.getDefaultMockConfig() 48 ? objectStorage.getDefaultMockConfig()
47 : {} 49 : {}
48 50
49 // Run server 2 to have transcoding enabled 51 // Run server 2 to have transcoding enabled
@@ -52,7 +54,7 @@ function runTests (objectStorage: boolean) {
52 54
53 await doubleFollow(servers[0], servers[1]) 55 await doubleFollow(servers[0], servers[1])
54 56
55 if (objectStorage) await ObjectStorageCommand.prepareDefaultMockBuckets() 57 if (enableObjectStorage) await objectStorage.prepareDefaultMockBuckets()
56 58
57 // Upload two videos for our needs 59 // Upload two videos for our needs
58 { 60 {
@@ -90,7 +92,7 @@ function runTests (objectStorage: boolean) {
90 assertVideoProperties(originalVideo, 720, 'webm', 218910) 92 assertVideoProperties(originalVideo, 720, 'webm', 218910)
91 assertVideoProperties(transcodedVideo, 480, 'webm', 69217) 93 assertVideoProperties(transcodedVideo, 480, 'webm', 69217)
92 94
93 await checkFiles(videoDetails, objectStorage) 95 await checkFiles(videoDetails, enableObjectStorage && objectStorage)
94 } 96 }
95 }) 97 })
96 98
@@ -114,7 +116,7 @@ function runTests (objectStorage: boolean) {
114 assertVideoProperties(transcodedVideo320, 360, 'mp4') 116 assertVideoProperties(transcodedVideo320, 360, 'mp4')
115 assertVideoProperties(transcodedVideo240, 240, 'mp4') 117 assertVideoProperties(transcodedVideo240, 240, 'mp4')
116 118
117 await checkFiles(videoDetails, objectStorage) 119 await checkFiles(videoDetails, enableObjectStorage && objectStorage)
118 } 120 }
119 }) 121 })
120 122
@@ -136,7 +138,7 @@ function runTests (objectStorage: boolean) {
136 assertVideoProperties(video720, 720, 'webm', 942961) 138 assertVideoProperties(video720, 720, 'webm', 942961)
137 assertVideoProperties(video480, 480, 'webm', 69217) 139 assertVideoProperties(video480, 480, 'webm', 69217)
138 140
139 await checkFiles(videoDetails, objectStorage) 141 await checkFiles(videoDetails, enableObjectStorage && objectStorage)
140 } 142 }
141 }) 143 })
142 144
@@ -146,6 +148,8 @@ function runTests (objectStorage: boolean) {
146 }) 148 })
147 149
148 after(async function () { 150 after(async function () {
151 await objectStorage.cleanupMock()
152
149 await cleanupTests(servers) 153 await cleanupTests(servers)
150 }) 154 })
151} 155}
diff --git a/server/tests/cli/create-move-video-storage-job.ts b/server/tests/cli/create-move-video-storage-job.ts
index 4927e0309..33a8cb9f9 100644
--- a/server/tests/cli/create-move-video-storage-job.ts
+++ b/server/tests/cli/create-move-video-storage-job.ts
@@ -15,10 +15,10 @@ import {
15} from '@shared/server-commands' 15} from '@shared/server-commands'
16import { checkDirectoryIsEmpty, expectStartWith } from '../shared' 16import { checkDirectoryIsEmpty, expectStartWith } from '../shared'
17 17
18async function checkFiles (origin: PeerTubeServer, video: VideoDetails, inObjectStorage: boolean) { 18async function checkFiles (origin: PeerTubeServer, video: VideoDetails, objectStorage?: ObjectStorageCommand) {
19 for (const file of video.files) { 19 for (const file of video.files) {
20 const start = inObjectStorage 20 const start = objectStorage
21 ? ObjectStorageCommand.getMockWebTorrentBaseUrl() 21 ? objectStorage.getMockWebVideosBaseUrl()
22 : origin.url 22 : origin.url
23 23
24 expectStartWith(file.fileUrl, start) 24 expectStartWith(file.fileUrl, start)
@@ -26,8 +26,8 @@ async function checkFiles (origin: PeerTubeServer, video: VideoDetails, inObject
26 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 }) 26 await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
27 } 27 }
28 28
29 const start = inObjectStorage 29 const start = objectStorage
30 ? ObjectStorageCommand.getMockPlaylistBaseUrl() 30 ? objectStorage.getMockPlaylistBaseUrl()
31 : origin.url 31 : origin.url
32 32
33 const hls = video.streamingPlaylists[0] 33 const hls = video.streamingPlaylists[0]
@@ -46,6 +46,7 @@ describe('Test create move video storage job', function () {
46 46
47 let servers: PeerTubeServer[] = [] 47 let servers: PeerTubeServer[] = []
48 const uuids: string[] = [] 48 const uuids: string[] = []
49 const objectStorage = new ObjectStorageCommand()
49 50
50 before(async function () { 51 before(async function () {
51 this.timeout(360000) 52 this.timeout(360000)
@@ -56,7 +57,7 @@ describe('Test create move video storage job', function () {
56 57
57 await doubleFollow(servers[0], servers[1]) 58 await doubleFollow(servers[0], servers[1])
58 59
59 await ObjectStorageCommand.prepareDefaultMockBuckets() 60 await objectStorage.prepareDefaultMockBuckets()
60 61
61 await servers[0].config.enableTranscoding() 62 await servers[0].config.enableTranscoding()
62 63
@@ -68,25 +69,25 @@ describe('Test create move video storage job', function () {
68 await waitJobs(servers) 69 await waitJobs(servers)
69 70
70 await servers[0].kill() 71 await servers[0].kill()
71 await servers[0].run(ObjectStorageCommand.getDefaultMockConfig()) 72 await servers[0].run(objectStorage.getDefaultMockConfig())
72 }) 73 })
73 74
74 it('Should move only one file', async function () { 75 it('Should move only one file', async function () {
75 this.timeout(120000) 76 this.timeout(120000)
76 77
77 const command = `npm run create-move-video-storage-job -- --to-object-storage -v ${uuids[1]}` 78 const command = `npm run create-move-video-storage-job -- --to-object-storage -v ${uuids[1]}`
78 await servers[0].cli.execWithEnv(command, ObjectStorageCommand.getDefaultMockConfig()) 79 await servers[0].cli.execWithEnv(command, objectStorage.getDefaultMockConfig())
79 await waitJobs(servers) 80 await waitJobs(servers)
80 81
81 for (const server of servers) { 82 for (const server of servers) {
82 const video = await server.videos.get({ id: uuids[1] }) 83 const video = await server.videos.get({ id: uuids[1] })
83 84
84 await checkFiles(servers[0], video, true) 85 await checkFiles(servers[0], video, objectStorage)
85 86
86 for (const id of [ uuids[0], uuids[2] ]) { 87 for (const id of [ uuids[0], uuids[2] ]) {
87 const video = await server.videos.get({ id }) 88 const video = await server.videos.get({ id })
88 89
89 await checkFiles(servers[0], video, false) 90 await checkFiles(servers[0], video)
90 } 91 }
91 } 92 }
92 }) 93 })
@@ -95,14 +96,14 @@ describe('Test create move video storage job', function () {
95 this.timeout(120000) 96 this.timeout(120000)
96 97
97 const command = `npm run create-move-video-storage-job -- --to-object-storage --all-videos` 98 const command = `npm run create-move-video-storage-job -- --to-object-storage --all-videos`
98 await servers[0].cli.execWithEnv(command, ObjectStorageCommand.getDefaultMockConfig()) 99 await servers[0].cli.execWithEnv(command, objectStorage.getDefaultMockConfig())
99 await waitJobs(servers) 100 await waitJobs(servers)
100 101
101 for (const server of servers) { 102 for (const server of servers) {
102 for (const id of [ uuids[0], uuids[2] ]) { 103 for (const id of [ uuids[0], uuids[2] ]) {
103 const video = await server.videos.get({ id }) 104 const video = await server.videos.get({ id })
104 105
105 await checkFiles(servers[0], video, true) 106 await checkFiles(servers[0], video, objectStorage)
106 } 107 }
107 } 108 }
108 }) 109 })