diff options
Diffstat (limited to 'shared/extra-utils')
-rw-r--r-- | shared/extra-utils/miscs/miscs.ts | 10 | ||||
-rw-r--r-- | shared/extra-utils/miscs/sql.ts | 3 | ||||
-rw-r--r-- | shared/extra-utils/server/jobs.ts | 5 | ||||
-rw-r--r-- | shared/extra-utils/server/servers.ts | 4 |
4 files changed, 13 insertions, 9 deletions
diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts index 42250886c..08f41a7e7 100644 --- a/shared/extra-utils/miscs/miscs.ts +++ b/shared/extra-utils/miscs/miscs.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* tslint:disable:no-unused-expression */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import { basename, isAbsolute, join, resolve } from 'path' | 4 | import { basename, dirname, isAbsolute, join, resolve } from 'path' |
5 | import * as request from 'supertest' | 5 | import * as request from 'supertest' |
6 | import * as WebTorrent from 'webtorrent' | 6 | import * as WebTorrent from 'webtorrent' |
7 | import { pathExists, readFile } from 'fs-extra' | 7 | import { ensureDir, pathExists, readFile } from 'fs-extra' |
8 | import * as ffmpeg from 'fluent-ffmpeg' | 8 | import * as ffmpeg from 'fluent-ffmpeg' |
9 | 9 | ||
10 | const expect = chai.expect | 10 | const expect = chai.expect |
@@ -59,12 +59,12 @@ async function testImage (url: string, imageName: string, imagePath: string, ext | |||
59 | expect(data.length).to.be.below(maxLength) | 59 | expect(data.length).to.be.below(maxLength) |
60 | } | 60 | } |
61 | 61 | ||
62 | function buildAbsoluteFixturePath (path: string, customTravisPath = false) { | 62 | function buildAbsoluteFixturePath (path: string, customCIPath = false) { |
63 | if (isAbsolute(path)) { | 63 | if (isAbsolute(path)) { |
64 | return path | 64 | return path |
65 | } | 65 | } |
66 | 66 | ||
67 | if (customTravisPath && process.env.TRAVIS) return join(process.env.HOME, 'fixtures', path) | 67 | if (customCIPath && process.env.GITLAB_CI) return join(root(), 'cached-fixtures', path) |
68 | 68 | ||
69 | return join(root(), 'server', 'tests', 'fixtures', path) | 69 | return join(root(), 'server', 'tests', 'fixtures', path) |
70 | } | 70 | } |
@@ -72,6 +72,8 @@ function buildAbsoluteFixturePath (path: string, customTravisPath = false) { | |||
72 | async function generateHighBitrateVideo () { | 72 | async function generateHighBitrateVideo () { |
73 | const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true) | 73 | const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true) |
74 | 74 | ||
75 | await ensureDir(dirname(tempFixturePath)) | ||
76 | |||
75 | const exists = await pathExists(tempFixturePath) | 77 | const exists = await pathExists(tempFixturePath) |
76 | if (!exists) { | 78 | if (!exists) { |
77 | 79 | ||
diff --git a/shared/extra-utils/miscs/sql.ts b/shared/extra-utils/miscs/sql.ts index 1961a8762..dfe840d8c 100644 --- a/shared/extra-utils/miscs/sql.ts +++ b/shared/extra-utils/miscs/sql.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { QueryTypes, Sequelize } from 'sequelize' | 1 | import { QueryTypes, Sequelize } from 'sequelize' |
2 | import { ServerInfo } from '../server/servers' | 2 | import { ServerInfo } from '../server/servers' |
3 | import { PluginType } from '../../models/plugins/plugin.type' | ||
4 | 3 | ||
5 | let sequelizes: { [ id: number ]: Sequelize } = {} | 4 | let sequelizes: { [ id: number ]: Sequelize } = {} |
6 | 5 | ||
@@ -10,7 +9,7 @@ function getSequelize (internalServerNumber: number) { | |||
10 | const dbname = 'peertube_test' + internalServerNumber | 9 | const dbname = 'peertube_test' + internalServerNumber |
11 | const username = 'peertube' | 10 | const username = 'peertube' |
12 | const password = 'peertube' | 11 | const password = 'peertube' |
13 | const host = 'localhost' | 12 | const host = process.env.GITLAB_CI ? 'postgres' : 'localhost' |
14 | const port = 5432 | 13 | const port = 5432 |
15 | 14 | ||
16 | const seq = new Sequelize(dbname, username, password, { | 15 | const seq = new Sequelize(dbname, username, password, { |
diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts index 692b5e24d..11b570f60 100644 --- a/shared/extra-utils/server/jobs.ts +++ b/shared/extra-utils/server/jobs.ts | |||
@@ -2,6 +2,7 @@ import * as request from 'supertest' | |||
2 | import { Job, JobState } from '../../models' | 2 | import { Job, JobState } from '../../models' |
3 | import { wait } from '../miscs/miscs' | 3 | import { wait } from '../miscs/miscs' |
4 | import { ServerInfo } from './servers' | 4 | import { ServerInfo } from './servers' |
5 | import { inspect } from 'util' | ||
5 | 6 | ||
6 | function getJobsList (url: string, accessToken: string, state: JobState) { | 7 | function getJobsList (url: string, accessToken: string, state: JobState) { |
7 | const path = '/api/v1/jobs/' + state | 8 | const path = '/api/v1/jobs/' + state |
@@ -49,7 +50,9 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) { | |||
49 | .then(res => res.body.data) | 50 | .then(res => res.body.data) |
50 | .then((jobs: Job[]) => jobs.filter(j => j.type !== 'videos-views')) | 51 | .then((jobs: Job[]) => jobs.filter(j => j.type !== 'videos-views')) |
51 | .then(jobs => { | 52 | .then(jobs => { |
52 | if (jobs.length !== 0) pendingRequests = true | 53 | if (jobs.length !== 0) { |
54 | pendingRequests = true | ||
55 | } | ||
53 | }) | 56 | }) |
54 | tasks.push(p) | 57 | tasks.push(p) |
55 | } | 58 | } |
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index 40cf7f0f3..a0720d778 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts | |||
@@ -79,8 +79,8 @@ function flushTests (serverNumber?: number) { | |||
79 | return new Promise<void>((res, rej) => { | 79 | return new Promise<void>((res, rej) => { |
80 | const suffix = serverNumber ? ` -- ${serverNumber}` : '' | 80 | const suffix = serverNumber ? ` -- ${serverNumber}` : '' |
81 | 81 | ||
82 | return exec('npm run clean:server:test' + suffix, err => { | 82 | return exec('npm run clean:server:test' + suffix, (err, _stdout, stderr) => { |
83 | if (err) return rej(err) | 83 | if (err || stderr) return rej(err || new Error(stderr)) |
84 | 84 | ||
85 | return res() | 85 | return res() |
86 | }) | 86 | }) |