Upgrade server packages

This commit is contained in:
Chocobozzz 2017-10-31 16:31:24 +01:00
parent 604e02abcb
commit 53abc4c272
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
17 changed files with 369 additions and 396 deletions

View File

@ -115,7 +115,7 @@
"standard": "^10.0.0", "standard": "^10.0.0",
"supertest": "^3.0.0", "supertest": "^3.0.0",
"tslint": "^5.7.0", "tslint": "^5.7.0",
"tslint-config-standard": "^6.0.0", "tslint-config-standard": "^7.0.0",
"webtorrent": "^0.98.0" "webtorrent": "^0.98.0"
}, },
"scripty": { "scripty": {

View File

@ -19,7 +19,7 @@ import {
videoRateValidator, videoRateValidator,
asyncMiddleware asyncMiddleware
} from '../../../middlewares' } from '../../../middlewares'
import { UserVideoRateUpdate, VideoRateType } from '../../../../shared' import { UserVideoRateUpdate } from '../../../../shared'
const rateVideoRouter = express.Router() const rateVideoRouter = express.Router()
@ -73,7 +73,7 @@ async function rateVideo (req: express.Request, res: express.Response) {
if (rateType === 'none') { // Destroy previous rate if (rateType === 'none') { // Destroy previous rate
await previousRate.destroy() await previousRate.destroy()
} else { // Update previous rate } else { // Update previous rate
previousRate.type = rateType as VideoRateType previousRate.type = rateType
await previousRate.save() await previousRate.save()
} }

View File

@ -122,9 +122,6 @@ async function generateWatchHtmlPage (req: express.Request, res: express.Respons
videoPromise videoPromise
]) ])
file = file as Buffer
video = video as VideoInstance
const html = file.toString() const html = file.toString()
// Let Angular application handle errors // Let Angular application handle errors

View File

@ -103,11 +103,11 @@ const writeFilePromise = promisify2WithVoid<string, any>(writeFile)
const readdirPromise = promisify1<string, string[]>(readdir) const readdirPromise = promisify1<string, string[]>(readdir)
const mkdirpPromise = promisify1<string, string>(mkdirp) const mkdirpPromise = promisify1<string, string>(mkdirp)
const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes) const pseudoRandomBytesPromise = promisify1<number, Buffer>(pseudoRandomBytes)
const accessPromise = promisify1WithVoid<string|Buffer>(access) const accessPromise = promisify1WithVoid<string | Buffer>(access)
const opensslExecPromise = promisify2WithVoid<string, any>(openssl.exec) const opensslExecPromise = promisify2WithVoid<string, any>(openssl.exec)
const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare) const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare)
const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt) const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt)
const bcryptHashPromise = promisify2<any, string|number, string>(bcrypt.hash) const bcryptHashPromise = promisify2<any, string | number, string>(bcrypt.hash)
const createTorrentPromise = promisify2<string, any, any>(createTorrent) const createTorrentPromise = promisify2<string, any, any>(createTorrent)
const rimrafPromise = promisify1WithVoid<string>(rimraf) const rimrafPromise = promisify1WithVoid<string>(rimraf)
const statPromise = promisify1<string, Stats>(stat) const statPromise = promisify1<string, Stats>(stat)

View File

@ -4,7 +4,7 @@ import * as retry from 'async/retry'
import { logger } from './logger' import { logger } from './logger'
type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[] } type RetryTransactionWrapperOptions = { errorMessage: string, arguments?: any[] }
function retryTransactionWrapper (functionToRetry: (... args) => Promise<any>, options: RetryTransactionWrapperOptions) { function retryTransactionWrapper (functionToRetry: (...args) => Promise<any>, options: RetryTransactionWrapperOptions) {
const args = options.arguments ? options.arguments : [] const args = options.arguments ? options.arguments : []
return transactionRetryer(callback => { return transactionRetryer(callback => {

View File

@ -40,7 +40,7 @@ function checkSignature (publicKey: string, data: string, hexSignature: string)
return isValid return isValid
} }
async function sign (data: string|Object) { async function sign (data: string | Object) {
const sign = crypto.createSign(SIGNATURE_ALGORITHM) const sign = crypto.createSign(SIGNATURE_ALGORITHM)
let dataString: string let dataString: string
@ -71,13 +71,13 @@ async function createCertsIfNotExist () {
return return
} }
return await createCerts() return createCerts()
} }
async function cryptPassword (password: string) { async function cryptPassword (password: string) {
const salt = await bcryptGenSaltPromise(BCRYPT_SALT_SIZE) const salt = await bcryptGenSaltPromise(BCRYPT_SALT_SIZE)
return await bcryptHashPromise(password, salt) return bcryptHashPromise(password, salt)
} }
function getMyPrivateCert () { function getMyPrivateCert () {

View File

@ -13,7 +13,7 @@ import { sign } from './peertube-crypto'
type MakeRetryRequestParams = { type MakeRetryRequestParams = {
url: string, url: string,
method: 'GET'|'POST', method: 'GET' | 'POST',
json: Object json: Object
} }
function makeRetryRequest (params: MakeRetryRequestParams) { function makeRetryRequest (params: MakeRetryRequestParams) {
@ -31,7 +31,7 @@ function makeRetryRequest (params: MakeRetryRequestParams) {
} }
type MakeSecureRequestParams = { type MakeSecureRequestParams = {
method: 'GET'|'POST' method: 'GET' | 'POST'
toPod: PodInstance toPod: PodInstance
path: string path: string
data?: Object data?: Object

View File

@ -34,7 +34,7 @@ async function up (utils: {
// Create one author per user that does not already exist // Create one author per user that does not already exist
const users = await utils.db.User.findAll() const users = await utils.db.User.findAll()
for (const user of users) { for (const user of users) {
const author = await utils.db.Author.find({ where: { userId: user.id }}) const author = await utils.db.Author.find({ where: { userId: user.id } })
if (!author) { if (!author) {
await utils.db.Author.create({ await utils.db.Author.create({
name: user.username, name: user.username,
@ -72,7 +72,7 @@ async function up (utils: {
const rawVideos = await utils.sequelize.query(query, options) const rawVideos = await utils.sequelize.query(query, options)
for (const rawVideo of rawVideos) { for (const rawVideo of rawVideos) {
const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId }}) const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId } })
const video = await utils.db.Video.findById(rawVideo.id) const video = await utils.db.Video.findById(rawVideo.id)
video.channelId = videoChannel.id video.channelId = videoChannel.id

View File

@ -3,10 +3,9 @@ import * as express from 'express'
import { database as db } from '../../initializers/database' import { database as db } from '../../initializers/database'
import { checkErrors } from './utils' import { checkErrors } from './utils'
import { logger, isEachUniqueHostValid } from '../../helpers' import { logger, isEachUniqueHostValid, isTestInstance } from '../../helpers'
import { CONFIG } from '../../initializers' import { CONFIG } from '../../initializers'
import { hasFriends } from '../../lib' import { hasFriends } from '../../lib'
import { isTestInstance } from '../../helpers'
const makeFriendsValidator = [ const makeFriendsValidator = [
body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'), body('hosts').custom(isEachUniqueHostValid).withMessage('Should have an array of unique hosts'),

View File

@ -1,7 +1,7 @@
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import * as Promise from 'bluebird' import * as Promise from 'bluebird'
import { getSort } from '../utils' import { getSort, addMethodsToModel } from '../utils'
import { import {
cryptPassword, cryptPassword,
comparePassword, comparePassword,
@ -13,7 +13,6 @@ import {
} from '../../helpers' } from '../../helpers'
import { UserRight, USER_ROLE_LABELS, hasUserRight } from '../../../shared' import { UserRight, USER_ROLE_LABELS, hasUserRight } from '../../../shared'
import { addMethodsToModel } from '../utils'
import { import {
UserInstance, UserInstance,
UserAttributes, UserAttributes,

View File

@ -1,12 +1,11 @@
import * as safeBuffer from 'safe-buffer' import * as safeBuffer from 'safe-buffer'
const Buffer = safeBuffer.Buffer const Buffer = safeBuffer.Buffer
import * as magnetUtil from 'magnet-uri' import * as magnetUtil from 'magnet-uri'
import { map } from 'lodash' import { map, maxBy, truncate } from 'lodash'
import * as parseTorrent from 'parse-torrent' import * as parseTorrent from 'parse-torrent'
import { join } from 'path' import { join } from 'path'
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import * as Promise from 'bluebird' import * as Promise from 'bluebird'
import { maxBy, truncate } from 'lodash'
import { TagInstance } from './tag-interface' import { TagInstance } from './tag-interface'
import { import {

View File

@ -106,7 +106,7 @@ describe('Test video abuses API validators', function () {
it('Should fail with a wrong video', async function () { it('Should fail with a wrong video', async function () {
const wrongPath = '/api/v1/videos/blabla/abuse' const wrongPath = '/api/v1/videos/blabla/abuse'
const fields = {} const fields = {}
await makePostBodyRequest({ url: server.url, path: wrongPath, token: server.accessToken, fields}) await makePostBodyRequest({ url: server.url, path: wrongPath, token: server.accessToken, fields })
}) })
it('Should fail with a non authenticated user', async function () { it('Should fail with a non authenticated user', async function () {

View File

@ -25,12 +25,12 @@ describe('Test advanced friends', function () {
async function makeFriendsWrapper (podNumber: number) { async function makeFriendsWrapper (podNumber: number) {
const server = servers[podNumber - 1] const server = servers[podNumber - 1]
return await makeFriends(server.url, server.accessToken) return makeFriends(server.url, server.accessToken)
} }
async function quitFriendsWrapper (podNumber: number) { async function quitFriendsWrapper (podNumber: number) {
const server = servers[podNumber - 1] const server = servers[podNumber - 1]
return await quitFriends(server.url, server.accessToken) return quitFriends(server.url, server.accessToken)
} }
async function removeFriendWrapper (podNumber: number, podNumberToRemove: number) { async function removeFriendWrapper (podNumber: number, podNumberToRemove: number) {
@ -42,12 +42,12 @@ describe('Test advanced friends', function () {
let friendsList = res.body.data let friendsList = res.body.data
let podToRemove = friendsList.find(friend => (friend.host === serverToRemove.host)) let podToRemove = friendsList.find(friend => (friend.host === serverToRemove.host))
return await quitOneFriend(server.url, server.accessToken, podToRemove.id) return quitOneFriend(server.url, server.accessToken, podToRemove.id)
} }
async function getFriendsListWrapper (podNumber: number) { async function getFriendsListWrapper (podNumber: number) {
const server = servers[podNumber - 1] const server = servers[podNumber - 1]
return await getFriendsList(server.url) return getFriendsList(server.url)
} }
async function uploadVideoWrapper (podNumber: number) { async function uploadVideoWrapper (podNumber: number) {
@ -56,11 +56,11 @@ describe('Test advanced friends', function () {
} }
const server = servers[podNumber - 1] const server = servers[podNumber - 1]
return await uploadVideo(server.url, server.accessToken, videoAttributes) return uploadVideo(server.url, server.accessToken, videoAttributes)
} }
async function getVideosWrapper (podNumber: number) { async function getVideosWrapper (podNumber: number) {
return await getVideosList(servers[podNumber - 1].url) return getVideosList(servers[podNumber - 1].url)
} }
// --------------------------------------------------------------- // ---------------------------------------------------------------

View File

@ -80,11 +80,15 @@ start()
async function start () { async function start () {
const servers = await runServers(numberOfPods) const servers = await runServers(numberOfPods)
process.on('exit', async () => await exitServers(servers, flushAtExit)) process.on('exit', async () => {
await exitServers(servers, flushAtExit)
return
})
process.on('SIGINT', goodbye) process.on('SIGINT', goodbye)
process.on('SIGTERM', goodbye) process.on('SIGTERM', goodbye)
console.log('Servers runned') console.log('Servers ran')
initializeRequestsPerServer(servers) initializeRequestsPerServer(servers)
let checking = false let checking = false
@ -150,10 +154,8 @@ function getRandomNumServer (servers) {
} }
async function runServers (numberOfPods: number) { async function runServers (numberOfPods: number) {
let servers = null const servers: ServerInfo[] = (await flushAndRunMultipleServers(numberOfPods))
.map(s => Object.assign({ requestsNumber: 0 }, s))
// Run servers
servers = await flushAndRunMultipleServers(numberOfPods)
// Get the access tokens // Get the access tokens
await setAccessTokensToServers(servers) await setAccessTokensToServers(servers)

View File

@ -1,7 +1,6 @@
import * as program from 'commander' import * as program from 'commander'
import * as Promise from 'bluebird' import * as Promise from 'bluebird'
import { isAbsolute } from 'path' import { isAbsolute, join } from 'path'
import { join } from 'path'
import { readdirPromise } from '../../../helpers/core-utils' import { readdirPromise } from '../../../helpers/core-utils'
import { execCLI } from '../../utils' import { execCLI } from '../../utils'

View File

@ -33,7 +33,7 @@ interface ServerInfo {
} }
} }
async function flushAndRunMultipleServers (totalServers) { function flushAndRunMultipleServers (totalServers) {
let apps = [] let apps = []
let i = 0 let i = 0

694
yarn.lock

File diff suppressed because it is too large Load Diff