aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/miscs/sql.ts35
-rw-r--r--shared/extra-utils/server/servers.ts4
-rw-r--r--shared/extra-utils/users/user-notifications.ts2
-rw-r--r--shared/extra-utils/videos/video-playlists.ts4
-rw-r--r--shared/extra-utils/videos/videos.ts4
5 files changed, 25 insertions, 24 deletions
diff --git a/shared/extra-utils/miscs/sql.ts b/shared/extra-utils/miscs/sql.ts
index 3cfae5c23..34477cb78 100644
--- a/shared/extra-utils/miscs/sql.ts
+++ b/shared/extra-utils/miscs/sql.ts
@@ -1,11 +1,12 @@
1import { QueryTypes, Sequelize } from 'sequelize' 1import { QueryTypes, Sequelize } from 'sequelize'
2import { ServerInfo } from '../server/servers'
2 3
3let sequelizes: { [ id: number ]: Sequelize } = {} 4let sequelizes: { [ id: number ]: Sequelize } = {}
4 5
5function getSequelize (serverNumber: number) { 6function getSequelize (internalServerNumber: number) {
6 if (sequelizes[serverNumber]) return sequelizes[serverNumber] 7 if (sequelizes[internalServerNumber]) return sequelizes[internalServerNumber]
7 8
8 const dbname = 'peertube_test' + serverNumber 9 const dbname = 'peertube_test' + internalServerNumber
9 const username = 'peertube' 10 const username = 'peertube'
10 const password = 'peertube' 11 const password = 'peertube'
11 const host = 'localhost' 12 const host = 'localhost'
@@ -18,37 +19,37 @@ function getSequelize (serverNumber: number) {
18 logging: false 19 logging: false
19 }) 20 })
20 21
21 sequelizes[serverNumber] = seq 22 sequelizes[internalServerNumber] = seq
22 23
23 return seq 24 return seq
24} 25}
25 26
26function setActorField (serverNumber: number, to: string, field: string, value: string) { 27function setActorField (internalServerNumber: number, to: string, field: string, value: string) {
27 const seq = getSequelize(serverNumber) 28 const seq = getSequelize(internalServerNumber)
28 29
29 const options = { type: QueryTypes.UPDATE } 30 const options = { type: QueryTypes.UPDATE }
30 31
31 return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options) 32 return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options)
32} 33}
33 34
34function setVideoField (serverNumber: number, uuid: string, field: string, value: string) { 35function setVideoField (internalServerNumber: number, uuid: string, field: string, value: string) {
35 const seq = getSequelize(serverNumber) 36 const seq = getSequelize(internalServerNumber)
36 37
37 const options = { type: QueryTypes.UPDATE } 38 const options = { type: QueryTypes.UPDATE }
38 39
39 return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options) 40 return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)
40} 41}
41 42
42function setPlaylistField (serverNumber: number, uuid: string, field: string, value: string) { 43function setPlaylistField (internalServerNumber: number, uuid: string, field: string, value: string) {
43 const seq = getSequelize(serverNumber) 44 const seq = getSequelize(internalServerNumber)
44 45
45 const options = { type: QueryTypes.UPDATE } 46 const options = { type: QueryTypes.UPDATE }
46 47
47 return seq.query(`UPDATE "videoPlaylist" SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options) 48 return seq.query(`UPDATE "videoPlaylist" SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)
48} 49}
49 50
50async function countVideoViewsOf (serverNumber: number, uuid: string) { 51async function countVideoViewsOf (internalServerNumber: number, uuid: string) {
51 const seq = getSequelize(serverNumber) 52 const seq = getSequelize(internalServerNumber)
52 53
53 // tslint:disable 54 // tslint:disable
54 const query = `SELECT SUM("videoView"."views") AS "total" FROM "videoView" INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'` 55 const query = `SELECT SUM("videoView"."views") AS "total" FROM "videoView" INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'`
@@ -62,11 +63,11 @@ async function countVideoViewsOf (serverNumber: number, uuid: string) {
62 return parseInt(total + '', 10) 63 return parseInt(total + '', 10)
63} 64}
64 65
65async function closeAllSequelize (servers: any[]) { 66async function closeAllSequelize (servers: ServerInfo[]) {
66 for (let i = 1; i <= servers.length; i++) { 67 for (const server of servers) {
67 if (sequelizes[ i ]) { 68 if (sequelizes[ server.internalServerNumber ]) {
68 await sequelizes[ i ].close() 69 await sequelizes[ server.internalServerNumber ].close()
69 delete sequelizes[ i ] 70 delete sequelizes[ server.internalServerNumber ]
70 } 71 }
71 } 72 }
72} 73}
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts
index ed41bfa48..4c7d6862a 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -246,7 +246,7 @@ async function checkTmpIsEmpty (server: ServerInfo) {
246} 246}
247 247
248async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) { 248async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) {
249 const testDirectory = 'test' + server.serverNumber 249 const testDirectory = 'test' + server.internalServerNumber
250 250
251 const directoryPath = join(root(), testDirectory, directory) 251 const directoryPath = join(root(), testDirectory, directory)
252 252
@@ -284,7 +284,7 @@ function cleanupTests (servers: ServerInfo[]) {
284} 284}
285 285
286async function waitUntilLog (server: ServerInfo, str: string, count = 1) { 286async function waitUntilLog (server: ServerInfo, str: string, count = 1) {
287 const logfile = join(root(), 'test' + server.serverNumber, 'logs/peertube.log') 287 const logfile = join(root(), 'test' + server.internalServerNumber, 'logs/peertube.log')
288 288
289 while (true) { 289 while (true) {
290 const buf = await readFile(logfile) 290 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,
380 } 380 }
381 } 381 }
382 382
383 const commentUrl = `http://localhost:9001/videos/watch/${uuid};threadId=${threadId}` 383 const commentUrl = `http://localhost:${base.server.port}/videos/watch/${uuid};threadId=${threadId}`
384 function emailFinder (email: object) { 384 function emailFinder (email: object) {
385 return email[ 'text' ].indexOf(commentUrl) !== -1 385 return email[ 'text' ].indexOf(commentUrl) !== -1
386 } 386 }
diff --git a/shared/extra-utils/videos/video-playlists.ts b/shared/extra-utils/videos/video-playlists.ts
index 4d110a131..fd62bef19 100644
--- a/shared/extra-utils/videos/video-playlists.ts
+++ b/shared/extra-utils/videos/video-playlists.ts
@@ -252,10 +252,10 @@ function reorderVideosPlaylist (options: {
252 252
253async function checkPlaylistFilesWereRemoved ( 253async function checkPlaylistFilesWereRemoved (
254 playlistUUID: string, 254 playlistUUID: string,
255 serverNumber: number, 255 internalServerNumber: number,
256 directories = [ 'thumbnails' ] 256 directories = [ 'thumbnails' ]
257) { 257) {
258 const testDirectory = 'test' + serverNumber 258 const testDirectory = 'test' + internalServerNumber
259 259
260 for (const directory of directories) { 260 for (const directory of directories) {
261 const directoryPath = join(root(), testDirectory, directory) 261 const directoryPath = join(root(), testDirectory, directory)
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index b5a07b792..b64de2470 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -568,8 +568,8 @@ async function completeVideoCheck (
568 expect(file).not.to.be.undefined 568 expect(file).not.to.be.undefined
569 569
570 let extension = extname(attributes.fixture) 570 let extension = extname(attributes.fixture)
571 // Transcoding enabled on server 2, extension will always be .mp4 571 // Transcoding enabled: extension will always be .mp4
572 if (attributes.account.host === 'localhost:9002') extension = '.mp4' 572 if (attributes.files.length > 1) extension = '.mp4'
573 573
574 const magnetUri = file.magnetUri 574 const magnetUri = file.magnetUri
575 expect(file.magnetUri).to.have.lengthOf.above(2) 575 expect(file.magnetUri).to.have.lengthOf.above(2)