blob: 87d7e944945b93aaeb59cc1c8f6779865c8c08cc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import { ensureDir } from 'fs-extra'
import { isGithubCI } from '../miscs'
import { PeerTubeServer, RunServerOptions } from './server'
async function createSingleServer (serverNumber: number, configOverride?: Object, args = [], options: RunServerOptions = {}) {
const server = new PeerTubeServer({ serverNumber })
await server.flushAndRun(configOverride, args, options)
return server
}
function createMultipleServers (totalServers: number, configOverride?: Object) {
const serverPromises: Promise<PeerTubeServer>[] = []
for (let i = 1; i <= totalServers; i++) {
serverPromises.push(createSingleServer(i, configOverride))
}
return Promise.all(serverPromises)
}
async function killallServers (servers: PeerTubeServer[]) {
return Promise.all(servers.map(s => s.kill()))
}
async function cleanupTests (servers: PeerTubeServer[]) {
await killallServers(servers)
if (isGithubCI()) {
await ensureDir('artifacts')
}
let p: Promise<any>[] = []
for (const server of servers) {
p = p.concat(server.servers.cleanupTests())
}
return Promise.all(p)
}
// ---------------------------------------------------------------------------
export {
createSingleServer,
createMultipleServers,
cleanupTests,
killallServers
}
|