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/live/live-constraints.ts | 24 ++++----- server/tests/api/live/live-permanent.ts | 32 ++++++------ server/tests/api/live/live-save-replay.ts | 52 +++++++++---------- server/tests/api/live/live-socket-messages.ts | 38 +++++++------- server/tests/api/live/live-views.ts | 20 ++++---- server/tests/api/live/live.ts | 72 +++++++++++++-------------- 6 files changed, 119 insertions(+), 119 deletions(-) (limited to 'server/tests/api/live') diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts index 7900b1abe..1c380883c 100644 --- a/server/tests/api/live/live-constraints.ts +++ b/server/tests/api/live/live-constraints.ts @@ -32,13 +32,13 @@ describe('Test live constraints', function () { saveReplay } - const { uuid } = await servers[0].liveCommand.create({ token: userAccessToken, fields: liveAttributes }) + const { uuid } = await servers[0].live.create({ token: userAccessToken, fields: liveAttributes }) return uuid } async function checkSaveReplay (videoId: string, resolutions = [ 720 ]) { for (const server of servers) { - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) expect(video.isLive).to.be.false expect(video.duration).to.be.greaterThan(0) } @@ -48,12 +48,12 @@ describe('Test live constraints', function () { async function waitUntilLivePublishedOnAllServers (videoId: string) { for (const server of servers) { - await server.liveCommand.waitUntilPublished({ videoId }) + await server.live.waitUntilPublished({ videoId }) } } function updateQuota (options: { total: number, daily: number }) { - return servers[0].usersCommand.update({ + return servers[0].users.update({ userId, videoQuota: options.total, videoQuotaDaily: options.daily @@ -69,7 +69,7 @@ describe('Test live constraints', function () { await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { live: { enabled: true, @@ -82,7 +82,7 @@ describe('Test live constraints', function () { }) { - const res = await servers[0].usersCommand.generate('user1') + const res = await servers[0].users.generate('user1') userId = res.userId userChannelId = res.userChannelId userAccessToken = res.token @@ -98,7 +98,7 @@ describe('Test live constraints', function () { this.timeout(60000) const userVideoLiveoId = await createLiveWrapper(false) - await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false }) + await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false }) }) it('Should have size limit depending on user global quota if save replay is enabled', async function () { @@ -108,7 +108,7 @@ describe('Test live constraints', function () { await wait(5000) const userVideoLiveoId = await createLiveWrapper(true) - await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true }) + await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true }) await waitUntilLivePublishedOnAllServers(userVideoLiveoId) await waitJobs(servers) @@ -125,7 +125,7 @@ describe('Test live constraints', function () { await updateQuota({ total: -1, daily: 1 }) const userVideoLiveoId = await createLiveWrapper(true) - await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true }) + await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true }) await waitUntilLivePublishedOnAllServers(userVideoLiveoId) await waitJobs(servers) @@ -142,13 +142,13 @@ describe('Test live constraints', function () { await updateQuota({ total: 10 * 1000 * 1000, daily: -1 }) const userVideoLiveoId = await createLiveWrapper(true) - await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false }) + await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false }) }) it('Should have max duration limit', async function () { this.timeout(60000) - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { live: { enabled: true, @@ -163,7 +163,7 @@ describe('Test live constraints', function () { }) const userVideoLiveoId = await createLiveWrapper(true) - await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true }) + await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true }) await waitUntilLivePublishedOnAllServers(userVideoLiveoId) await waitJobs(servers) diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts index 707f2edf8..900bd6f5c 100644 --- a/server/tests/api/live/live-permanent.ts +++ b/server/tests/api/live/live-permanent.ts @@ -24,20 +24,20 @@ describe('Permanent live', function () { async function createLiveWrapper (permanentLive: boolean) { const attributes: LiveVideoCreate = { - channelId: servers[0].videoChannel.id, + channelId: servers[0].store.channel.id, privacy: VideoPrivacy.PUBLIC, name: 'my super live', saveReplay: false, permanentLive } - const { uuid } = await servers[0].liveCommand.create({ fields: attributes }) + const { uuid } = await servers[0].live.create({ fields: attributes }) return uuid } async function checkVideoState (videoId: string, state: VideoState) { for (const server of servers) { - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) expect(video.state.id).to.equal(state) } } @@ -54,7 +54,7 @@ describe('Permanent live', function () { // Server 1 and server 2 follow each other await doubleFollow(servers[0], servers[1]) - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { live: { enabled: true, @@ -75,14 +75,14 @@ describe('Permanent live', function () { const videoUUID = await createLiveWrapper(false) { - const live = await servers[0].liveCommand.get({ videoId: videoUUID }) + const live = await servers[0].live.get({ videoId: videoUUID }) expect(live.permanentLive).to.be.false } - await servers[0].liveCommand.update({ videoId: videoUUID, fields: { permanentLive: true } }) + await servers[0].live.update({ videoId: videoUUID, fields: { permanentLive: true } }) { - const live = await servers[0].liveCommand.get({ videoId: videoUUID }) + const live = await servers[0].live.get({ videoId: videoUUID }) expect(live.permanentLive).to.be.true } }) @@ -92,7 +92,7 @@ describe('Permanent live', function () { videoUUID = await createLiveWrapper(true) - const live = await servers[0].liveCommand.get({ videoId: videoUUID }) + const live = await servers[0].live.get({ videoId: videoUUID }) expect(live.permanentLive).to.be.true await waitJobs(servers) @@ -101,16 +101,16 @@ describe('Permanent live', function () { it('Should stream into this permanent live', async function () { this.timeout(120000) - const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID }) + const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID }) for (const server of servers) { - await server.liveCommand.waitUntilPublished({ videoId: videoUUID }) + await server.live.waitUntilPublished({ videoId: videoUUID }) } await checkVideoState(videoUUID, VideoState.PUBLISHED) await stopFfmpeg(ffmpegCommand) - await servers[0].liveCommand.waitUntilWaiting({ videoId: videoUUID }) + await servers[0].live.waitUntilWaiting({ videoId: videoUUID }) await waitJobs(servers) }) @@ -122,7 +122,7 @@ describe('Permanent live', function () { await waitJobs(servers) for (const server of servers) { - const videoDetails = await server.videosCommand.get({ id: videoUUID }) + const videoDetails = await server.videos.get({ id: videoUUID }) expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) } }) @@ -136,7 +136,7 @@ describe('Permanent live', function () { it('Should be able to stream again in the permanent live', async function () { this.timeout(20000) - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { live: { enabled: true, @@ -150,15 +150,15 @@ describe('Permanent live', function () { } }) - const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID }) + const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID }) for (const server of servers) { - await server.liveCommand.waitUntilPublished({ videoId: videoUUID }) + await server.live.waitUntilPublished({ videoId: videoUUID }) } await checkVideoState(videoUUID, VideoState.PUBLISHED) - const count = await servers[0].liveCommand.countPlaylists({ videoUUID }) + const count = await servers[0].live.countPlaylists({ videoUUID }) // master playlist and 720p playlist expect(count).to.equal(2) diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index a87a2cd12..7a33df90a 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts @@ -30,19 +30,19 @@ describe('Save replay setting', function () { async function createLiveWrapper (saveReplay: boolean) { if (liveVideoUUID) { try { - await servers[0].videosCommand.remove({ id: liveVideoUUID }) + await servers[0].videos.remove({ id: liveVideoUUID }) await waitJobs(servers) } catch {} } const attributes: LiveVideoCreate = { - channelId: servers[0].videoChannel.id, + channelId: servers[0].store.channel.id, privacy: VideoPrivacy.PUBLIC, name: 'my super live', saveReplay } - const { uuid } = await servers[0].liveCommand.create({ fields: attributes }) + const { uuid } = await servers[0].live.create({ fields: attributes }) return uuid } @@ -50,32 +50,32 @@ describe('Save replay setting', function () { for (const server of servers) { const length = existsInList ? 1 : 0 - const { data, total } = await server.videosCommand.list() + const { data, total } = await server.videos.list() expect(data).to.have.lengthOf(length) expect(total).to.equal(length) if (expectedStatus) { - await server.videosCommand.get({ id: videoId, expectedStatus }) + await server.videos.get({ id: videoId, expectedStatus }) } } } async function checkVideoState (videoId: string, state: VideoState) { for (const server of servers) { - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) expect(video.state.id).to.equal(state) } } async function waitUntilLivePublishedOnAllServers (videoId: string) { for (const server of servers) { - await server.liveCommand.waitUntilPublished({ videoId }) + await server.live.waitUntilPublished({ videoId }) } } async function waitUntilLiveSavedOnAllServers (videoId: string) { for (const server of servers) { - await server.liveCommand.waitUntilSaved({ videoId }) + await server.live.waitUntilSaved({ videoId }) } } @@ -91,7 +91,7 @@ describe('Save replay setting', function () { // Server 1 and server 2 follow each other await doubleFollow(servers[0], servers[1]) - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { live: { enabled: true, @@ -126,7 +126,7 @@ describe('Save replay setting', function () { it('Should correctly have updated the live and federated it when streaming in the live', async function () { this.timeout(30000) - ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) + ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) await waitUntilLivePublishedOnAllServers(liveVideoUUID) @@ -142,7 +142,7 @@ describe('Save replay setting', function () { await stopFfmpeg(ffmpegCommand) for (const server of servers) { - await server.liveCommand.waitUntilEnded({ videoId: liveVideoUUID }) + await server.live.waitUntilEnded({ videoId: liveVideoUUID }) } await waitJobs(servers) @@ -159,7 +159,7 @@ describe('Save replay setting', function () { liveVideoUUID = await createLiveWrapper(false) - ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) + ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) await waitUntilLivePublishedOnAllServers(liveVideoUUID) @@ -167,7 +167,7 @@ describe('Save replay setting', function () { await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) await Promise.all([ - servers[0].blacklistCommand.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }), + servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }), testFfmpegStreamError(ffmpegCommand, true) ]) @@ -175,8 +175,8 @@ describe('Save replay setting', function () { await checkVideosExist(liveVideoUUID, false) - await servers[0].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) - await servers[1].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await servers[0].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) + await servers[1].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) await wait(5000) await waitJobs(servers) @@ -188,7 +188,7 @@ describe('Save replay setting', function () { liveVideoUUID = await createLiveWrapper(false) - ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) + ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) await waitUntilLivePublishedOnAllServers(liveVideoUUID) @@ -197,7 +197,7 @@ describe('Save replay setting', function () { await Promise.all([ testFfmpegStreamError(ffmpegCommand, true), - servers[0].videosCommand.remove({ id: liveVideoUUID }) + servers[0].videos.remove({ id: liveVideoUUID }) ]) await wait(5000) @@ -224,7 +224,7 @@ describe('Save replay setting', function () { it('Should correctly have updated the live and federated it when streaming in the live', async function () { this.timeout(20000) - ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) + ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) await waitUntilLivePublishedOnAllServers(liveVideoUUID) await waitJobs(servers) @@ -249,11 +249,11 @@ describe('Save replay setting', function () { it('Should update the saved live and correctly federate the updated attributes', async function () { this.timeout(30000) - await servers[0].videosCommand.update({ id: liveVideoUUID, attributes: { name: 'video updated' } }) + await servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'video updated' } }) await waitJobs(servers) for (const server of servers) { - const video = await server.videosCommand.get({ id: liveVideoUUID }) + const video = await server.videos.get({ id: liveVideoUUID }) expect(video.name).to.equal('video updated') expect(video.isLive).to.be.false } @@ -268,14 +268,14 @@ describe('Save replay setting', function () { liveVideoUUID = await createLiveWrapper(true) - ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) + ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) await waitUntilLivePublishedOnAllServers(liveVideoUUID) await waitJobs(servers) await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) await Promise.all([ - servers[0].blacklistCommand.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }), + servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }), testFfmpegStreamError(ffmpegCommand, true) ]) @@ -283,8 +283,8 @@ describe('Save replay setting', function () { await checkVideosExist(liveVideoUUID, false) - await servers[0].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) - await servers[1].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await servers[0].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) + await servers[1].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) await wait(5000) await waitJobs(servers) @@ -296,14 +296,14 @@ describe('Save replay setting', function () { liveVideoUUID = await createLiveWrapper(true) - ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) + ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) await waitUntilLivePublishedOnAllServers(liveVideoUUID) await waitJobs(servers) await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) await Promise.all([ - servers[0].videosCommand.remove({ id: liveVideoUUID }), + servers[0].videos.remove({ id: liveVideoUUID }), testFfmpegStreamError(ffmpegCommand, true) ]) diff --git a/server/tests/api/live/live-socket-messages.ts b/server/tests/api/live/live-socket-messages.ts index 1f3d455a8..ad67d6285 100644 --- a/server/tests/api/live/live-socket-messages.ts +++ b/server/tests/api/live/live-socket-messages.ts @@ -30,7 +30,7 @@ describe('Test live', function () { await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { live: { enabled: true, @@ -51,11 +51,11 @@ describe('Test live', function () { async function createLiveWrapper () { const liveAttributes = { name: 'live video', - channelId: servers[0].videoChannel.id, + channelId: servers[0].store.channel.id, privacy: VideoPrivacy.PUBLIC } - const { uuid } = await servers[0].liveCommand.create({ fields: liveAttributes }) + const { uuid } = await servers[0].live.create({ fields: liveAttributes }) return uuid } @@ -69,22 +69,22 @@ describe('Test live', function () { await waitJobs(servers) { - const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID }) + const videoId = await servers[0].videos.getId({ uuid: liveVideoUUID }) - const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket() + const localSocket = servers[0].socketIO.getLiveNotificationSocket() localSocket.on('state-change', data => localStateChanges.push(data.state)) localSocket.emit('subscribe', { videoId }) } { - const videoId = await servers[1].videosCommand.getId({ uuid: liveVideoUUID }) + const videoId = await servers[1].videos.getId({ uuid: liveVideoUUID }) - const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket() + const remoteSocket = servers[1].socketIO.getLiveNotificationSocket() remoteSocket.on('state-change', data => remoteStateChanges.push(data.state)) remoteSocket.emit('subscribe', { videoId }) } - const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) + const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) await waitJobs(servers) @@ -97,7 +97,7 @@ describe('Test live', function () { await stopFfmpeg(ffmpegCommand) for (const server of servers) { - await server.liveCommand.waitUntilEnded({ videoId: liveVideoUUID }) + await server.live.waitUntilEnded({ videoId: liveVideoUUID }) } await waitJobs(servers) @@ -117,22 +117,22 @@ describe('Test live', function () { await waitJobs(servers) { - const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID }) + const videoId = await servers[0].videos.getId({ uuid: liveVideoUUID }) - const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket() + const localSocket = servers[0].socketIO.getLiveNotificationSocket() localSocket.on('views-change', data => { localLastVideoViews = data.views }) localSocket.emit('subscribe', { videoId }) } { - const videoId = await servers[1].videosCommand.getId({ uuid: liveVideoUUID }) + const videoId = await servers[1].videos.getId({ uuid: liveVideoUUID }) - const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket() + const remoteSocket = servers[1].socketIO.getLiveNotificationSocket() remoteSocket.on('views-change', data => { remoteLastVideoViews = data.views }) remoteSocket.emit('subscribe', { videoId }) } - const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) + const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) await waitJobs(servers) @@ -140,8 +140,8 @@ describe('Test live', function () { expect(localLastVideoViews).to.equal(0) expect(remoteLastVideoViews).to.equal(0) - await servers[0].videosCommand.view({ id: liveVideoUUID }) - await servers[1].videosCommand.view({ id: liveVideoUUID }) + await servers[0].videos.view({ id: liveVideoUUID }) + await servers[1].videos.view({ id: liveVideoUUID }) await waitJobs(servers) await wait(5000) @@ -161,13 +161,13 @@ describe('Test live', function () { const liveVideoUUID = await createLiveWrapper() await waitJobs(servers) - const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID }) + const videoId = await servers[0].videos.getId({ uuid: liveVideoUUID }) - const socket = servers[0].socketIOCommand.getLiveNotificationSocket() + const socket = servers[0].socketIO.getLiveNotificationSocket() socket.on('state-change', data => stateChanges.push(data.state)) socket.emit('subscribe', { videoId }) - const command = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) + const command = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) await waitJobs(servers) diff --git a/server/tests/api/live/live-views.ts b/server/tests/api/live/live-views.ts index 1951b11a5..43222f9c9 100644 --- a/server/tests/api/live/live-views.ts +++ b/server/tests/api/live/live-views.ts @@ -31,7 +31,7 @@ describe('Test live', function () { await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { live: { enabled: true, @@ -53,7 +53,7 @@ describe('Test live', function () { async function countViews (expected: number) { for (const server of servers) { - const video = await server.videosCommand.get({ id: liveVideoId }) + const video = await server.videos.get({ id: liveVideoId }) expect(video.views).to.equal(expected) } } @@ -63,14 +63,14 @@ describe('Test live', function () { const liveAttributes = { name: 'live video', - channelId: servers[0].videoChannel.id, + channelId: servers[0].store.channel.id, privacy: VideoPrivacy.PUBLIC } - const live = await servers[0].liveCommand.create({ fields: liveAttributes }) + const live = await servers[0].live.create({ fields: liveAttributes }) liveVideoId = live.uuid - command = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId }) + command = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoId }) await waitUntilLivePublishedOnAllServers(servers, liveVideoId) await waitJobs(servers) }) @@ -82,8 +82,8 @@ describe('Test live', function () { it('Should view a live twice and display 1 view', async function () { this.timeout(30000) - await servers[0].videosCommand.view({ id: liveVideoId }) - await servers[0].videosCommand.view({ id: liveVideoId }) + await servers[0].videos.view({ id: liveVideoId }) + await servers[0].videos.view({ id: liveVideoId }) await wait(7000) @@ -104,9 +104,9 @@ describe('Test live', function () { it('Should view a live on a remote and on local and display 2 views', async function () { this.timeout(30000) - await servers[0].videosCommand.view({ id: liveVideoId }) - await servers[1].videosCommand.view({ id: liveVideoId }) - await servers[1].videosCommand.view({ id: liveVideoId }) + await servers[0].videos.view({ id: liveVideoId }) + await servers[1].videos.view({ id: liveVideoId }) + await servers[1].videos.view({ id: liveVideoId }) await wait(7000) await waitJobs(servers) diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index c88143982..2cce1f448 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts @@ -44,7 +44,7 @@ describe('Test live', function () { await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { live: { enabled: true, @@ -59,7 +59,7 @@ describe('Test live', function () { // Server 1 and server 2 follow each other await doubleFollow(servers[0], servers[1]) - commands = servers.map(s => s.liveCommand) + commands = servers.map(s => s.live) }) describe('Live creation, update and delete', function () { @@ -74,7 +74,7 @@ describe('Test live', function () { language: 'fr', description: 'super live description', support: 'support field', - channelId: servers[0].videoChannel.id, + channelId: servers[0].store.channel.id, nsfw: false, waitTranscoding: false, name: 'my super live', @@ -93,7 +93,7 @@ describe('Test live', function () { await waitJobs(servers) for (const server of servers) { - const video = await server.videosCommand.get({ id: liveVideoUUID }) + const video = await server.videos.get({ id: liveVideoUUID }) expect(video.category.id).to.equal(1) expect(video.licence.id).to.equal(2) @@ -101,8 +101,8 @@ describe('Test live', function () { expect(video.description).to.equal('super live description') expect(video.support).to.equal('support field') - expect(video.channel.name).to.equal(servers[0].videoChannel.name) - expect(video.channel.host).to.equal(servers[0].videoChannel.host) + expect(video.channel.name).to.equal(servers[0].store.channel.name) + expect(video.channel.host).to.equal(servers[0].store.channel.host) expect(video.isLive).to.be.true @@ -117,7 +117,7 @@ describe('Test live', function () { await testImage(server.url, 'video_short1-preview.webm', video.previewPath) await testImage(server.url, 'video_short1.webm', video.thumbnailPath) - const live = await server.liveCommand.get({ videoId: liveVideoUUID }) + const live = await server.live.get({ videoId: liveVideoUUID }) if (server.url === servers[0].url) { expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live') @@ -136,7 +136,7 @@ describe('Test live', function () { const attributes: LiveVideoCreate = { name: 'default live thumbnail', - channelId: servers[0].videoChannel.id, + channelId: servers[0].store.channel.id, privacy: VideoPrivacy.UNLISTED, nsfw: true } @@ -147,7 +147,7 @@ describe('Test live', function () { await waitJobs(servers) for (const server of servers) { - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) expect(video.privacy.id).to.equal(VideoPrivacy.UNLISTED) expect(video.nsfw).to.be.true @@ -158,7 +158,7 @@ describe('Test live', function () { it('Should not have the live listed since nobody streams into', async function () { for (const server of servers) { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(0) expect(data).to.have.lengthOf(0) @@ -178,7 +178,7 @@ describe('Test live', function () { it('Have the live updated', async function () { for (const server of servers) { - const live = await server.liveCommand.get({ videoId: liveVideoUUID }) + const live = await server.live.get({ videoId: liveVideoUUID }) if (server.url === servers[0].url) { expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live') @@ -195,14 +195,14 @@ describe('Test live', function () { it('Delete the live', async function () { this.timeout(10000) - await servers[0].videosCommand.remove({ id: liveVideoUUID }) + await servers[0].videos.remove({ id: liveVideoUUID }) await waitJobs(servers) }) it('Should have the live deleted', async function () { for (const server of servers) { - await server.videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) - await server.liveCommand.get({ videoId: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await server.videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await server.live.get({ videoId: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) } }) }) @@ -215,19 +215,19 @@ describe('Test live', function () { before(async function () { this.timeout(120000) - vodVideoId = (await servers[0].videosCommand.quickUpload({ name: 'vod video' })).uuid + vodVideoId = (await servers[0].videos.quickUpload({ name: 'vod video' })).uuid - const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].videoChannel.id } + const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].store.channel.id } const live = await commands[0].create({ fields: liveOptions }) liveVideoId = live.uuid - ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId }) + ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoId }) await waitUntilLivePublishedOnAllServers(servers, liveVideoId) await waitJobs(servers) }) it('Should only display lives', async function () { - const { data, total } = await servers[0].videosCommand.list({ isLive: true }) + const { data, total } = await servers[0].videos.list({ isLive: true }) expect(total).to.equal(1) expect(data).to.have.lengthOf(1) @@ -235,7 +235,7 @@ describe('Test live', function () { }) it('Should not display lives', async function () { - const { data, total } = await servers[0].videosCommand.list({ isLive: false }) + const { data, total } = await servers[0].videos.list({ isLive: false }) expect(total).to.equal(1) expect(data).to.have.lengthOf(1) @@ -248,22 +248,22 @@ describe('Test live', function () { await stopFfmpeg(ffmpegCommand) await waitJobs(servers) - const { data } = await servers[0].videosCommand.listMyVideos({ isLive: true }) + const { data } = await servers[0].videos.listMyVideos({ isLive: true }) const result = data.every(v => v.isLive) expect(result).to.be.true }) it('Should not display my lives', async function () { - const { data } = await servers[0].videosCommand.listMyVideos({ isLive: false }) + const { data } = await servers[0].videos.listMyVideos({ isLive: false }) const result = data.every(v => !v.isLive) expect(result).to.be.true }) after(async function () { - await servers[0].videosCommand.remove({ id: vodVideoId }) - await servers[0].videosCommand.remove({ id: liveVideoId }) + await servers[0].videos.remove({ id: vodVideoId }) + await servers[0].videos.remove({ id: liveVideoId }) }) }) @@ -278,7 +278,7 @@ describe('Test live', function () { async function createLiveWrapper () { const liveAttributes = { name: 'user live', - channelId: servers[0].videoChannel.id, + channelId: servers[0].store.channel.id, privacy: VideoPrivacy.PUBLIC, saveReplay: false } @@ -286,7 +286,7 @@ describe('Test live', function () { const { uuid } = await commands[0].create({ fields: liveAttributes }) const live = await commands[0].get({ videoId: uuid }) - const video = await servers[0].videosCommand.get({ id: uuid }) + const video = await servers[0].videos.get({ id: uuid }) return Object.assign(video, live) } @@ -316,7 +316,7 @@ describe('Test live', function () { it('Should list this live now someone stream into it', async function () { for (const server of servers) { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(1) expect(data).to.have.lengthOf(1) @@ -332,7 +332,7 @@ describe('Test live', function () { liveVideo = await createLiveWrapper() - await servers[0].blacklistCommand.add({ videoId: liveVideo.uuid }) + await servers[0].blacklist.add({ videoId: liveVideo.uuid }) const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey) await testFfmpegStreamError(command, true) @@ -343,7 +343,7 @@ describe('Test live', function () { liveVideo = await createLiveWrapper() - await servers[0].videosCommand.remove({ id: liveVideo.uuid }) + await servers[0].videos.remove({ id: liveVideo.uuid }) const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey) await testFfmpegStreamError(command, true) @@ -356,7 +356,7 @@ describe('Test live', function () { async function createLiveWrapper (saveReplay: boolean) { const liveAttributes = { name: 'live video', - channelId: servers[0].videoChannel.id, + channelId: servers[0].store.channel.id, privacy: VideoPrivacy.PUBLIC, saveReplay } @@ -367,10 +367,10 @@ describe('Test live', function () { async function testVideoResolutions (liveVideoId: string, resolutions: number[]) { for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() expect(data.find(v => v.uuid === liveVideoId)).to.exist - const video = await server.videosCommand.get({ id: liveVideoId }) + const video = await server.videos.get({ id: liveVideoId }) expect(video.streamingPlaylists).to.have.lengthOf(1) @@ -387,7 +387,7 @@ describe('Test live', function () { const segmentName = `${i}-00000${segmentNum}.ts` await commands[0].waitUntilSegmentGeneration({ videoUUID: video.uuid, resolution: i, segment: segmentNum }) - const subPlaylist = await servers[0].streamingPlaylistsCommand.get({ + const subPlaylist = await servers[0].streamingPlaylists.get({ url: `${servers[0].url}/static/streaming-playlists/hls/${video.uuid}/${i}.m3u8` }) @@ -406,7 +406,7 @@ describe('Test live', function () { } function updateConf (resolutions: number[]) { - return servers[0].configCommand.updateCustomSubConfig({ + return servers[0].config.updateCustomSubConfig({ newConfig: { live: { enabled: true, @@ -490,7 +490,7 @@ describe('Test live', function () { } for (const server of servers) { - const video = await server.videosCommand.get({ id: liveVideoId }) + const video = await server.videos.get({ id: liveVideoId }) expect(video.state.id).to.equal(VideoState.PUBLISHED) expect(video.duration).to.be.greaterThan(1) @@ -515,7 +515,7 @@ describe('Test live', function () { } const filename = `${video.uuid}-${resolution}-fragmented.mp4` - const segmentPath = servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename)) + const segmentPath = servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename)) const probe = await ffprobePromise(segmentPath) const videoStream = await getVideoStreamFromFile(segmentPath, probe) @@ -542,7 +542,7 @@ describe('Test live', function () { async function createLiveWrapper (saveReplay: boolean) { const liveAttributes = { name: 'live video', - channelId: servers[0].videoChannel.id, + channelId: servers[0].store.channel.id, privacy: VideoPrivacy.PUBLIC, saveReplay } -- cgit v1.2.3