aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-21 15:51:30 +0200
committerChocobozzz <me@florianbigard.com>2021-07-21 15:51:30 +0200
commita24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch)
treea54b0f6c921ba83a6e909cd0ced325b2d4b8863c /scripts
parent5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff)
parentc63830f15403ac4e750829f27d8bbbdc9a59282c (diff)
downloadPeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz
PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst
PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip
Merge branch 'next' into develop
Diffstat (limited to 'scripts')
-rw-r--r--scripts/benchmark.ts50
-rwxr-xr-xscripts/generate-code-contributors.ts4
2 files changed, 20 insertions, 34 deletions
diff --git a/scripts/benchmark.ts b/scripts/benchmark.ts
index 0cadb36d9..83b932909 100644
--- a/scripts/benchmark.ts
+++ b/scripts/benchmark.ts
@@ -1,22 +1,12 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths()
3
4import * as autocannon from 'autocannon' 1import * as autocannon from 'autocannon'
5import {
6 addVideoCommentReply,
7 addVideoCommentThread,
8 createVideoCaption,
9 flushAndRunServer,
10 getVideosList,
11 killallServers,
12 ServerInfo,
13 setAccessTokensToServers,
14 uploadVideo
15} from '@shared/extra-utils'
16import { Video, VideoPrivacy } from '@shared/models'
17import { writeJson } from 'fs-extra' 2import { writeJson } from 'fs-extra'
3import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
4import { Video, VideoPrivacy } from '@shared/models'
5import { registerTSPaths } from '../server/helpers/register-ts-paths'
6
7registerTSPaths()
18 8
19let server: ServerInfo 9let server: PeerTubeServer
20let video: Video 10let video: Video
21let threadId: number 11let threadId: number
22 12
@@ -25,7 +15,7 @@ const outfile = process.argv[2]
25run() 15run()
26 .catch(err => console.error(err)) 16 .catch(err => console.error(err))
27 .finally(() => { 17 .finally(() => {
28 if (server) killallServers([ server ]) 18 if (server) return killallServers([ server ])
29 }) 19 })
30 20
31function buildAuthorizationHeader () { 21function buildAuthorizationHeader () {
@@ -198,7 +188,7 @@ function runBenchmark (options: {
198} 188}
199 189
200async function prepare () { 190async function prepare () {
201 server = await flushAndRunServer(1, { 191 server = await createSingleServer(1, {
202 rates_limit: { 192 rates_limit: {
203 api: { 193 api: {
204 max: 5_000_000 194 max: 5_000_000
@@ -207,7 +197,7 @@ async function prepare () {
207 }) 197 })
208 await setAccessTokensToServers([ server ]) 198 await setAccessTokensToServers([ server ])
209 199
210 const videoAttributes = { 200 const attributes = {
211 name: 'my super video', 201 name: 'my super video',
212 category: 2, 202 category: 2,
213 nsfw: true, 203 nsfw: true,
@@ -220,33 +210,29 @@ async function prepare () {
220 } 210 }
221 211
222 for (let i = 0; i < 10; i++) { 212 for (let i = 0; i < 10; i++) {
223 Object.assign(videoAttributes, { name: 'my super video ' + i }) 213 await server.videos.upload({ attributes: { ...attributes, name: 'my super video ' + i } })
224 await uploadVideo(server.url, server.accessToken, videoAttributes)
225 } 214 }
226 215
227 const resVideos = await getVideosList(server.url) 216 const { data } = await server.videos.list()
228 video = resVideos.body.data.find(v => v.name === 'my super video 1') 217 video = data.find(v => v.name === 'my super video 1')
229 218
230 for (let i = 0; i < 10; i++) { 219 for (let i = 0; i < 10; i++) {
231 const text = 'my super first comment' 220 const text = 'my super first comment'
232 const res = await addVideoCommentThread(server.url, server.accessToken, video.id, text) 221 const created = await server.comments.createThread({ videoId: video.id, text })
233 threadId = res.body.comment.id 222 threadId = created.id
234 223
235 const text1 = 'my super answer to thread 1' 224 const text1 = 'my super answer to thread 1'
236 const childCommentRes = await addVideoCommentReply(server.url, server.accessToken, video.id, threadId, text1) 225 const child = await server.comments.addReply({ videoId: video.id, toCommentId: threadId, text: text1 })
237 const childCommentId = childCommentRes.body.comment.id
238 226
239 const text2 = 'my super answer to answer of thread 1' 227 const text2 = 'my super answer to answer of thread 1'
240 await addVideoCommentReply(server.url, server.accessToken, video.id, childCommentId, text2) 228 await server.comments.addReply({ videoId: video.id, toCommentId: child.id, text: text2 })
241 229
242 const text3 = 'my second answer to thread 1' 230 const text3 = 'my second answer to thread 1'
243 await addVideoCommentReply(server.url, server.accessToken, video.id, threadId, text3) 231 await server.comments.addReply({ videoId: video.id, toCommentId: threadId, text: text3 })
244 } 232 }
245 233
246 for (const caption of [ 'ar', 'fr', 'en', 'zh' ]) { 234 for (const caption of [ 'ar', 'fr', 'en', 'zh' ]) {
247 await createVideoCaption({ 235 await server.captions.add({
248 url: server.url,
249 accessToken: server.accessToken,
250 language: caption, 236 language: caption,
251 videoId: video.id, 237 videoId: video.id,
252 fixture: 'subtitle-good2.vtt' 238 fixture: 'subtitle-good2.vtt'
diff --git a/scripts/generate-code-contributors.ts b/scripts/generate-code-contributors.ts
index db5af3f91..935ed3c5a 100755
--- a/scripts/generate-code-contributors.ts
+++ b/scripts/generate-code-contributors.ts
@@ -1,7 +1,7 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths' 1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths() 2registerTSPaths()
3 3
4import { execCLI } from '@shared/extra-utils' 4import { CLICommand } from '@shared/extra-utils'
5 5
6run() 6run()
7 .then(() => process.exit(0)) 7 .then(() => process.exit(0))
@@ -59,7 +59,7 @@ async function run () {
59} 59}
60 60
61async function getGitContributors () { 61async function getGitContributors () {
62 const output = await execCLI(`git --no-pager shortlog -sn < /dev/tty | sed 's/^\\s\\+[0-9]\\+\\s\\+//g'`) 62 const output = await CLICommand.exec(`git --no-pager shortlog -sn < /dev/tty | sed 's/^\\s\\+[0-9]\\+\\s\\+//g'`)
63 63
64 return output.split('\n') 64 return output.split('\n')
65 .filter(l => !!l) 65 .filter(l => !!l)