]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/transcoding/update-while-transcoding.ts
Increase timeouts
[github/Chocobozzz/PeerTube.git] / server / tests / api / transcoding / update-while-transcoding.ts
1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3 import { completeCheckHlsPlaylist } from '@server/tests/shared'
4 import { areMockObjectStorageTestsDisabled, wait } from '@shared/core-utils'
5 import { VideoPrivacy } from '@shared/models'
6 import {
7 cleanupTests,
8 createMultipleServers,
9 doubleFollow,
10 ObjectStorageCommand,
11 PeerTubeServer,
12 setAccessTokensToServers,
13 waitJobs
14 } from '@shared/server-commands'
15
16 describe('Test update video privacy while transcoding', function () {
17 let servers: PeerTubeServer[] = []
18
19 const videoUUIDs: string[] = []
20
21 function runTestSuite (hlsOnly: boolean, objectStorageBaseUrl?: string) {
22
23 it('Should not have an error while quickly updating a private video to public after upload #1', async function () {
24 this.timeout(360_000)
25
26 const attributes = {
27 name: 'quick update',
28 privacy: VideoPrivacy.PRIVATE
29 }
30
31 const { uuid } = await servers[0].videos.upload({ attributes, waitTorrentGeneration: false })
32 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
33 videoUUIDs.push(uuid)
34
35 await waitJobs(servers)
36
37 await completeCheckHlsPlaylist({ servers, videoUUID: uuid, hlsOnly, objectStorageBaseUrl })
38 })
39
40 it('Should not have an error while quickly updating a private video to public after upload #2', async function () {
41 this.timeout(60000)
42
43 {
44 const attributes = {
45 name: 'quick update 2',
46 privacy: VideoPrivacy.PRIVATE
47 }
48
49 const { uuid } = await servers[0].videos.upload({ attributes, waitTorrentGeneration: true })
50 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
51 videoUUIDs.push(uuid)
52
53 await waitJobs(servers)
54
55 await completeCheckHlsPlaylist({ servers, videoUUID: uuid, hlsOnly, objectStorageBaseUrl })
56 }
57 })
58
59 it('Should not have an error while quickly updating a private video to public after upload #3', async function () {
60 this.timeout(60000)
61
62 const attributes = {
63 name: 'quick update 3',
64 privacy: VideoPrivacy.PRIVATE
65 }
66
67 const { uuid } = await servers[0].videos.upload({ attributes, waitTorrentGeneration: true })
68 await wait(1000)
69 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
70 videoUUIDs.push(uuid)
71
72 await waitJobs(servers)
73
74 await completeCheckHlsPlaylist({ servers, videoUUID: uuid, hlsOnly, objectStorageBaseUrl })
75 })
76 }
77
78 before(async function () {
79 this.timeout(120000)
80
81 const configOverride = {
82 transcoding: {
83 enabled: true,
84 allow_audio_files: true,
85 hls: {
86 enabled: true
87 }
88 }
89 }
90 servers = await createMultipleServers(2, configOverride)
91
92 // Get the access tokens
93 await setAccessTokensToServers(servers)
94
95 // Server 1 and server 2 follow each other
96 await doubleFollow(servers[0], servers[1])
97 })
98
99 describe('With WebTorrent & HLS enabled', function () {
100 runTestSuite(false)
101 })
102
103 describe('With only HLS enabled', function () {
104
105 before(async function () {
106 await servers[0].config.updateCustomSubConfig({
107 newConfig: {
108 transcoding: {
109 enabled: true,
110 allowAudioFiles: true,
111 resolutions: {
112 '144p': false,
113 '240p': true,
114 '360p': true,
115 '480p': true,
116 '720p': true,
117 '1080p': true,
118 '1440p': true,
119 '2160p': true
120 },
121 hls: {
122 enabled: true
123 },
124 webtorrent: {
125 enabled: false
126 }
127 }
128 }
129 })
130 })
131
132 runTestSuite(true)
133 })
134
135 describe('With object storage enabled', function () {
136 if (areMockObjectStorageTestsDisabled()) return
137
138 before(async function () {
139 this.timeout(120000)
140
141 const configOverride = ObjectStorageCommand.getDefaultMockConfig()
142 await ObjectStorageCommand.prepareDefaultMockBuckets()
143
144 await servers[0].kill()
145 await servers[0].run(configOverride)
146 })
147
148 runTestSuite(true, ObjectStorageCommand.getMockPlaylistBaseUrl())
149 })
150
151 after(async function () {
152 await cleanupTests(servers)
153 })
154 })