X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Fhandle-down.ts;h=0bbd9ef474600f02ca4f5ca95fd6f14107dcc082;hb=d102de1b38f2877463529c3b27bd35ffef4fd8bf;hp=5f20b00931f191d541b8ba5089ef6a025a782494;hpb=254d3579f5338f5fd775c17d15cdfc37078bcfb4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index 5f20b0093..0bbd9ef47 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts @@ -1,25 +1,23 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import * as chai from 'chai' -import { HttpStatusCode } from '@shared/core-utils' +import { expect } from 'chai' +import { completeVideoCheck, SQLCommand } from '@server/tests/shared' +import { wait } from '@shared/core-utils' +import { HttpStatusCode, JobState, VideoCreateResult, VideoPrivacy } from '@shared/models' import { cleanupTests, CommentsCommand, - completeVideoCheck, createMultipleServers, killallServers, PeerTubeServer, setAccessTokensToServers, - wait, waitJobs -} from '@shared/extra-utils' -import { JobState, VideoCreateResult, VideoPrivacy } from '@shared/models' - -const expect = chai.expect +} from '@shared/server-commands' describe('Test handle downs', function () { let servers: PeerTubeServer[] = [] + let sqlCommands: SQLCommand[] + let threadIdServer1: number let threadIdServer2: number let commentIdServer1: number @@ -51,7 +49,7 @@ describe('Test handle downs', function () { let commentCommands: CommentsCommand[] before(async function () { - this.timeout(30000) + this.timeout(120000) servers = await createMultipleServers(3) commentCommands = servers.map(s => s.comments) @@ -66,7 +64,7 @@ describe('Test handle downs', function () { support: 'my super support text for server 1', account: { name: 'root', - host: 'localhost:' + servers[0].port + host: servers[0].host }, isLocal: false, duration: 10, @@ -92,14 +90,16 @@ describe('Test handle downs', function () { // Get the access tokens await setAccessTokensToServers(servers) + + sqlCommands = servers.map(s => new SQLCommand(s)) }) it('Should remove followers that are often down', async function () { this.timeout(240000) // Server 2 and 3 follow server 1 - await servers[1].follows.follow({ targets: [ servers[0].url ] }) - await servers[2].follows.follow({ targets: [ servers[0].url ] }) + await servers[1].follows.follow({ hosts: [ servers[0].url ] }) + await servers[2].follows.follow({ hosts: [ servers[0].url ] }) await waitJobs(servers) @@ -155,15 +155,15 @@ describe('Test handle downs', function () { const body = await servers[0].follows.getFollowers({ start: 0, count: 2, sort: 'createdAt' }) expect(body.data).to.be.an('array') expect(body.data).to.have.lengthOf(1) - expect(body.data[0].follower.host).to.equal('localhost:' + servers[2].port) + expect(body.data[0].follower.host).to.equal(servers[2].host) }) it('Should not have pending/processing jobs anymore', async function () { const states: JobState[] = [ 'waiting', 'active' ] for (const state of states) { - const body = await servers[0].jobs.getJobsList({ - state: state, + const body = await servers[0].jobs.list({ + state, start: 0, count: 50, sort: '-createdAt' @@ -173,7 +173,7 @@ describe('Test handle downs', function () { }) it('Should re-follow server 1', async function () { - this.timeout(35000) + this.timeout(70000) await servers[1].run() await servers[2].run() @@ -181,7 +181,7 @@ describe('Test handle downs', function () { await servers[1].follows.unfollow({ target: servers[0] }) await waitJobs(servers) - await servers[1].follows.follow({ targets: [ servers[0].url ] }) + await servers[1].follows.follow({ hosts: [ servers[0].url ] }) await waitJobs(servers) @@ -213,7 +213,7 @@ describe('Test handle downs', function () { // Check unlisted video const video = await servers[2].videos.get({ id: unlistedVideo.uuid }) - await completeVideoCheck(servers[2], video, unlistedCheckAttributes) + await completeVideoCheck({ server: servers[2], originServer: servers[0], videoUUID: video.uuid, attributes: unlistedCheckAttributes }) }) it('Should send comments on a video to server 3, and automatically fetch the video', async function () { @@ -296,7 +296,7 @@ describe('Test handle downs', function () { } await waitJobs(servers) - await servers[1].sql.setActorFollowScores(20) + await sqlCommands[1].setActorFollowScores(20) // Wait video expiration await wait(11000) @@ -329,6 +329,10 @@ describe('Test handle downs', function () { }) after(async function () { + for (const sqlCommand of sqlCommands) { + await sqlCommand.cleanup() + } + await cleanupTests(servers) }) })