diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/live/live-constraints.ts | 4 | ||||
-rw-r--r-- | server/tests/api/live/live-save-replay.ts | 14 | ||||
-rw-r--r-- | server/tests/api/live/live.ts | 14 | ||||
-rw-r--r-- | server/tests/api/users/users-multiple-servers.ts | 4 | ||||
-rw-r--r-- | server/tests/api/videos/resumable-upload.ts | 7 | ||||
-rw-r--r-- | server/tests/api/videos/video-hls.ts | 11 |
6 files changed, 33 insertions, 21 deletions
diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts index 20346113d..4acde3cc5 100644 --- a/server/tests/api/live/live-constraints.ts +++ b/server/tests/api/live/live-constraints.ts | |||
@@ -4,7 +4,7 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { VideoPrivacy } from '@shared/models' | 5 | import { VideoPrivacy } from '@shared/models' |
6 | import { | 6 | import { |
7 | checkLiveCleanup, | 7 | checkLiveCleanupAfterSave, |
8 | cleanupTests, | 8 | cleanupTests, |
9 | ConfigCommand, | 9 | ConfigCommand, |
10 | createMultipleServers, | 10 | createMultipleServers, |
@@ -43,7 +43,7 @@ describe('Test live constraints', function () { | |||
43 | expect(video.duration).to.be.greaterThan(0) | 43 | expect(video.duration).to.be.greaterThan(0) |
44 | } | 44 | } |
45 | 45 | ||
46 | await checkLiveCleanup(servers[0], videoId, resolutions) | 46 | await checkLiveCleanupAfterSave(servers[0], videoId, resolutions) |
47 | } | 47 | } |
48 | 48 | ||
49 | async function waitUntilLivePublishedOnAllServers (videoId: string) { | 49 | async function waitUntilLivePublishedOnAllServers (videoId: string) { |
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index bd15396ec..8f1fb78a5 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts | |||
@@ -4,7 +4,7 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FfmpegCommand } from 'fluent-ffmpeg' | 5 | import { FfmpegCommand } from 'fluent-ffmpeg' |
6 | import { | 6 | import { |
7 | checkLiveCleanup, | 7 | checkLiveCleanupAfterSave, |
8 | cleanupTests, | 8 | cleanupTests, |
9 | ConfigCommand, | 9 | ConfigCommand, |
10 | createMultipleServers, | 10 | createMultipleServers, |
@@ -150,7 +150,7 @@ describe('Save replay setting', function () { | |||
150 | await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED) | 150 | await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED) |
151 | 151 | ||
152 | // No resolutions saved since we did not save replay | 152 | // No resolutions saved since we did not save replay |
153 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | 153 | await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, []) |
154 | }) | 154 | }) |
155 | 155 | ||
156 | it('Should correctly terminate the stream on blacklist and delete the live', async function () { | 156 | it('Should correctly terminate the stream on blacklist and delete the live', async function () { |
@@ -179,7 +179,7 @@ describe('Save replay setting', function () { | |||
179 | 179 | ||
180 | await wait(5000) | 180 | await wait(5000) |
181 | await waitJobs(servers) | 181 | await waitJobs(servers) |
182 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | 182 | await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, []) |
183 | }) | 183 | }) |
184 | 184 | ||
185 | it('Should correctly terminate the stream on delete and delete the video', async function () { | 185 | it('Should correctly terminate the stream on delete and delete the video', async function () { |
@@ -203,7 +203,7 @@ describe('Save replay setting', function () { | |||
203 | await waitJobs(servers) | 203 | await waitJobs(servers) |
204 | 204 | ||
205 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) | 205 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) |
206 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | 206 | await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, []) |
207 | }) | 207 | }) |
208 | }) | 208 | }) |
209 | 209 | ||
@@ -259,7 +259,7 @@ describe('Save replay setting', function () { | |||
259 | }) | 259 | }) |
260 | 260 | ||
261 | it('Should have cleaned up the live files', async function () { | 261 | it('Should have cleaned up the live files', async function () { |
262 | await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ]) | 262 | await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [ 720 ]) |
263 | }) | 263 | }) |
264 | 264 | ||
265 | it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { | 265 | it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { |
@@ -287,7 +287,7 @@ describe('Save replay setting', function () { | |||
287 | 287 | ||
288 | await wait(5000) | 288 | await wait(5000) |
289 | await waitJobs(servers) | 289 | await waitJobs(servers) |
290 | await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ]) | 290 | await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, [ 720 ]) |
291 | }) | 291 | }) |
292 | 292 | ||
293 | it('Should correctly terminate the stream on delete and delete the video', async function () { | 293 | it('Should correctly terminate the stream on delete and delete the video', async function () { |
@@ -310,7 +310,7 @@ describe('Save replay setting', function () { | |||
310 | await waitJobs(servers) | 310 | await waitJobs(servers) |
311 | 311 | ||
312 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) | 312 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) |
313 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | 313 | await checkLiveCleanupAfterSave(servers[0], liveVideoUUID, []) |
314 | }) | 314 | }) |
315 | }) | 315 | }) |
316 | 316 | ||
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index 4676a840a..d555cff19 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts | |||
@@ -2,10 +2,10 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { join } from 'path' | 5 | import { basename, join } from 'path' |
6 | import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' | 6 | import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' |
7 | import { | 7 | import { |
8 | checkLiveCleanup, | 8 | checkLiveCleanupAfterSave, |
9 | checkLiveSegmentHash, | 9 | checkLiveSegmentHash, |
10 | checkResolutionsInMasterPlaylist, | 10 | checkResolutionsInMasterPlaylist, |
11 | cleanupTests, | 11 | cleanupTests, |
@@ -506,6 +506,10 @@ describe('Test live', function () { | |||
506 | await makeRawRequest(hlsPlaylist.playlistUrl, HttpStatusCode.OK_200) | 506 | await makeRawRequest(hlsPlaylist.playlistUrl, HttpStatusCode.OK_200) |
507 | await makeRawRequest(hlsPlaylist.segmentsSha256Url, HttpStatusCode.OK_200) | 507 | await makeRawRequest(hlsPlaylist.segmentsSha256Url, HttpStatusCode.OK_200) |
508 | 508 | ||
509 | // We should have generated random filenames | ||
510 | expect(basename(hlsPlaylist.playlistUrl)).to.not.equal('master.m3u8') | ||
511 | expect(basename(hlsPlaylist.segmentsSha256Url)).to.not.equal('segments-sha256.json') | ||
512 | |||
509 | expect(hlsPlaylist.files).to.have.lengthOf(resolutions.length) | 513 | expect(hlsPlaylist.files).to.have.lengthOf(resolutions.length) |
510 | 514 | ||
511 | for (const resolution of resolutions) { | 515 | for (const resolution of resolutions) { |
@@ -520,7 +524,9 @@ describe('Test live', function () { | |||
520 | expect(file.fps).to.be.approximately(30, 2) | 524 | expect(file.fps).to.be.approximately(30, 2) |
521 | } | 525 | } |
522 | 526 | ||
523 | const filename = `${video.uuid}-${resolution}-fragmented.mp4` | 527 | const filename = basename(file.fileUrl) |
528 | expect(filename).to.not.contain(video.uuid) | ||
529 | |||
524 | const segmentPath = servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename)) | 530 | const segmentPath = servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename)) |
525 | 531 | ||
526 | const probe = await ffprobePromise(segmentPath) | 532 | const probe = await ffprobePromise(segmentPath) |
@@ -537,7 +543,7 @@ describe('Test live', function () { | |||
537 | it('Should correctly have cleaned up the live files', async function () { | 543 | it('Should correctly have cleaned up the live files', async function () { |
538 | this.timeout(30000) | 544 | this.timeout(30000) |
539 | 545 | ||
540 | await checkLiveCleanup(servers[0], liveVideoId, [ 240, 360, 720 ]) | 546 | await checkLiveCleanupAfterSave(servers[0], liveVideoId, [ 240, 360, 720 ]) |
541 | }) | 547 | }) |
542 | }) | 548 | }) |
543 | 549 | ||
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index 16372b039..d0ca82b07 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -58,10 +58,10 @@ describe('Test users with multiple servers', function () { | |||
58 | const { uuid } = await servers[0].videos.upload({ token: userAccessToken }) | 58 | const { uuid } = await servers[0].videos.upload({ token: userAccessToken }) |
59 | videoUUID = uuid | 59 | videoUUID = uuid |
60 | 60 | ||
61 | await waitJobs(servers) | ||
62 | |||
61 | await saveVideoInServers(servers, videoUUID) | 63 | await saveVideoInServers(servers, videoUUID) |
62 | } | 64 | } |
63 | |||
64 | await waitJobs(servers) | ||
65 | }) | 65 | }) |
66 | 66 | ||
67 | it('Should be able to update my display name', async function () { | 67 | it('Should be able to update my display name', async function () { |
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts index c94d92cf2..857859fd3 100644 --- a/server/tests/api/videos/resumable-upload.ts +++ b/server/tests/api/videos/resumable-upload.ts | |||
@@ -170,8 +170,13 @@ describe('Test resumable upload', function () { | |||
170 | 170 | ||
171 | const size = 1000 | 171 | const size = 1000 |
172 | 172 | ||
173 | // Content length check seems to have changed in v16 | ||
174 | const expectedStatus = process.version.startsWith('v16') | ||
175 | ? HttpStatusCode.CONFLICT_409 | ||
176 | : HttpStatusCode.BAD_REQUEST_400 | ||
177 | |||
173 | const contentRangeBuilder = (start: number) => `bytes ${start}-${start + size - 1}/${size}` | 178 | const contentRangeBuilder = (start: number) => `bytes ${start}-${start + size - 1}/${size}` |
174 | await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409, contentRangeBuilder, contentLength: size }) | 179 | await sendChunks({ pathUploadId: uploadId, expectedStatus, contentRangeBuilder, contentLength: size }) |
175 | await checkFileSize(uploadId, 0) | 180 | await checkFileSize(uploadId, 0) |
176 | }) | 181 | }) |
177 | }) | 182 | }) |
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 921d7ce64..961f0e617 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts | |||
@@ -2,7 +2,8 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { join } from 'path' | 5 | import { basename, join } from 'path' |
6 | import { removeFragmentedMP4Ext, uuidRegex } from '@shared/core-utils' | ||
6 | import { | 7 | import { |
7 | checkDirectoryIsEmpty, | 8 | checkDirectoryIsEmpty, |
8 | checkResolutionsInMasterPlaylist, | 9 | checkResolutionsInMasterPlaylist, |
@@ -19,8 +20,6 @@ import { | |||
19 | } from '@shared/extra-utils' | 20 | } from '@shared/extra-utils' |
20 | import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models' | 21 | import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models' |
21 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' | 22 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' |
22 | import { uuidRegex } from '@shared/core-utils' | ||
23 | import { basename } from 'path/posix' | ||
24 | 23 | ||
25 | const expect = chai.expect | 24 | const expect = chai.expect |
26 | 25 | ||
@@ -78,11 +77,13 @@ async function checkHlsPlaylist (servers: PeerTubeServer[], videoUUID: string, h | |||
78 | // Check resolution playlists | 77 | // Check resolution playlists |
79 | { | 78 | { |
80 | for (const resolution of resolutions) { | 79 | for (const resolution of resolutions) { |
80 | const file = hlsFiles.find(f => f.resolution.id === resolution) | ||
81 | const playlistName = removeFragmentedMP4Ext(basename(file.fileUrl)) + '.m3u8' | ||
82 | |||
81 | const subPlaylist = await server.streamingPlaylists.get({ | 83 | const subPlaylist = await server.streamingPlaylists.get({ |
82 | url: `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8` | 84 | url: `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${playlistName}` |
83 | }) | 85 | }) |
84 | 86 | ||
85 | const file = hlsFiles.find(f => f.resolution.id === resolution) | ||
86 | expect(subPlaylist).to.match(new RegExp(`${uuidRegex}-${resolution}-fragmented.mp4`)) | 87 | expect(subPlaylist).to.match(new RegExp(`${uuidRegex}-${resolution}-fragmented.mp4`)) |
87 | expect(subPlaylist).to.contain(basename(file.fileUrl)) | 88 | expect(subPlaylist).to.contain(basename(file.fileUrl)) |
88 | } | 89 | } |