X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=inline;f=server%2Ftests%2Fapi%2Fredundancy%2Fredundancy-constraints.ts;h=217691fb6a5e49a12cbd8269c4e5430c7cf0390a;hb=254d3579f5338f5fd775c17d15cdfc37078bcfb4;hp=500b967473634f0d6aa359dfa2e62b19467dfecf;hpb=a54618880c394ad7571f3f3222dc96ec2dd10d9a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 500b96747..217691fb6 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts @@ -4,22 +4,18 @@ import 'mocha' import { expect } from 'chai' import { cleanupTests, - flushAndRunServer, + createSingleServer, killallServers, - reRunServer, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, - updateVideo, - uploadVideo, - waitJobs, - waitUntilLog + waitJobs } from '@shared/extra-utils' import { VideoPrivacy } from '@shared/models' describe('Test redundancy constraints', function () { - let remoteServer: ServerInfo - let localServer: ServerInfo - let servers: ServerInfo[] + let remoteServer: PeerTubeServer + let localServer: PeerTubeServer + let servers: PeerTubeServer[] const remoteServerConfig = { redundancy: { @@ -39,21 +35,21 @@ describe('Test redundancy constraints', function () { async function uploadWrapper (videoName: string) { // Wait for transcoding - const res = await uploadVideo(localServer.url, localServer.accessToken, { name: 'to transcode', privacy: VideoPrivacy.PRIVATE }) + const { id } = await localServer.videos.upload({ attributes: { name: 'to transcode', privacy: VideoPrivacy.PRIVATE } }) await waitJobs([ localServer ]) // Update video to schedule a federation - await updateVideo(localServer.url, localServer.accessToken, res.body.video.id, { name: videoName, privacy: VideoPrivacy.PUBLIC }) + await localServer.videos.update({ id, attributes: { name: videoName, privacy: VideoPrivacy.PUBLIC } }) } async function getTotalRedundanciesLocalServer () { - const body = await localServer.redundancyCommand.listVideos({ target: 'my-videos' }) + const body = await localServer.redundancy.listVideos({ target: 'my-videos' }) return body.total } async function getTotalRedundanciesRemoteServer () { - const body = await remoteServer.redundancyCommand.listVideos({ target: 'remote-videos' }) + const body = await remoteServer.redundancy.listVideos({ target: 'remote-videos' }) return body.total } @@ -62,7 +58,7 @@ describe('Test redundancy constraints', function () { this.timeout(120000) { - remoteServer = await flushAndRunServer(1, remoteServerConfig) + remoteServer = await createSingleServer(1, remoteServerConfig) } { @@ -73,7 +69,7 @@ describe('Test redundancy constraints', function () { } } } - localServer = await flushAndRunServer(2, config) + localServer = await createSingleServer(2, config) } servers = [ remoteServer, localServer ] @@ -81,14 +77,14 @@ describe('Test redundancy constraints', function () { // Get the access tokens await setAccessTokensToServers(servers) - await uploadVideo(localServer.url, localServer.accessToken, { name: 'video 1 server 2' }) + await localServer.videos.upload({ attributes: { name: 'video 1 server 2' } }) await waitJobs(servers) // Server 1 and server 2 follow each other - await remoteServer.followsCommand.follow({ targets: [ localServer.url ] }) + await remoteServer.follows.follow({ targets: [ localServer.url ] }) await waitJobs(servers) - await remoteServer.redundancyCommand.updateRedundancy({ host: localServer.host, redundancyAllowed: true }) + await remoteServer.redundancy.updateRedundancy({ host: localServer.host, redundancyAllowed: true }) await waitJobs(servers) }) @@ -97,7 +93,7 @@ describe('Test redundancy constraints', function () { this.timeout(120000) await waitJobs(servers) - await waitUntilLog(remoteServer, 'Duplicated ', 5) + await remoteServer.servers.waitUntilLog('Duplicated ', 5) await waitJobs(servers) { @@ -121,12 +117,12 @@ describe('Test redundancy constraints', function () { } } } - await killallServers([ localServer ]) - await reRunServer(localServer, config) + await await killallServers([ localServer ]) + await localServer.run(config) await uploadWrapper('video 2 server 2') - await waitUntilLog(remoteServer, 'Duplicated ', 10) + await remoteServer.servers.waitUntilLog('Duplicated ', 10) await waitJobs(servers) { @@ -150,12 +146,12 @@ describe('Test redundancy constraints', function () { } } } - killallServers([ localServer ]) - await reRunServer(localServer, config) + await killallServers([ localServer ]) + await localServer.run(config) await uploadWrapper('video 3 server 2') - await waitUntilLog(remoteServer, 'Duplicated ', 15) + await remoteServer.servers.waitUntilLog('Duplicated ', 15) await waitJobs(servers) { @@ -172,11 +168,11 @@ describe('Test redundancy constraints', function () { it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', async function () { this.timeout(120000) - await localServer.followsCommand.follow({ targets: [ remoteServer.url ] }) + await localServer.follows.follow({ targets: [ remoteServer.url ] }) await waitJobs(servers) await uploadWrapper('video 4 server 2') - await waitUntilLog(remoteServer, 'Duplicated ', 20) + await remoteServer.servers.waitUntilLog('Duplicated ', 20) await waitJobs(servers) {