Introduce CLI command
This commit is contained in:
parent
a6a79eae0d
commit
329619b345
|
@ -1,7 +1,7 @@
|
||||||
import { registerTSPaths } from '../server/helpers/register-ts-paths'
|
import { registerTSPaths } from '../server/helpers/register-ts-paths'
|
||||||
registerTSPaths()
|
registerTSPaths()
|
||||||
|
|
||||||
import { execCLI } from '@shared/extra-utils'
|
import { CLICommand } from '@shared/extra-utils'
|
||||||
|
|
||||||
run()
|
run()
|
||||||
.then(() => process.exit(0))
|
.then(() => process.exit(0))
|
||||||
|
@ -59,7 +59,7 @@ async function run () {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getGitContributors () {
|
async function getGitContributors () {
|
||||||
const output = await execCLI(`git --no-pager shortlog -sn < /dev/tty | sed 's/^\\s\\+[0-9]\\+\\s\\+//g'`)
|
const output = await CLICommand.exec(`git --no-pager shortlog -sn < /dev/tty | sed 's/^\\s\\+[0-9]\\+\\s\\+//g'`)
|
||||||
|
|
||||||
return output.split('\n')
|
return output.split('\n')
|
||||||
.filter(l => !!l)
|
.filter(l => !!l)
|
||||||
|
|
|
@ -6,9 +6,7 @@ import { VideoFile } from '@shared/models/videos/video-file.model'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
execCLI,
|
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
getEnvCli,
|
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
|
@ -57,8 +55,8 @@ describe('Test create import video jobs', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should run a import job on video 1 with a lower resolution', async function () {
|
it('Should run a import job on video 1 with a lower resolution', async function () {
|
||||||
const env = getEnvCli(servers[0])
|
const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`
|
||||||
await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`)
|
await servers[0].cliCommand.execWithEnv(command)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -77,8 +75,8 @@ describe('Test create import video jobs', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should run a import job on video 2 with the same resolution and a different extension', async function () {
|
it('Should run a import job on video 2 with the same resolution and a different extension', async function () {
|
||||||
const env = getEnvCli(servers[1])
|
const command = `npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`
|
||||||
await execCLI(`${env} npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`)
|
await servers[1].cliCommand.execWithEnv(command)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -99,8 +97,8 @@ describe('Test create import video jobs', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should run a import job on video 2 with the same resolution and the same extension', async function () {
|
it('Should run a import job on video 2 with the same resolution and the same extension', async function () {
|
||||||
const env = getEnvCli(servers[0])
|
const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`
|
||||||
await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`)
|
await servers[0].cliCommand.execWithEnv(command)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,10 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { VideoDetails } from '../../../shared/models/videos'
|
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
execCLI,
|
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
getEnvCli,
|
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
|
@ -17,6 +14,7 @@ import {
|
||||||
uploadVideo
|
uploadVideo
|
||||||
} from '../../../shared/extra-utils'
|
} from '../../../shared/extra-utils'
|
||||||
import { waitJobs } from '../../../shared/extra-utils/server/jobs'
|
import { waitJobs } from '../../../shared/extra-utils/server/jobs'
|
||||||
|
import { VideoDetails } from '../../../shared/models/videos'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -81,9 +79,7 @@ describe('Test create transcoding jobs', function () {
|
||||||
it('Should run a transcoding job on video 2', async function () {
|
it('Should run a transcoding job on video 2', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(servers[0])
|
await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`)
|
||||||
await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[1]}`)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
|
@ -123,8 +119,7 @@ describe('Test create transcoding jobs', function () {
|
||||||
it('Should run a transcoding job on video 1 with resolution', async function () {
|
it('Should run a transcoding job on video 1 with resolution', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(servers[0])
|
await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`)
|
||||||
await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -147,8 +142,7 @@ describe('Test create transcoding jobs', function () {
|
||||||
it('Should generate an HLS resolution', async function () {
|
it('Should generate an HLS resolution', async function () {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
|
|
||||||
const env = getEnvCli(servers[0])
|
await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
|
||||||
await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -168,8 +162,7 @@ describe('Test create transcoding jobs', function () {
|
||||||
it('Should not duplicate an HLS resolution', async function () {
|
it('Should not duplicate an HLS resolution', async function () {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
|
|
||||||
const env = getEnvCli(servers[0])
|
await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
|
||||||
await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -186,8 +179,7 @@ describe('Test create transcoding jobs', function () {
|
||||||
it('Should generate all HLS resolutions', async function () {
|
it('Should generate all HLS resolutions', async function () {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
|
|
||||||
const env = getEnvCli(servers[0])
|
await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`)
|
||||||
await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
@ -209,8 +201,7 @@ describe('Test create transcoding jobs', function () {
|
||||||
config.transcoding.hls.enabled = true
|
config.transcoding.hls.enabled = true
|
||||||
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config)
|
||||||
|
|
||||||
const env = getEnvCli(servers[0])
|
await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`)
|
||||||
await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[4]}`)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,8 @@ import {
|
||||||
buildServerDirectory,
|
buildServerDirectory,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
execCLI,
|
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
generateHighBitrateVideo,
|
generateHighBitrateVideo,
|
||||||
getEnvCli,
|
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
|
@ -73,9 +71,7 @@ describe('Test optimize old videos', function () {
|
||||||
it('Should run optimize script', async function () {
|
it('Should run optimize script', async function () {
|
||||||
this.timeout(200000)
|
this.timeout(200000)
|
||||||
|
|
||||||
const env = getEnvCli(servers[0])
|
await servers[0].cliCommand.execWithEnv('npm run optimize-old-videos')
|
||||||
await execCLI(`${env} npm run optimize-old-videos`)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
|
|
|
@ -8,11 +8,10 @@ import {
|
||||||
areHttpImportTestsDisabled,
|
areHttpImportTestsDisabled,
|
||||||
buildAbsoluteFixturePath,
|
buildAbsoluteFixturePath,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
CLICommand,
|
||||||
createUser,
|
createUser,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
execCLI,
|
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getEnvCli,
|
|
||||||
getLocalIdByUUID,
|
getLocalIdByUUID,
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
|
@ -30,6 +29,8 @@ describe('Test CLI wrapper', function () {
|
||||||
let server: ServerInfo
|
let server: ServerInfo
|
||||||
let userAccessToken: string
|
let userAccessToken: string
|
||||||
|
|
||||||
|
let cliCommand: CLICommand
|
||||||
|
|
||||||
const cmd = 'node ./dist/server/tools/peertube.js'
|
const cmd = 'node ./dist/server/tools/peertube.js'
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
|
@ -46,6 +47,8 @@ describe('Test CLI wrapper', function () {
|
||||||
const args = { name: 'user_channel', displayName: 'User channel', support: 'super support text' }
|
const args = { name: 'user_channel', displayName: 'User channel', support: 'super support text' }
|
||||||
await addVideoChannel(server.url, userAccessToken, args)
|
await addVideoChannel(server.url, userAccessToken, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cliCommand = server.cliCommand
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Authentication and instance selection', function () {
|
describe('Authentication and instance selection', function () {
|
||||||
|
@ -53,46 +56,38 @@ describe('Test CLI wrapper', function () {
|
||||||
it('Should display no selected instance', async function () {
|
it('Should display no selected instance', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
const stdout = await cliCommand.execWithEnv(`${cmd} --help`)
|
||||||
const stdout = await execCLI(`${env} ${cmd} --help`)
|
|
||||||
|
|
||||||
expect(stdout).to.contain('no instance selected')
|
expect(stdout).to.contain('no instance selected')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should add a user', async function () {
|
it('Should add a user', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
await cliCommand.execWithEnv(`${cmd} auth add -u ${server.url} -U user_1 -p super_password`)
|
||||||
await execCLI(`${env} ${cmd} auth add -u ${server.url} -U user_1 -p super_password`)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should not fail to add a user if there is a slash at the end of the instance URL', async function () {
|
it('Should not fail to add a user if there is a slash at the end of the instance URL', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
let fullServerURL = server.url + '/'
|
||||||
let fullServerURL
|
|
||||||
fullServerURL = server.url + '/'
|
await cliCommand.execWithEnv(`${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`)
|
||||||
await execCLI(`${env} ${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`)
|
|
||||||
|
|
||||||
fullServerURL = server.url + '/asdfasdf'
|
fullServerURL = server.url + '/asdfasdf'
|
||||||
await execCLI(`${env} ${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`)
|
await cliCommand.execWithEnv(`${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should default to this user', async function () {
|
it('Should default to this user', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
const stdout = await cliCommand.execWithEnv(`${cmd} --help`)
|
||||||
const stdout = await execCLI(`${env} ${cmd} --help`)
|
|
||||||
|
|
||||||
expect(stdout).to.contain(`instance ${server.url} selected`)
|
expect(stdout).to.contain(`instance ${server.url} selected`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should remember the user', async function () {
|
it('Should remember the user', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
const stdout = await cliCommand.execWithEnv(`${cmd} auth list`)
|
||||||
const stdout = await execCLI(`${env} ${cmd} auth list`)
|
|
||||||
|
|
||||||
expect(stdout).to.contain(server.url)
|
expect(stdout).to.contain(server.url)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -102,13 +97,10 @@ describe('Test CLI wrapper', function () {
|
||||||
it('Should upload a video', async function () {
|
it('Should upload a video', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
|
||||||
|
|
||||||
const fixture = buildAbsoluteFixturePath('60fps_720p_small.mp4')
|
const fixture = buildAbsoluteFixturePath('60fps_720p_small.mp4')
|
||||||
|
|
||||||
const params = `-f ${fixture} --video-name 'test upload' --channel-name user_channel --support 'support_text'`
|
const params = `-f ${fixture} --video-name 'test upload' --channel-name user_channel --support 'support_text'`
|
||||||
|
|
||||||
await execCLI(`${env} ${cmd} upload ${params}`)
|
await cliCommand.execWithEnv(`${cmd} upload ${params}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have the video uploaded', async function () {
|
it('Should have the video uploaded', async function () {
|
||||||
|
@ -130,11 +122,8 @@ describe('Test CLI wrapper', function () {
|
||||||
|
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
|
||||||
|
|
||||||
const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel`
|
const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel`
|
||||||
|
await cliCommand.execWithEnv(`${cmd} import ${params}`)
|
||||||
await execCLI(`${env} ${cmd} import ${params}`)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have imported the video', async function () {
|
it('Should have imported the video', async function () {
|
||||||
|
@ -166,11 +155,8 @@ describe('Test CLI wrapper', function () {
|
||||||
|
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
|
||||||
|
|
||||||
const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel --video-name toto --nsfw --support support`
|
const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel --video-name toto --nsfw --support support`
|
||||||
|
await cliCommand.execWithEnv(`${cmd} import ${params}`)
|
||||||
await execCLI(`${env} ${cmd} import ${params}`)
|
|
||||||
|
|
||||||
await waitJobs([ server ])
|
await waitJobs([ server ])
|
||||||
|
|
||||||
|
@ -194,18 +180,14 @@ describe('Test CLI wrapper', function () {
|
||||||
describe('Admin auth', function () {
|
describe('Admin auth', function () {
|
||||||
|
|
||||||
it('Should remove the auth user', async function () {
|
it('Should remove the auth user', async function () {
|
||||||
const env = getEnvCli(server)
|
await cliCommand.execWithEnv(`${cmd} auth del ${server.url}`)
|
||||||
|
|
||||||
await execCLI(`${env} ${cmd} auth del ${server.url}`)
|
|
||||||
|
|
||||||
const stdout = await execCLI(`${env} ${cmd} --help`)
|
|
||||||
|
|
||||||
|
const stdout = await cliCommand.execWithEnv(`${cmd} --help`)
|
||||||
expect(stdout).to.contain('no instance selected')
|
expect(stdout).to.contain('no instance selected')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should add the admin user', async function () {
|
it('Should add the admin user', async function () {
|
||||||
const env = getEnvCli(server)
|
await cliCommand.execWithEnv(`${cmd} auth add -u ${server.url} -U root -p test${server.internalServerNumber}`)
|
||||||
await execCLI(`${env} ${cmd} auth add -u ${server.url} -U root -p test${server.internalServerNumber}`)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -214,8 +196,7 @@ describe('Test CLI wrapper', function () {
|
||||||
it('Should install a plugin', async function () {
|
it('Should install a plugin', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
await cliCommand.execWithEnv(`${cmd} plugins install --npm-name peertube-plugin-hello-world`)
|
||||||
await execCLI(`${env} ${cmd} plugins install --npm-name peertube-plugin-hello-world`)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have registered settings', async function () {
|
it('Should have registered settings', async function () {
|
||||||
|
@ -223,15 +204,13 @@ describe('Test CLI wrapper', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should list installed plugins', async function () {
|
it('Should list installed plugins', async function () {
|
||||||
const env = getEnvCli(server)
|
const res = await cliCommand.execWithEnv(`${cmd} plugins list`)
|
||||||
const res = await execCLI(`${env} ${cmd} plugins list`)
|
|
||||||
|
|
||||||
expect(res).to.contain('peertube-plugin-hello-world')
|
expect(res).to.contain('peertube-plugin-hello-world')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should uninstall the plugin', async function () {
|
it('Should uninstall the plugin', async function () {
|
||||||
const env = getEnvCli(server)
|
const res = await cliCommand.execWithEnv(`${cmd} plugins uninstall --npm-name peertube-plugin-hello-world`)
|
||||||
const res = await execCLI(`${env} ${cmd} plugins uninstall --npm-name peertube-plugin-hello-world`)
|
|
||||||
|
|
||||||
expect(res).to.not.contain('peertube-plugin-hello-world')
|
expect(res).to.not.contain('peertube-plugin-hello-world')
|
||||||
})
|
})
|
||||||
|
@ -262,11 +241,8 @@ describe('Test CLI wrapper', function () {
|
||||||
it('Should add a redundancy', async function () {
|
it('Should add a redundancy', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
|
||||||
|
|
||||||
const params = `add --video ${video1Server2}`
|
const params = `add --video ${video1Server2}`
|
||||||
|
await cliCommand.execWithEnv(`${cmd} redundancy ${params}`)
|
||||||
await execCLI(`${env} ${cmd} redundancy ${params}`)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
@ -275,10 +251,8 @@ describe('Test CLI wrapper', function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
{
|
{
|
||||||
const env = getEnvCli(server)
|
|
||||||
|
|
||||||
const params = 'list-my-redundancies'
|
const params = 'list-my-redundancies'
|
||||||
const stdout = await execCLI(`${env} ${cmd} redundancy ${params}`)
|
const stdout = await cliCommand.execWithEnv(`${cmd} redundancy ${params}`)
|
||||||
|
|
||||||
expect(stdout).to.contain('super video')
|
expect(stdout).to.contain('super video')
|
||||||
expect(stdout).to.contain(`localhost:${server.port}`)
|
expect(stdout).to.contain(`localhost:${server.port}`)
|
||||||
|
@ -288,18 +262,14 @@ describe('Test CLI wrapper', function () {
|
||||||
it('Should remove a redundancy', async function () {
|
it('Should remove a redundancy', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
|
||||||
|
|
||||||
const params = `remove --video ${video1Server2}`
|
const params = `remove --video ${video1Server2}`
|
||||||
|
await cliCommand.execWithEnv(`${cmd} redundancy ${params}`)
|
||||||
await execCLI(`${env} ${cmd} redundancy ${params}`)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
{
|
{
|
||||||
const env = getEnvCli(server)
|
|
||||||
const params = 'list-my-redundancies'
|
const params = 'list-my-redundancies'
|
||||||
const stdout = await execCLI(`${env} ${cmd} redundancy ${params}`)
|
const stdout = await cliCommand.execWithEnv(`${cmd} redundancy ${params}`)
|
||||||
|
|
||||||
expect(stdout).to.not.contain('super video')
|
expect(stdout).to.not.contain('super video')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
import { expect } from 'chai'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
execCLI,
|
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getConfig,
|
getConfig,
|
||||||
getEnvCli,
|
|
||||||
getPluginTestPath,
|
getPluginTestPath,
|
||||||
killallServers,
|
killallServers,
|
||||||
reRunServer,
|
reRunServer,
|
||||||
|
@ -14,7 +13,6 @@ import {
|
||||||
setAccessTokensToServers
|
setAccessTokensToServers
|
||||||
} from '../../../shared/extra-utils'
|
} from '../../../shared/extra-utils'
|
||||||
import { ServerConfig } from '../../../shared/models/server'
|
import { ServerConfig } from '../../../shared/models/server'
|
||||||
import { expect } from 'chai'
|
|
||||||
|
|
||||||
describe('Test plugin scripts', function () {
|
describe('Test plugin scripts', function () {
|
||||||
let server: ServerInfo
|
let server: ServerInfo
|
||||||
|
@ -31,15 +29,13 @@ describe('Test plugin scripts', function () {
|
||||||
|
|
||||||
const packagePath = getPluginTestPath()
|
const packagePath = getPluginTestPath()
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
await server.cliCommand.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
|
||||||
await execCLI(`${env} npm run plugin:install -- --plugin-path ${packagePath}`)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should install a theme from stateless CLI', async function () {
|
it('Should install a theme from stateless CLI', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
await server.cliCommand.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`)
|
||||||
await execCLI(`${env} npm run plugin:install -- --npm-name peertube-theme-background-red`)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have the theme and the plugin registered when we restart peertube', async function () {
|
it('Should have the theme and the plugin registered when we restart peertube', async function () {
|
||||||
|
@ -63,8 +59,7 @@ describe('Test plugin scripts', function () {
|
||||||
it('Should uninstall a plugin from stateless CLI', async function () {
|
it('Should uninstall a plugin from stateless CLI', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
await server.cliCommand.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
|
||||||
await execCLI(`${env} npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have removed the plugin on another peertube restart', async function () {
|
it('Should have removed the plugin on another peertube restart', async function () {
|
||||||
|
|
|
@ -2,14 +2,15 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { execCLI } from '../../../shared/extra-utils'
|
import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils'
|
||||||
|
import { CLICommand } from '@shared/extra-utils'
|
||||||
import { getTargetBitrate, VideoResolution } from '../../../shared/models/videos'
|
import { getTargetBitrate, VideoResolution } from '../../../shared/models/videos'
|
||||||
import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants'
|
import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants'
|
||||||
import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
describe('Test create transcoding jobs', function () {
|
describe('Test create transcoding jobs', function () {
|
||||||
|
|
||||||
it('Should print the correct command for each resolution', async function () {
|
it('Should print the correct command for each resolution', async function () {
|
||||||
const fixturePath = 'server/tests/fixtures/video_short.webm'
|
const fixturePath = 'server/tests/fixtures/video_short.webm'
|
||||||
const fps = await getVideoFileFPS(fixturePath)
|
const fps = await getVideoFileFPS(fixturePath)
|
||||||
|
@ -19,7 +20,7 @@ describe('Test create transcoding jobs', function () {
|
||||||
VideoResolution.H_720P,
|
VideoResolution.H_720P,
|
||||||
VideoResolution.H_1080P
|
VideoResolution.H_1080P
|
||||||
]) {
|
]) {
|
||||||
const command = await execCLI(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`)
|
const command = await CLICommand.exec(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`)
|
||||||
const targetBitrate = Math.min(getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS), bitrate)
|
const targetBitrate = Math.min(getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS), bitrate)
|
||||||
|
|
||||||
expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`)
|
expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`)
|
||||||
|
|
|
@ -9,12 +9,11 @@ import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-code
|
||||||
import {
|
import {
|
||||||
buildServerDirectory,
|
buildServerDirectory,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
CLICommand,
|
||||||
createVideoPlaylist,
|
createVideoPlaylist,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
execCLI,
|
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
getAccount,
|
getAccount,
|
||||||
getEnvCli,
|
|
||||||
killallServers,
|
killallServers,
|
||||||
makeGetRequest,
|
makeGetRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
|
@ -193,8 +192,8 @@ describe('Test prune storage scripts', function () {
|
||||||
it('Should run prune storage', async function () {
|
it('Should run prune storage', async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
const env = getEnvCli(servers[0])
|
const env = servers[0].cliCommand.getEnv()
|
||||||
await execCLI(`echo y | ${env} npm run prune-storage`)
|
await CLICommand.exec(`echo y | ${env} npm run prune-storage`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have removed files', async function () {
|
it('Should have removed files', async function () {
|
||||||
|
|
|
@ -7,9 +7,7 @@ import {
|
||||||
buildServerDirectory,
|
buildServerDirectory,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
execCLI,
|
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
getEnvCli,
|
|
||||||
getVideo,
|
getVideo,
|
||||||
makeRawRequest,
|
makeRawRequest,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
|
@ -91,8 +89,7 @@ describe('Test regenerate thumbnails script', function () {
|
||||||
it('Should regenerate local thumbnails from the CLI', async function () {
|
it('Should regenerate local thumbnails from the CLI', async function () {
|
||||||
this.timeout(15000)
|
this.timeout(15000)
|
||||||
|
|
||||||
const env = getEnvCli(servers[0])
|
await servers[0].cliCommand.execWithEnv(`npm run regenerate-thumbnails`)
|
||||||
await execCLI(`${env} npm run regenerate-thumbnails`)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have generated new thumbnail files', async function () {
|
it('Should have generated new thumbnail files', async function () {
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
CLICommand,
|
||||||
createUser,
|
createUser,
|
||||||
execCLI,
|
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getEnvCli,
|
|
||||||
login,
|
login,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers
|
setAccessTokensToServers
|
||||||
} from '../../../shared/extra-utils'
|
} from '../../../shared/extra-utils'
|
||||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
describe('Test reset password scripts', function () {
|
describe('Test reset password scripts', function () {
|
||||||
let server: ServerInfo
|
let server: ServerInfo
|
||||||
|
@ -26,8 +24,8 @@ describe('Test reset password scripts', function () {
|
||||||
it('Should change the user password from CLI', async function () {
|
it('Should change the user password from CLI', async function () {
|
||||||
this.timeout(60000)
|
this.timeout(60000)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
const env = server.cliCommand.getEnv()
|
||||||
await execCLI(`echo coucou | ${env} npm run reset-password -- -u user_1`)
|
await CLICommand.exec(`echo coucou | ${env} npm run reset-password -- -u user_1`)
|
||||||
|
|
||||||
await login(server.url, server.client, { username: 'user_1', password: 'coucou' }, HttpStatusCode.OK_200)
|
await login(server.url, server.client, { username: 'user_1', password: 'coucou' }, HttpStatusCode.OK_200)
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,27 +2,26 @@
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import { VideoDetails } from '../../../shared/models/videos'
|
|
||||||
import { waitJobs } from '../../../shared/extra-utils/server/jobs'
|
|
||||||
import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
|
|
||||||
import {
|
import {
|
||||||
addVideoChannel,
|
addVideoChannel,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
createUser,
|
createUser,
|
||||||
execCLI,
|
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getEnvCli,
|
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideoChannelsList,
|
getVideoChannelsList,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
killallServers,
|
killallServers,
|
||||||
makeActivityPubGetRequest,
|
makeActivityPubGetRequest,
|
||||||
parseTorrentVideo, reRunServer,
|
parseTorrentVideo,
|
||||||
|
reRunServer,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo
|
uploadVideo
|
||||||
} from '../../../shared/extra-utils'
|
} from '../../../shared/extra-utils'
|
||||||
|
import { waitJobs } from '../../../shared/extra-utils/server/jobs'
|
||||||
import { getAccountsList } from '../../../shared/extra-utils/users/accounts'
|
import { getAccountsList } from '../../../shared/extra-utils/users/accounts'
|
||||||
|
import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments'
|
||||||
|
import { VideoDetails } from '../../../shared/models/videos'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -72,8 +71,7 @@ describe('Test update host scripts', function () {
|
||||||
// Run server with standard configuration
|
// Run server with standard configuration
|
||||||
await reRunServer(server)
|
await reRunServer(server)
|
||||||
|
|
||||||
const env = getEnvCli(server)
|
await server.cliCommand.execWithEnv(`npm run update-host`)
|
||||||
await execCLI(`${env} npm run update-host`)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have updated videos url', async function () {
|
it('Should have updated videos url', async function () {
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './bulk'
|
|
@ -1,24 +1,27 @@
|
||||||
import { exec } from 'child_process'
|
import { exec } from 'child_process'
|
||||||
|
import { AbstractCommand } from '../shared'
|
||||||
|
|
||||||
import { ServerInfo } from '../server/servers'
|
class CLICommand extends AbstractCommand {
|
||||||
|
|
||||||
function getEnvCli (server?: ServerInfo) {
|
static exec (command: string) {
|
||||||
return `NODE_ENV=test NODE_APP_INSTANCE=${server.internalServerNumber}`
|
|
||||||
}
|
|
||||||
|
|
||||||
async function execCLI (command: string) {
|
|
||||||
return new Promise<string>((res, rej) => {
|
return new Promise<string>((res, rej) => {
|
||||||
exec(command, (err, stdout, stderr) => {
|
exec(command, (err, stdout, _stderr) => {
|
||||||
if (err) return rej(err)
|
if (err) return rej(err)
|
||||||
|
|
||||||
return res(stdout)
|
return res(stdout)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
getEnv () {
|
||||||
|
return `NODE_ENV=test NODE_APP_INSTANCE=${this.server.internalServerNumber}`
|
||||||
|
}
|
||||||
|
|
||||||
|
async execWithEnv (command: string) {
|
||||||
|
return CLICommand.exec(`${this.getEnv()} ${command}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
execCLI,
|
CLICommand
|
||||||
getEnvCli
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './cli'
|
|
@ -1,6 +1,6 @@
|
||||||
export * from './bulk/bulk'
|
export * from './bulk'
|
||||||
|
|
||||||
export * from './cli/cli'
|
export * from './cli'
|
||||||
|
|
||||||
export * from './custom-pages/custom-pages'
|
export * from './custom-pages/custom-pages'
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ import { copy, ensureDir, pathExists, readdir, readFile, remove } from 'fs-extra
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { randomInt } from '../../core-utils/miscs/miscs'
|
import { randomInt } from '../../core-utils/miscs/miscs'
|
||||||
import { VideoChannel } from '../../models/videos'
|
import { VideoChannel } from '../../models/videos'
|
||||||
|
import { BulkCommand } from '../bulk'
|
||||||
|
import { CLICommand } from '../cli'
|
||||||
import { buildServerDirectory, getFileSize, isGithubCI, root, wait } from '../miscs/miscs'
|
import { buildServerDirectory, getFileSize, isGithubCI, root, wait } from '../miscs/miscs'
|
||||||
import { makeGetRequest } from '../requests/requests'
|
import { makeGetRequest } from '../requests/requests'
|
||||||
|
|
||||||
|
@ -60,6 +62,9 @@ interface ServerInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
videos?: { id: number, uuid: string }[]
|
videos?: { id: number, uuid: string }[]
|
||||||
|
|
||||||
|
bulkCommand?: BulkCommand
|
||||||
|
cliCommand?: CLICommand
|
||||||
}
|
}
|
||||||
|
|
||||||
function parallelTests () {
|
function parallelTests () {
|
||||||
|
@ -265,6 +270,9 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
|
||||||
} catch { /* empty */ }
|
} catch { /* empty */ }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
server.bulkCommand = new BulkCommand(server)
|
||||||
|
server.cliCommand = new CLICommand(server)
|
||||||
|
|
||||||
res(server)
|
res(server)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue