import * as chai from 'chai'
import {
cleanupTests,
+ createMultipleServers,
doubleFollow,
- flushAndRunMultipleServers,
- getLocalIdByUUID,
+ PeerTubeServer,
RedundancyCommand,
- ServerInfo,
setAccessTokensToServers,
- uploadVideo,
- uploadVideoAndGetId,
- waitJobs,
- waitUntilLog
-} from '@shared/extra-utils'
+ waitJobs
+} from '@shared/server-commands'
import { VideoPrivacy, VideoRedundanciesTarget } from '@shared/models'
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[] = []
}
}
}
- 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 res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 1 server 2' })
- video1Server2UUID = res.body.video.uuid
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } })
+ video1Server2UUID = uuid
}
{
- const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 2 server 2' })
- video2Server2UUID = res.body.video.uuid
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 2 server 2' } })
+ video2Server2UUID = uuid
}
await waitJobs(servers)
// 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)
}
})
+ 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 waitUntilLog(servers[0], 'Duplicated ', 10)
+ await servers[0].servers.waitUntilLog('Duplicated ', 10)
await waitJobs(servers)
const body = await commands[1].listVideos({ target: 'remote-videos' })
it('Should manually add a redundancy and list it', async function () {
this.timeout(120000)
- const uuid = (await uploadVideoAndGetId({ server: servers[1], videoName: '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 getLocalIdByUUID(servers[0].url, uuid)
+ const videoId = await servers[0].videos.getId({ uuid })
await commands[0].addVideo({ videoId })
await waitJobs(servers)
- await waitUntilLog(servers[0], 'Duplicated ', 15)
+ await servers[0].servers.waitUntilLog('Duplicated ', 15)
await waitJobs(servers)
{