waitJobs
} from '@shared/server-commands'
-async function checkFilesInObjectStorage (video: VideoDetails) {
+async function checkFilesInObjectStorage (objectStorage: ObjectStorageCommand, video: VideoDetails) {
for (const file of video.files) {
- expectStartWith(file.fileUrl, ObjectStorageCommand.getMockWebTorrentBaseUrl())
+ expectStartWith(file.fileUrl, objectStorage.getMockWebVideosBaseUrl())
await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
}
const hlsPlaylist = video.streamingPlaylists[0]
for (const file of hlsPlaylist.files) {
- expectStartWith(file.fileUrl, ObjectStorageCommand.getMockPlaylistBaseUrl())
+ expectStartWith(file.fileUrl, objectStorage.getMockPlaylistBaseUrl())
await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
}
- expectStartWith(hlsPlaylist.playlistUrl, ObjectStorageCommand.getMockPlaylistBaseUrl())
+ expectStartWith(hlsPlaylist.playlistUrl, objectStorage.getMockPlaylistBaseUrl())
await makeRawRequest({ url: hlsPlaylist.playlistUrl, expectedStatus: HttpStatusCode.OK_200 })
- expectStartWith(hlsPlaylist.segmentsSha256Url, ObjectStorageCommand.getMockPlaylistBaseUrl())
+ expectStartWith(hlsPlaylist.segmentsSha256Url, objectStorage.getMockPlaylistBaseUrl())
await makeRawRequest({ url: hlsPlaylist.segmentsSha256Url, expectedStatus: HttpStatusCode.OK_200 })
}
-function runTests (objectStorage: boolean) {
+function runTests (enableObjectStorage: boolean) {
let servers: PeerTubeServer[] = []
let videoUUID: string
let publishedAt: string
let shouldBeDeleted: string[]
+ const objectStorage = new ObjectStorageCommand()
before(async function () {
this.timeout(120000)
- const config = objectStorage
- ? ObjectStorageCommand.getDefaultMockConfig()
+ const config = enableObjectStorage
+ ? objectStorage.getDefaultMockConfig()
: {}
// Run server 2 to have transcoding enabled
await doubleFollow(servers[0], servers[1])
- if (objectStorage) await ObjectStorageCommand.prepareDefaultMockBuckets()
+ if (enableObjectStorage) await objectStorage.prepareDefaultMockBuckets()
const { shortUUID } = await servers[0].videos.quickUpload({ name: 'video' })
videoUUID = shortUUID
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5)
- if (objectStorage) await checkFilesInObjectStorage(videoDetails)
+ if (enableObjectStorage) await checkFilesInObjectStorage(objectStorage, videoDetails)
}
})
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5)
- if (objectStorage) await checkFilesInObjectStorage(videoDetails)
+ if (enableObjectStorage) await checkFilesInObjectStorage(objectStorage, videoDetails)
}
})
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5)
- if (objectStorage) await checkFilesInObjectStorage(videoDetails)
+ if (enableObjectStorage) await checkFilesInObjectStorage(objectStorage, videoDetails)
}
})
expect(videoDetails.files).to.have.lengthOf(5)
expect(videoDetails.streamingPlaylists).to.have.lengthOf(0)
- if (objectStorage) await checkFilesInObjectStorage(videoDetails)
+ if (enableObjectStorage) await checkFilesInObjectStorage(objectStorage, videoDetails)
}
})
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(1)
- if (objectStorage) await checkFilesInObjectStorage(videoDetails)
+ if (enableObjectStorage) await checkFilesInObjectStorage(objectStorage, videoDetails)
shouldBeDeleted = [
videoDetails.streamingPlaylists[0].files[0].fileUrl,
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(5)
- if (objectStorage) {
- await checkFilesInObjectStorage(videoDetails)
+ if (enableObjectStorage) {
+ await checkFilesInObjectStorage(objectStorage, videoDetails)
const hlsPlaylist = videoDetails.streamingPlaylists[0]
const resolutions = hlsPlaylist.files.map(f => f.resolution.id)
})
after(async function () {
+ if (objectStorage) await objectStorage.cleanupMock()
+
await cleanupTests(servers)
})
}