}
await retryTransactionWrapper(updateVideoFromAP, updateOptions)
await syncVideoExternalAttributes(video, videoObject, options.syncParam)
+
+ return video
} catch (err) {
logger.warn('Cannot refresh video %s.', options.video.url, { err })
return video
setAccessTokensToServers, unfollow,
uploadVideo,
viewVideo,
- wait
+ wait,
+ waitUntilLog
} from '../../utils'
import { waitJobs } from '../../utils/server/jobs'
import * as magnetUtil from 'magnet-uri'
this.timeout(40000)
await waitJobs(servers)
- await wait(15000)
+ await waitUntilLog(servers[0], 'Duplicated ', 4)
await waitJobs(servers)
await check2Webseeds(strategy)
this.timeout(40000)
await waitJobs(servers)
- await wait(15000)
+ await waitUntilLog(servers[0], 'Duplicated ', 4)
await waitJobs(servers)
await check2Webseeds(strategy)
this.timeout(40000)
await waitJobs(servers)
- await wait(15000)
+ await waitUntilLog(servers[0], 'Duplicated ', 4)
await waitJobs(servers)
await check2Webseeds(strategy)
await enableRedundancyOnServer1()
await waitJobs(servers)
- await wait(5000)
+ await waitUntilLog(servers[0], 'Duplicated ', 4)
await waitJobs(servers)
await check2Webseeds(strategy)
})
it('Should cache video 2 webseed on the first video', async function () {
- this.timeout(40000)
- this.retries(3)
+ this.timeout(50000)
await waitJobs(servers)
await wait(7000)
- await check1WebSeed(strategy, video1Server2UUID)
- await check2Webseeds(strategy, video2Server2UUID)
+ try {
+ await check1WebSeed(strategy, video1Server2UUID)
+ await check2Webseeds(strategy, video2Server2UUID)
+ } catch {
+ await wait(7000)
+
+ await check1WebSeed(strategy, video1Server2UUID)
+ await check2Webseeds(strategy, video2Server2UUID)
+ }
})
after(function () {
import { ChildProcess, exec, fork } from 'child_process'
import { join } from 'path'
+import { root, wait } from '../miscs/miscs'
+import { readFile } from 'fs-extra'
interface ServerInfo {
app: ChildProcess,
}
}
+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 {
flushTests,
runServer,
killallServers,
- reRunServer
+ reRunServer,
+ waitUntilLog
}