diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/live/live-constraints.ts | 2 | ||||
-rw-r--r-- | server/tests/api/live/live-permanent.ts | 12 | ||||
-rw-r--r-- | server/tests/api/live/live-save-replay.ts | 18 | ||||
-rw-r--r-- | server/tests/shared/live.ts | 17 |
4 files changed, 38 insertions, 11 deletions
diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts index 64ef73a2a..c82585a9e 100644 --- a/server/tests/api/live/live-constraints.ts +++ b/server/tests/api/live/live-constraints.ts | |||
@@ -49,7 +49,7 @@ describe('Test live constraints', function () { | |||
49 | expect(video.duration).to.be.greaterThan(0) | 49 | expect(video.duration).to.be.greaterThan(0) |
50 | } | 50 | } |
51 | 51 | ||
52 | await checkLiveCleanup(servers[0], videoId, resolutions) | 52 | await checkLiveCleanup({ server: servers[0], permanent: false, videoUUID: videoId, savedResolutions: resolutions }) |
53 | } | 53 | } |
54 | 54 | ||
55 | function updateQuota (options: { total: number, daily: number }) { | 55 | function updateQuota (options: { total: number, daily: number }) { |
diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts index 5d227200e..4203b1bfc 100644 --- a/server/tests/api/live/live-permanent.ts +++ b/server/tests/api/live/live-permanent.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { checkLiveCleanup } from '@server/tests/shared' | ||
4 | import { wait } from '@shared/core-utils' | 5 | import { wait } from '@shared/core-utils' |
5 | import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' | 6 | import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models' |
6 | import { | 7 | import { |
@@ -129,6 +130,8 @@ describe('Permanent live', function () { | |||
129 | 130 | ||
130 | expect(videoDetails.streamingPlaylists).to.have.lengthOf(0) | 131 | expect(videoDetails.streamingPlaylists).to.have.lengthOf(0) |
131 | } | 132 | } |
133 | |||
134 | await checkLiveCleanup({ server: servers[0], permanent: true, videoUUID }) | ||
132 | }) | 135 | }) |
133 | 136 | ||
134 | it('Should have set this live to waiting for live state', async function () { | 137 | it('Should have set this live to waiting for live state', async function () { |
@@ -186,6 +189,15 @@ describe('Permanent live', function () { | |||
186 | } | 189 | } |
187 | }) | 190 | }) |
188 | 191 | ||
192 | it('Should remove the live and have cleaned up the directory', async function () { | ||
193 | this.timeout(60000) | ||
194 | |||
195 | await servers[0].videos.remove({ id: videoUUID }) | ||
196 | await waitJobs(servers) | ||
197 | |||
198 | await checkLiveCleanup({ server: servers[0], permanent: true, videoUUID }) | ||
199 | }) | ||
200 | |||
189 | after(async function () { | 201 | after(async function () { |
190 | await cleanupTests(servers) | 202 | await cleanupTests(servers) |
191 | }) | 203 | }) |
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index 7014292d0..8f17b4566 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts | |||
@@ -186,7 +186,7 @@ describe('Save replay setting', function () { | |||
186 | await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED) | 186 | await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED) |
187 | 187 | ||
188 | // No resolutions saved since we did not save replay | 188 | // No resolutions saved since we did not save replay |
189 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | 189 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) |
190 | }) | 190 | }) |
191 | 191 | ||
192 | it('Should have appropriate ended session', async function () { | 192 | it('Should have appropriate ended session', async function () { |
@@ -220,7 +220,7 @@ describe('Save replay setting', function () { | |||
220 | 220 | ||
221 | await wait(5000) | 221 | await wait(5000) |
222 | await waitJobs(servers) | 222 | await waitJobs(servers) |
223 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | 223 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) |
224 | }) | 224 | }) |
225 | 225 | ||
226 | it('Should have blacklisted session error', async function () { | 226 | it('Should have blacklisted session error', async function () { |
@@ -238,7 +238,7 @@ describe('Save replay setting', function () { | |||
238 | await publishLiveAndDelete({ permanent: false, replay: false }) | 238 | await publishLiveAndDelete({ permanent: false, replay: false }) |
239 | 239 | ||
240 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) | 240 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) |
241 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | 241 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) |
242 | }) | 242 | }) |
243 | }) | 243 | }) |
244 | 244 | ||
@@ -317,7 +317,7 @@ describe('Save replay setting', function () { | |||
317 | }) | 317 | }) |
318 | 318 | ||
319 | it('Should have cleaned up the live files', async function () { | 319 | it('Should have cleaned up the live files', async function () { |
320 | await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ]) | 320 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false, savedResolutions: [ 720 ] }) |
321 | }) | 321 | }) |
322 | 322 | ||
323 | it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { | 323 | it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { |
@@ -332,7 +332,7 @@ describe('Save replay setting', function () { | |||
332 | 332 | ||
333 | await wait(5000) | 333 | await wait(5000) |
334 | await waitJobs(servers) | 334 | await waitJobs(servers) |
335 | await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ]) | 335 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false, savedResolutions: [ 720 ] }) |
336 | }) | 336 | }) |
337 | 337 | ||
338 | it('Should correctly terminate the stream on delete and delete the video', async function () { | 338 | it('Should correctly terminate the stream on delete and delete the video', async function () { |
@@ -341,7 +341,7 @@ describe('Save replay setting', function () { | |||
341 | await publishLiveAndDelete({ permanent: false, replay: true }) | 341 | await publishLiveAndDelete({ permanent: false, replay: true }) |
342 | 342 | ||
343 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) | 343 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) |
344 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | 344 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) |
345 | }) | 345 | }) |
346 | }) | 346 | }) |
347 | 347 | ||
@@ -413,7 +413,7 @@ describe('Save replay setting', function () { | |||
413 | }) | 413 | }) |
414 | 414 | ||
415 | it('Should have cleaned up the live files', async function () { | 415 | it('Should have cleaned up the live files', async function () { |
416 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | 416 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) |
417 | }) | 417 | }) |
418 | 418 | ||
419 | it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { | 419 | it('Should correctly terminate the stream on blacklist and blacklist the saved replay video', async function () { |
@@ -432,7 +432,7 @@ describe('Save replay setting', function () { | |||
432 | await servers[1].videos.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) | 432 | await servers[1].videos.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
433 | } | 433 | } |
434 | 434 | ||
435 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | 435 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) |
436 | }) | 436 | }) |
437 | 437 | ||
438 | it('Should correctly terminate the stream on delete and not save the video', async function () { | 438 | it('Should correctly terminate the stream on delete and not save the video', async function () { |
@@ -444,7 +444,7 @@ describe('Save replay setting', function () { | |||
444 | expect(replay).to.not.exist | 444 | expect(replay).to.not.exist |
445 | 445 | ||
446 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) | 446 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) |
447 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | 447 | await checkLiveCleanup({ server: servers[0], videoUUID: liveVideoUUID, permanent: false }) |
448 | }) | 448 | }) |
449 | }) | 449 | }) |
450 | 450 | ||
diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts index 78e29f575..47e0dc481 100644 --- a/server/tests/shared/live.ts +++ b/server/tests/shared/live.ts | |||
@@ -7,10 +7,25 @@ import { LiveVideo, VideoStreamingPlaylistType } from '@shared/models' | |||
7 | import { ObjectStorageCommand, PeerTubeServer } from '@shared/server-commands' | 7 | import { ObjectStorageCommand, PeerTubeServer } from '@shared/server-commands' |
8 | import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist } from './streaming-playlists' | 8 | import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist } from './streaming-playlists' |
9 | 9 | ||
10 | async function checkLiveCleanup (server: PeerTubeServer, videoUUID: string, savedResolutions: number[] = []) { | 10 | async function checkLiveCleanup (options: { |
11 | server: PeerTubeServer | ||
12 | videoUUID: string | ||
13 | permanent: boolean | ||
14 | savedResolutions?: number[] | ||
15 | }) { | ||
16 | const { server, videoUUID, permanent, savedResolutions = [] } = options | ||
17 | |||
11 | const basePath = server.servers.buildDirectory('streaming-playlists') | 18 | const basePath = server.servers.buildDirectory('streaming-playlists') |
12 | const hlsPath = join(basePath, 'hls', videoUUID) | 19 | const hlsPath = join(basePath, 'hls', videoUUID) |
13 | 20 | ||
21 | if (permanent) { | ||
22 | if (!await pathExists(hlsPath)) return | ||
23 | |||
24 | const files = await readdir(hlsPath) | ||
25 | expect(files).to.have.lengthOf(0) | ||
26 | return | ||
27 | } | ||
28 | |||
14 | if (savedResolutions.length === 0) { | 29 | if (savedResolutions.length === 0) { |
15 | return checkUnsavedLiveCleanup(server, videoUUID, hlsPath) | 30 | return checkUnsavedLiveCleanup(server, videoUUID, hlsPath) |
16 | } | 31 | } |