Try to improve redundancy tests
This commit is contained in:
parent
913f08f2bd
commit
792e5b8e5b
|
@ -396,6 +396,8 @@ async function refreshVideoIfNeeded (options: {
|
||||||
}
|
}
|
||||||
await retryTransactionWrapper(updateVideoFromAP, updateOptions)
|
await retryTransactionWrapper(updateVideoFromAP, updateOptions)
|
||||||
await syncVideoExternalAttributes(video, videoObject, options.syncParam)
|
await syncVideoExternalAttributes(video, videoObject, options.syncParam)
|
||||||
|
|
||||||
|
return video
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.warn('Cannot refresh video %s.', options.video.url, { err })
|
logger.warn('Cannot refresh video %s.', options.video.url, { err })
|
||||||
return video
|
return video
|
||||||
|
|
|
@ -157,6 +157,8 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
|
||||||
createdModel.VideoFile = file
|
createdModel.VideoFile = file
|
||||||
|
|
||||||
await sendCreateCacheFile(serverActor, createdModel)
|
await sendCreateCacheFile(serverActor, createdModel)
|
||||||
|
|
||||||
|
logger.info('Duplicated %s - %d -> %s.', video.url, file.resolution, createdModel.url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@ import {
|
||||||
setAccessTokensToServers, unfollow,
|
setAccessTokensToServers, unfollow,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
viewVideo,
|
viewVideo,
|
||||||
wait
|
wait,
|
||||||
|
waitUntilLog
|
||||||
} from '../../utils'
|
} from '../../utils'
|
||||||
import { waitJobs } from '../../utils/server/jobs'
|
import { waitJobs } from '../../utils/server/jobs'
|
||||||
import * as magnetUtil from 'magnet-uri'
|
import * as magnetUtil from 'magnet-uri'
|
||||||
|
@ -225,7 +226,7 @@ describe('Test videos redundancy', function () {
|
||||||
this.timeout(40000)
|
this.timeout(40000)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await wait(15000)
|
await waitUntilLog(servers[0], 'Duplicated ', 4)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await check2Webseeds(strategy)
|
await check2Webseeds(strategy)
|
||||||
|
@ -270,7 +271,7 @@ describe('Test videos redundancy', function () {
|
||||||
this.timeout(40000)
|
this.timeout(40000)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await wait(15000)
|
await waitUntilLog(servers[0], 'Duplicated ', 4)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await check2Webseeds(strategy)
|
await check2Webseeds(strategy)
|
||||||
|
@ -336,7 +337,7 @@ describe('Test videos redundancy', function () {
|
||||||
this.timeout(40000)
|
this.timeout(40000)
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await wait(15000)
|
await waitUntilLog(servers[0], 'Duplicated ', 4)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await check2Webseeds(strategy)
|
await check2Webseeds(strategy)
|
||||||
|
@ -423,7 +424,7 @@ describe('Test videos redundancy', function () {
|
||||||
await enableRedundancyOnServer1()
|
await enableRedundancyOnServer1()
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
await wait(5000)
|
await waitUntilLog(servers[0], 'Duplicated ', 4)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await check2Webseeds(strategy)
|
await check2Webseeds(strategy)
|
||||||
|
@ -434,15 +435,21 @@ describe('Test videos redundancy', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should cache video 2 webseed on the first video', async function () {
|
it('Should cache video 2 webseed on the first video', async function () {
|
||||||
this.timeout(40000)
|
this.timeout(50000)
|
||||||
this.retries(3)
|
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
await wait(7000)
|
await wait(7000)
|
||||||
|
|
||||||
await check1WebSeed(strategy, video1Server2UUID)
|
try {
|
||||||
await check2Webseeds(strategy, video2Server2UUID)
|
await check1WebSeed(strategy, video1Server2UUID)
|
||||||
|
await check2Webseeds(strategy, video2Server2UUID)
|
||||||
|
} catch {
|
||||||
|
await wait(7000)
|
||||||
|
|
||||||
|
await check1WebSeed(strategy, video1Server2UUID)
|
||||||
|
await check2Webseeds(strategy, video2Server2UUID)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
after(function () {
|
after(function () {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { ChildProcess, exec, fork } from 'child_process'
|
import { ChildProcess, exec, fork } from 'child_process'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
|
import { root, wait } from '../miscs/miscs'
|
||||||
|
import { readFile } from 'fs-extra'
|
||||||
|
|
||||||
interface ServerInfo {
|
interface ServerInfo {
|
||||||
app: ChildProcess,
|
app: ChildProcess,
|
||||||
|
@ -157,6 +159,19 @@ function killallServers (servers: ServerInfo[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function waitUntilLog (server: ServerInfo, str: string, count = 1) {
|
||||||
|
const logfile = join(root(), 'test' + server.serverNumber, 'logs/peertube.log')
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const buf = await readFile(logfile)
|
||||||
|
|
||||||
|
const matches = buf.toString().match(new RegExp(str, 'g'))
|
||||||
|
if (matches && matches.length === count) return
|
||||||
|
|
||||||
|
await wait(1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
@ -165,5 +180,6 @@ export {
|
||||||
flushTests,
|
flushTests,
|
||||||
runServer,
|
runServer,
|
||||||
killallServers,
|
killallServers,
|
||||||
reRunServer
|
reRunServer,
|
||||||
|
waitUntilLog
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue