diff options
Diffstat (limited to 'server/tests/api/redundancy/redundancy.ts')
-rw-r--r-- | server/tests/api/redundancy/redundancy.ts | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index dfe8099ed..5b970473c 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -5,7 +5,8 @@ import * as chai from 'chai' | |||
5 | import { readdir } from 'fs-extra' | 5 | import { readdir } from 'fs-extra' |
6 | import * as magnetUtil from 'magnet-uri' | 6 | import * as magnetUtil from 'magnet-uri' |
7 | import { join } from 'path' | 7 | import { join } from 'path' |
8 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 8 | import { removeVideoRedundancy } from '@server/lib/redundancy' |
9 | import { HttpStatusCode } from '@shared/core-utils' | ||
9 | import { | 10 | import { |
10 | checkSegmentHash, | 11 | checkSegmentHash, |
11 | checkVideoFilesWereRemoved, | 12 | checkVideoFilesWereRemoved, |
@@ -26,19 +27,18 @@ import { | |||
26 | uploadVideo, | 27 | uploadVideo, |
27 | viewVideo, | 28 | viewVideo, |
28 | wait, | 29 | wait, |
30 | waitJobs, | ||
29 | waitUntilLog | 31 | waitUntilLog |
30 | } from '../../../../shared/extra-utils' | 32 | } from '@shared/extra-utils' |
31 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 33 | import { getStats } from '@shared/extra-utils/server/stats' |
32 | import { | 34 | import { |
33 | addVideoRedundancy, | 35 | ServerStats, |
34 | listVideoRedundancies, | 36 | VideoDetails, |
35 | removeVideoRedundancy, | 37 | VideoPrivacy, |
36 | updateRedundancy | 38 | VideoRedundancy, |
37 | } from '../../../../shared/extra-utils/server/redundancy' | 39 | VideoRedundancyStrategy, |
38 | import { getStats } from '../../../../shared/extra-utils/server/stats' | 40 | VideoRedundancyStrategyWithManual |
39 | import { VideoRedundancy, VideoRedundancyStrategy, VideoRedundancyStrategyWithManual } from '../../../../shared/models/redundancy' | 41 | } from '@shared/models' |
40 | import { ServerStats } from '../../../../shared/models/server/server-stats.model' | ||
41 | import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos' | ||
42 | 42 | ||
43 | const expect = chai.expect | 43 | const expect = chai.expect |
44 | 44 | ||
@@ -279,7 +279,7 @@ async function findServerFollows () { | |||
279 | } | 279 | } |
280 | 280 | ||
281 | async function enableRedundancyOnServer1 () { | 281 | async function enableRedundancyOnServer1 () { |
282 | await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, true) | 282 | await servers[0].redundancyCommand.updateRedundancy({ host: servers[1].host, redundancyAllowed: true }) |
283 | 283 | ||
284 | const { server2, server3 } = await findServerFollows() | 284 | const { server2, server3 } = await findServerFollows() |
285 | 285 | ||
@@ -291,7 +291,7 @@ async function enableRedundancyOnServer1 () { | |||
291 | } | 291 | } |
292 | 292 | ||
293 | async function disableRedundancyOnServer1 () { | 293 | async function disableRedundancyOnServer1 () { |
294 | await updateRedundancy(servers[0].url, servers[0].accessToken, servers[1].host, false) | 294 | await servers[0].redundancyCommand.updateRedundancy({ host: servers[1].host, redundancyAllowed: false }) |
295 | 295 | ||
296 | const { server2, server3 } = await findServerFollows() | 296 | const { server2, server3 } = await findServerFollows() |
297 | 297 | ||
@@ -551,11 +551,7 @@ describe('Test videos redundancy', function () { | |||
551 | }) | 551 | }) |
552 | 552 | ||
553 | it('Should create a redundancy on first video', async function () { | 553 | it('Should create a redundancy on first video', async function () { |
554 | await addVideoRedundancy({ | 554 | await servers[0].redundancyCommand.addVideo({ videoId: video1Server2Id }) |
555 | url: servers[0].url, | ||
556 | accessToken: servers[0].accessToken, | ||
557 | videoId: video1Server2Id | ||
558 | }) | ||
559 | }) | 555 | }) |
560 | 556 | ||
561 | it('Should have 2 webseeds on the first video', async function () { | 557 | it('Should have 2 webseeds on the first video', async function () { |
@@ -573,22 +569,15 @@ describe('Test videos redundancy', function () { | |||
573 | it('Should manually remove redundancies on server 1 and remove duplicated videos', async function () { | 569 | it('Should manually remove redundancies on server 1 and remove duplicated videos', async function () { |
574 | this.timeout(80000) | 570 | this.timeout(80000) |
575 | 571 | ||
576 | const res = await listVideoRedundancies({ | 572 | const body = await servers[0].redundancyCommand.listVideos({ target: 'remote-videos' }) |
577 | url: servers[0].url, | ||
578 | accessToken: servers[0].accessToken, | ||
579 | target: 'remote-videos' | ||
580 | }) | ||
581 | 573 | ||
582 | const videos = res.body.data as VideoRedundancy[] | 574 | const videos = body.data |
583 | expect(videos).to.have.lengthOf(1) | 575 | expect(videos).to.have.lengthOf(1) |
584 | 576 | ||
585 | const video = videos[0] | 577 | const video = videos[0] |
578 | |||
586 | for (const r of video.redundancies.files.concat(video.redundancies.streamingPlaylists)) { | 579 | for (const r of video.redundancies.files.concat(video.redundancies.streamingPlaylists)) { |
587 | await removeVideoRedundancy({ | 580 | await servers[0].redundancyCommand.removeVideo({ redundancyId: r.id }) |
588 | url: servers[0].url, | ||
589 | accessToken: servers[0].accessToken, | ||
590 | redundancyId: r.id | ||
591 | }) | ||
592 | } | 581 | } |
593 | 582 | ||
594 | await waitJobs(servers) | 583 | await waitJobs(servers) |