aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/real-world
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-21 13:43:29 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commit0f91ae62df8a37194fea84ce1efa9e733d9c1fd8 (patch)
tree1cb0fccadebb629d02632dc8e21fae7ba521c464 /server/tests/real-world
parent81de19482b89342c3dbc098a9f512ef7f1056e45 (diff)
downloadPeerTube-0f91ae62df8a37194fea84ce1efa9e733d9c1fd8.tar.gz
PeerTube-0f91ae62df8a37194fea84ce1efa9e733d9c1fd8.tar.zst
PeerTube-0f91ae62df8a37194fea84ce1efa9e733d9c1fd8.zip
Add follow tests
Diffstat (limited to 'server/tests/real-world')
-rw-r--r--server/tests/real-world/real-world.ts745
1 files changed, 372 insertions, 373 deletions
diff --git a/server/tests/real-world/real-world.ts b/server/tests/real-world/real-world.ts
index ac83d64a6..1afa55267 100644
--- a/server/tests/real-world/real-world.ts
+++ b/server/tests/real-world/real-world.ts
@@ -1,373 +1,372 @@
1// /!\ Before imports /!\ 1// // /!\ Before imports /!\
2process.env.NODE_ENV = 'test' 2// process.env.NODE_ENV = 'test'
3 3//
4import * as program from 'commander' 4// import * as program from 'commander'
5import { Video, VideoFile, VideoRateType } from '../../../shared' 5// import { Video, VideoFile, VideoRateType } from '../../../shared'
6import { 6// import {
7 flushAndRunMultipleServers, 7// flushAndRunMultipleServers,
8 flushTests, 8// flushTests,
9 getAllVideosListBy, 9// getAllVideosListBy,
10 getRequestsStats, 10// getVideo,
11 getVideo, 11// getVideosList,
12 getVideosList, 12// killallServers,
13 killallServers, 13// removeVideo,
14 removeVideo, 14// ServerInfo as DefaultServerInfo,
15 ServerInfo as DefaultServerInfo, 15// setAccessTokensToServers,
16 setAccessTokensToServers, 16// updateVideo,
17 updateVideo, 17// uploadVideo,
18 uploadVideo, 18// wait
19 wait 19// } from '../utils'
20} from '../utils' 20// import { follow } from '../utils/follows'
21import { follow } from '../utils/follows' 21//
22 22// interface ServerInfo extends DefaultServerInfo {
23interface ServerInfo extends DefaultServerInfo { 23// requestsNumber: number
24 requestsNumber: number 24// }
25} 25//
26 26// program
27program 27// .option('-c, --create [weight]', 'Weight for creating videos')
28 .option('-c, --create [weight]', 'Weight for creating videos') 28// .option('-r, --remove [weight]', 'Weight for removing videos')
29 .option('-r, --remove [weight]', 'Weight for removing videos') 29// .option('-u, --update [weight]', 'Weight for updating videos')
30 .option('-u, --update [weight]', 'Weight for updating videos') 30// .option('-v, --view [weight]', 'Weight for viewing videos')
31 .option('-v, --view [weight]', 'Weight for viewing videos') 31// .option('-l, --like [weight]', 'Weight for liking videos')
32 .option('-l, --like [weight]', 'Weight for liking videos') 32// .option('-s, --dislike [weight]', 'Weight for disliking videos')
33 .option('-s, --dislike [weight]', 'Weight for disliking videos') 33// .option('-p, --servers [n]', 'Number of servers to run (3 or 6)', /^3|6$/, 3)
34 .option('-p, --servers [n]', 'Number of servers to run (3 or 6)', /^3|6$/, 3) 34// .option('-i, --interval-action [interval]', 'Interval in ms for an action')
35 .option('-i, --interval-action [interval]', 'Interval in ms for an action') 35// .option('-I, --interval-integrity [interval]', 'Interval in ms for an integrity check')
36 .option('-I, --interval-integrity [interval]', 'Interval in ms for an integrity check') 36// .option('-f, --flush', 'Flush datas on exit')
37 .option('-f, --flush', 'Flush datas on exit') 37// .option('-d, --difference', 'Display difference if integrity is not okay')
38 .option('-d, --difference', 'Display difference if integrity is not okay') 38// .parse(process.argv)
39 .parse(process.argv) 39//
40 40// const createWeight = program['create'] !== undefined ? parseInt(program['create'], 10) : 5
41const createWeight = program['create'] !== undefined ? parseInt(program['create'], 10) : 5 41// const removeWeight = program['remove'] !== undefined ? parseInt(program['remove'], 10) : 4
42const removeWeight = program['remove'] !== undefined ? parseInt(program['remove'], 10) : 4 42// const updateWeight = program['update'] !== undefined ? parseInt(program['update'], 10) : 4
43const updateWeight = program['update'] !== undefined ? parseInt(program['update'], 10) : 4 43// const viewWeight = program['view'] !== undefined ? parseInt(program['view'], 10) : 4
44const viewWeight = program['view'] !== undefined ? parseInt(program['view'], 10) : 4 44// const likeWeight = program['like'] !== undefined ? parseInt(program['like'], 10) : 4
45const likeWeight = program['like'] !== undefined ? parseInt(program['like'], 10) : 4 45// const dislikeWeight = program['dislike'] !== undefined ? parseInt(program['dislike'], 10) : 4
46const dislikeWeight = program['dislike'] !== undefined ? parseInt(program['dislike'], 10) : 4 46// const flushAtExit = program['flush'] || false
47const flushAtExit = program['flush'] || false 47// const actionInterval = program['intervalAction'] !== undefined ? parseInt(program['intervalAction'], 10) : 500
48const actionInterval = program['intervalAction'] !== undefined ? parseInt(program['intervalAction'], 10) : 500 48// const integrityInterval = program['intervalIntegrity'] !== undefined ? parseInt(program['intervalIntegrity'], 10) : 60000
49const integrityInterval = program['intervalIntegrity'] !== undefined ? parseInt(program['intervalIntegrity'], 10) : 60000 49// const displayDiffOnFail = program['difference'] || false
50const displayDiffOnFail = program['difference'] || false 50//
51 51// const numberOfServers = 6
52const numberOfServers = 6 52//
53 53// console.log(
54console.log( 54// 'Create weight: %d, update weight: %d, remove weight: %d, view weight: %d, like weight: %d, dislike weight: %d.',
55 'Create weight: %d, update weight: %d, remove weight: %d, view weight: %d, like weight: %d, dislike weight: %d.', 55// createWeight, updateWeight, removeWeight, viewWeight, likeWeight, dislikeWeight
56 createWeight, updateWeight, removeWeight, viewWeight, likeWeight, dislikeWeight 56// )
57) 57//
58 58// if (flushAtExit) {
59if (flushAtExit) { 59// console.log('Program will flush data on exit.')
60 console.log('Program will flush data on exit.') 60// } else {
61} else { 61// console.log('Program will not flush data on exit.')
62 console.log('Program will not flush data on exit.') 62// }
63} 63// if (displayDiffOnFail) {
64if (displayDiffOnFail) { 64// console.log('Program will display diff on failure.')
65 console.log('Program will display diff on failure.') 65// } else {
66} else { 66// console.log('Program will not display diff on failure')
67 console.log('Program will not display diff on failure') 67// }
68} 68// console.log('Interval in ms for each action: %d.', actionInterval)
69console.log('Interval in ms for each action: %d.', actionInterval) 69// console.log('Interval in ms for each integrity check: %d.', integrityInterval)
70console.log('Interval in ms for each integrity check: %d.', integrityInterval) 70//
71 71// console.log('Run servers...')
72console.log('Run servers...') 72//
73 73// start()
74start() 74//
75 75// // ----------------------------------------------------------------------------
76// ---------------------------------------------------------------------------- 76//
77 77// async function start () {
78async function start () { 78// const servers = await runServers(numberOfServers)
79 const servers = await runServers(numberOfServers) 79//
80 80// process.on('exit', async () => {
81 process.on('exit', async () => { 81// await exitServers(servers, flushAtExit)
82 await exitServers(servers, flushAtExit) 82//
83 83// return
84 return 84// })
85 }) 85// process.on('SIGINT', goodbye)
86 process.on('SIGINT', goodbye) 86// process.on('SIGTERM', goodbye)
87 process.on('SIGTERM', goodbye) 87//
88 88// console.log('Servers ran')
89 console.log('Servers ran') 89// initializeRequestsPerServer(servers)
90 initializeRequestsPerServer(servers) 90//
91 91// let checking = false
92 let checking = false 92//
93 93// setInterval(async () => {
94 setInterval(async () => { 94// if (checking === true) return
95 if (checking === true) return 95//
96 96// const rand = getRandomInt(0, createWeight + updateWeight + removeWeight + viewWeight + likeWeight + dislikeWeight)
97 const rand = getRandomInt(0, createWeight + updateWeight + removeWeight + viewWeight + likeWeight + dislikeWeight) 97//
98 98// const numServer = getRandomNumServer(servers)
99 const numServer = getRandomNumServer(servers) 99// servers[numServer].requestsNumber++
100 servers[numServer].requestsNumber++ 100//
101 101// if (rand < createWeight) {
102 if (rand < createWeight) { 102// await upload(servers, numServer)
103 await upload(servers, numServer) 103// } else if (rand < createWeight + updateWeight) {
104 } else if (rand < createWeight + updateWeight) { 104// await update(servers, numServer)
105 await update(servers, numServer) 105// } else if (rand < createWeight + updateWeight + removeWeight) {
106 } else if (rand < createWeight + updateWeight + removeWeight) { 106// await remove(servers, numServer)
107 await remove(servers, numServer) 107// } else if (rand < createWeight + updateWeight + removeWeight + viewWeight) {
108 } else if (rand < createWeight + updateWeight + removeWeight + viewWeight) { 108// await view(servers, numServer)
109 await view(servers, numServer) 109// } else if (rand < createWeight + updateWeight + removeWeight + viewWeight + likeWeight) {
110 } else if (rand < createWeight + updateWeight + removeWeight + viewWeight + likeWeight) { 110// await like(servers, numServer)
111 await like(servers, numServer) 111// } else {
112 } else { 112// await dislike(servers, numServer)
113 await dislike(servers, numServer) 113// }
114 } 114// }, actionInterval)
115 }, actionInterval) 115//
116 116// // The function will check the consistency between servers (should have the same videos with same attributes...)
117 // The function will check the consistency between servers (should have the same videos with same attributes...) 117// setInterval(function () {
118 setInterval(function () { 118// if (checking === true) return
119 if (checking === true) return 119//
120 120// console.log('Checking integrity...')
121 console.log('Checking integrity...') 121// checking = true
122 checking = true 122//
123 123// const waitingInterval = setInterval(async () => {
124 const waitingInterval = setInterval(async () => { 124// const pendingRequests = await isTherePendingRequests(servers)
125 const pendingRequests = await isTherePendingRequests(servers) 125// if (pendingRequests === true) {
126 if (pendingRequests === true) { 126// console.log('A server has pending requests, waiting...')
127 console.log('A server has pending requests, waiting...') 127// return
128 return 128// }
129 } 129//
130 130// // Even if there are no pending request, wait some potential processes
131 // Even if there are no pending request, wait some potential processes 131// await wait(2000)
132 await wait(2000) 132// await checkIntegrity(servers)
133 await checkIntegrity(servers) 133//
134 134// initializeRequestsPerServer(servers)
135 initializeRequestsPerServer(servers) 135// checking = false
136 checking = false 136// clearInterval(waitingInterval)
137 clearInterval(waitingInterval) 137// }, 10000)
138 }, 10000) 138// }, integrityInterval)
139 }, integrityInterval) 139// }
140} 140//
141 141// function initializeRequestsPerServer (servers: ServerInfo[]) {
142function initializeRequestsPerServer (servers: ServerInfo[]) { 142// servers.forEach(server => server.requestsNumber = 0)
143 servers.forEach(server => server.requestsNumber = 0) 143// }
144} 144//
145 145// function getRandomInt (min, max) {
146function getRandomInt (min, max) { 146// return Math.floor(Math.random() * (max - min)) + min
147 return Math.floor(Math.random() * (max - min)) + min 147// }
148} 148//
149 149// function getRandomNumServer (servers) {
150function getRandomNumServer (servers) { 150// return getRandomInt(0, servers.length)
151 return getRandomInt(0, servers.length) 151// }
152} 152//
153 153// async function runServers (numberOfServers: number) {
154async function runServers (numberOfServers: number) { 154// const servers: ServerInfo[] = (await flushAndRunMultipleServers(numberOfServers))
155 const servers: ServerInfo[] = (await flushAndRunMultipleServers(numberOfServers)) 155// .map(s => Object.assign({ requestsNumber: 0 }, s))
156 .map(s => Object.assign({ requestsNumber: 0 }, s)) 156//
157 157// // Get the access tokens
158 // Get the access tokens 158// await setAccessTokensToServers(servers)
159 await setAccessTokensToServers(servers) 159//
160 160// for (let i = 0; i < numberOfServers; i++) {
161 for (let i = 0; i < numberOfServers; i++) { 161// for (let j = 0; j < numberOfServers; j++) {
162 for (let j = 0; j < numberOfServers; j++) { 162// if (i === j) continue
163 if (i === j) continue 163//
164 164// await follow(servers[i].url, [ servers[j].url ], servers[i].accessToken)
165 await follow(servers[i].url, [ servers[j].url ], servers[i].accessToken) 165// }
166 } 166// }
167 } 167//
168 168// return servers
169 return servers 169// }
170} 170//
171 171// async function exitServers (servers: ServerInfo[], flushAtExit: boolean) {
172async function exitServers (servers: ServerInfo[], flushAtExit: boolean) { 172// killallServers(servers)
173 killallServers(servers) 173//
174 174// if (flushAtExit) await flushTests()
175 if (flushAtExit) await flushTests() 175// }
176} 176//
177 177// function upload (servers: ServerInfo[], numServer: number) {
178function upload (servers: ServerInfo[], numServer: number) { 178// console.log('Uploading video to server ' + numServer)
179 console.log('Uploading video to server ' + numServer) 179//
180 180// const videoAttributes = {
181 const videoAttributes = { 181// name: Date.now() + ' name',
182 name: Date.now() + ' name', 182// category: 4,
183 category: 4, 183// nsfw: false,
184 nsfw: false, 184// licence: 2,
185 licence: 2, 185// language: 1,
186 language: 1, 186// description: Date.now() + ' description',
187 description: Date.now() + ' description', 187// tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ],
188 tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ], 188// fixture: 'video_short1.webm'
189 fixture: 'video_short1.webm' 189// }
190 } 190// return uploadVideo(servers[numServer].url, servers[numServer].accessToken, videoAttributes)
191 return uploadVideo(servers[numServer].url, servers[numServer].accessToken, videoAttributes) 191// }
192} 192//
193 193// async function update (servers: ServerInfo[], numServer: number) {
194async function update (servers: ServerInfo[], numServer: number) { 194// const res = await getVideosList(servers[numServer].url)
195 const res = await getVideosList(servers[numServer].url) 195//
196 196// const videos = res.body.data.filter(video => video.isLocal === true)
197 const videos = res.body.data.filter(video => video.isLocal === true) 197// if (videos.length === 0) return undefined
198 if (videos.length === 0) return undefined 198//
199 199// const toUpdate = videos[getRandomInt(0, videos.length)].id
200 const toUpdate = videos[getRandomInt(0, videos.length)].id 200// const attributes = {
201 const attributes = { 201// name: Date.now() + ' name',
202 name: Date.now() + ' name', 202// description: Date.now() + ' description',
203 description: Date.now() + ' description', 203// tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ]
204 tags: [ Date.now().toString().substring(0, 5) + 't1', Date.now().toString().substring(0, 5) + 't2' ] 204// }
205 } 205//
206 206// console.log('Updating video of server ' + numServer)
207 console.log('Updating video of server ' + numServer) 207//
208 208// return updateVideo(servers[numServer].url, servers[numServer].accessToken, toUpdate, attributes)
209 return updateVideo(servers[numServer].url, servers[numServer].accessToken, toUpdate, attributes) 209// }
210} 210//
211 211// async function remove (servers: ServerInfo[], numServer: number) {
212async function remove (servers: ServerInfo[], numServer: number) { 212// const res = await getVideosList(servers[numServer].url)
213 const res = await getVideosList(servers[numServer].url) 213// const videos = res.body.data.filter(video => video.isLocal === true)
214 const videos = res.body.data.filter(video => video.isLocal === true) 214// if (videos.length === 0) return undefined
215 if (videos.length === 0) return undefined 215//
216 216// const toRemove = videos[getRandomInt(0, videos.length)].id
217 const toRemove = videos[getRandomInt(0, videos.length)].id 217//
218 218// console.log('Removing video from server ' + numServer)
219 console.log('Removing video from server ' + numServer) 219// return removeVideo(servers[numServer].url, servers[numServer].accessToken, toRemove)
220 return removeVideo(servers[numServer].url, servers[numServer].accessToken, toRemove) 220// }
221} 221//
222 222// async function view (servers: ServerInfo[], numServer: number) {
223async function view (servers: ServerInfo[], numServer: number) { 223// const res = await getVideosList(servers[numServer].url)
224 const res = await getVideosList(servers[numServer].url) 224//
225 225// const videos = res.body.data
226 const videos = res.body.data 226// if (videos.length === 0) return undefined
227 if (videos.length === 0) return undefined 227//
228 228// const toView = videos[getRandomInt(0, videos.length)].id
229 const toView = videos[getRandomInt(0, videos.length)].id 229//
230 230// console.log('Viewing video from server ' + numServer)
231 console.log('Viewing video from server ' + numServer) 231// return getVideo(servers[numServer].url, toView)
232 return getVideo(servers[numServer].url, toView) 232// }
233} 233//
234 234// function like (servers: ServerInfo[], numServer: number) {
235function like (servers: ServerInfo[], numServer: number) { 235// return rate(servers, numServer, 'like')
236 return rate(servers, numServer, 'like') 236// }
237} 237//
238 238// function dislike (servers: ServerInfo[], numServer: number) {
239function dislike (servers: ServerInfo[], numServer: number) { 239// return rate(servers, numServer, 'dislike')
240 return rate(servers, numServer, 'dislike') 240// }
241} 241//
242 242// async function rate (servers: ServerInfo[], numServer: number, rating: VideoRateType) {
243async function rate (servers: ServerInfo[], numServer: number, rating: VideoRateType) { 243// const res = await getVideosList(servers[numServer].url)
244 const res = await getVideosList(servers[numServer].url) 244//
245 245// const videos = res.body.data
246 const videos = res.body.data 246// if (videos.length === 0) return undefined
247 if (videos.length === 0) return undefined 247//
248 248// const toRate = videos[getRandomInt(0, videos.length)].id
249 const toRate = videos[getRandomInt(0, videos.length)].id 249//
250 250// console.log('Rating (%s) video from server %d', rating, numServer)
251 console.log('Rating (%s) video from server %d', rating, numServer) 251// return getVideo(servers[numServer].url, toRate)
252 return getVideo(servers[numServer].url, toRate) 252// }
253} 253//
254 254// async function checkIntegrity (servers: ServerInfo[]) {
255async function checkIntegrity (servers: ServerInfo[]) { 255// const videos: Video[][] = []
256 const videos: Video[][] = [] 256// const tasks: Promise<any>[] = []
257 const tasks: Promise<any>[] = [] 257//
258 258// // Fetch all videos and remove some fields that can differ between servers
259 // Fetch all videos and remove some fields that can differ between servers 259// for (const server of servers) {
260 for (const server of servers) { 260// const p = getAllVideosListBy(server.url).then(res => videos.push(res.body.data))
261 const p = getAllVideosListBy(server.url).then(res => videos.push(res.body.data)) 261// tasks.push(p)
262 tasks.push(p) 262// }
263 } 263//
264 264// await Promise.all(tasks)
265 await Promise.all(tasks) 265//
266 266// let i = 0
267 let i = 0 267// for (const video of videos) {
268 for (const video of videos) { 268// const differences = areDifferences(video, videos[0])
269 const differences = areDifferences(video, videos[0]) 269// if (differences !== undefined) {
270 if (differences !== undefined) { 270// console.error('Integrity not ok with server %d!', i + 1)
271 console.error('Integrity not ok with server %d!', i + 1) 271//
272 272// if (displayDiffOnFail) {
273 if (displayDiffOnFail) { 273// console.log(differences)
274 console.log(differences) 274// }
275 } 275//
276 276// process.exit(-1)
277 process.exit(-1) 277// }
278 } 278//
279 279// i++
280 i++ 280// }
281 } 281//
282 282// console.log('Integrity ok.')
283 console.log('Integrity ok.') 283// }
284} 284//
285 285// function areDifferences (videos1: Video[], videos2: Video[]) {
286function areDifferences (videos1: Video[], videos2: Video[]) { 286// // Remove some keys we don't want to compare
287 // Remove some keys we don't want to compare 287// videos1.concat(videos2).forEach(video => {
288 videos1.concat(videos2).forEach(video => { 288// delete video.id
289 delete video.id 289// delete video.isLocal
290 delete video.isLocal 290// delete video.thumbnailPath
291 delete video.thumbnailPath 291// delete video.updatedAt
292 delete video.updatedAt 292// delete video.views
293 delete video.views 293// })
294 }) 294//
295 295// if (videos1.length !== videos2.length) {
296 if (videos1.length !== videos2.length) { 296// return `Videos length are different (${videos1.length}/${videos2.length}).`
297 return `Videos length are different (${videos1.length}/${videos2.length}).` 297// }
298 } 298//
299 299// for (const video1 of videos1) {
300 for (const video1 of videos1) { 300// const video2 = videos2.find(video => video.uuid === video1.uuid)
301 const video2 = videos2.find(video => video.uuid === video1.uuid) 301//
302 302// if (!video2) return 'Video ' + video1.uuid + ' is missing.'
303 if (!video2) return 'Video ' + video1.uuid + ' is missing.' 303//
304 304// for (const videoKey of Object.keys(video1)) {
305 for (const videoKey of Object.keys(video1)) { 305// const attribute1 = video1[videoKey]
306 const attribute1 = video1[videoKey] 306// const attribute2 = video2[videoKey]
307 const attribute2 = video2[videoKey] 307//
308 308// if (videoKey === 'tags') {
309 if (videoKey === 'tags') { 309// if (attribute1.length !== attribute2.length) {
310 if (attribute1.length !== attribute2.length) { 310// return 'Tags are different.'
311 return 'Tags are different.' 311// }
312 } 312//
313 313// attribute1.forEach(tag1 => {
314 attribute1.forEach(tag1 => { 314// if (attribute2.indexOf(tag1) === -1) {
315 if (attribute2.indexOf(tag1) === -1) { 315// return 'Tag ' + tag1 + ' is missing.'
316 return 'Tag ' + tag1 + ' is missing.' 316// }
317 } 317// })
318 }) 318// } else if (videoKey === 'files') {
319 } else if (videoKey === 'files') { 319// if (attribute1.length !== attribute2.length) {
320 if (attribute1.length !== attribute2.length) { 320// return 'Video files are different.'
321 return 'Video files are different.' 321// }
322 } 322//
323 323// attribute1.forEach((videoFile1: VideoFile) => {
324 attribute1.forEach((videoFile1: VideoFile) => { 324// const videoFile2: VideoFile = attribute2.find(videoFile => videoFile.magnetUri === videoFile1.magnetUri)
325 const videoFile2: VideoFile = attribute2.find(videoFile => videoFile.magnetUri === videoFile1.magnetUri) 325// if (!videoFile2) {
326 if (!videoFile2) { 326// return `Video ${video1.uuid} has missing video file ${videoFile1.magnetUri}.`
327 return `Video ${video1.uuid} has missing video file ${videoFile1.magnetUri}.` 327// }
328 } 328//
329 329// if (videoFile1.size !== videoFile2.size || videoFile1.resolutionLabel !== videoFile2.resolutionLabel) {
330 if (videoFile1.size !== videoFile2.size || videoFile1.resolutionLabel !== videoFile2.resolutionLabel) { 330// return `Video ${video1.uuid} has different video file ${videoFile1.magnetUri}.`
331 return `Video ${video1.uuid} has different video file ${videoFile1.magnetUri}.` 331// }
332 } 332// })
333 }) 333// } else {
334 } else { 334// if (attribute1 !== attribute2) {
335 if (attribute1 !== attribute2) { 335// return `Video ${video1.uuid} has different value for attribute ${videoKey}.`
336 return `Video ${video1.uuid} has different value for attribute ${videoKey}.` 336// }
337 } 337// }
338 } 338// }
339 } 339// }
340 } 340//
341 341// return undefined
342 return undefined 342// }
343} 343//
344 344// function goodbye () {
345function goodbye () { 345// return process.exit(-1)
346 return process.exit(-1) 346// }
347} 347//
348 348// async function isTherePendingRequests (servers: ServerInfo[]) {
349async function isTherePendingRequests (servers: ServerInfo[]) { 349// const tasks: Promise<any>[] = []
350 const tasks: Promise<any>[] = [] 350// let pendingRequests = false
351 let pendingRequests = false 351//
352 352// // Check if each server has pending request
353 // Check if each server has pending request 353// for (const server of servers) {
354 for (const server of servers) { 354// const p = getRequestsStats(server).then(res => {
355 const p = getRequestsStats(server).then(res => { 355// const stats = res.body
356 const stats = res.body 356//
357 357// if (
358 if ( 358// stats.requestScheduler.totalRequests !== 0 ||
359 stats.requestScheduler.totalRequests !== 0 || 359// stats.requestVideoEventScheduler.totalRequests !== 0 ||
360 stats.requestVideoEventScheduler.totalRequests !== 0 || 360// stats.requestVideoQaduScheduler.totalRequests !== 0
361 stats.requestVideoQaduScheduler.totalRequests !== 0 361// ) {
362 ) { 362// pendingRequests = true
363 pendingRequests = true 363// }
364 } 364// })
365 }) 365//
366 366// tasks.push(p)
367 tasks.push(p) 367// }
368 } 368//
369 369// await Promise.all(tasks)
370 await Promise.all(tasks) 370//
371 371// return pendingRequests
372 return pendingRequests 372// }
373}