From 65e6e2602c0d5521f3a6740f7469bb92830ecb53 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 11:51:09 +0200 Subject: Introduce config command --- server/tests/api/videos/video-hls.ts | 41 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'server/tests/api/videos/video-hls.ts') diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 03ac3f321..3821cfed0 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -3,6 +3,7 @@ import 'mocha' import * as chai from 'chai' import { join } from 'path' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { checkDirectoryIsEmpty, checkResolutionsInMasterPlaylist, @@ -17,7 +18,6 @@ import { removeVideo, ServerInfo, setAccessTokensToServers, - updateCustomSubConfig, updateVideo, uploadVideo, waitJobs, @@ -26,7 +26,6 @@ import { import { VideoDetails } from '../../../../shared/models/videos' import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' const expect = chai.expect @@ -192,24 +191,26 @@ describe('Test HLS videos', function () { describe('With only HLS enabled', function () { before(async function () { - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, { - transcoding: { - enabled: true, - allowAudioFiles: true, - resolutions: { - '240p': true, - '360p': true, - '480p': true, - '720p': true, - '1080p': true, - '1440p': true, - '2160p': true - }, - hls: { - enabled: true - }, - webtorrent: { - enabled: false + await servers[0].configCommand.updateCustomSubConfig({ + newConfig: { + transcoding: { + enabled: true, + allowAudioFiles: true, + resolutions: { + '240p': true, + '360p': true, + '480p': true, + '720p': true, + '1080p': true, + '1440p': true, + '2160p': true + }, + hls: { + enabled: true + }, + webtorrent: { + enabled: false + } } } }) -- cgit v1.2.3 From 57f879a540551c3b958b0991c8e1e3657a4481d8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 10:21:10 +0200 Subject: Introduce streaming playlists command --- server/tests/api/videos/video-hls.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'server/tests/api/videos/video-hls.ts') diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 3821cfed0..3dd8c9066 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -12,7 +12,6 @@ import { cleanupTests, doubleFollow, flushAndRunMultipleServers, - getPlaylist, getVideo, makeRawRequest, removeVideo, @@ -67,10 +66,9 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn } { - await checkResolutionsInMasterPlaylist(hlsPlaylist.playlistUrl, resolutions) + await checkResolutionsInMasterPlaylist({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions }) - const res = await getPlaylist(hlsPlaylist.playlistUrl) - const masterPlaylist = res.text + const masterPlaylist = await server.streamingPlaylistsCommand.get({ url: hlsPlaylist.playlistUrl }) for (const resolution of resolutions) { expect(masterPlaylist).to.contain(`${resolution}.m3u8`) @@ -80,9 +78,10 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn { for (const resolution of resolutions) { - const res = await getPlaylist(`${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`) + const subPlaylist = await server.streamingPlaylistsCommand.get({ + url: `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8` + }) - const subPlaylist = res.text expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) } } @@ -91,7 +90,14 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn const baseUrlAndPath = baseUrl + '/static/streaming-playlists/hls' for (const resolution of resolutions) { - await checkSegmentHash(baseUrlAndPath, baseUrlAndPath, videoUUID, resolution, hlsPlaylist) + await checkSegmentHash({ + server, + baseUrlPlaylist: baseUrlAndPath, + baseUrlSegment: baseUrlAndPath, + videoUUID, + resolution, + hlsPlaylist + }) } } } -- cgit v1.2.3 From dd0ebb715123dfa126a82d4e4fe3a04064ae77b8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 16:23:01 +0200 Subject: Introduce notifications command --- server/tests/api/videos/video-hls.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'server/tests/api/videos/video-hls.ts') diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 3dd8c9066..428e1316d 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -109,6 +109,7 @@ describe('Test HLS videos', function () { let videoAudioUUID = '' function runTestSuite (hlsOnly: boolean) { + it('Should upload a video and transcode it to HLS', async function () { this.timeout(120000) -- cgit v1.2.3 From d23dd9fbfc4d26026352c10f81d2795ceaf2908a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Jul 2021 10:02:54 +0200 Subject: Introduce videos command --- server/tests/api/videos/video-hls.ts | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'server/tests/api/videos/video-hls.ts') diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 428e1316d..d63b81694 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -3,7 +3,7 @@ import 'mocha' import * as chai from 'chai' import { join } from 'path' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '@shared/core-utils' import { checkDirectoryIsEmpty, checkResolutionsInMasterPlaylist, @@ -12,26 +12,20 @@ import { cleanupTests, doubleFollow, flushAndRunMultipleServers, - getVideo, makeRawRequest, - removeVideo, ServerInfo, setAccessTokensToServers, - updateVideo, - uploadVideo, waitJobs, webtorrentAdd -} from '../../../../shared/extra-utils' -import { VideoDetails } from '../../../../shared/models/videos' -import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' +} from '@shared/extra-utils' +import { VideoStreamingPlaylistType } from '@shared/models' import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' const expect = chai.expect async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOnly: boolean, resolutions = [ 240, 360, 480, 720 ]) { for (const server of servers) { - const resVideoDetails = await getVideo(server.url, videoUUID) - const videoDetails: VideoDetails = resVideoDetails.body + const videoDetails = await server.videosCommand.get({ id: videoUUID }) const baseUrl = `http://${videoDetails.account.host}` expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) @@ -113,8 +107,8 @@ describe('Test HLS videos', function () { it('Should upload a video and transcode it to HLS', async function () { this.timeout(120000) - const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video 1', fixture: 'video_short.webm' }) - videoUUID = res.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } }) + videoUUID = uuid await waitJobs(servers) @@ -124,8 +118,8 @@ describe('Test HLS videos', function () { it('Should upload an audio file and transcode it to HLS', async function () { this.timeout(120000) - const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video audio', fixture: 'sample.ogg' }) - videoAudioUUID = res.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } }) + videoAudioUUID = uuid await waitJobs(servers) @@ -135,7 +129,7 @@ describe('Test HLS videos', function () { it('Should update the video', async function () { this.timeout(10000) - await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, { name: 'video 1 updated' }) + await servers[0].videosCommand.update({ id: videoUUID, attributes: { name: 'video 1 updated' } }) await waitJobs(servers) @@ -145,14 +139,14 @@ describe('Test HLS videos', function () { it('Should delete videos', async function () { this.timeout(10000) - await removeVideo(servers[0].url, servers[0].accessToken, videoUUID) - await removeVideo(servers[0].url, servers[0].accessToken, videoAudioUUID) + await servers[0].videosCommand.remove({ id: videoUUID }) + await servers[0].videosCommand.remove({ id: videoAudioUUID }) await waitJobs(servers) for (const server of servers) { - await getVideo(server.url, videoUUID, HttpStatusCode.NOT_FOUND_404) - await getVideo(server.url, videoAudioUUID, HttpStatusCode.NOT_FOUND_404) + await server.videosCommand.get({ id: videoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await server.videosCommand.get({ id: videoAudioUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) } }) -- cgit v1.2.3 From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- server/tests/api/videos/video-hls.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'server/tests/api/videos/video-hls.ts') diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index d63b81694..9d79f2683 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -25,7 +25,7 @@ const expect = chai.expect async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOnly: boolean, resolutions = [ 240, 360, 480, 720 ]) { for (const server of servers) { - const videoDetails = await server.videosCommand.get({ id: videoUUID }) + const videoDetails = await server.videos.get({ id: videoUUID }) const baseUrl = `http://${videoDetails.account.host}` expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) @@ -62,7 +62,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn { await checkResolutionsInMasterPlaylist({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions }) - const masterPlaylist = await server.streamingPlaylistsCommand.get({ url: hlsPlaylist.playlistUrl }) + const masterPlaylist = await server.streamingPlaylists.get({ url: hlsPlaylist.playlistUrl }) for (const resolution of resolutions) { expect(masterPlaylist).to.contain(`${resolution}.m3u8`) @@ -72,7 +72,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn { for (const resolution of resolutions) { - const subPlaylist = await server.streamingPlaylistsCommand.get({ + const subPlaylist = await server.streamingPlaylists.get({ url: `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8` }) @@ -107,7 +107,7 @@ describe('Test HLS videos', function () { it('Should upload a video and transcode it to HLS', async function () { this.timeout(120000) - const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } }) + const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } }) videoUUID = uuid await waitJobs(servers) @@ -118,7 +118,7 @@ describe('Test HLS videos', function () { it('Should upload an audio file and transcode it to HLS', async function () { this.timeout(120000) - const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } }) + const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } }) videoAudioUUID = uuid await waitJobs(servers) @@ -129,7 +129,7 @@ describe('Test HLS videos', function () { it('Should update the video', async function () { this.timeout(10000) - await servers[0].videosCommand.update({ id: videoUUID, attributes: { name: 'video 1 updated' } }) + await servers[0].videos.update({ id: videoUUID, attributes: { name: 'video 1 updated' } }) await waitJobs(servers) @@ -139,14 +139,14 @@ describe('Test HLS videos', function () { it('Should delete videos', async function () { this.timeout(10000) - await servers[0].videosCommand.remove({ id: videoUUID }) - await servers[0].videosCommand.remove({ id: videoAudioUUID }) + await servers[0].videos.remove({ id: videoUUID }) + await servers[0].videos.remove({ id: videoAudioUUID }) await waitJobs(servers) for (const server of servers) { - await server.videosCommand.get({ id: videoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) - await server.videosCommand.get({ id: videoAudioUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await server.videos.get({ id: videoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await server.videos.get({ id: videoAudioUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) } }) @@ -192,7 +192,7 @@ describe('Test HLS videos', function () { describe('With only HLS enabled', function () { before(async function () { - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { transcoding: { enabled: true, -- cgit v1.2.3 From 254d3579f5338f5fd775c17d15cdfc37078bcfb4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:47:51 +0200 Subject: Use an object to represent a server --- server/tests/api/videos/video-hls.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'server/tests/api/videos/video-hls.ts') diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 9d79f2683..4c4b18887 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -11,9 +11,9 @@ import { checkTmpIsEmpty, cleanupTests, doubleFollow, - flushAndRunMultipleServers, + createMultipleServers, makeRawRequest, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, waitJobs, webtorrentAdd @@ -23,7 +23,7 @@ import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' const expect = chai.expect -async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOnly: boolean, resolutions = [ 240, 360, 480, 720 ]) { +async function checkHlsPlaylist (servers: PeerTubeServer[], videoUUID: string, hlsOnly: boolean, resolutions = [ 240, 360, 480, 720 ]) { for (const server of servers) { const videoDetails = await server.videos.get({ id: videoUUID }) const baseUrl = `http://${videoDetails.account.host}` @@ -98,7 +98,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn } describe('Test HLS videos', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] let videoUUID = '' let videoAudioUUID = '' @@ -176,7 +176,7 @@ describe('Test HLS videos', function () { } } } - servers = await flushAndRunMultipleServers(2, configOverride) + servers = await createMultipleServers(2, configOverride) // Get the access tokens await setAccessTokensToServers(servers) -- cgit v1.2.3 From c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:42:24 +0200 Subject: Refactor requests --- server/tests/api/videos/video-hls.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/tests/api/videos/video-hls.ts') diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 4c4b18887..df030110b 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -3,7 +3,7 @@ import 'mocha' import * as chai from 'chai' import { join } from 'path' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { checkDirectoryIsEmpty, checkResolutionsInMasterPlaylist, -- cgit v1.2.3 From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- server/tests/api/videos/video-hls.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'server/tests/api/videos/video-hls.ts') diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index df030110b..7845f7334 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -3,22 +3,21 @@ import 'mocha' import * as chai from 'chai' import { join } from 'path' -import { HttpStatusCode } from '@shared/models' import { checkDirectoryIsEmpty, checkResolutionsInMasterPlaylist, checkSegmentHash, checkTmpIsEmpty, cleanupTests, - doubleFollow, createMultipleServers, + doubleFollow, makeRawRequest, PeerTubeServer, setAccessTokensToServers, waitJobs, webtorrentAdd } from '@shared/extra-utils' -import { VideoStreamingPlaylistType } from '@shared/models' +import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models' import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' const expect = chai.expect -- cgit v1.2.3