diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-26 08:50:52 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-05-15 15:14:21 +0200 |
commit | 48f07b4a4091cb10dc4d179118e155f3a118dca8 (patch) | |
tree | 8fcc6bd8cafa636ebaf97a083fafbcc0d52ad5cd /server/tests/api/videos | |
parent | 7243f84db0f34c6d5610a54603b0cce7c284a7b3 (diff) | |
download | PeerTube-48f07b4a4091cb10dc4d179118e155f3a118dca8.tar.gz PeerTube-48f07b4a4091cb10dc4d179118e155f3a118dca8.tar.zst PeerTube-48f07b4a4091cb10dc4d179118e155f3a118dca8.zip |
All API tests in parallel
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 2 | ||||
-rw-r--r-- | server/tests/api/videos/single-server.ts | 19 | ||||
-rw-r--r-- | server/tests/api/videos/video-change-ownership.ts | 8 | ||||
-rw-r--r-- | server/tests/api/videos/video-channels.ts | 8 | ||||
-rw-r--r-- | server/tests/api/videos/video-hls.ts | 4 | ||||
-rw-r--r-- | server/tests/api/videos/video-playlists.ts | 4 | ||||
-rw-r--r-- | server/tests/api/videos/videos-views-cleaner.ts | 16 |
7 files changed, 31 insertions, 30 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 89904759a..09b461200 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -109,7 +109,7 @@ describe('Test multiple servers', function () { | |||
109 | // All servers should have this video | 109 | // All servers should have this video |
110 | let publishedAt: string = null | 110 | let publishedAt: string = null |
111 | for (const server of servers) { | 111 | for (const server of servers) { |
112 | const isLocal = server.url === 'http://localhost:' + servers[0].port | 112 | const isLocal = server.port === servers[0].port |
113 | const checkAttributes = { | 113 | const checkAttributes = { |
114 | name: 'my super name for server 1', | 114 | name: 'my super name for server 1', |
115 | category: 5, | 115 | category: 5, |
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index b0412f4df..d8f394ac7 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -37,7 +37,7 @@ describe('Test a single server', function () { | |||
37 | let videoUUID = '' | 37 | let videoUUID = '' |
38 | let videosListBase: any[] = null | 38 | let videosListBase: any[] = null |
39 | 39 | ||
40 | const getCheckAttributes = { | 40 | const getCheckAttributes = () => ({ |
41 | name: 'my super name', | 41 | name: 'my super name', |
42 | category: 2, | 42 | category: 2, |
43 | licence: 6, | 43 | licence: 6, |
@@ -68,9 +68,9 @@ describe('Test a single server', function () { | |||
68 | size: 218910 | 68 | size: 218910 |
69 | } | 69 | } |
70 | ] | 70 | ] |
71 | } | 71 | }) |
72 | 72 | ||
73 | const updateCheckAttributes = { | 73 | const updateCheckAttributes = () => ({ |
74 | name: 'my super video updated', | 74 | name: 'my super video updated', |
75 | category: 4, | 75 | category: 4, |
76 | licence: 2, | 76 | licence: 2, |
@@ -101,7 +101,7 @@ describe('Test a single server', function () { | |||
101 | size: 292677 | 101 | size: 292677 |
102 | } | 102 | } |
103 | ] | 103 | ] |
104 | } | 104 | }) |
105 | 105 | ||
106 | before(async function () { | 106 | before(async function () { |
107 | this.timeout(30000) | 107 | this.timeout(30000) |
@@ -182,7 +182,7 @@ describe('Test a single server', function () { | |||
182 | expect(res.body.data.length).to.equal(1) | 182 | expect(res.body.data.length).to.equal(1) |
183 | 183 | ||
184 | const video = res.body.data[0] | 184 | const video = res.body.data[0] |
185 | await completeVideoCheck(server.url, video, getCheckAttributes) | 185 | await completeVideoCheck(server.url, video, getCheckAttributes()) |
186 | }) | 186 | }) |
187 | 187 | ||
188 | it('Should get the video by UUID', async function () { | 188 | it('Should get the video by UUID', async function () { |
@@ -191,7 +191,7 @@ describe('Test a single server', function () { | |||
191 | const res = await getVideo(server.url, videoUUID) | 191 | const res = await getVideo(server.url, videoUUID) |
192 | 192 | ||
193 | const video = res.body | 193 | const video = res.body |
194 | await completeVideoCheck(server.url, video, getCheckAttributes) | 194 | await completeVideoCheck(server.url, video, getCheckAttributes()) |
195 | }) | 195 | }) |
196 | 196 | ||
197 | it('Should have the views updated', async function () { | 197 | it('Should have the views updated', async function () { |
@@ -376,7 +376,7 @@ describe('Test a single server', function () { | |||
376 | const res = await getVideo(server.url, videoId) | 376 | const res = await getVideo(server.url, videoId) |
377 | const video = res.body | 377 | const video = res.body |
378 | 378 | ||
379 | await completeVideoCheck(server.url, video, updateCheckAttributes) | 379 | await completeVideoCheck(server.url, video, updateCheckAttributes()) |
380 | }) | 380 | }) |
381 | 381 | ||
382 | it('Should update only the tags of a video', async function () { | 382 | it('Should update only the tags of a video', async function () { |
@@ -388,7 +388,7 @@ describe('Test a single server', function () { | |||
388 | const res = await getVideo(server.url, videoId) | 388 | const res = await getVideo(server.url, videoId) |
389 | const video = res.body | 389 | const video = res.body |
390 | 390 | ||
391 | await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes)) | 391 | await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes(), attributes)) |
392 | }) | 392 | }) |
393 | 393 | ||
394 | it('Should update only the description of a video', async function () { | 394 | it('Should update only the description of a video', async function () { |
@@ -400,7 +400,8 @@ describe('Test a single server', function () { | |||
400 | const res = await getVideo(server.url, videoId) | 400 | const res = await getVideo(server.url, videoId) |
401 | const video = res.body | 401 | const video = res.body |
402 | 402 | ||
403 | await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes)) | 403 | const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes) |
404 | await completeVideoCheck(server.url, video, expectedAttributes) | ||
404 | }) | 405 | }) |
405 | 406 | ||
406 | it('Should like a video', async function () { | 407 | it('Should like a video', async function () { |
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts index 1c0327d40..3a3add71b 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/server/tests/api/videos/video-change-ownership.ts | |||
@@ -4,7 +4,8 @@ import * as chai from 'chai' | |||
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { | 5 | import { |
6 | acceptChangeOwnership, | 6 | acceptChangeOwnership, |
7 | changeVideoOwnership, cleanupTests, | 7 | changeVideoOwnership, |
8 | cleanupTests, | ||
8 | createUser, | 9 | createUser, |
9 | doubleFollow, | 10 | doubleFollow, |
10 | flushAndRunMultipleServers, | 11 | flushAndRunMultipleServers, |
@@ -13,7 +14,6 @@ import { | |||
13 | getVideo, | 14 | getVideo, |
14 | getVideoChangeOwnershipList, | 15 | getVideoChangeOwnershipList, |
15 | getVideosList, | 16 | getVideosList, |
16 | killallServers, | ||
17 | refuseChangeOwnership, | 17 | refuseChangeOwnership, |
18 | ServerInfo, | 18 | ServerInfo, |
19 | setAccessTokensToServers, | 19 | setAccessTokensToServers, |
@@ -203,8 +203,8 @@ describe('Test video change ownership - nominal', function () { | |||
203 | } | 203 | } |
204 | }) | 204 | }) |
205 | 205 | ||
206 | after(function () { | 206 | after(async function () { |
207 | killallServers(servers) | 207 | await cleanupTests(servers) |
208 | }) | 208 | }) |
209 | }) | 209 | }) |
210 | 210 | ||
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index f09148404..41fe3be5c 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts | |||
@@ -41,7 +41,7 @@ describe('Test video channels', function () { | |||
41 | let videoUUID: string | 41 | let videoUUID: string |
42 | 42 | ||
43 | before(async function () { | 43 | before(async function () { |
44 | this.timeout(30000) | 44 | this.timeout(60000) |
45 | 45 | ||
46 | servers = await flushAndRunMultipleServers(2) | 46 | servers = await flushAndRunMultipleServers(2) |
47 | 47 | ||
@@ -213,7 +213,7 @@ describe('Test video channels', function () { | |||
213 | this.timeout(10000) | 213 | this.timeout(10000) |
214 | 214 | ||
215 | for (const server of servers) { | 215 | for (const server of servers) { |
216 | const channelURI = 'second_video_channel@localhost:' + server.port | 216 | const channelURI = 'second_video_channel@localhost:' + servers[0].port |
217 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) | 217 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) |
218 | expect(res1.body.total).to.equal(1) | 218 | expect(res1.body.total).to.equal(1) |
219 | expect(res1.body.data).to.be.an('array') | 219 | expect(res1.body.data).to.be.an('array') |
@@ -234,11 +234,11 @@ describe('Test video channels', function () { | |||
234 | this.timeout(10000) | 234 | this.timeout(10000) |
235 | 235 | ||
236 | for (const server of servers) { | 236 | for (const server of servers) { |
237 | const secondChannelURI = 'second_video_channel@localhost:' + server.port | 237 | const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port |
238 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5) | 238 | const res1 = await getVideoChannelVideos(server.url, server.accessToken, secondChannelURI, 0, 5) |
239 | expect(res1.body.total).to.equal(0) | 239 | expect(res1.body.total).to.equal(0) |
240 | 240 | ||
241 | const channelURI = 'root_channel@localhost:' + server.port | 241 | const channelURI = 'root_channel@localhost:' + servers[0].port |
242 | const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) | 242 | const res2 = await getVideoChannelVideos(server.url, server.accessToken, channelURI, 0, 5) |
243 | expect(res2.body.total).to.equal(1) | 243 | expect(res2.body.total).to.equal(1) |
244 | 244 | ||
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 4565d0ebe..504c50dee 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts | |||
@@ -50,7 +50,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { | |||
50 | 50 | ||
51 | { | 51 | { |
52 | for (const resolution of resolutions) { | 52 | for (const resolution of resolutions) { |
53 | const res2 = await getPlaylist(`http://localhost:${server.port}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`) | 53 | const res2 = await getPlaylist(`http://localhost:${servers[0].port}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`) |
54 | 54 | ||
55 | const subPlaylist = res2.text | 55 | const subPlaylist = res2.text |
56 | expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) | 56 | expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) |
@@ -58,7 +58,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string) { | |||
58 | } | 58 | } |
59 | 59 | ||
60 | { | 60 | { |
61 | const baseUrl = 'http://localhost:' + server.port + '/static/streaming-playlists/hls' | 61 | const baseUrl = 'http://localhost:' + servers[0].port + '/static/streaming-playlists/hls' |
62 | 62 | ||
63 | for (const resolution of resolutions) { | 63 | for (const resolution of resolutions) { |
64 | await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist) | 64 | await checkSegmentHash(baseUrl, baseUrl, videoUUID, resolution, hlsPlaylist) |
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index e4d817ff8..83a2f3d4d 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts | |||
@@ -358,7 +358,7 @@ describe('Test video playlists', function () { | |||
358 | 358 | ||
359 | for (const server of servers) { | 359 | for (const server of servers) { |
360 | const results = [ | 360 | const results = [ |
361 | await getAccountPlaylistsList(server.url, 'root@localhost:9002', 0, 5, '-createdAt'), | 361 | await getAccountPlaylistsList(server.url, 'root@localhost:' + servers[1].port, 0, 5, '-createdAt'), |
362 | await getVideoPlaylistsList(server.url, 0, 2, '-createdAt') | 362 | await getVideoPlaylistsList(server.url, 0, 2, '-createdAt') |
363 | ] | 363 | ] |
364 | 364 | ||
@@ -757,7 +757,7 @@ describe('Test video playlists', function () { | |||
757 | this.timeout(30000) | 757 | this.timeout(30000) |
758 | 758 | ||
759 | for (const server of servers) { | 759 | for (const server of servers) { |
760 | await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.serverNumber) | 760 | await checkPlaylistFilesWereRemoved(playlistServer1UUID, server.internalServerNumber) |
761 | } | 761 | } |
762 | }) | 762 | }) |
763 | 763 | ||
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts index c21d46d56..fbddd40f4 100644 --- a/server/tests/api/videos/videos-views-cleaner.ts +++ b/server/tests/api/videos/videos-views-cleaner.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | flushAndRunServer, | 10 | flushAndRunServer, |
11 | ServerInfo, | 11 | ServerInfo, |
12 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
13 | uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests | 13 | uploadVideo, uploadVideoAndGetId, viewVideo, wait, countVideoViewsOf, doubleFollow, waitJobs, cleanupTests, closeAllSequelize |
14 | } from '../../../../shared/extra-utils' | 14 | } from '../../../../shared/extra-utils' |
15 | import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' | 15 | import { getVideosOverview } from '../../../../shared/extra-utils/overviews/overviews' |
16 | import { VideosOverview } from '../../../../shared/models/overviews' | 16 | import { VideosOverview } from '../../../../shared/models/overviews' |
@@ -58,14 +58,14 @@ describe('Test video views cleaner', function () { | |||
58 | 58 | ||
59 | { | 59 | { |
60 | for (const server of servers) { | 60 | for (const server of servers) { |
61 | const total = await countVideoViewsOf(server.serverNumber, videoIdServer1) | 61 | const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1) |
62 | expect(total).to.equal(2) | 62 | expect(total).to.equal(2) |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | { | 66 | { |
67 | for (const server of servers) { | 67 | for (const server of servers) { |
68 | const total = await countVideoViewsOf(server.serverNumber, videoIdServer2) | 68 | const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer2) |
69 | expect(total).to.equal(2) | 69 | expect(total).to.equal(2) |
70 | } | 70 | } |
71 | } | 71 | } |
@@ -74,8 +74,6 @@ describe('Test video views cleaner', function () { | |||
74 | it('Should clean old video views', async function () { | 74 | it('Should clean old video views', async function () { |
75 | this.timeout(50000) | 75 | this.timeout(50000) |
76 | 76 | ||
77 | this.timeout(50000) | ||
78 | |||
79 | killallServers([ servers[0] ]) | 77 | killallServers([ servers[0] ]) |
80 | 78 | ||
81 | await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } }) | 79 | await reRunServer(servers[0], { views: { videos: { remote: { max_age: '5 seconds' } } } }) |
@@ -86,21 +84,23 @@ describe('Test video views cleaner', function () { | |||
86 | 84 | ||
87 | { | 85 | { |
88 | for (const server of servers) { | 86 | for (const server of servers) { |
89 | const total = await countVideoViewsOf(server.serverNumber, videoIdServer1) | 87 | const total = await countVideoViewsOf(server.internalServerNumber, videoIdServer1) |
90 | expect(total).to.equal(2) | 88 | expect(total).to.equal(2) |
91 | } | 89 | } |
92 | } | 90 | } |
93 | 91 | ||
94 | { | 92 | { |
95 | const totalServer1 = await countVideoViewsOf(servers[0].serverNumber, videoIdServer2) | 93 | const totalServer1 = await countVideoViewsOf(servers[0].internalServerNumber, videoIdServer2) |
96 | expect(totalServer1).to.equal(0) | 94 | expect(totalServer1).to.equal(0) |
97 | 95 | ||
98 | const totalServer2 = await countVideoViewsOf(servers[1].serverNumber, videoIdServer2) | 96 | const totalServer2 = await countVideoViewsOf(servers[1].internalServerNumber, videoIdServer2) |
99 | expect(totalServer2).to.equal(2) | 97 | expect(totalServer2).to.equal(2) |
100 | } | 98 | } |
101 | }) | 99 | }) |
102 | 100 | ||
103 | after(async function () { | 101 | after(async function () { |
102 | await closeAllSequelize(servers) | ||
103 | |||
104 | await cleanupTests(servers) | 104 | await cleanupTests(servers) |
105 | }) | 105 | }) |
106 | }) | 106 | }) |