From c3d29f694bf8c910f917be655626d0f80871124f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 09:16:40 +0200 Subject: Introduce follows command --- server/tests/api/redundancy/redundancy-constraints.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'server/tests/api/redundancy/redundancy-constraints.ts') diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 1cb1603bc..602f4bc1b 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts @@ -7,7 +7,6 @@ import { VideoPrivacy } from '@shared/models' import { cleanupTests, flushAndRunServer, - follow, killallServers, reRunServer, ServerInfo, @@ -98,7 +97,7 @@ describe('Test redundancy constraints', function () { await waitJobs(servers) // Server 1 and server 2 follow each other - await follow(remoteServer.url, [ localServer.url ], remoteServer.accessToken) + await remoteServer.followsCommand.follow({ targets: [ localServer.url ] }) await waitJobs(servers) await updateRedundancy(remoteServer.url, remoteServer.accessToken, localServer.host, true) @@ -184,7 +183,7 @@ 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 follow(localServer.url, [ remoteServer.url ], localServer.accessToken) + await localServer.followsCommand.follow({ targets: [ remoteServer.url ] }) await waitJobs(servers) await uploadWrapper('video 4 server 2') -- cgit v1.2.3 From dab047092b51b453f175069573d8865fb17acdfc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 10:56:45 +0200 Subject: Introduce redundancy command --- .../tests/api/redundancy/redundancy-constraints.ts | 28 +++++++--------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'server/tests/api/redundancy/redundancy-constraints.ts') diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 602f4bc1b..a666976b3 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts @@ -1,9 +1,6 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' -import * as chai from 'chai' -import { listVideoRedundancies, updateRedundancy } from '@shared/extra-utils/server/redundancy' -import { VideoPrivacy } from '@shared/models' import { cleanupTests, flushAndRunServer, @@ -13,9 +10,10 @@ import { setAccessTokensToServers, updateVideo, uploadVideo, + waitJobs, waitUntilLog -} from '../../../../shared/extra-utils' -import { waitJobs } from '../../../../shared/extra-utils/server/jobs' +} from '@shared/extra-utils' +import { VideoPrivacy } from '@shared/models' const expect = chai.expect @@ -50,23 +48,15 @@ describe('Test redundancy constraints', function () { } async function getTotalRedundanciesLocalServer () { - const res = await listVideoRedundancies({ - url: localServer.url, - accessToken: localServer.accessToken, - target: 'my-videos' - }) + const body = await localServer.redundancyCommand.listVideos({ target: 'my-videos' }) - return res.body.total + return body.total } async function getTotalRedundanciesRemoteServer () { - const res = await listVideoRedundancies({ - url: remoteServer.url, - accessToken: remoteServer.accessToken, - target: 'remote-videos' - }) + const body = await remoteServer.redundancyCommand.listVideos({ target: 'remote-videos' }) - return res.body.total + return body.total } before(async function () { @@ -99,7 +89,7 @@ describe('Test redundancy constraints', function () { // Server 1 and server 2 follow each other await remoteServer.followsCommand.follow({ targets: [ localServer.url ] }) await waitJobs(servers) - await updateRedundancy(remoteServer.url, remoteServer.accessToken, localServer.host, true) + await remoteServer.redundancyCommand.updateRedundancy({ host: localServer.host, redundancyAllowed: true }) await waitJobs(servers) }) @@ -161,7 +151,7 @@ describe('Test redundancy constraints', function () { } } } - await killallServers([ localServer ]) + killallServers([ localServer ]) await reRunServer(localServer, config) await uploadWrapper('video 3 server 2') -- cgit v1.2.3 From a54618880c394ad7571f3f3222dc96ec2dd10d9a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 11:21:30 +0200 Subject: Introduce channels command --- server/tests/api/redundancy/redundancy-constraints.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'server/tests/api/redundancy/redundancy-constraints.ts') diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index a666976b3..500b96747 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' +import { expect } from 'chai' import { cleanupTests, flushAndRunServer, @@ -15,8 +16,6 @@ import { } from '@shared/extra-utils' import { VideoPrivacy } from '@shared/models' -const expect = chai.expect - describe('Test redundancy constraints', function () { let remoteServer: ServerInfo let localServer: ServerInfo -- cgit v1.2.3 From 9293139fde7091e9badcafa9b570b83cea9a10ad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 15:37:43 +0200 Subject: Introduce sql command --- server/tests/api/redundancy/redundancy-constraints.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/tests/api/redundancy/redundancy-constraints.ts') diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 500b96747..82d952471 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts @@ -121,7 +121,7 @@ describe('Test redundancy constraints', function () { } } } - await killallServers([ localServer ]) + await await killallServers([ localServer ]) await reRunServer(localServer, config) await uploadWrapper('video 2 server 2') @@ -150,7 +150,7 @@ describe('Test redundancy constraints', function () { } } } - killallServers([ localServer ]) + await killallServers([ localServer ]) await reRunServer(localServer, config) await uploadWrapper('video 3 server 2') -- cgit v1.2.3 From 6c5065a011b099618681a37bd77eaa7bd3db752e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 09:43:59 +0200 Subject: Introduce server commands --- server/tests/api/redundancy/redundancy-constraints.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'server/tests/api/redundancy/redundancy-constraints.ts') diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 82d952471..a31278de7 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts @@ -11,8 +11,7 @@ import { setAccessTokensToServers, updateVideo, uploadVideo, - waitJobs, - waitUntilLog + waitJobs } from '@shared/extra-utils' import { VideoPrivacy } from '@shared/models' @@ -97,7 +96,7 @@ describe('Test redundancy constraints', function () { this.timeout(120000) await waitJobs(servers) - await waitUntilLog(remoteServer, 'Duplicated ', 5) + await remoteServer.serversCommand.waitUntilLog('Duplicated ', 5) await waitJobs(servers) { @@ -126,7 +125,7 @@ describe('Test redundancy constraints', function () { await uploadWrapper('video 2 server 2') - await waitUntilLog(remoteServer, 'Duplicated ', 10) + await remoteServer.serversCommand.waitUntilLog('Duplicated ', 10) await waitJobs(servers) { @@ -155,7 +154,7 @@ describe('Test redundancy constraints', function () { await uploadWrapper('video 3 server 2') - await waitUntilLog(remoteServer, 'Duplicated ', 15) + await remoteServer.serversCommand.waitUntilLog('Duplicated ', 15) await waitJobs(servers) { @@ -176,7 +175,7 @@ describe('Test redundancy constraints', function () { await waitJobs(servers) await uploadWrapper('video 4 server 2') - await waitUntilLog(remoteServer, 'Duplicated ', 20) + await remoteServer.serversCommand.waitUntilLog('Duplicated ', 20) await waitJobs(servers) { -- cgit v1.2.3 From d23dd9fbfc4d26026352c10f81d2795ceaf2908a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Jul 2021 10:02:54 +0200 Subject: Introduce videos command --- server/tests/api/redundancy/redundancy-constraints.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'server/tests/api/redundancy/redundancy-constraints.ts') diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index a31278de7..b3f6ed160 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts @@ -9,8 +9,6 @@ import { reRunServer, ServerInfo, setAccessTokensToServers, - updateVideo, - uploadVideo, waitJobs } from '@shared/extra-utils' import { VideoPrivacy } from '@shared/models' @@ -38,11 +36,11 @@ 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.videosCommand.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.videosCommand.update({ id, attributes: { name: videoName, privacy: VideoPrivacy.PUBLIC } }) } async function getTotalRedundanciesLocalServer () { @@ -80,7 +78,7 @@ 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.videosCommand.upload({ attributes: { name: 'video 1 server 2' } }) await waitJobs(servers) -- cgit v1.2.3 From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- .../tests/api/redundancy/redundancy-constraints.ts | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'server/tests/api/redundancy/redundancy-constraints.ts') diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index b3f6ed160..0378cc122 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts @@ -36,21 +36,21 @@ describe('Test redundancy constraints', function () { async function uploadWrapper (videoName: string) { // Wait for transcoding - const { id } = await localServer.videosCommand.upload({ attributes: { 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 localServer.videosCommand.update({ id, attributes: { 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 } @@ -78,14 +78,14 @@ describe('Test redundancy constraints', function () { // Get the access tokens await setAccessTokensToServers(servers) - await localServer.videosCommand.upload({ attributes: { 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) }) @@ -94,7 +94,7 @@ describe('Test redundancy constraints', function () { this.timeout(120000) await waitJobs(servers) - await remoteServer.serversCommand.waitUntilLog('Duplicated ', 5) + await remoteServer.servers.waitUntilLog('Duplicated ', 5) await waitJobs(servers) { @@ -123,7 +123,7 @@ describe('Test redundancy constraints', function () { await uploadWrapper('video 2 server 2') - await remoteServer.serversCommand.waitUntilLog('Duplicated ', 10) + await remoteServer.servers.waitUntilLog('Duplicated ', 10) await waitJobs(servers) { @@ -152,7 +152,7 @@ describe('Test redundancy constraints', function () { await uploadWrapper('video 3 server 2') - await remoteServer.serversCommand.waitUntilLog('Duplicated ', 15) + await remoteServer.servers.waitUntilLog('Duplicated ', 15) await waitJobs(servers) { @@ -169,11 +169,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 remoteServer.serversCommand.waitUntilLog('Duplicated ', 20) + await remoteServer.servers.waitUntilLog('Duplicated ', 20) await waitJobs(servers) { -- cgit v1.2.3 From 254d3579f5338f5fd775c17d15cdfc37078bcfb4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:47:51 +0200 Subject: Use an object to represent a server --- server/tests/api/redundancy/redundancy-constraints.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'server/tests/api/redundancy/redundancy-constraints.ts') diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 0378cc122..217691fb6 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts @@ -4,19 +4,18 @@ import 'mocha' import { expect } from 'chai' import { cleanupTests, - flushAndRunServer, + createSingleServer, killallServers, - reRunServer, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, 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: { @@ -59,7 +58,7 @@ describe('Test redundancy constraints', function () { this.timeout(120000) { - remoteServer = await flushAndRunServer(1, remoteServerConfig) + remoteServer = await createSingleServer(1, remoteServerConfig) } { @@ -70,7 +69,7 @@ describe('Test redundancy constraints', function () { } } } - localServer = await flushAndRunServer(2, config) + localServer = await createSingleServer(2, config) } servers = [ remoteServer, localServer ] @@ -119,7 +118,7 @@ describe('Test redundancy constraints', function () { } } await await killallServers([ localServer ]) - await reRunServer(localServer, config) + await localServer.run(config) await uploadWrapper('video 2 server 2') @@ -148,7 +147,7 @@ describe('Test redundancy constraints', function () { } } await killallServers([ localServer ]) - await reRunServer(localServer, config) + await localServer.run(config) await uploadWrapper('video 3 server 2') -- cgit v1.2.3 From c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:42:24 +0200 Subject: Refactor requests --- server/tests/api/redundancy/redundancy-constraints.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/tests/api/redundancy/redundancy-constraints.ts') diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 217691fb6..71b93901e 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts @@ -117,7 +117,7 @@ describe('Test redundancy constraints', function () { } } } - await await killallServers([ localServer ]) + await killallServers([ localServer ]) await localServer.run(config) await uploadWrapper('video 2 server 2') -- cgit v1.2.3 From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- server/tests/api/redundancy/redundancy-constraints.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'server/tests/api/redundancy/redundancy-constraints.ts') diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 71b93901e..25cd11658 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts @@ -2,14 +2,7 @@ import 'mocha' import { expect } from 'chai' -import { - cleanupTests, - createSingleServer, - killallServers, - PeerTubeServer, - setAccessTokensToServers, - waitJobs -} from '@shared/extra-utils' +import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' import { VideoPrivacy } from '@shared/models' describe('Test redundancy constraints', function () { -- cgit v1.2.3 From 4d029ef8ec3d5274eeaa3ee6d808eb7035e7faef Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Jul 2021 14:15:15 +0200 Subject: Add ability for instances to follow any actor --- server/tests/api/redundancy/redundancy-constraints.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/tests/api/redundancy/redundancy-constraints.ts') diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 25cd11658..933a2c776 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts @@ -75,7 +75,7 @@ describe('Test redundancy constraints', function () { await waitJobs(servers) // Server 1 and server 2 follow each other - await remoteServer.follows.follow({ targets: [ localServer.url ] }) + await remoteServer.follows.follow({ hosts: [ localServer.url ] }) await waitJobs(servers) await remoteServer.redundancy.updateRedundancy({ host: localServer.host, redundancyAllowed: true }) @@ -161,7 +161,7 @@ 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.follows.follow({ targets: [ remoteServer.url ] }) + await localServer.follows.follow({ hosts: [ remoteServer.url ] }) await waitJobs(servers) await uploadWrapper('video 4 server 2') -- cgit v1.2.3