diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /scripts | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/benchmark.ts | 50 | ||||
-rwxr-xr-x | scripts/generate-code-contributors.ts | 4 |
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 @@ | |||
1 | import { registerTSPaths } from '../server/helpers/register-ts-paths' | ||
2 | registerTSPaths() | ||
3 | |||
4 | import * as autocannon from 'autocannon' | 1 | import * as autocannon from 'autocannon' |
5 | import { | ||
6 | addVideoCommentReply, | ||
7 | addVideoCommentThread, | ||
8 | createVideoCaption, | ||
9 | flushAndRunServer, | ||
10 | getVideosList, | ||
11 | killallServers, | ||
12 | ServerInfo, | ||
13 | setAccessTokensToServers, | ||
14 | uploadVideo | ||
15 | } from '@shared/extra-utils' | ||
16 | import { Video, VideoPrivacy } from '@shared/models' | ||
17 | import { writeJson } from 'fs-extra' | 2 | import { writeJson } from 'fs-extra' |
3 | import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | ||
4 | import { Video, VideoPrivacy } from '@shared/models' | ||
5 | import { registerTSPaths } from '../server/helpers/register-ts-paths' | ||
6 | |||
7 | registerTSPaths() | ||
18 | 8 | ||
19 | let server: ServerInfo | 9 | let server: PeerTubeServer |
20 | let video: Video | 10 | let video: Video |
21 | let threadId: number | 11 | let threadId: number |
22 | 12 | ||
@@ -25,7 +15,7 @@ const outfile = process.argv[2] | |||
25 | run() | 15 | run() |
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 | ||
31 | function buildAuthorizationHeader () { | 21 | function buildAuthorizationHeader () { |
@@ -198,7 +188,7 @@ function runBenchmark (options: { | |||
198 | } | 188 | } |
199 | 189 | ||
200 | async function prepare () { | 190 | async 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 @@ | |||
1 | import { registerTSPaths } from '../server/helpers/register-ts-paths' | 1 | import { registerTSPaths } from '../server/helpers/register-ts-paths' |
2 | registerTSPaths() | 2 | registerTSPaths() |
3 | 3 | ||
4 | import { execCLI } from '@shared/extra-utils' | 4 | import { CLICommand } from '@shared/extra-utils' |
5 | 5 | ||
6 | run() | 6 | run() |
7 | .then(() => process.exit(0)) | 7 | .then(() => process.exit(0)) |
@@ -59,7 +59,7 @@ async function run () { | |||
59 | } | 59 | } |
60 | 60 | ||
61 | async function getGitContributors () { | 61 | async 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) |