diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-17 11:35:10 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | afffe98839db7ccbfa9fb8b7d1413b97900fdc73 (patch) | |
tree | f0b3cbe58f73e81a5ba4bb31dabd9691994cf2ca /server/tests/api/video-abuse.ts | |
parent | 1b3989b0961d22a5a45ad16239e3c3f58f66180c (diff) | |
download | PeerTube-afffe98839db7ccbfa9fb8b7d1413b97900fdc73.tar.gz PeerTube-afffe98839db7ccbfa9fb8b7d1413b97900fdc73.tar.zst PeerTube-afffe98839db7ccbfa9fb8b7d1413b97900fdc73.zip |
Speed up activity pub http requests
Diffstat (limited to 'server/tests/api/video-abuse.ts')
-rw-r--r-- | server/tests/api/video-abuse.ts | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/server/tests/api/video-abuse.ts b/server/tests/api/video-abuse.ts index f2a2c322a..bc21ee59b 100644 --- a/server/tests/api/video-abuse.ts +++ b/server/tests/api/video-abuse.ts | |||
@@ -1,22 +1,22 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* tslint:disable:no-unused-expression */ |
2 | 2 | ||
3 | import 'mocha' | ||
4 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
5 | const expect = chai.expect | 4 | import 'mocha' |
6 | |||
7 | import { | 5 | import { |
8 | ServerInfo, | ||
9 | flushAndRunMultipleServers, | 6 | flushAndRunMultipleServers, |
10 | uploadVideo, | 7 | flushTests, |
11 | makeFriends, | ||
12 | getVideosList, | ||
13 | wait, | ||
14 | setAccessTokensToServers, | ||
15 | getVideoAbusesList, | 8 | getVideoAbusesList, |
16 | reportVideoAbuse, | 9 | getVideosList, |
17 | killallServers, | 10 | killallServers, |
18 | flushTests | 11 | reportVideoAbuse, |
12 | ServerInfo, | ||
13 | setAccessTokensToServers, | ||
14 | uploadVideo, | ||
15 | wait | ||
19 | } from '../utils' | 16 | } from '../utils' |
17 | import { doubleFollow } from '../utils/follows' | ||
18 | |||
19 | const expect = chai.expect | ||
20 | 20 | ||
21 | describe('Test video abuses', function () { | 21 | describe('Test video abuses', function () { |
22 | let servers: ServerInfo[] = [] | 22 | let servers: ServerInfo[] = [] |
@@ -30,32 +30,32 @@ describe('Test video abuses', function () { | |||
30 | // Get the access tokens | 30 | // Get the access tokens |
31 | await setAccessTokensToServers(servers) | 31 | await setAccessTokensToServers(servers) |
32 | 32 | ||
33 | // Pod 1 makes friend with pod 2 | 33 | // Server 1 and server 2 follow each other |
34 | await makeFriends(servers[0].url, servers[0].accessToken) | 34 | await doubleFollow(servers[0], servers[1]) |
35 | 35 | ||
36 | // Upload some videos on each pods | 36 | // Upload some videos on each servers |
37 | const video1Attributes = { | 37 | const video1Attributes = { |
38 | name: 'my super name for pod 1', | 38 | name: 'my super name for server 1', |
39 | description: 'my super description for pod 1' | 39 | description: 'my super description for server 1' |
40 | } | 40 | } |
41 | await uploadVideo(servers[0].url, servers[0].accessToken, video1Attributes) | 41 | await uploadVideo(servers[0].url, servers[0].accessToken, video1Attributes) |
42 | 42 | ||
43 | const video2Attributes = { | 43 | const video2Attributes = { |
44 | name: 'my super name for pod 2', | 44 | name: 'my super name for server 2', |
45 | description: 'my super description for pod 2' | 45 | description: 'my super description for server 2' |
46 | } | 46 | } |
47 | await uploadVideo(servers[1].url, servers[1].accessToken, video2Attributes) | 47 | await uploadVideo(servers[1].url, servers[1].accessToken, video2Attributes) |
48 | 48 | ||
49 | // Wait videos propagation | 49 | // Wait videos propagation |
50 | await wait(22000) | 50 | await wait(25000) |
51 | 51 | ||
52 | const res = await getVideosList(servers[0].url) | 52 | const res = await getVideosList(servers[0].url) |
53 | const videos = res.body.data | 53 | const videos = res.body.data |
54 | 54 | ||
55 | expect(videos.length).to.equal(2) | 55 | expect(videos.length).to.equal(2) |
56 | 56 | ||
57 | servers[0].video = videos.find(video => video.name === 'my super name for pod 1') | 57 | servers[0].video = videos.find(video => video.name === 'my super name for server 1') |
58 | servers[1].video = videos.find(video => video.name === 'my super name for pod 2') | 58 | servers[1].video = videos.find(video => video.name === 'my super name for server 2') |
59 | }) | 59 | }) |
60 | 60 | ||
61 | it('Should not have video abuses', async function () { | 61 | it('Should not have video abuses', async function () { |
@@ -72,11 +72,11 @@ describe('Test video abuses', function () { | |||
72 | const reason = 'my super bad reason' | 72 | const reason = 'my super bad reason' |
73 | await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[0].video.id, reason) | 73 | await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[0].video.id, reason) |
74 | 74 | ||
75 | // We wait requests propagation, even if the pod 1 is not supposed to make a request to pod 2 | 75 | // We wait requests propagation, even if the server 1 is not supposed to make a request to server 2 |
76 | await wait(11000) | 76 | await wait(11000) |
77 | }) | 77 | }) |
78 | 78 | ||
79 | it('Should have 1 video abuses on pod 1 and 0 on pod 2', async function () { | 79 | it('Should have 1 video abuses on server 1 and 0 on server 2', async function () { |
80 | const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 80 | const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) |
81 | 81 | ||
82 | expect(res1.body.total).to.equal(1) | 82 | expect(res1.body.total).to.equal(1) |
@@ -86,7 +86,7 @@ describe('Test video abuses', function () { | |||
86 | const abuse = res1.body.data[0] | 86 | const abuse = res1.body.data[0] |
87 | expect(abuse.reason).to.equal('my super bad reason') | 87 | expect(abuse.reason).to.equal('my super bad reason') |
88 | expect(abuse.reporterUsername).to.equal('root') | 88 | expect(abuse.reporterUsername).to.equal('root') |
89 | expect(abuse.reporterPodHost).to.equal('localhost:9001') | 89 | expect(abuse.reporterServerHost).to.equal('localhost:9001') |
90 | expect(abuse.videoId).to.equal(servers[0].video.id) | 90 | expect(abuse.videoId).to.equal(servers[0].video.id) |
91 | 91 | ||
92 | const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 92 | const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) |
@@ -96,16 +96,16 @@ describe('Test video abuses', function () { | |||
96 | }) | 96 | }) |
97 | 97 | ||
98 | it('Should report abuse on a remote video', async function () { | 98 | it('Should report abuse on a remote video', async function () { |
99 | this.timeout(15000) | 99 | this.timeout(25000) |
100 | 100 | ||
101 | const reason = 'my super bad reason 2' | 101 | const reason = 'my super bad reason 2' |
102 | await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[1].video.id, reason) | 102 | await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[1].video.id, reason) |
103 | 103 | ||
104 | // We wait requests propagation | 104 | // We wait requests propagation |
105 | await wait(11000) | 105 | await wait(15000) |
106 | }) | 106 | }) |
107 | 107 | ||
108 | it('Should have 2 video abuse on pod 1 and 1 on pod 2', async function () { | 108 | it('Should have 2 video abuse on server 1 and 1 on server 2', async function () { |
109 | const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 109 | const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) |
110 | expect(res1.body.total).to.equal(2) | 110 | expect(res1.body.total).to.equal(2) |
111 | expect(res1.body.data).to.be.an('array') | 111 | expect(res1.body.data).to.be.an('array') |
@@ -114,13 +114,13 @@ describe('Test video abuses', function () { | |||
114 | const abuse1 = res1.body.data[0] | 114 | const abuse1 = res1.body.data[0] |
115 | expect(abuse1.reason).to.equal('my super bad reason') | 115 | expect(abuse1.reason).to.equal('my super bad reason') |
116 | expect(abuse1.reporterUsername).to.equal('root') | 116 | expect(abuse1.reporterUsername).to.equal('root') |
117 | expect(abuse1.reporterPodHost).to.equal('localhost:9001') | 117 | expect(abuse1.reporterServerHost).to.equal('localhost:9001') |
118 | expect(abuse1.videoId).to.equal(servers[0].video.id) | 118 | expect(abuse1.videoId).to.equal(servers[0].video.id) |
119 | 119 | ||
120 | const abuse2 = res1.body.data[1] | 120 | const abuse2 = res1.body.data[1] |
121 | expect(abuse2.reason).to.equal('my super bad reason 2') | 121 | expect(abuse2.reason).to.equal('my super bad reason 2') |
122 | expect(abuse2.reporterUsername).to.equal('root') | 122 | expect(abuse2.reporterUsername).to.equal('root') |
123 | expect(abuse2.reporterPodHost).to.equal('localhost:9001') | 123 | expect(abuse2.reporterServerHost).to.equal('localhost:9001') |
124 | expect(abuse2.videoId).to.equal(servers[1].video.id) | 124 | expect(abuse2.videoId).to.equal(servers[1].video.id) |
125 | 125 | ||
126 | const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 126 | const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) |
@@ -131,7 +131,7 @@ describe('Test video abuses', function () { | |||
131 | const abuse3 = res2.body.data[0] | 131 | const abuse3 = res2.body.data[0] |
132 | expect(abuse3.reason).to.equal('my super bad reason 2') | 132 | expect(abuse3.reason).to.equal('my super bad reason 2') |
133 | expect(abuse3.reporterUsername).to.equal('root') | 133 | expect(abuse3.reporterUsername).to.equal('root') |
134 | expect(abuse3.reporterPodHost).to.equal('localhost:9001') | 134 | expect(abuse3.reporterServerHost).to.equal('localhost:9001') |
135 | }) | 135 | }) |
136 | 136 | ||
137 | after(async function () { | 137 | after(async function () { |