diff options
author | Chocobozzz <me@florianbigard.com> | 2019-05-16 08:43:35 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-05-16 08:43:35 +0200 |
commit | bec4ea343987c69252b84d02f444c0f033d4a3f9 (patch) | |
tree | c0c709104aa97f1b5472a17e3e0c1436ab2dab06 /server/tests/api/redundancy/redundancy.ts | |
parent | ab5f9ed86e08cb7de3a1be955ca991a4517bdc57 (diff) | |
parent | d183ee9bda2588f07032ca4a2fce58651e684abf (diff) | |
download | PeerTube-bec4ea343987c69252b84d02f444c0f033d4a3f9.tar.gz PeerTube-bec4ea343987c69252b84d02f444c0f033d4a3f9.tar.zst PeerTube-bec4ea343987c69252b84d02f444c0f033d4a3f9.zip |
Merge branch 'feature/parallel-tests' into develop
Diffstat (limited to 'server/tests/api/redundancy/redundancy.ts')
-rw-r--r-- | server/tests/api/redundancy/redundancy.ts | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index e31329c25..6f2c59076 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -100,7 +100,7 @@ async function check1WebSeed (videoUUID?: string) { | |||
100 | if (!videoUUID) videoUUID = video1Server2UUID | 100 | if (!videoUUID) videoUUID = video1Server2UUID |
101 | 101 | ||
102 | const webseeds = [ | 102 | const webseeds = [ |
103 | 'http://localhost:9002/static/webseed/' + videoUUID | 103 | `http://localhost:${servers[ 1 ].port}/static/webseed/${videoUUID}` |
104 | ] | 104 | ] |
105 | 105 | ||
106 | for (const server of servers) { | 106 | for (const server of servers) { |
@@ -118,8 +118,8 @@ async function check2Webseeds (videoUUID?: string) { | |||
118 | if (!videoUUID) videoUUID = video1Server2UUID | 118 | if (!videoUUID) videoUUID = video1Server2UUID |
119 | 119 | ||
120 | const webseeds = [ | 120 | const webseeds = [ |
121 | 'http://localhost:9001/static/redundancy/' + videoUUID, | 121 | `http://localhost:${servers[ 0 ].port}/static/redundancy/${videoUUID}`, |
122 | 'http://localhost:9002/static/webseed/' + videoUUID | 122 | `http://localhost:${servers[ 1 ].port}/static/webseed/${videoUUID}` |
123 | ] | 123 | ] |
124 | 124 | ||
125 | for (const server of servers) { | 125 | for (const server of servers) { |
@@ -145,7 +145,12 @@ async function check2Webseeds (videoUUID?: string) { | |||
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | for (const directory of [ 'test1/redundancy', 'test2/videos' ]) { | 148 | const directories = [ |
149 | 'test' + servers[0].internalServerNumber + '/redundancy', | ||
150 | 'test' + servers[1].internalServerNumber + '/videos' | ||
151 | ] | ||
152 | |||
153 | for (const directory of directories) { | ||
149 | const files = await readdir(join(root(), directory)) | 154 | const files = await readdir(join(root(), directory)) |
150 | expect(files).to.have.length.at.least(4) | 155 | expect(files).to.have.length.at.least(4) |
151 | 156 | ||
@@ -194,7 +199,12 @@ async function check1PlaylistRedundancies (videoUUID?: string) { | |||
194 | await checkSegmentHash(baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist) | 199 | await checkSegmentHash(baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist) |
195 | } | 200 | } |
196 | 201 | ||
197 | for (const directory of [ 'test1/redundancy/hls', 'test2/streaming-playlists/hls' ]) { | 202 | const directories = [ |
203 | 'test' + servers[0].internalServerNumber + '/redundancy/hls', | ||
204 | 'test' + servers[1].internalServerNumber + '/streaming-playlists/hls' | ||
205 | ] | ||
206 | |||
207 | for (const directory of directories) { | ||
198 | const files = await readdir(join(root(), directory, videoUUID)) | 208 | const files = await readdir(join(root(), directory, videoUUID)) |
199 | expect(files).to.have.length.at.least(4) | 209 | expect(files).to.have.length.at.least(4) |
200 | 210 | ||
@@ -239,8 +249,8 @@ async function enableRedundancyOnServer1 () { | |||
239 | 249 | ||
240 | const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt') | 250 | const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt') |
241 | const follows: ActorFollow[] = res.body.data | 251 | const follows: ActorFollow[] = res.body.data |
242 | const server2 = follows.find(f => f.following.host === 'localhost:9002') | 252 | const server2 = follows.find(f => f.following.host === `localhost:${servers[ 1 ].port}`) |
243 | const server3 = follows.find(f => f.following.host === 'localhost:9003') | 253 | const server3 = follows.find(f => f.following.host === `localhost:${servers[ 2 ].port}`) |
244 | 254 | ||
245 | expect(server3).to.not.be.undefined | 255 | expect(server3).to.not.be.undefined |
246 | expect(server3.following.hostRedundancyAllowed).to.be.false | 256 | expect(server3.following.hostRedundancyAllowed).to.be.false |
@@ -254,8 +264,8 @@ async function disableRedundancyOnServer1 () { | |||
254 | 264 | ||
255 | const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt') | 265 | const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt') |
256 | const follows: ActorFollow[] = res.body.data | 266 | const follows: ActorFollow[] = res.body.data |
257 | const server2 = follows.find(f => f.following.host === 'localhost:9002') | 267 | const server2 = follows.find(f => f.following.host === `localhost:${servers[ 1 ].port}`) |
258 | const server3 = follows.find(f => f.following.host === 'localhost:9003') | 268 | const server3 = follows.find(f => f.following.host === `localhost:${servers[ 2 ].port}`) |
259 | 269 | ||
260 | expect(server3).to.not.be.undefined | 270 | expect(server3).to.not.be.undefined |
261 | expect(server3.following.hostRedundancyAllowed).to.be.false | 271 | expect(server3.following.hostRedundancyAllowed).to.be.false |
@@ -475,12 +485,12 @@ describe('Test videos redundancy', function () { | |||
475 | await wait(10000) | 485 | await wait(10000) |
476 | 486 | ||
477 | try { | 487 | try { |
478 | await checkContains(servers, 'http%3A%2F%2Flocalhost%3A9001') | 488 | await checkContains(servers, 'http%3A%2F%2Flocalhost%3A' + servers[0].port) |
479 | } catch { | 489 | } catch { |
480 | // Maybe a server deleted a redundancy in the scheduler | 490 | // Maybe a server deleted a redundancy in the scheduler |
481 | await wait(2000) | 491 | await wait(2000) |
482 | 492 | ||
483 | await checkContains(servers, 'http%3A%2F%2Flocalhost%3A9001') | 493 | await checkContains(servers, 'http%3A%2F%2Flocalhost%3A' + servers[0].port) |
484 | } | 494 | } |
485 | }) | 495 | }) |
486 | 496 | ||
@@ -491,7 +501,7 @@ describe('Test videos redundancy', function () { | |||
491 | 501 | ||
492 | await wait(15000) | 502 | await wait(15000) |
493 | 503 | ||
494 | await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A9001') | 504 | await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A' + servers[0].port) |
495 | }) | 505 | }) |
496 | 506 | ||
497 | after(async function () { | 507 | after(async function () { |