-import { registerTSPaths } from '../server/helpers/register-ts-paths'
-registerTSPaths()
-
-import * as autocannon from 'autocannon'
+import autocannon, { printResult } from 'autocannon'
+import { program } from 'commander'
import { writeJson } from 'fs-extra'
-import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
import { Video, VideoPrivacy } from '@shared/models'
+import { createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
let server: PeerTubeServer
let video: Video
let threadId: number
-const outfile = process.argv[2]
+program
+ .option('-o, --outfile [outfile]', 'Outfile')
+ .option('--grep [string]', 'Filter tests you want to execute')
+ .description('Run API REST benchmark')
+ .parse(process.argv)
+
+const options = program.opts()
+
+const outfile = options.outfile
run()
.catch(err => console.error(err))
title: 'API - config',
path: '/api/v1/config',
expecter: (body, status) => {
- return status === 200 && body.startsWith('{"instance":')
+ return status === 200 && body.startsWith('{"client":')
}
}
- ]
+ ].filter(t => {
+ if (!options.grep) return true
+
+ return t.title.includes(options.grep)
+ })
const finalResult: any[] = []
Object.assign(testResult, { title: test.title, path: test.path })
finalResult.push(testResult)
- console.log(autocannon.printResult(testResult))
+ console.log(printResult(testResult))
}
if (outfile) await writeJson(outfile, finalResult)
language: 'fr',
privacy: VideoPrivacy.PUBLIC,
support: 'please give me a coffee',
- description: 'my super description'.repeat(10),
+ description: 'my super description\n'.repeat(10) + ' * list1\n * list 2\n * list 3',
tags: [ 'tag1', 'tag2', 'tag3' ]
}