]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/real-world/populate-database.ts
Speedup video watch layout build
[github/Chocobozzz/PeerTube.git] / server / tests / real-world / populate-database.ts
index f0f82f7f8cf2fd587906a52c89cb8a5373eaae68..b1c1688e7c571b3ffce56506f34bc29ba8bdd937 100644 (file)
@@ -6,11 +6,11 @@ import {
   getVideosList,
   killallServers,
   rateVideo,
-  runServer,
+  flushAndRunServer,
   ServerInfo,
   setAccessTokensToServers,
   uploadVideo
-} from '../utils'
+} from '../../../shared/extra-utils'
 import * as Bluebird from 'bluebird'
 
 start()
@@ -19,11 +19,10 @@ start()
 // ----------------------------------------------------------------------------
 
 async function start () {
-  await flushTests()
 
   console.log('Flushed tests.')
 
-  const server = await runServer(6)
+  const server = await flushAndRunServer(6)
 
   process.on('exit', async () => {
     killallServers([ server ])
@@ -38,15 +37,26 @@ async function start () {
 
   // 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) {
@@ -55,6 +65,7 @@ function getRandomInt (min, max) {
 
 function createCustomChannel (server: ServerInfo) {
   const videoChannel = {
+    name: Date.now().toString(),
     displayName: Date.now().toString(),
     description: Date.now().toString()
   }
@@ -66,7 +77,7 @@ function createUserCustom (server: ServerInfo) {
   const username = Date.now().toString() + getRandomInt(0, 100000)
   console.log('Creating user %s.', username)
 
-  return createUser(server.url, server.accessToken, username, 'coucou')
+  return createUser({ url: server.url, accessToken: server.accessToken, username: username, password: 'coucou' })
 }
 
 function uploadCustom (server: ServerInfo) {