X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fredundancy%2Fmanage-redundancy.ts;h=d415ac3bfab55407024913e24508678ab00f10e0;hb=0582b4f972a72c2297676faf1e574f817a5712f9;hp=efb60dc56a31f0540baec1c05a3c41ac4b8121be;hpb=d23dd9fbfc4d26026352c10f81d2795ceaf2908a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/redundancy/manage-redundancy.ts b/server/tests/api/redundancy/manage-redundancy.ts index efb60dc56..d415ac3bf 100644 --- a/server/tests/api/redundancy/manage-redundancy.ts +++ b/server/tests/api/redundancy/manage-redundancy.ts @@ -4,13 +4,13 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, + createMultipleServers, doubleFollow, - flushAndRunMultipleServers, + PeerTubeServer, RedundancyCommand, - ServerInfo, setAccessTokensToServers, waitJobs -} from '@shared/extra-utils' +} from '@shared/server-commands' import { VideoPrivacy, VideoRedundanciesTarget } from '@shared/models' const expect = chai.expect @@ -18,7 +18,7 @@ const expect = chai.expect describe('Test manage videos redundancy', function () { const targets: VideoRedundanciesTarget[] = [ 'my-videos', 'remote-videos' ] - let servers: ServerInfo[] + let servers: PeerTubeServer[] let video1Server2UUID: string let video2Server2UUID: string let redundanciesToRemove: number[] = [] @@ -48,20 +48,20 @@ describe('Test manage videos redundancy', function () { } } } - servers = await flushAndRunMultipleServers(3, config) + servers = await createMultipleServers(3, config) // Get the access tokens await setAccessTokensToServers(servers) - commands = servers.map(s => s.redundancyCommand) + commands = servers.map(s => s.redundancy) { - const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } }) + const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } }) video1Server2UUID = uuid } { - const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 2 server 2' } }) + const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 2 server 2' } }) video2Server2UUID = uuid } @@ -69,6 +69,7 @@ describe('Test manage videos redundancy', function () { // Server 1 and server 2 follow each other await doubleFollow(servers[0], servers[1]) + await doubleFollow(servers[0], servers[2]) await commands[0].updateRedundancy({ host: servers[1].host, redundancyAllowed: true }) await waitJobs(servers) @@ -83,11 +84,21 @@ describe('Test manage videos redundancy', function () { } }) + it('Should correctly list followings by redundancy', async function () { + const body = await servers[0].follows.getFollowings({ sort: '-redundancyAllowed' }) + + expect(body.total).to.equal(2) + expect(body.data).to.have.lengthOf(2) + + expect(body.data[0].following.host).to.equal(servers[1].host) + expect(body.data[1].following.host).to.equal(servers[2].host) + }) + it('Should not have "remote-videos" redundancies on server 2', async function () { this.timeout(120000) await waitJobs(servers) - await servers[0].serversCommand.waitUntilLog('Duplicated ', 10) + await servers[0].servers.waitUntilLog('Duplicated ', 10) await waitJobs(servers) const body = await commands[1].listVideos({ target: 'remote-videos' }) @@ -203,14 +214,14 @@ describe('Test manage videos redundancy', function () { it('Should manually add a redundancy and list it', async function () { this.timeout(120000) - const uuid = (await servers[1].videosCommand.quickUpload({ name: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid + const uuid = (await servers[1].videos.quickUpload({ name: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid await waitJobs(servers) - const videoId = await servers[0].videosCommand.getId({ uuid }) + const videoId = await servers[0].videos.getId({ uuid }) await commands[0].addVideo({ videoId }) await waitJobs(servers) - await servers[0].serversCommand.waitUntilLog('Duplicated ', 15) + await servers[0].servers.waitUntilLog('Duplicated ', 15) await waitJobs(servers) {