aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/tests/api/videos/multiple-servers.ts9
-rw-r--r--shared/utils/server/servers.ts19
-rw-r--r--shared/utils/videos/videos.ts2
3 files changed, 28 insertions, 2 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index aa38b6b33..6c281e49e 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -8,6 +8,7 @@ import { VideoPrivacy } from '../../../../shared/models/videos'
8import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' 8import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
9import { 9import {
10 addVideoChannel, 10 addVideoChannel,
11 checkTmpIsEmpty,
11 checkVideoFilesWereRemoved, 12 checkVideoFilesWereRemoved,
12 completeVideoCheck, 13 completeVideoCheck,
13 createUser, 14 createUser,
@@ -1008,6 +1009,14 @@ describe('Test multiple servers', function () {
1008 }) 1009 })
1009 }) 1010 })
1010 1011
1012 describe('TMP directory', function () {
1013 it('Should have an empty tmp directory', async function () {
1014 for (const server of servers) {
1015 await checkTmpIsEmpty(server)
1016 }
1017 })
1018 })
1019
1011 after(async function () { 1020 after(async function () {
1012 killallServers(servers) 1021 killallServers(servers)
1013 1022
diff --git a/shared/utils/server/servers.ts b/shared/utils/server/servers.ts
index 88d2b390c..568385a41 100644
--- a/shared/utils/server/servers.ts
+++ b/shared/utils/server/servers.ts
@@ -1,7 +1,11 @@
1/* tslint:disable:no-unused-expression */
2
1import { ChildProcess, exec, fork } from 'child_process' 3import { ChildProcess, exec, fork } from 'child_process'
2import { join } from 'path' 4import { join } from 'path'
3import { root, wait } from '../miscs/miscs' 5import { root, wait } from '../miscs/miscs'
4import { readFile } from 'fs-extra' 6import { readdir, readFile } from 'fs-extra'
7import { existsSync } from 'fs'
8import { expect } from 'chai'
5 9
6interface ServerInfo { 10interface ServerInfo {
7 app: ChildProcess, 11 app: ChildProcess,
@@ -153,6 +157,18 @@ async function reRunServer (server: ServerInfo, configOverride?: any) {
153 return server 157 return server
154} 158}
155 159
160async function checkTmpIsEmpty (server: ServerInfo) {
161 const testDirectory = 'test' + server.serverNumber
162
163 const directoryPath = join(root(), testDirectory, 'tmp')
164
165 const directoryExists = existsSync(directoryPath)
166 expect(directoryExists).to.be.true
167
168 const files = await readdir(directoryPath)
169 expect(files).to.have.lengthOf(0)
170}
171
156function killallServers (servers: ServerInfo[]) { 172function killallServers (servers: ServerInfo[]) {
157 for (const server of servers) { 173 for (const server of servers) {
158 process.kill(-server.app.pid) 174 process.kill(-server.app.pid)
@@ -175,6 +191,7 @@ async function waitUntilLog (server: ServerInfo, str: string, count = 1) {
175// --------------------------------------------------------------------------- 191// ---------------------------------------------------------------------------
176 192
177export { 193export {
194 checkTmpIsEmpty,
178 ServerInfo, 195 ServerInfo,
179 flushAndRunMultipleServers, 196 flushAndRunMultipleServers,
180 flushTests, 197 flushTests,
diff --git a/shared/utils/videos/videos.ts b/shared/utils/videos/videos.ts
index f5fcc6a8a..0cf6e7c4f 100644
--- a/shared/utils/videos/videos.ts
+++ b/shared/utils/videos/videos.ts
@@ -271,7 +271,7 @@ function removeVideo (url: string, token: string, id: number | string, expectedS
271async function checkVideoFilesWereRemoved ( 271async function checkVideoFilesWereRemoved (
272 videoUUID: string, 272 videoUUID: string,
273 serverNumber: number, 273 serverNumber: number,
274 directories = [ 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ] 274 directories = [ 'redundancy', 'videos', 'thumbnails', 'torrents', 'previews', 'captions' ]
275) { 275) {
276 const testDirectory = 'test' + serverNumber 276 const testDirectory = 'test' + serverNumber
277 277