aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/transcoding/update-while-transcoding.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-31 14:34:36 +0200
committerChocobozzz <me@florianbigard.com>2023-08-11 15:02:33 +0200
commit3a4992633ee62d5edfbb484d9c6bcb3cf158489d (patch)
treee4510b39bdac9c318fdb4b47018d08f15368b8f0 /server/tests/api/transcoding/update-while-transcoding.ts
parent04d1da5621d25d59bd5fa1543b725c497bf5d9a8 (diff)
downloadPeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.gz
PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.zst
PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.zip
Migrate server to ESM
Sorry for the very big commit that may lead to git log issues and merge conflicts, but it's a major step forward: * Server can be faster at startup because imports() are async and we can easily lazy import big modules * Angular doesn't seem to support ES import (with .js extension), so we had to correctly organize peertube into a monorepo: * Use yarn workspace feature * Use typescript reference projects for dependencies * Shared projects have been moved into "packages", each one is now a node module (with a dedicated package.json/tsconfig.json) * server/tools have been moved into apps/ and is now a dedicated app bundled and published on NPM so users don't have to build peertube cli tools manually * server/tests have been moved into packages/ so we don't compile them every time we want to run the server * Use isolatedModule option: * Had to move from const enum to const (https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums) * Had to explictely specify "type" imports when used in decorators * Prefer tsx (that uses esbuild under the hood) instead of ts-node to load typescript files (tests with mocha or scripts): * To reduce test complexity as esbuild doesn't support decorator metadata, we only test server files that do not import server models * We still build tests files into js files for a faster CI * Remove unmaintained peertube CLI import script * Removed some barrels to speed up execution (less imports)
Diffstat (limited to 'server/tests/api/transcoding/update-while-transcoding.ts')
-rw-r--r--server/tests/api/transcoding/update-while-transcoding.ts160
1 files changed, 0 insertions, 160 deletions
diff --git a/server/tests/api/transcoding/update-while-transcoding.ts b/server/tests/api/transcoding/update-while-transcoding.ts
deleted file mode 100644
index cfb4fa0cc..000000000
--- a/server/tests/api/transcoding/update-while-transcoding.ts
+++ /dev/null
@@ -1,160 +0,0 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import { completeCheckHlsPlaylist } from '@server/tests/shared'
4import { areMockObjectStorageTestsDisabled, wait } from '@shared/core-utils'
5import { VideoPrivacy } from '@shared/models'
6import {
7 cleanupTests,
8 createMultipleServers,
9 doubleFollow,
10 ObjectStorageCommand,
11 PeerTubeServer,
12 setAccessTokensToServers,
13 waitJobs
14} from '@shared/server-commands'
15
16describe('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 Web Video & 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 webVideos: {
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 const objectStorage = new ObjectStorageCommand()
139
140 before(async function () {
141 this.timeout(120000)
142
143 const configOverride = objectStorage.getDefaultMockConfig()
144 await objectStorage.prepareDefaultMockBuckets()
145
146 await servers[0].kill()
147 await servers[0].run(configOverride)
148 })
149
150 runTestSuite(true, objectStorage.getMockPlaylistBaseUrl())
151
152 after(async function () {
153 await objectStorage.cleanupMock()
154 })
155 })
156
157 after(async function () {
158 await cleanupTests(servers)
159 })
160})