aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-24 12:02:04 +0200
committerChocobozzz <me@florianbigard.com>2019-04-24 16:26:24 +0200
commit42e1ec25ece5ef6b7a29d64610e3729578059e52 (patch)
treedb9cf34513d92700599142d3ada366b18e7b0438
parent86ebdf8c46f0663610196b7b012ca1d9c43e1bb2 (diff)
downloadPeerTube-42e1ec25ece5ef6b7a29d64610e3729578059e52.tar.gz
PeerTube-42e1ec25ece5ef6b7a29d64610e3729578059e52.tar.zst
PeerTube-42e1ec25ece5ef6b7a29d64610e3729578059e52.zip
Try to fix travis
-rw-r--r--server/tests/api/check-params/users.ts24
-rw-r--r--server/tests/api/check-params/video-comments.ts11
-rw-r--r--server/tests/api/videos/videos-overview.ts2
-rw-r--r--shared/extra-utils/server/servers.ts76
4 files changed, 68 insertions, 45 deletions
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 00d0a7e2b..d2fea65f6 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -6,9 +6,27 @@ import { join } from 'path'
6import { UserRole, VideoImport, VideoImportState } from '../../../../shared' 6import { UserRole, VideoImport, VideoImportState } from '../../../../shared'
7 7
8import { 8import {
9 createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest, 9 blockUser,
10 makePostBodyRequest, makeUploadRequest, makePutBodyRequest, registerUser, removeUser, flushAndRunServer, ServerInfo, setAccessTokensToServers, 10 createUser,
11 updateUser, uploadVideo, userLogin, deleteMe, unblockUser, blockUser 11 deleteMe,
12 flushAndRunServer,
13 getMyUserInformation,
14 getMyUserVideoRating,
15 getUsersList,
16 immutableAssign,
17 killallServers,
18 makeGetRequest,
19 makePostBodyRequest,
20 makePutBodyRequest,
21 makeUploadRequest,
22 registerUser,
23 removeUser,
24 ServerInfo,
25 setAccessTokensToServers,
26 unblockUser,
27 updateUser,
28 uploadVideo,
29 userLogin
12} from '../../../../shared/extra-utils' 30} from '../../../../shared/extra-utils'
13import { 31import {
14 checkBadCountPagination, 32 checkBadCountPagination,
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index bb14abbfd..dfa4c29b6 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -4,8 +4,15 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { 5import {
6 createUser, 6 createUser,
7 flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePostBodyRequest, flushAndRunServer, ServerInfo, setAccessTokensToServers, 7 flushAndRunServer,
8 uploadVideo, userLogin 8 killallServers,
9 makeDeleteRequest,
10 makeGetRequest,
11 makePostBodyRequest,
12 ServerInfo,
13 setAccessTokensToServers,
14 uploadVideo,
15 userLogin
9} from '../../../../shared/extra-utils' 16} from '../../../../shared/extra-utils'
10import { 17import {
11 checkBadCountPagination, 18 checkBadCountPagination,
diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts
index c921eb74d..c63725d71 100644
--- a/server/tests/api/videos/videos-overview.ts
+++ b/server/tests/api/videos/videos-overview.ts
@@ -2,7 +2,7 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { flushTests, killallServers, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils' 5import { flushAndRunServer, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/extra-utils'
6import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' 6import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews'
7import { VideosOverview } from '../../../../shared/models/overviews' 7import { VideosOverview } from '../../../../shared/models/overviews'
8 8
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts
index 480d12330..add738056 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -87,12 +87,14 @@ function randomServer () {
87 return Math.floor(Math.random() * (high - low) + low) 87 return Math.floor(Math.random() * (high - low) + low)
88} 88}
89 89
90function flushAndRunServer (serverNumber: number, configOverrideArg?: Object, args = []) { 90async function flushAndRunServer (serverNumber: number, configOverrideArg?: Object, args = []) {
91 const parallel = process.env.MOCHA_PARALLEL === 'true' 91 const parallel = process.env.MOCHA_PARALLEL === 'true'
92 92
93 const internalServerNumber = parallel ? randomServer() : serverNumber 93 const internalServerNumber = parallel ? randomServer() : serverNumber
94 const port = 9000 + internalServerNumber 94 const port = 9000 + internalServerNumber
95 95
96 await flushTests(serverNumber)
97
96 const server: ServerInfo = { 98 const server: ServerInfo = {
97 app: null, 99 app: null,
98 port, 100 port,
@@ -175,45 +177,41 @@ function flushAndRunServer (serverNumber: number, configOverrideArg?: Object, ar
175 } 177 }
176 178
177 return new Promise<ServerInfo>(res => { 179 return new Promise<ServerInfo>(res => {
178 flushTests(internalServerNumber) 180 server.app = fork(join(root(), 'dist', 'server.js'), args, options)
179 .then(() => { 181 server.app.stdout.on('data', function onStdout (data) {
180 182 let dontContinue = false
181 server.app = fork(join(root(), 'dist', 'server.js'), args, options) 183
182 server.app.stdout.on('data', function onStdout (data) { 184 // Capture things if we want to
183 let dontContinue = false 185 for (const key of Object.keys(regexps)) {
184 186 const regexp = regexps[ key ]
185 // Capture things if we want to 187 const matches = data.toString().match(regexp)
186 for (const key of Object.keys(regexps)) { 188 if (matches !== null) {
187 const regexp = regexps[ key ] 189 if (key === 'client_id') server.client.id = matches[ 1 ]
188 const matches = data.toString().match(regexp) 190 else if (key === 'client_secret') server.client.secret = matches[ 1 ]
189 if (matches !== null) { 191 else if (key === 'user_username') server.user.username = matches[ 1 ]
190 if (key === 'client_id') server.client.id = matches[ 1 ] 192 else if (key === 'user_password') server.user.password = matches[ 1 ]
191 else if (key === 'client_secret') server.client.secret = matches[ 1 ] 193 }
192 else if (key === 'user_username') server.user.username = matches[ 1 ] 194 }
193 else if (key === 'user_password') server.user.password = matches[ 1 ] 195
194 } 196 // Check if all required sentences are here
195 } 197 for (const key of Object.keys(serverRunString)) {
196 198 if (data.toString().indexOf(key) !== -1) serverRunString[ key ] = true
197 // Check if all required sentences are here 199 if (serverRunString[ key ] === false) dontContinue = true
198 for (const key of Object.keys(serverRunString)) { 200 }
199 if (data.toString().indexOf(key) !== -1) serverRunString[ key ] = true 201
200 if (serverRunString[ key ] === false) dontContinue = true 202 // If no, there is maybe one thing not already initialized (client/user credentials generation...)
201 } 203 if (dontContinue === true) return
202 204
203 // If no, there is maybe one thing not already initialized (client/user credentials generation...) 205 server.app.stdout.removeListener('data', onStdout)
204 if (dontContinue === true) return 206
205 207 process.on('exit', () => {
206 server.app.stdout.removeListener('data', onStdout) 208 try {
207 209 process.kill(server.app.pid)
208 process.on('exit', () => { 210 } catch { /* empty */ }
209 try {
210 process.kill(server.app.pid)
211 } catch { /* empty */ }
212 })
213
214 res(server)
215 })
216 }) 211 })
212
213 res(server)
214 })
217 }) 215 })
218} 216}
219 217