aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/friends-advanced.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-24 19:41:30 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-26 09:11:38 +0200
commit5f04dd2f743961e0a06c29531cc3ccc9e4928d56 (patch)
treea73085d0d83affc2377b78a2c7c25bda08d26388 /server/tests/api/friends-advanced.ts
parent72c7248b6fdcdb2175e726ff51b42e7555f2bd84 (diff)
downloadPeerTube-5f04dd2f743961e0a06c29531cc3ccc9e4928d56.tar.gz
PeerTube-5f04dd2f743961e0a06c29531cc3ccc9e4928d56.tar.zst
PeerTube-5f04dd2f743961e0a06c29531cc3ccc9e4928d56.zip
Add video channel tests
Diffstat (limited to 'server/tests/api/friends-advanced.ts')
-rw-r--r--server/tests/api/friends-advanced.ts61
1 files changed, 46 insertions, 15 deletions
diff --git a/server/tests/api/friends-advanced.ts b/server/tests/api/friends-advanced.ts
index dc5c83c5e..fbfdf227e 100644
--- a/server/tests/api/friends-advanced.ts
+++ b/server/tests/api/friends-advanced.ts
@@ -72,7 +72,7 @@ describe('Test advanced friends', function () {
72 await setAccessTokensToServers(servers) 72 await setAccessTokensToServers(servers)
73 }) 73 })
74 74
75 it('Should make friends with two pod each in a different group', async function () { 75 it('Should not make friends with two different groups', async function () {
76 this.timeout(20000) 76 this.timeout(20000)
77 77
78 // Pod 3 makes friend with the first one 78 // Pod 3 makes friend with the first one
@@ -81,7 +81,7 @@ describe('Test advanced friends', function () {
81 // Pod 4 makes friend with the second one 81 // Pod 4 makes friend with the second one
82 await makeFriendsWrapper(4) 82 await makeFriendsWrapper(4)
83 83
84 // Now if the fifth wants to make friends with the third et the first 84 // Now if the fifth wants to make friends with the third and the first
85 await makeFriendsWrapper(5) 85 await makeFriendsWrapper(5)
86 86
87 await wait(11000) 87 await wait(11000)
@@ -104,8 +104,8 @@ describe('Test advanced friends', function () {
104 } 104 }
105 }) 105 })
106 106
107 it('Should make friends with the pods 1, 2, 3', async function () { 107 it('Should remove bad pod and new pod should not become friend with it', async function () {
108 this.timeout(150000) 108 this.timeout(200000)
109 109
110 // Pods 1, 2, 3 and 4 become friends 110 // Pods 1, 2, 3 and 4 become friends
111 await makeFriendsWrapper(2) 111 await makeFriendsWrapper(2)
@@ -119,6 +119,9 @@ describe('Test advanced friends', function () {
119 expect(res.body.data.length).to.equal(3) 119 expect(res.body.data.length).to.equal(3)
120 } 120 }
121 121
122 // Wait initial video channel requests
123 await wait(11000)
124
122 // Kill pod 4 125 // Kill pod 4
123 servers[3].app.kill() 126 servers[3].app.kill()
124 127
@@ -133,6 +136,16 @@ describe('Test advanced friends', function () {
133 136
134 await wait(11000) 137 await wait(11000)
135 138
139 await uploadVideoWrapper(1)
140 await uploadVideoWrapper(2)
141
142 await wait(11000)
143
144 await uploadVideoWrapper(1)
145 await uploadVideoWrapper(2)
146
147 await wait(11000)
148
136 serverNumbersToTest = [ 1, 2 ] 149 serverNumbersToTest = [ 1, 2 ]
137 150
138 for (const i of serverNumbersToTest) { 151 for (const i of serverNumbersToTest) {
@@ -147,31 +160,39 @@ describe('Test advanced friends', function () {
147 } 160 }
148 } 161 }
149 162
150 // Rerun server 4 163 // Rerun server 4
151 const newServer = await runServer(4) 164 const newServer = await runServer(4)
152 servers[3].app = newServer.app 165 servers[3].app = newServer.app
153 servers[3].app 166 servers[3].app
154 167
155 const res1 = await getFriendsListWrapper(4)
156
157 // Pod 4 didn't know pod 1 and 2 removed it 168 // Pod 4 didn't know pod 1 and 2 removed it
169 const res1 = await getFriendsListWrapper(4)
158 expect(res1.body.data.length).to.equal(3) 170 expect(res1.body.data.length).to.equal(3)
159 171
172 // Pod 3 didn't upload video, it's still friend with pod 3
173 const res2 = await getFriendsListWrapper(3)
174 expect(res2.body.data.length).to.equal(3)
175
160 // Pod 6 asks pod 1, 2 and 3 176 // Pod 6 asks pod 1, 2 and 3
161 await makeFriendsWrapper(6) 177 await makeFriendsWrapper(6)
162 178
163 await wait(11000) 179 await wait(11000)
164 180
165 const res2 = await getFriendsListWrapper(6) 181 const res3 = await getFriendsListWrapper(6)
166 182
167 // Pod 4 should not be our friend 183 // Pod 4 should not be our friend
168 const friends = res2.body.data 184 const friends = res3.body.data
169 expect(friends.length).to.equal(3) 185 expect(friends.length).to.equal(3)
170 for (const pod of friends) { 186 for (const pod of friends) {
171 expect(pod.host).not.equal(servers[3].host) 187 expect(pod.host).not.equal(servers[3].host)
172 } 188 }
173 }) 189 })
174 190
191 // Pod 1 is friend with : 2 3 6
192 // Pod 2 is friend with : 1 3 6
193 // Pod 3 is friend with : 1 2 4 6
194 // Pod 4 is friend with : 1 2 3
195 // Pod 6 is friend with : 1 2 3
175 it('Should pod 1 quit friends', async function () { 196 it('Should pod 1 quit friends', async function () {
176 this.timeout(25000) 197 this.timeout(25000)
177 198
@@ -180,21 +201,26 @@ describe('Test advanced friends', function () {
180 201
181 await wait(15000) 202 await wait(15000)
182 203
204 // Pod 1 remove friends
183 await quitFriendsWrapper(1) 205 await quitFriendsWrapper(1)
184 206
185 // Remove pod 1 from pod 2
186 const res1 = await getVideosWrapper(1) 207 const res1 = await getVideosWrapper(1)
187 const videos1 = res1.body.data 208 const videos1 = res1.body.data
188 expect(videos1).to.be.an('array') 209 expect(videos1).to.be.an('array')
189 expect(videos1.length).to.equal(2) 210 expect(videos1.length).to.equal(4)
190 211
191 const res2 = await getVideosWrapper(2) 212 const res2 = await getVideosWrapper(2)
192 const videos2 = res2.body.data 213 const videos2 = res2.body.data
193 expect(videos2).to.be.an('array') 214 expect(videos2).to.be.an('array')
194 expect(videos2.length).to.equal(3) 215 expect(videos2.length).to.equal(5)
195 }) 216 })
196 217
197 it('Should make friends between pod 1 and 2 and exchange their videos', async function () { 218 // Pod 1 is friend with nothing
219 // Pod 2 is friend with : 3 6
220 // Pod 3 is friend with : 2 4 6
221 // Pod 4 is friend with : 2 3
222 // Pod 6 is friend with : 2 3
223 it('Should make friends between pod 1, 2, 3 and 6 and exchange their videos', async function () {
198 this.timeout(20000) 224 this.timeout(20000)
199 225
200 await makeFriendsWrapper(1) 226 await makeFriendsWrapper(1)
@@ -204,10 +230,15 @@ describe('Test advanced friends', function () {
204 const res = await getVideosWrapper(1) 230 const res = await getVideosWrapper(1)
205 const videos = res.body.data 231 const videos = res.body.data
206 expect(videos).to.be.an('array') 232 expect(videos).to.be.an('array')
207 expect(videos.length).to.equal(5) 233 expect(videos.length).to.equal(9)
208 }) 234 })
209 235
210 it('Should allow pod 6 to quit pod 1 & 2 and be friend with pod 3', async function () { 236 // Pod 1 is friend with : 2 3 6
237 // Pod 2 is friend with : 1 3 6
238 // Pod 3 is friend with : 1 2 4 6
239 // Pod 4 is friend with : 2 3
240 // Pod 6 is friend with : 1 2 3
241 it('Should allow pod 6 to quit pod 1, 2 and 3 and be friend with pod 3', async function () {
211 this.timeout(30000) 242 this.timeout(30000)
212 243
213 // Pod 3 should have 4 friends 244 // Pod 3 should have 4 friends