diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-01 11:57:21 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-01 15:03:28 +0100 |
commit | 6949a1a1113cc6af3442dc3d5446b8fe6143f28e (patch) | |
tree | 70f8fecc38ff3f5dd848343caa338fc8993a2124 /server/tests/api/redundancy/redundancy.ts | |
parent | 56df7815b56f35d4e1b539087aac16f4ceabf7be (diff) | |
download | PeerTube-6949a1a1113cc6af3442dc3d5446b8fe6143f28e.tar.gz PeerTube-6949a1a1113cc6af3442dc3d5446b8fe6143f28e.tar.zst PeerTube-6949a1a1113cc6af3442dc3d5446b8fe6143f28e.zip |
Fix tests
Diffstat (limited to 'server/tests/api/redundancy/redundancy.ts')
-rw-r--r-- | server/tests/api/redundancy/redundancy.ts | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 8da0ba72a..811dc8c55 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -1,8 +1,11 @@ | |||
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 * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
5 | import { VideoDetails } from '../../../../shared/models/videos' | 4 | import * as chai from 'chai' |
5 | import { readdir } from 'fs-extra' | ||
6 | import * as magnetUtil from 'magnet-uri' | ||
7 | import { join } from 'path' | ||
8 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
6 | import { | 9 | import { |
7 | checkSegmentHash, | 10 | checkSegmentHash, |
8 | checkVideoFilesWereRemoved, | 11 | checkVideoFilesWereRemoved, |
@@ -21,29 +24,23 @@ import { | |||
21 | ServerInfo, | 24 | ServerInfo, |
22 | setAccessTokensToServers, | 25 | setAccessTokensToServers, |
23 | unfollow, | 26 | unfollow, |
24 | updateCustomConfig, | ||
25 | updateCustomSubConfig, | ||
26 | uploadVideo, | 27 | uploadVideo, |
27 | viewVideo, | 28 | viewVideo, |
28 | wait, | 29 | wait, |
29 | waitUntilLog | 30 | waitUntilLog |
30 | } from '../../../../shared/extra-utils' | 31 | } from '../../../../shared/extra-utils' |
31 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 32 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
32 | |||
33 | import * as magnetUtil from 'magnet-uri' | ||
34 | import { | 33 | import { |
35 | addVideoRedundancy, | 34 | addVideoRedundancy, |
36 | listVideoRedundancies, | 35 | listVideoRedundancies, |
37 | removeVideoRedundancy, | 36 | removeVideoRedundancy, |
38 | updateRedundancy | 37 | updateRedundancy |
39 | } from '../../../../shared/extra-utils/server/redundancy' | 38 | } from '../../../../shared/extra-utils/server/redundancy' |
39 | import { getStats } from '../../../../shared/extra-utils/server/stats' | ||
40 | import { ActorFollow } from '../../../../shared/models/actors' | 40 | import { ActorFollow } from '../../../../shared/models/actors' |
41 | import { readdir } from 'fs-extra' | ||
42 | import { join } from 'path' | ||
43 | import { VideoRedundancy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../../shared/models/redundancy' | 41 | import { VideoRedundancy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../../shared/models/redundancy' |
44 | import { getStats } from '../../../../shared/extra-utils/server/stats' | ||
45 | import { ServerStats } from '../../../../shared/models/server/server-stats.model' | 42 | import { ServerStats } from '../../../../shared/models/server/server-stats.model' |
46 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 43 | import { VideoDetails } from '../../../../shared/models/videos' |
47 | 44 | ||
48 | const expect = chai.expect | 45 | const expect = chai.expect |
49 | 46 | ||
@@ -258,11 +255,11 @@ async function checkStatsGlobal (strategy: VideoRedundancyStrategyWithManual) { | |||
258 | return stat | 255 | return stat |
259 | } | 256 | } |
260 | 257 | ||
261 | async function checkStatsWith1Redundancy (strategy: VideoRedundancyStrategyWithManual) { | 258 | async function checkStatsWith1Redundancy (strategy: VideoRedundancyStrategyWithManual, onlyHls = false) { |
262 | const stat = await checkStatsGlobal(strategy) | 259 | const stat = await checkStatsGlobal(strategy) |
263 | 260 | ||
264 | expect(stat.totalUsed).to.be.at.least(1).and.below(409601) | 261 | expect(stat.totalUsed).to.be.at.least(1).and.below(409601) |
265 | expect(stat.totalVideoFiles).to.equal(4) | 262 | expect(stat.totalVideoFiles).to.equal(onlyHls ? 4 : 8) |
266 | expect(stat.totalVideos).to.equal(1) | 263 | expect(stat.totalVideos).to.equal(1) |
267 | } | 264 | } |
268 | 265 | ||
@@ -519,7 +516,7 @@ describe('Test videos redundancy', function () { | |||
519 | await waitJobs(servers) | 516 | await waitJobs(servers) |
520 | 517 | ||
521 | await check1PlaylistRedundancies() | 518 | await check1PlaylistRedundancies() |
522 | await checkStatsWith1Redundancy(strategy) | 519 | await checkStatsWith1Redundancy(strategy, true) |
523 | }) | 520 | }) |
524 | 521 | ||
525 | it('Should remove the video and the redundancy files', async function () { | 522 | it('Should remove the video and the redundancy files', async function () { |
@@ -533,6 +530,10 @@ describe('Test videos redundancy', function () { | |||
533 | await checkVideoFilesWereRemoved(video1Server2UUID, server.internalServerNumber) | 530 | await checkVideoFilesWereRemoved(video1Server2UUID, server.internalServerNumber) |
534 | } | 531 | } |
535 | }) | 532 | }) |
533 | |||
534 | after(async function () { | ||
535 | await cleanupTests(servers) | ||
536 | }) | ||
536 | }) | 537 | }) |
537 | 538 | ||
538 | describe('With manual strategy', function () { | 539 | describe('With manual strategy', function () { |