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