diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index f479e1785..662b64e05 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -114,11 +114,12 @@ describe('Test users notifications', function () { before(async function () { this.timeout(120000) - await MockSmtpServer.Instance.collectEmails(emails) + const port = await MockSmtpServer.Instance.collectEmails(emails) const overrideConfig = { smtp: { - hostname: 'localhost' + hostname: 'localhost', + port } } servers = await flushAndRunMultipleServers(3, overrideConfig) @@ -194,7 +195,7 @@ describe('Test users notifications', function () { it('Should send a new video notification if the user follows the local video publisher', async function () { this.timeout(15000) - await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:9001') + await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[0].port) await waitJobs(servers) const { name, uuid } = await uploadVideoByLocalAccount(servers) @@ -204,7 +205,7 @@ describe('Test users notifications', function () { it('Should send a new video notification from a remote account', async function () { this.timeout(50000) // Server 2 has transcoding enabled - await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:9002') + await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[1].port) await waitJobs(servers) const { name, uuid } = await uploadVideoByRemoteAccount(servers) @@ -578,7 +579,9 @@ describe('Test users notifications', function () { const uuid = resVideo.body.video.uuid await waitJobs(servers) - const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, 'hello @user_1@localhost:9001 1') + + const text1 = `hello @user_1@localhost:${servers[ 0 ].port} 1` + const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, text1) const server2ThreadId = resThread.body.comment.id await waitJobs(servers) @@ -588,8 +591,8 @@ describe('Test users notifications', function () { const server1ThreadId = resThread2.body.data[0].id await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence') - const text = '@user_1@localhost:9001 hello 2 @root@localhost:9001' - await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, server2ThreadId, text) + const text2 = `@user_1@localhost:${servers[ 0 ].port} hello 2 @root@localhost:${servers[ 0 ].port}` + await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, server2ThreadId, text2) await waitJobs(servers) @@ -889,10 +892,10 @@ describe('Test users notifications', function () { await waitJobs(servers) - await checkNewInstanceFollower(baseParams, 'localhost:9003', 'presence') + await checkNewInstanceFollower(baseParams, 'localhost:' + servers[2].port, 'presence') const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } - await checkNewInstanceFollower(immutableAssign(baseParams, userOverride), 'localhost:9003', 'absence') + await checkNewInstanceFollower(immutableAssign(baseParams, userOverride), 'localhost:' + servers[2].port, 'absence') }) }) @@ -933,29 +936,29 @@ describe('Test users notifications', function () { it('Should notify when a local channel is following one of our channel', async function () { this.timeout(10000) - await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:9001') + await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) await waitJobs(servers) await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence') - await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:9001') + await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) }) it('Should notify when a remote channel is following one of our channel', async function () { this.timeout(10000) - await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:9001') + await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) await waitJobs(servers) await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence') - await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:9001') + await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) }) it('Should notify when a local account is following one of our channel', async function () { this.timeout(10000) - await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@localhost:9001') + await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@localhost:' + servers[0].port) await waitJobs(servers) @@ -965,7 +968,7 @@ describe('Test users notifications', function () { it('Should notify when a remote account is following one of our channel', async function () { this.timeout(10000) - await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@localhost:9001') + await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@localhost:' + servers[0].port) await waitJobs(servers) @@ -1019,8 +1022,8 @@ describe('Test users notifications', function () { autoBlacklistTestsCustomConfig.transcoding.enabled = true await updateCustomConfig(servers[0].url, servers[0].accessToken, autoBlacklistTestsCustomConfig) - await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:9001') - await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:9001') + await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) + await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) }) @@ -1142,8 +1145,8 @@ describe('Test users notifications', function () { after(async () => { await updateCustomConfig(servers[0].url, servers[0].accessToken, currentCustomConfig) - await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:9001') - await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:9001') + await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) + await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) }) }) diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index e31329c25..6f2c59076 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts @@ -100,7 +100,7 @@ async function check1WebSeed (videoUUID?: string) { if (!videoUUID) videoUUID = video1Server2UUID const webseeds = [ - 'http://localhost:9002/static/webseed/' + videoUUID + `http://localhost:${servers[ 1 ].port}/static/webseed/${videoUUID}` ] for (const server of servers) { @@ -118,8 +118,8 @@ async function check2Webseeds (videoUUID?: string) { if (!videoUUID) videoUUID = video1Server2UUID const webseeds = [ - 'http://localhost:9001/static/redundancy/' + videoUUID, - 'http://localhost:9002/static/webseed/' + videoUUID + `http://localhost:${servers[ 0 ].port}/static/redundancy/${videoUUID}`, + `http://localhost:${servers[ 1 ].port}/static/webseed/${videoUUID}` ] for (const server of servers) { @@ -145,7 +145,12 @@ async function check2Webseeds (videoUUID?: string) { } } - for (const directory of [ 'test1/redundancy', 'test2/videos' ]) { + const directories = [ + 'test' + servers[0].internalServerNumber + '/redundancy', + 'test' + servers[1].internalServerNumber + '/videos' + ] + + for (const directory of directories) { const files = await readdir(join(root(), directory)) expect(files).to.have.length.at.least(4) @@ -194,7 +199,12 @@ async function check1PlaylistRedundancies (videoUUID?: string) { await checkSegmentHash(baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist) } - for (const directory of [ 'test1/redundancy/hls', 'test2/streaming-playlists/hls' ]) { + const directories = [ + 'test' + servers[0].internalServerNumber + '/redundancy/hls', + 'test' + servers[1].internalServerNumber + '/streaming-playlists/hls' + ] + + for (const directory of directories) { const files = await readdir(join(root(), directory, videoUUID)) expect(files).to.have.length.at.least(4) @@ -239,8 +249,8 @@ async function enableRedundancyOnServer1 () { const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt') const follows: ActorFollow[] = res.body.data - const server2 = follows.find(f => f.following.host === 'localhost:9002') - const server3 = follows.find(f => f.following.host === 'localhost:9003') + const server2 = follows.find(f => f.following.host === `localhost:${servers[ 1 ].port}`) + const server3 = follows.find(f => f.following.host === `localhost:${servers[ 2 ].port}`) expect(server3).to.not.be.undefined expect(server3.following.hostRedundancyAllowed).to.be.false @@ -254,8 +264,8 @@ async function disableRedundancyOnServer1 () { const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt') const follows: ActorFollow[] = res.body.data - const server2 = follows.find(f => f.following.host === 'localhost:9002') - const server3 = follows.find(f => f.following.host === 'localhost:9003') + const server2 = follows.find(f => f.following.host === `localhost:${servers[ 1 ].port}`) + const server3 = follows.find(f => f.following.host === `localhost:${servers[ 2 ].port}`) expect(server3).to.not.be.undefined expect(server3.following.hostRedundancyAllowed).to.be.false @@ -475,12 +485,12 @@ describe('Test videos redundancy', function () { await wait(10000) try { - await checkContains(servers, 'http%3A%2F%2Flocalhost%3A9001') + await checkContains(servers, 'http%3A%2F%2Flocalhost%3A' + servers[0].port) } catch { // Maybe a server deleted a redundancy in the scheduler await wait(2000) - await checkContains(servers, 'http%3A%2F%2Flocalhost%3A9001') + await checkContains(servers, 'http%3A%2F%2Flocalhost%3A' + servers[0].port) } }) @@ -491,7 +501,7 @@ describe('Test videos redundancy', function () { await wait(15000) - await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A9001') + await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A' + servers[0].port) }) after(async function () { diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index 70a077ffc..8a008b8c6 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -3,16 +3,17 @@ import * as chai from 'chai' import 'mocha' import { - addVideoChannel, cleanupTests, + addVideoChannel, + cleanupTests, createUser, deleteVideoChannel, flushAndRunMultipleServers, - flushTests, - getVideoChannelsList, getVideoChannelVideos, - killallServers, + getVideoChannelsList, + getVideoChannelVideos, ServerInfo, setAccessTokensToServers, - updateMyUser, updateVideo, + updateMyUser, + updateVideo, updateVideoChannel, uploadVideo, userLogin, @@ -67,7 +68,7 @@ describe('Test ActivityPub video channels search', function () { it('Should not find a remote video channel', async function () { { - const search = 'http://localhost:9002/video-channels/channel1_server3' + const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server3' const res = await searchVideoChannel(servers[ 0 ].url, search, servers[ 0 ].accessToken) expect(res.body.total).to.equal(0) @@ -77,7 +78,7 @@ describe('Test ActivityPub video channels search', function () { { // Without token - const search = 'http://localhost:9002/video-channels/channel1_server2' + const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2' const res = await searchVideoChannel(servers[0].url, search) expect(res.body.total).to.equal(0) @@ -88,8 +89,8 @@ describe('Test ActivityPub video channels search', function () { it('Should search a local video channel', async function () { const searches = [ - 'http://localhost:9001/video-channels/channel1_server1', - 'channel1_server1@localhost:9001' + 'http://localhost:' + servers[ 0 ].port + '/video-channels/channel1_server1', + 'channel1_server1@localhost:' + servers[ 0 ].port ] for (const search of searches) { @@ -105,8 +106,8 @@ describe('Test ActivityPub video channels search', function () { it('Should search a remote video channel with URL or handle', async function () { const searches = [ - 'http://localhost:9002/video-channels/channel1_server2', - 'channel1_server2@localhost:9002' + 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2', + 'channel1_server2@localhost:' + servers[ 1 ].port ] for (const search of searches) { @@ -134,13 +135,13 @@ describe('Test ActivityPub video channels search', function () { await waitJobs(servers) - const res = await getVideoChannelVideos(servers[0].url, null, 'channel1_server2@localhost:9002', 0, 5) + const res = await getVideoChannelVideos(servers[0].url, null, 'channel1_server2@localhost:' + servers[ 1 ].port, 0, 5) expect(res.body.total).to.equal(0) expect(res.body.data).to.have.lengthOf(0) }) it('Should list video channel videos of server 2 with token', async function () { - const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:9002', 0, 5) + const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:' + servers[ 1 ].port, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data[0].name).to.equal('video 1 server 2') @@ -156,7 +157,7 @@ describe('Test ActivityPub video channels search', function () { // Expire video channel await wait(10000) - const search = 'http://localhost:9002/video-channels/channel1_server2' + const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2' const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) @@ -179,12 +180,13 @@ describe('Test ActivityPub video channels search', function () { // Expire video channel await wait(10000) - const search = 'http://localhost:9002/video-channels/channel1_server2' + const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2' await searchVideoChannel(servers[0].url, search, servers[0].accessToken) await waitJobs(servers) - const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:9002', 0, 5, '-createdAt') + const videoChannelName = 'channel1_server2@localhost:' + servers[ 1 ].port + const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, videoChannelName, 0, 5, '-createdAt') expect(res.body.total).to.equal(2) expect(res.body.data[0].name).to.equal('video 2 server 2') @@ -200,7 +202,8 @@ describe('Test ActivityPub video channels search', function () { // Expire video await wait(10000) - const res = await searchVideoChannel(servers[0].url, 'http://localhost:9002/video-channels/channel1_server2', servers[0].accessToken) + const search = 'http://localhost:' + servers[ 1 ].port + '/video-channels/channel1_server2' + const res = await searchVideoChannel(servers[0].url, search, servers[0].accessToken) expect(res.body.total).to.equal(0) expect(res.body.data).to.have.lengthOf(0) }) diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts index e8e2b5a64..dbfefadda 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/server/tests/api/search/search-activitypub-videos.ts @@ -4,18 +4,17 @@ import * as chai from 'chai' import 'mocha' import { addVideoChannel, + cleanupTests, flushAndRunMultipleServers, - flushTests, getVideosList, - killallServers, removeVideo, + searchVideo, searchVideoWithToken, ServerInfo, setAccessTokensToServers, updateVideo, uploadVideo, - wait, - searchVideo, cleanupTests + wait } from '../../../../shared/extra-utils' import { waitJobs } from '../../../../shared/extra-utils/server/jobs' import { Video, VideoPrivacy } from '../../../../shared/models/videos' @@ -49,7 +48,8 @@ describe('Test ActivityPub videos search', function () { it('Should not find a remote video', async function () { { - const res = await searchVideoWithToken(servers[ 0 ].url, 'http://localhost:9002/videos/watch/43', servers[ 0 ].accessToken) + const search = 'http://localhost:' + servers[1].port + '/videos/watch/43' + const res = await searchVideoWithToken(servers[ 0 ].url, search, servers[ 0 ].accessToken) expect(res.body.total).to.equal(0) expect(res.body.data).to.be.an('array') @@ -58,7 +58,8 @@ describe('Test ActivityPub videos search', function () { { // Without token - const res = await searchVideo(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID) + const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID + const res = await searchVideo(servers[0].url, search) expect(res.body.total).to.equal(0) expect(res.body.data).to.be.an('array') @@ -67,7 +68,8 @@ describe('Test ActivityPub videos search', function () { }) it('Should search a local video', async function () { - const res = await searchVideo(servers[0].url, 'http://localhost:9001/videos/watch/' + videoServer1UUID) + const search = 'http://localhost:' + servers[0].port + '/videos/watch/' + videoServer1UUID + const res = await searchVideo(servers[0].url, search) expect(res.body.total).to.equal(1) expect(res.body.data).to.be.an('array') @@ -76,7 +78,8 @@ describe('Test ActivityPub videos search', function () { }) it('Should search a remote video', async function () { - const res = await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) + const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID + const res = await searchVideoWithToken(servers[0].url, search, servers[0].accessToken) expect(res.body.total).to.equal(1) expect(res.body.data).to.be.an('array') @@ -114,12 +117,13 @@ describe('Test ActivityPub videos search', function () { await wait(10000) // Will run refresh async - await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) + const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID + await searchVideoWithToken(servers[0].url, search, servers[0].accessToken) // Wait refresh await wait(5000) - const res = await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) + const res = await searchVideoWithToken(servers[0].url, search, servers[0].accessToken) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) @@ -139,12 +143,13 @@ describe('Test ActivityPub videos search', function () { await wait(10000) // Will run refresh async - await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) + const search = 'http://localhost:' + servers[1].port + '/videos/watch/' + videoServer2UUID + await searchVideoWithToken(servers[0].url, search, servers[0].accessToken) // Wait refresh await wait(5000) - const res = await searchVideoWithToken(servers[0].url, 'http://localhost:9002/videos/watch/' + videoServer2UUID, servers[0].accessToken) + const res = await searchVideoWithToken(servers[0].url, search, servers[0].accessToken) expect(res.body.total).to.equal(0) expect(res.body.data).to.have.lengthOf(0) }) diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index 22d3a5951..92cc0dc71 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -4,16 +4,14 @@ import * as chai from 'chai' import 'mocha' import { advancedVideosSearch, - flushTests, - killallServers, + cleanupTests, flushAndRunServer, + immutableAssign, searchVideo, ServerInfo, setAccessTokensToServers, uploadVideo, - wait, - immutableAssign, - cleanupTests + wait } from '../../../../shared/extra-utils' const expect = chai.expect diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts index ba51198b3..0a1c49ef5 100644 --- a/server/tests/api/server/contact-form.ts +++ b/server/tests/api/server/contact-form.ts @@ -24,11 +24,12 @@ describe('Test contact form', function () { before(async function () { this.timeout(30000) - await MockSmtpServer.Instance.collectEmails(emails) + const port = await MockSmtpServer.Instance.collectEmails(emails) const overrideConfig = { smtp: { - hostname: 'localhost' + hostname: 'localhost', + port } } server = await flushAndRunServer(1, overrideConfig) diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index bacdf1b1b..9ccb1c36f 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts @@ -7,18 +7,18 @@ import { askResetPassword, askSendVerifyEmail, blockUser, - createUser, removeVideoFromBlacklist, + cleanupTests, + createUser, + flushAndRunServer, + removeVideoFromBlacklist, reportVideoAbuse, resetPassword, - flushAndRunServer, + ServerInfo, + setAccessTokensToServers, unblockUser, uploadVideo, userLogin, - verifyEmail, - flushTests, - killallServers, - ServerInfo, - setAccessTokensToServers, cleanupTests + verifyEmail } from '../../../../shared/extra-utils' import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' import { waitJobs } from '../../../../shared/extra-utils/server/jobs' @@ -87,7 +87,7 @@ describe('Test emails', function () { const email = emails[0] - expect(email['from'][0]['name']).equal('localhost:9001') + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains('password') @@ -132,7 +132,7 @@ describe('Test emails', function () { const email = emails[1] - expect(email['from'][0]['name']).equal('localhost:9001') + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('admin1@example.com') expect(email['subject']).contains('abuse') @@ -153,7 +153,7 @@ describe('Test emails', function () { const email = emails[2] - expect(email['from'][0]['name']).equal('localhost:9001') + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' blocked') @@ -171,7 +171,7 @@ describe('Test emails', function () { const email = emails[3] - expect(email['from'][0]['name']).equal('localhost:9001') + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' unblocked') @@ -191,7 +191,7 @@ describe('Test emails', function () { const email = emails[4] - expect(email['from'][0]['name']).equal('localhost:9001') + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' blacklisted') @@ -209,7 +209,7 @@ describe('Test emails', function () { const email = emails[5] - expect(email['from'][0]['name']).equal('localhost:9001') + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' unblacklisted') @@ -229,7 +229,7 @@ describe('Test emails', function () { const email = emails[6] - expect(email['from'][0]['name']).equal('localhost:9001') + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains('Verify') diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts index 4285a9e7a..ac3ff37f0 100644 --- a/server/tests/api/server/follow-constraints.ts +++ b/server/tests/api/server/follow-constraints.ts @@ -3,16 +3,16 @@ import * as chai from 'chai' import 'mocha' import { + cleanupTests, doubleFollow, + flushAndRunMultipleServers, getAccountVideos, getVideo, getVideoChannelVideos, getVideoWithToken, - flushAndRunMultipleServers, - killallServers, ServerInfo, setAccessTokensToServers, - uploadVideo, cleanupTests + uploadVideo } from '../../../../shared/extra-utils' import { unfollow } from '../../../../shared/extra-utils/server/follows' import { userLogin } from '../../../../shared/extra-utils/users/login' @@ -66,28 +66,30 @@ describe('Test follow constraints', function () { }) it('Should list local account videos', async function () { - const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9001', 0, 5) + const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:' + servers[0].port, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) }) it('Should list remote account videos', async function () { - const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9002', 0, 5) + const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:' + servers[1].port, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) }) it('Should list local channel videos', async function () { - const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9001', 0, 5) + const videoChannelName = 'root_channel@localhost:' + servers[0].port + const res = await getVideoChannelVideos(servers[0].url, undefined, videoChannelName, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) }) it('Should list remote channel videos', async function () { - const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9002', 0, 5) + const videoChannelName = 'root_channel@localhost:' + servers[1].port + const res = await getVideoChannelVideos(servers[0].url, undefined, videoChannelName, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) @@ -104,28 +106,30 @@ describe('Test follow constraints', function () { }) it('Should list local account videos', async function () { - const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9001', 0, 5) + const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:' + servers[0].port, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) }) it('Should list remote account videos', async function () { - const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9002', 0, 5) + const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:' + servers[1].port, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) }) it('Should list local channel videos', async function () { - const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9001', 0, 5) + const videoChannelName = 'root_channel@localhost:' + servers[0].port + const res = await getVideoChannelVideos(servers[0].url, userAccessToken, videoChannelName, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) }) it('Should list remote channel videos', async function () { - const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9002', 0, 5) + const videoChannelName = 'root_channel@localhost:' + servers[1].port + const res = await getVideoChannelVideos(servers[0].url, userAccessToken, videoChannelName, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) @@ -152,28 +156,30 @@ describe('Test follow constraints', function () { }) it('Should list local account videos', async function () { - const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9001', 0, 5) + const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:' + servers[0].port, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) }) it('Should not list remote account videos', async function () { - const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:9002', 0, 5) + const res = await getAccountVideos(servers[0].url, undefined, 'root@localhost:' + servers[1].port, 0, 5) expect(res.body.total).to.equal(0) expect(res.body.data).to.have.lengthOf(0) }) it('Should list local channel videos', async function () { - const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9001', 0, 5) + const videoChannelName = 'root_channel@localhost:' + servers[0].port + const res = await getVideoChannelVideos(servers[0].url, undefined, videoChannelName, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) }) it('Should not list remote channel videos', async function () { - const res = await getVideoChannelVideos(servers[0].url, undefined, 'root_channel@localhost:9002', 0, 5) + const videoChannelName = 'root_channel@localhost:' + servers[1].port + const res = await getVideoChannelVideos(servers[0].url, undefined, videoChannelName, 0, 5) expect(res.body.total).to.equal(0) expect(res.body.data).to.have.lengthOf(0) @@ -190,28 +196,30 @@ describe('Test follow constraints', function () { }) it('Should list local account videos', async function () { - const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9001', 0, 5) + const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:' + servers[0].port, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) }) it('Should list remote account videos', async function () { - const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:9002', 0, 5) + const res = await getAccountVideos(servers[0].url, userAccessToken, 'root@localhost:' + servers[1].port, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) }) it('Should list local channel videos', async function () { - const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9001', 0, 5) + const videoChannelName = 'root_channel@localhost:' + servers[0].port + const res = await getVideoChannelVideos(servers[0].url, userAccessToken, videoChannelName, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) }) it('Should list remote channel videos', async function () { - const res = await getVideoChannelVideos(servers[0].url, userAccessToken, 'root_channel@localhost:9002', 0, 5) + const videoChannelName = 'root_channel@localhost:' + servers[1].port + const res = await getVideoChannelVideos(servers[0].url, userAccessToken, videoChannelName, 0, 5) expect(res.body.total).to.equal(1) expect(res.body.data).to.have.lengthOf(1) diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.ts index 2a3a4d5c8..fc20f8961 100644 --- a/server/tests/api/server/follows-moderation.ts +++ b/server/tests/api/server/follows-moderation.ts @@ -3,9 +3,9 @@ import * as chai from 'chai' import 'mocha' import { - acceptFollower, cleanupTests, + acceptFollower, + cleanupTests, flushAndRunMultipleServers, - killallServers, ServerInfo, setAccessTokensToServers, updateCustomSubConfig @@ -14,8 +14,8 @@ import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, - removeFollower, - rejectFollower + rejectFollower, + removeFollower } from '../../../../shared/extra-utils/server/follows' import { waitJobs } from '../../../../shared/extra-utils/server/jobs' import { ActorFollow } from '../../../../shared/models/actors' @@ -29,8 +29,8 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc const follow = res.body.data[0] as ActorFollow expect(follow.state).to.equal(state) - expect(follow.follower.url).to.equal('http://localhost:9001/accounts/peertube') - expect(follow.following.url).to.equal('http://localhost:9002/accounts/peertube') + expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + 'accounts/peertube') + expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube') } { @@ -39,8 +39,8 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc const follow = res.body.data[0] as ActorFollow expect(follow.state).to.equal(state) - expect(follow.follower.url).to.equal('http://localhost:9001/accounts/peertube') - expect(follow.following.url).to.equal('http://localhost:9002/accounts/peertube') + expect(follow.follower.url).to.equal('http://localhost:' + servers[0].port + 'accounts/peertube') + expect(follow.following.url).to.equal('http://localhost:' + servers[1].port + '/accounts/peertube') } } @@ -151,7 +151,7 @@ describe('Test follows moderation', function () { }) it('Should accept a follower', async function () { - await acceptFollower(servers[1].url, servers[1].accessToken, 'peertube@localhost:9001') + await acceptFollower(servers[1].url, servers[1].accessToken, 'peertube@localhost:' + servers[0].port) await waitJobs(servers) await checkServer1And2HasFollowers(servers) @@ -178,7 +178,7 @@ describe('Test follows moderation', function () { expect(res.body.total).to.equal(1) } - await rejectFollower(servers[2].url, servers[2].accessToken, 'peertube@localhost:9001') + await rejectFollower(servers[2].url, servers[2].accessToken, 'peertube@localhost:' + servers[0].port) await waitJobs(servers) await checkServer1And2HasFollowers(servers) diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index 397093cdb..d4155667f 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts @@ -8,7 +8,6 @@ import { cleanupTests, completeVideoCheck } from '../../../../shared/extra-utils import { flushAndRunMultipleServers, getVideosList, - killallServers, ServerInfo, setAccessTokensToServers, uploadVideo @@ -89,8 +88,8 @@ describe('Test follows', function () { res = await getFollowingListPaginationAndSort(servers[0].url, 1, 1, 'createdAt') follows = follows.concat(res.body.data) - const server2Follow = follows.find(f => f.following.host === 'localhost:9002') - const server3Follow = follows.find(f => f.following.host === 'localhost:9003') + const server2Follow = follows.find(f => f.following.host === 'localhost:' + servers[1].port) + const server3Follow = follows.find(f => f.following.host === 'localhost:' + servers[2].port) expect(server2Follow).to.not.be.undefined expect(server3Follow).to.not.be.undefined @@ -100,12 +99,12 @@ describe('Test follows', function () { it('Should search followings on server 1', async function () { { - const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt', ':9002') + const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt', ':' + servers[1].port) const follows = res.body.data expect(res.body.total).to.equal(1) expect(follows.length).to.equal(1) - expect(follows[ 0 ].following.host).to.equal('localhost:9002') + expect(follows[ 0 ].following.host).to.equal('localhost:' + servers[1].port) } { @@ -136,7 +135,7 @@ describe('Test follows', function () { expect(res.body.total).to.equal(1) expect(follows).to.be.an('array') expect(follows.length).to.equal(1) - expect(follows[0].follower.host).to.equal('localhost:9001') + expect(follows[0].follower.host).to.equal('localhost:' + servers[0].port) } }) @@ -147,7 +146,7 @@ describe('Test follows', function () { expect(res.body.total).to.equal(1) expect(follows.length).to.equal(1) - expect(follows[ 0 ].following.host).to.equal('localhost:9003') + expect(follows[ 0 ].following.host).to.equal('localhost:' + servers[2].port) } { @@ -169,16 +168,16 @@ describe('Test follows', function () { }) it('Should have the correct follows counts', async function () { - await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2) - await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) - await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0) + await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[0].port, 0, 2) + await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[1].port, 1, 0) + await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[2].port, 1, 0) // Server 2 and 3 does not know server 1 follow another server (there was not a refresh) - await expectAccountFollows(servers[1].url, 'peertube@localhost:9001', 0, 1) - await expectAccountFollows(servers[1].url, 'peertube@localhost:9002', 1, 0) + await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[0].port, 0, 1) + await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[1].port, 1, 0) - await expectAccountFollows(servers[2].url, 'peertube@localhost:9001', 0, 1) - await expectAccountFollows(servers[2].url, 'peertube@localhost:9003', 1, 0) + await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[0].port, 0, 1) + await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[2].port, 1, 0) }) it('Should unfollow server 3 on server 1', async function () { @@ -197,7 +196,7 @@ describe('Test follows', function () { expect(follows).to.be.an('array') expect(follows.length).to.equal(1) - expect(follows[0].following.host).to.equal('localhost:9002') + expect(follows[0].following.host).to.equal('localhost:' + servers[1].port) }) it('Should not have server 1 as follower on server 3 anymore', async function () { @@ -210,14 +209,14 @@ describe('Test follows', function () { }) it('Should have the correct follows counts 2', async function () { - await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 1) - await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) + await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[0].port, 0, 1) + await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[1].port, 1, 0) - await expectAccountFollows(servers[1].url, 'peertube@localhost:9001', 0, 1) - await expectAccountFollows(servers[1].url, 'peertube@localhost:9002', 1, 0) + await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[0].port, 0, 1) + await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[1].port, 1, 0) - await expectAccountFollows(servers[2].url, 'peertube@localhost:9001', 0, 0) - await expectAccountFollows(servers[2].url, 'peertube@localhost:9003', 0, 0) + await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[0].port, 0, 0) + await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[2].port, 0, 0) }) it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { @@ -310,15 +309,15 @@ describe('Test follows', function () { }) it('Should have the correct follows counts 3', async function () { - await expectAccountFollows(servers[0].url, 'peertube@localhost:9001', 0, 2) - await expectAccountFollows(servers[0].url, 'peertube@localhost:9002', 1, 0) - await expectAccountFollows(servers[0].url, 'peertube@localhost:9003', 1, 0) + await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[0].port, 0, 2) + await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[1].port, 1, 0) + await expectAccountFollows(servers[0].url, 'peertube@localhost:' + servers[2].port, 1, 0) - await expectAccountFollows(servers[1].url, 'peertube@localhost:9001', 0, 1) - await expectAccountFollows(servers[1].url, 'peertube@localhost:9002', 1, 0) + await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[0].port, 0, 1) + await expectAccountFollows(servers[1].url, 'peertube@localhost:' + servers[1].port, 1, 0) - await expectAccountFollows(servers[2].url, 'peertube@localhost:9001', 0, 2) - await expectAccountFollows(servers[2].url, 'peertube@localhost:9003', 1, 0) + await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[0].port, 0, 2) + await expectAccountFollows(servers[2].url, 'peertube@localhost:' + servers[2].port, 1, 0) }) it('Should have propagated videos', async function () { @@ -344,7 +343,7 @@ describe('Test follows', function () { support: 'my super support text', account: { name: 'root', - host: 'localhost:9003' + host: 'localhost:' + servers[2].port }, isLocal, commentsEnabled: true, @@ -384,7 +383,7 @@ describe('Test follows', function () { expect(comment.videoId).to.equal(video4.id) expect(comment.id).to.equal(comment.threadId) expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:9003') + expect(comment.account.host).to.equal('localhost:' + servers[2].port) expect(comment.totalReplies).to.equal(3) expect(dateIsValid(comment.createdAt as string)).to.be.true expect(dateIsValid(comment.updatedAt as string)).to.be.true diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index 19010dbc1..9a8bc08f9 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts @@ -70,7 +70,7 @@ describe('Test handle downs', function () { support: 'my super support text for server 1', account: { name: 'root', - host: 'localhost:9001' + host: 'localhost:' + servers[0].port }, isLocal: false, duration: 10, @@ -172,7 +172,7 @@ describe('Test handle downs', function () { const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 2, 'createdAt') expect(res.body.data).to.be.an('array') expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].follower.host).to.equal('localhost:9003') + expect(res.body.data[0].follower.host).to.equal('localhost:' + servers[2].port) }) it('Should not have pending/processing jobs anymore', async function () { diff --git a/server/tests/api/travis-1.sh b/server/tests/api/travis-1.sh index e4761d2f9..0673bb2bf 100644 --- a/server/tests/api/travis-1.sh +++ b/server/tests/api/travis-1.sh @@ -2,9 +2,9 @@ set -eu -files=$(find server/tests/api/check-params -type f | grep -v index.ts | xargs echo) +notificationsFiles=$(find server/tests/api/notifications -type f | grep -v index.ts | xargs echo) +searchFiles=$(find server/tests/api/search -type f | grep -v index.ts | xargs echo) +checkParamFiles=$(find server/tests/api/check-params -type f | grep -v index.ts | xargs echo) -MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 4 --timeout 5000 --exit --require ts-node/register --bail $files - -mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/notifications/index.ts -mocha --timeout 5000 --exit --require ts-node/register --bail server/tests/api/search/index.ts +MOCHA_PARALLEL=true mocha-parallel-tests --max-parallel 4 --timeout 5000 --exit --require ts-node/register --bail \ + $notificationsFiles $searchFiles $checkParamFiles diff --git a/server/tests/api/users/blocklist.ts b/server/tests/api/users/blocklist.ts index fbc57e0ef..c25e85ada 100644 --- a/server/tests/api/users/blocklist.ts +++ b/server/tests/api/users/blocklist.ts @@ -144,7 +144,7 @@ describe('Test blocklist', function () { }) it('Should block a remote account', async function () { - await addAccountToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:9002') + await addAccountToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port) }) it('Should hide its videos', async function () { @@ -209,7 +209,7 @@ describe('Test blocklist', function () { expect(block.byAccount.name).to.equal('root') expect(block.blockedAccount.displayName).to.equal('user2') expect(block.blockedAccount.name).to.equal('user2') - expect(block.blockedAccount.host).to.equal('localhost:9002') + expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port) } { @@ -223,12 +223,12 @@ describe('Test blocklist', function () { expect(block.byAccount.name).to.equal('root') expect(block.blockedAccount.displayName).to.equal('user1') expect(block.blockedAccount.name).to.equal('user1') - expect(block.blockedAccount.host).to.equal('localhost:9001') + expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port) } }) it('Should unblock the remote account', async function () { - await removeAccountFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:9002') + await removeAccountFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port) }) it('Should display its videos', async function () { @@ -260,7 +260,7 @@ describe('Test blocklist', function () { }) it('Should block a remote server', async function () { - await addServerToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:9002') + await addServerToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port) }) it('Should hide its videos', async function () { @@ -291,11 +291,11 @@ describe('Test blocklist', function () { const block = blocks[ 0 ] expect(block.byAccount.displayName).to.equal('root') expect(block.byAccount.name).to.equal('root') - expect(block.blockedServer.host).to.equal('localhost:9002') + expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) }) it('Should unblock the remote server', async function () { - await removeServerFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:9002') + await removeServerFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port) }) it('Should display its videos', function () { @@ -324,7 +324,7 @@ describe('Test blocklist', function () { }) it('Should block a remote account', async function () { - await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:9002') + await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port) }) it('Should hide its videos', async function () { @@ -387,7 +387,7 @@ describe('Test blocklist', function () { expect(block.byAccount.name).to.equal('peertube') expect(block.blockedAccount.displayName).to.equal('user2') expect(block.blockedAccount.name).to.equal('user2') - expect(block.blockedAccount.host).to.equal('localhost:9002') + expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port) } { @@ -401,12 +401,12 @@ describe('Test blocklist', function () { expect(block.byAccount.name).to.equal('peertube') expect(block.blockedAccount.displayName).to.equal('user1') expect(block.blockedAccount.name).to.equal('user1') - expect(block.blockedAccount.host).to.equal('localhost:9001') + expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port) } }) it('Should unblock the remote account', async function () { - await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:9002') + await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port) }) it('Should display its videos', async function () { @@ -446,7 +446,7 @@ describe('Test blocklist', function () { }) it('Should block a remote server', async function () { - await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:9002') + await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port) }) it('Should hide its videos', async function () { @@ -478,11 +478,11 @@ describe('Test blocklist', function () { const block = blocks[ 0 ] expect(block.byAccount.displayName).to.equal('peertube') expect(block.byAccount.name).to.equal('peertube') - expect(block.blockedServer.host).to.equal('localhost:9002') + expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) }) it('Should unblock the remote server', async function () { - await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:9002') + await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port) }) it('Should list all videos', async function () { diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts index 514acf2e7..3b37a26cf 100644 --- a/server/tests/api/users/users-verification.ts +++ b/server/tests/api/users/users-verification.ts @@ -30,11 +30,12 @@ describe('Test users account verification', function () { before(async function () { this.timeout(30000) - await MockSmtpServer.Instance.collectEmails(emails) + const port = await MockSmtpServer.Instance.collectEmails(emails) const overrideConfig = { smtp: { - hostname: 'localhost' + hostname: 'localhost', + port } } server = await flushAndRunServer(1, overrideConfig) diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 68c1e9a8d..89904759a 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -9,18 +9,17 @@ import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/ import { addVideoChannel, checkTmpIsEmpty, - checkVideoFilesWereRemoved, cleanupTests, + checkVideoFilesWereRemoved, + cleanupTests, completeVideoCheck, createUser, dateIsValid, doubleFollow, flushAndRunMultipleServers, - flushTests, getLocalVideos, getVideo, getVideoChannelsList, getVideosList, - killallServers, rateVideo, removeVideo, ServerInfo, @@ -110,7 +109,7 @@ describe('Test multiple servers', function () { // All servers should have this video let publishedAt: string = null for (const server of servers) { - const isLocal = server.url === 'http://localhost:9001' + const isLocal = server.url === 'http://localhost:' + servers[0].port const checkAttributes = { name: 'my super name for server 1', category: 5, @@ -122,7 +121,7 @@ describe('Test multiple servers', function () { originallyPublishedAt: '2019-02-10T13:38:14.449Z', account: { name: 'root', - host: 'localhost:9001' + host: 'localhost:' + servers[0].port }, isLocal, publishedAt, @@ -187,7 +186,7 @@ describe('Test multiple servers', function () { // All servers should have this video for (const server of servers) { - const isLocal = server.url === 'http://localhost:9002' + const isLocal = server.url === 'http://localhost:' + servers[1].port const checkAttributes = { name: 'my super name for server 2', category: 4, @@ -198,7 +197,7 @@ describe('Test multiple servers', function () { support: 'my super support text for server 2', account: { name: 'user1', - host: 'localhost:9002' + host: 'localhost:' + servers[1].port }, isLocal, commentsEnabled: true, @@ -278,7 +277,7 @@ describe('Test multiple servers', function () { // All servers should have this video for (const server of servers) { - const isLocal = server.url === 'http://localhost:9003' + const isLocal = server.url === 'http://localhost:' + servers[2].port const res = await getVideosList(server.url) const videos = res.body.data @@ -306,7 +305,7 @@ describe('Test multiple servers', function () { support: 'my super support text for server 3', account: { name: 'root', - host: 'localhost:9003' + host: 'localhost:' + servers[2].port }, isLocal, duration: 5, @@ -340,7 +339,7 @@ describe('Test multiple servers', function () { support: 'my super support text for server 3-2', account: { name: 'root', - host: 'localhost:9003' + host: 'localhost:' + servers[2].port }, commentsEnabled: true, downloadEnabled: true, @@ -646,7 +645,7 @@ describe('Test multiple servers', function () { const videoUpdated = videos.find(video => video.name === 'my super video updated') expect(!!videoUpdated).to.be.true - const isLocal = server.url === 'http://localhost:9003' + const isLocal = server.url === 'http://localhost:' + servers[2].port const checkAttributes = { name: 'my super video updated', category: 10, @@ -658,7 +657,7 @@ describe('Test multiple servers', function () { originallyPublishedAt: '2019-02-11T13:38:14.449Z', account: { name: 'root', - host: 'localhost:9003' + host: 'localhost:' + servers[2].port }, isLocal, duration: 5, @@ -813,7 +812,7 @@ describe('Test multiple servers', function () { expect(comment).to.not.be.undefined expect(comment.inReplyToCommentId).to.be.null expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:9001') + expect(comment.account.host).to.equal('localhost:' + servers[0].port) expect(comment.totalReplies).to.equal(3) expect(dateIsValid(comment.createdAt as string)).to.be.true expect(dateIsValid(comment.updatedAt as string)).to.be.true @@ -824,7 +823,7 @@ describe('Test multiple servers', function () { expect(comment).to.not.be.undefined expect(comment.inReplyToCommentId).to.be.null expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:9003') + expect(comment.account.host).to.equal('localhost:' + servers[2].port) expect(comment.totalReplies).to.equal(0) expect(dateIsValid(comment.createdAt as string)).to.be.true expect(dateIsValid(comment.updatedAt as string)).to.be.true @@ -842,25 +841,25 @@ describe('Test multiple servers', function () { const tree: VideoCommentThreadTree = res2.body expect(tree.comment.text).equal('my super first comment') expect(tree.comment.account.name).equal('root') - expect(tree.comment.account.host).equal('localhost:9001') + expect(tree.comment.account.host).equal('localhost:' + servers[0].port) expect(tree.children).to.have.lengthOf(2) const firstChild = tree.children[0] expect(firstChild.comment.text).to.equal('my super answer to thread 1') expect(firstChild.comment.account.name).equal('root') - expect(firstChild.comment.account.host).equal('localhost:9002') + expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port) expect(firstChild.children).to.have.lengthOf(1) childOfFirstChild = firstChild.children[0] expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') expect(childOfFirstChild.comment.account.name).equal('root') - expect(childOfFirstChild.comment.account.host).equal('localhost:9003') + expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port) expect(childOfFirstChild.children).to.have.lengthOf(0) const secondChild = tree.children[1] expect(secondChild.comment.text).to.equal('my second answer to thread 1') expect(secondChild.comment.account.name).equal('root') - expect(secondChild.comment.account.host).equal('localhost:9003') + expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port) expect(secondChild.children).to.have.lengthOf(0) } }) @@ -915,7 +914,7 @@ describe('Test multiple servers', function () { expect(comment).to.not.be.undefined expect(comment.inReplyToCommentId).to.be.null expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:9003') + expect(comment.account.host).to.equal('localhost:' + servers[2].port) expect(comment.totalReplies).to.equal(0) expect(dateIsValid(comment.createdAt as string)).to.be.true expect(dateIsValid(comment.updatedAt as string)).to.be.true @@ -971,7 +970,7 @@ describe('Test multiple servers', function () { const res = await getVideosList(server.url) const video = res.body.data.find(v => v.name === 'minimum parameters') - const isLocal = server.url === 'http://localhost:9002' + const isLocal = server.url === 'http://localhost:' + servers[1].port const checkAttributes = { name: 'minimum parameters', category: null, @@ -982,7 +981,7 @@ describe('Test multiple servers', function () { support: null, account: { name: 'root', - host: 'localhost:9002' + host: 'localhost:' + servers[1].port }, isLocal, duration: 5, diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts index e9ad947b2..38e232e5f 100644 --- a/server/tests/api/videos/services.ts +++ b/server/tests/api/videos/services.ts @@ -27,13 +27,13 @@ describe('Test services', function () { }) it('Should have a valid oEmbed response', async function () { - const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid + const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid const res = await getOEmbed(server.url, oembedUrl) const expectedHtml = '' - const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg' + const expectedThumbnailUrl = 'http://localhost:' + server.port + '/static/previews/' + server.video.uuid + '.jpg' expect(res.body.html).to.equal(expectedHtml) expect(res.body.title).to.equal(server.video.name) @@ -46,14 +46,14 @@ describe('Test services', function () { }) it('Should have a valid oEmbed response with small max height query', async function () { - const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid + const oembedUrl = 'http://localhost:' + server.port + '/videos/watch/' + server.video.uuid const format = 'json' const maxHeight = 50 const maxWidth = 50 const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth) const expectedHtml = '' expect(res.body.html).to.equal(expectedHtml) diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index 1f366b642..b0412f4df 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts @@ -47,7 +47,7 @@ describe('Test a single server', function () { support: 'my super support text', account: { name: 'root', - host: 'localhost:9001' + host: 'localhost:' + server.port }, isLocal: true, duration: 5, @@ -80,7 +80,7 @@ describe('Test a single server', function () { support: 'my super support text updated', account: { name: 'root', - host: 'localhost:9001' + host: 'localhost:' + server.port }, isLocal: true, tags: [ 'tagup1', 'tagup2' ], diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts index 7318497d5..a2f3ee161 100644 --- a/server/tests/api/videos/video-abuse.ts +++ b/server/tests/api/videos/video-abuse.ts @@ -9,7 +9,6 @@ import { flushAndRunMultipleServers, getVideoAbusesList, getVideosList, - killallServers, reportVideoAbuse, ServerInfo, setAccessTokensToServers, @@ -90,7 +89,7 @@ describe('Test video abuses', function () { const abuse: VideoAbuse = res1.body.data[0] expect(abuse.reason).to.equal('my super bad reason') expect(abuse.reporterAccount.name).to.equal('root') - expect(abuse.reporterAccount.host).to.equal('localhost:9001') + expect(abuse.reporterAccount.host).to.equal('localhost:' + servers[0].port) expect(abuse.video.id).to.equal(servers[0].video.id) const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) @@ -118,7 +117,7 @@ describe('Test video abuses', function () { const abuse1: VideoAbuse = res1.body.data[0] expect(abuse1.reason).to.equal('my super bad reason') expect(abuse1.reporterAccount.name).to.equal('root') - expect(abuse1.reporterAccount.host).to.equal('localhost:9001') + expect(abuse1.reporterAccount.host).to.equal('localhost:' + servers[0].port) expect(abuse1.video.id).to.equal(servers[0].video.id) expect(abuse1.state.id).to.equal(VideoAbuseState.PENDING) expect(abuse1.state.label).to.equal('Pending') @@ -127,7 +126,7 @@ describe('Test video abuses', function () { const abuse2: VideoAbuse = res1.body.data[1] expect(abuse2.reason).to.equal('my super bad reason 2') expect(abuse2.reporterAccount.name).to.equal('root') - expect(abuse2.reporterAccount.host).to.equal('localhost:9001') + expect(abuse2.reporterAccount.host).to.equal('localhost:' + servers[0].port) expect(abuse2.video.id).to.equal(servers[1].video.id) expect(abuse2.state.id).to.equal(VideoAbuseState.PENDING) expect(abuse2.state.label).to.equal('Pending') @@ -141,7 +140,7 @@ describe('Test video abuses', function () { abuseServer2 = res2.body.data[0] expect(abuseServer2.reason).to.equal('my super bad reason 2') expect(abuseServer2.reporterAccount.name).to.equal('root') - expect(abuseServer2.reporterAccount.host).to.equal('localhost:9001') + expect(abuseServer2.reporterAccount.host).to.equal('localhost:' + servers[0].port) expect(abuseServer2.state.id).to.equal(VideoAbuseState.PENDING) expect(abuseServer2.state.label).to.equal('Pending') expect(abuseServer2.moderationComment).to.be.null diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 345e96f43..f09148404 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts @@ -213,7 +213,7 @@ describe('Test video channels', function () { this.timeout(10000) for (const server of servers) { - const channelURI = 'second_video_channel@localhost:9001' + const channelURI = 'second_video_channel@localhost:' + server.port const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) expect(res1.body.total).to.equal(1) expect(res1.body.data).to.be.an('array') @@ -234,11 +234,11 @@ describe('Test video channels', function () { this.timeout(10000) for (const server of servers) { - const secondChannelURI = 'second_video_channel@localhost:9001' + const secondChannelURI = 'second_video_channel@localhost:' + server.port const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5) expect(res1.body.total).to.equal(0) - const channelURI = 'root_channel@localhost:9001' + const channelURI = 'root_channel@localhost:' + server.port const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) expect(res2.body.total).to.equal(1) diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index 22fd8c058..82182cc7c 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts @@ -66,8 +66,8 @@ describe('Test video comments', function () { expect(comment.videoId).to.equal(videoId) expect(comment.id).to.equal(comment.threadId) expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:9001') - expect(comment.account.url).to.equal('http://localhost:9001/accounts/root') + expect(comment.account.host).to.equal('localhost:' + server.port) + expect(comment.account.url).to.equal('http://localhost:' + server.port + '/accounts/root') expect(comment.totalReplies).to.equal(0) expect(dateIsValid(comment.createdAt as string)).to.be.true expect(dateIsValid(comment.updatedAt as string)).to.be.true @@ -86,7 +86,7 @@ describe('Test video comments', function () { expect(comment.videoId).to.equal(videoId) expect(comment.id).to.equal(comment.threadId) expect(comment.account.name).to.equal('root') - expect(comment.account.host).to.equal('localhost:9001') + expect(comment.account.host).to.equal('localhost:' + server.port) await testImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png') diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 22031c18b..4565d0ebe 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -5,13 +5,12 @@ import 'mocha' import { checkDirectoryIsEmpty, checkSegmentHash, - checkTmpIsEmpty, cleanupTests, + checkTmpIsEmpty, + cleanupTests, doubleFollow, flushAndRunMultipleServers, - flushTests, getPlaylist, getVideo, - killallServers, removeVideo, ServerInfo, setAccessTokensToServers, @@ -51,7 +50,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { { for (const resolution of resolutions) { - const res2 = await getPlaylist(`http://localhost:9001/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`) + const res2 = await getPlaylist(`http://localhost:${server.port}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`) const subPlaylist = res2.text expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) @@ -59,7 +58,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { } { - const baseUrl = 'http://localhost:9001/static/streaming-playlists/hls' + const baseUrl = 'http://localhost:' + server.port + '/static/streaming-playlists/hls' for (const resolution of resolutions) { await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist) diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 3cd43e99b..45a8c09f0 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -6,21 +6,21 @@ import { omit } from 'lodash' import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos' import { audio, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' import { - buildAbsoluteFixturePath, cleanupTests, + buildAbsoluteFixturePath, + cleanupTests, doubleFollow, flushAndRunMultipleServers, generateHighBitrateVideo, getMyVideos, getVideo, getVideosList, - killallServers, root, ServerInfo, setAccessTokensToServers, uploadVideo, webtorrentAdd } from '../../../../shared/extra-utils' -import { extname, join } from 'path' +import { join } from 'path' import { waitJobs } from '../../../../shared/extra-utils/server/jobs' import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' @@ -121,7 +121,7 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(4) - const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') + const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') const probe = await audio.get(path) if (probe.audioStream) { @@ -152,7 +152,7 @@ describe('Test video transcoding', function () { const videoDetails: VideoDetails = res2.body expect(videoDetails.files).to.have.lengthOf(4) - const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') + const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') const probe = await audio.get(path) expect(probe).to.not.have.property('audioStream') } @@ -179,7 +179,7 @@ describe('Test video transcoding', function () { expect(videoDetails.files).to.have.lengthOf(4) const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) const fixtureVideoProbe = await audio.get(fixturePath) - const path = join(root(), 'test2', 'videos', video.uuid + '-240.mp4') + const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') const videoProbe = await audio.get(path) if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ] @@ -216,13 +216,13 @@ describe('Test video transcoding', function () { expect(videoDetails.files[ 3 ].fps).to.be.below(31) for (const resolution of [ '240', '360', '480' ]) { - const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') + const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') const fps = await getVideoFileFPS(path) expect(fps).to.be.below(31) } - const path = join(root(), 'test2', 'videos', video.uuid + '-720.mp4') + const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-720.mp4') const fps = await getVideoFileFPS(path) expect(fps).to.be.above(58).and.below(62) @@ -310,7 +310,7 @@ describe('Test video transcoding', function () { const video = res.body.data.find(v => v.name === videoAttributes.name) for (const resolution of ['240', '360', '480', '720', '1080']) { - const path = join(root(), 'test2', 'videos', video.uuid + '-' + resolution + '.mp4') + const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') const bitrate = await getVideoFileBitrate(path) const fps = await getVideoFileFPS(path) const resolution2 = await getVideoFileResolution(path) diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts index 5e12c0089..3822fca42 100644 --- a/server/tests/cli/optimize-old-videos.ts +++ b/server/tests/cli/optimize-old-videos.ts @@ -8,14 +8,16 @@ import { doubleFollow, execCLI, flushAndRunMultipleServers, - flushTests, generateHighBitrateVideo, + generateHighBitrateVideo, getEnvCli, getVideo, getVideosList, - killallServers, root, + root, ServerInfo, setAccessTokensToServers, - uploadVideo, viewVideo, wait + uploadVideo, + viewVideo, + wait } from '../../../shared/extra-utils' import { waitJobs } from '../../../shared/extra-utils/server/jobs' import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffmpeg-utils' @@ -102,7 +104,7 @@ describe('Test optimize old videos', function () { expect(file.size).to.be.below(5000000) - const path = join(root(), 'test1', 'videos', video.uuid + '-' + file.resolution.id + '.mp4') + const path = join(root(), 'test' + servers[0].internalServerNumber, 'videos', video.uuid + '-' + file.resolution.id + '.mp4') const bitrate = await getVideoFileBitrate(path) const fps = await getVideoFileFPS(path) const resolution = await getVideoFileResolution(path) diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index ed41bfa48..3992735e1 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts @@ -284,7 +284,7 @@ function cleanupTests (servers: ServerInfo[]) { } async function waitUntilLog (server: ServerInfo, str: string, count = 1) { - const logfile = join(root(), 'test' + server.serverNumber, 'logs/peertube.log') + const logfile = join(root(), 'test' + server.internalServerNumber, 'logs/peertube.log') while (true) { const buf = await readFile(logfile) diff --git a/shared/extra-utils/users/user-notifications.ts b/shared/extra-utils/users/user-notifications.ts index 495ff80d9..f7de542bf 100644 --- a/shared/extra-utils/users/user-notifications.ts +++ b/shared/extra-utils/users/user-notifications.ts @@ -380,7 +380,7 @@ async function checkNewCommentOnMyVideo (base: CheckerBaseParams, uuid: string, } } - const commentUrl = `http://localhost:9001/videos/watch/${uuid};threadId=${threadId}` + const commentUrl = `http://localhost:${base.server.port}/videos/watch/${uuid};threadId=${threadId}` function emailFinder (email: object) { return email[ 'text' ].indexOf(commentUrl) !== -1 }