]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/real-world/populate-database.ts
Graceful job queue shutdown
[github/Chocobozzz/PeerTube.git] / server / tests / real-world / populate-database.ts
index 5f93d09dbfcab9c1fb03721813337e7d7ca04582..d41ac8d3633b5be286b221e14e6305e3934fd5be 100644 (file)
@@ -19,6 +19,12 @@ start()
 // ----------------------------------------------------------------------------
 
 async function start () {
+  await flushTests()
+
+  console.log('Flushed tests.')
+
+  const server = await runServer(6)
+
   process.on('exit', async () => {
     killallServers([ server ])
     return
@@ -26,26 +32,32 @@ async function start () {
   process.on('SIGINT', goodbye)
   process.on('SIGTERM', goodbye)
 
-  await flushTests()
-
-  console.log('Flushed tests.')
-
-  const server = await runServer(6)
   await setAccessTokensToServers([ server ])
 
   console.log('Servers ran.')
 
   // Forever
   const fakeTab = Array.from(Array(1000000).keys())
-  await Bluebird.map(fakeTab, () => {
-    return Promise.all([
-      uploadCustom(server),
-      likeCustom(server),
-      dislikeCustom(server),
-      createUserCustom(server),
-      createCustomChannel(server)
-    ]).catch(err => console.error(err))
-  }, { concurrency: 5 })
+  const funs = [
+    uploadCustom
+    // uploadCustom,
+    // uploadCustom,
+    // uploadCustom,
+    // likeCustom,
+    // createUserCustom,
+    // createCustomChannel
+  ]
+  const promises = []
+
+  for (const fun of funs) {
+    promises.push(
+      Bluebird.map(fakeTab, () => {
+        return fun(server).catch(err => console.error(err))
+      }, { concurrency: 3 })
+    )
+  }
+
+  await Promise.all(promises)
 }
 
 function getRandomInt (min, max) {