import { merge } from 'lodash'
import {
checkTmpIsEmpty,
+ checkWebTorrentWorks,
expectLogDoesNotContain,
expectStartWith,
generateHighBitrateVideo,
- MockObjectStorage
+ MockObjectStorageProxy,
+ SQLCommand
} from '@server/tests/shared'
import { areMockObjectStorageTestsDisabled } from '@shared/core-utils'
+import { sha1 } from '@shared/extra-utils'
import { HttpStatusCode, VideoDetails } from '@shared/models'
import {
cleanupTests,
ObjectStorageCommand,
PeerTubeServer,
setAccessTokensToServers,
- waitJobs,
- webtorrentAdd
+ waitJobs
} from '@shared/server-commands'
async function checkFiles (options: {
+ server: PeerTubeServer
+ originServer: PeerTubeServer
+ originSQLCommand: SQLCommand
+
video: VideoDetails
baseMockUrl?: string
webtorrentPrefix?: string
}) {
const {
+ server,
+ originServer,
+ originSQLCommand,
video,
playlistBucket,
webtorrentBucket,
const resSha = await makeRawRequest({ url: hls.segmentsSha256Url, expectedStatus: HttpStatusCode.OK_200 })
expect(JSON.stringify(resSha.body)).to.not.throw
+ let i = 0
for (const file of hls.files) {
expectStartWith(file.fileUrl, start)
expectStartWith(location, start)
await makeRawRequest({ url: location, expectedStatus: HttpStatusCode.OK_200 })
+
+ if (originServer.internalServerNumber === server.internalServerNumber) {
+ const infohash = sha1(`${2 + hls.playlistUrl}+V${i}`)
+ const dbInfohashes = await originSQLCommand.getPlaylistInfohash(hls.id)
+
+ expect(dbInfohashes).to.include(infohash)
+ }
+
+ i++
}
}
for (const file of allFiles) {
- const torrent = await webtorrentAdd(file.magnetUri, true)
-
- expect(torrent.files).to.be.an('array')
- expect(torrent.files.length).to.equal(1)
- expect(torrent.files[0].path).to.exist.and.to.not.equal('')
+ await checkWebTorrentWorks(file.magnetUri)
const res = await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
expect(res.body).to.have.length.above(100)
useMockBaseUrl?: boolean
}) {
- const mockObjectStorage = new MockObjectStorage()
+ const mockObjectStorageProxy = new MockObjectStorageProxy()
const { fixture } = options
let baseMockUrl: string
let servers: PeerTubeServer[]
+ let sqlCommands: SQLCommand[] = []
let keptUrls: string[] = []
let deletedUrls: string[] = []
before(async function () {
- this.timeout(120000)
+ this.timeout(240000)
- const port = await mockObjectStorage.initialize()
- baseMockUrl = options.useMockBaseUrl ? `http://localhost:${port}` : undefined
+ const port = await mockObjectStorageProxy.initialize()
+ baseMockUrl = options.useMockBaseUrl
+ ? `http://127.0.0.1:${port}`
+ : undefined
await ObjectStorageCommand.createMockBucket(options.playlistBucket)
await ObjectStorageCommand.createMockBucket(options.webtorrentBucket)
const files = await server.videos.listFiles({ id: uuid })
keptUrls = keptUrls.concat(files.map(f => f.fileUrl))
}
+
+ sqlCommands = servers.map(s => new SQLCommand(s))
})
it('Should upload a video and move it to the object storage without transcoding', async function () {
for (const server of servers) {
const video = await server.videos.get({ id: uuid })
- const files = await checkFiles({ ...options, video, baseMockUrl })
+ const files = await checkFiles({ ...options, server, originServer: servers[0], originSQLCommand: sqlCommands[0], video, baseMockUrl })
deletedUrls = deletedUrls.concat(files)
}
for (const server of servers) {
const video = await server.videos.get({ id: uuid })
- const files = await checkFiles({ ...options, video, baseMockUrl })
+ const files = await checkFiles({ ...options, server, originServer: servers[0], originSQLCommand: sqlCommands[0], video, baseMockUrl })
deletedUrls = deletedUrls.concat(files)
}
})
after(async function () {
- await mockObjectStorage.terminate()
+ await mockObjectStorageProxy.terminate()
+
+ for (const sqlCommand of sqlCommands) {
+ await sqlCommand.cleanup()
+ }
await cleanupTests(servers)
})
const { uuid } = await server.videos.quickUpload({ name: 'video' })
- await waitJobs([ server ], true)
+ await waitJobs([ server ], { skipDelayed: true })
const video = await server.videos.get({ id: uuid })
expectStartWith(video.files[0].fileUrl, server.url)
const { uuid } = await server.videos.quickUpload({ name: 'video' })
- await waitJobs([ server ], true)
+ await waitJobs([ server ], { skipDelayed: true })
const video = await server.videos.get({ id: uuid })
expectStartWith(video.files[0].fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl())
})
after(async function () {
- await killallServers([ server ])
+ await cleanupTests([ server ])
})
})