1
|
|
|
"""Module to test the KytosGraph in graph.py.""" |
2
|
|
|
from itertools import combinations |
3
|
|
|
|
4
|
|
|
# Core modules to import |
5
|
|
|
from kytos.core.link import Link |
6
|
|
|
|
7
|
|
|
# module under test |
8
|
|
|
from tests.integration.test_results import TestResults |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
class TestResultsEdges(TestResults): |
12
|
|
|
"""Tests for the graph class. |
13
|
|
|
|
14
|
|
|
Tests to see if reflexive searches and impossible searches |
15
|
|
|
show correct results. |
16
|
|
|
""" |
17
|
|
|
|
18
|
|
|
def test_path1(self): |
19
|
|
|
"""Tests paths between all users using unconstrained path algorithm.""" |
20
|
|
|
combos = combinations(["User1", "User2", "User3", "User4"], 2) |
21
|
|
|
self.initializer() |
22
|
|
|
|
23
|
|
|
valid = True |
24
|
|
|
for point_a, point_b in combos: |
25
|
|
|
results = self.get_path(point_a, point_b) |
26
|
|
|
if not results: |
27
|
|
|
valid = False |
28
|
|
|
break |
29
|
|
|
|
30
|
|
|
self.assertNotEqual(valid, False) |
31
|
|
|
|
32
|
|
|
def test_path12(self): |
33
|
|
|
"""Tests paths between all users using unconstrained path algorithm.""" |
34
|
|
|
combos = combinations(["User1", "User2", "User3", "User4", "User5"], 2) |
35
|
|
|
self.initializer() |
36
|
|
|
|
37
|
|
|
valid = True |
38
|
|
|
for point_a, point_b in combos: |
39
|
|
|
results = self.get_path(point_a, point_b) |
40
|
|
|
if not results: |
41
|
|
|
valid = False |
42
|
|
|
break |
43
|
|
|
|
44
|
|
|
self.assertEqual(valid, False) |
45
|
|
|
|
46
|
|
|
def test_path2(self): |
47
|
|
|
"""Tests paths between all users using constrained path algorithm, |
48
|
|
|
with no constraints set. |
49
|
|
|
""" |
50
|
|
|
combos = combinations(["User1", "User2", "User3", "User4"], 2) |
51
|
|
|
self.initializer() |
52
|
|
|
|
53
|
|
|
for point_a, point_b in combos: |
54
|
|
|
results = self.get_path_constrained(point_a, point_b) |
55
|
|
|
self.assertNotEqual(results, []) |
56
|
|
|
|
57
|
|
|
def paths_between_all_users(self, item, base=None): |
58
|
|
|
combos = combinations(["User1", "User2", "User3", "User4"], 2) |
59
|
|
|
self.initializer() |
60
|
|
|
|
61
|
|
|
if base is not None: |
62
|
|
|
value = {my_key: my_val for (my_key, my_val) in base.items()} |
63
|
|
|
base.update(value) |
64
|
|
|
|
65
|
|
|
valid = True |
66
|
|
|
for point_a, point_b in combos: |
67
|
|
|
results = self.get_path_constrained( |
68
|
|
|
point_a, point_b, base=base) |
69
|
|
|
for result in results: |
70
|
|
|
for path in result["paths"]: |
71
|
|
|
if item in path: |
72
|
|
|
valid = False |
73
|
|
|
|
74
|
|
|
return valid |
75
|
|
|
|
76
|
|
|
def test_path3_1(self): |
77
|
|
|
"""Tests paths between all users using constrained path algorithm, |
78
|
|
|
with the ownership constraint set to B. |
79
|
|
|
""" |
80
|
|
|
self.assertTrue(self.paths_between_all_users("S4:1", {'ownership': "B"})) |
81
|
|
|
|
82
|
|
|
def test_path3_2(self): |
83
|
|
|
"""Tests paths between all users using constrained path algorithm, |
84
|
|
|
with the ownership constraint set to B. |
85
|
|
|
""" |
86
|
|
|
self.assertTrue(self.paths_between_all_users("S5:2", {'ownership': "B"})) |
87
|
|
|
|
88
|
|
|
def test_path3_3(self): |
89
|
|
|
"""Tests paths between all users using constrained path algorithm, |
90
|
|
|
with the ownership constraint set to B. |
91
|
|
|
""" |
92
|
|
|
self.assertTrue(self.paths_between_all_users("S4:2", {'ownership': "B"})) |
93
|
|
|
|
94
|
|
|
def test_path3_4(self): |
95
|
|
|
"""Tests paths between all users using constrained path algorithm, |
96
|
|
|
with the ownership constraint set to B. |
97
|
|
|
""" |
98
|
|
|
self.assertTrue(self.paths_between_all_users("User1:2", {'ownership': "B"})) |
99
|
|
|
|
100
|
|
|
def test_path3_5(self): |
101
|
|
|
"""Tests paths between all users using constrained path algorithm, |
102
|
|
|
with the ownership constraint set to B. |
103
|
|
|
""" |
104
|
|
|
self.assertTrue(self.paths_between_all_users("S5:4", {'ownership': "B"})) |
105
|
|
|
|
106
|
|
|
def test_path3_6(self): |
107
|
|
|
"""Tests paths between all users using constrained path algorithm, |
108
|
|
|
with the ownership constraint set to B. |
109
|
|
|
""" |
110
|
|
|
self.assertTrue(self.paths_between_all_users("S6:2", {'ownership': "B"})) |
111
|
|
|
|
112
|
|
|
def test_path3_7(self): |
113
|
|
|
"""Tests paths between all users using constrained path algorithm, |
114
|
|
|
with the ownership constraint set to B. |
115
|
|
|
""" |
116
|
|
|
self.assertTrue(self.paths_between_all_users("S6:5", {'ownership': "B"})) |
117
|
|
|
|
118
|
|
|
def test_path3_8(self): |
119
|
|
|
"""Tests paths between all users using constrained path algorithm, |
120
|
|
|
with the ownership constraint set to B. |
121
|
|
|
""" |
122
|
|
|
self.assertTrue(self.paths_between_all_users("S10:1", {'ownership': "B"})) |
123
|
|
|
|
124
|
|
|
def test_path3_9(self): |
125
|
|
|
"""Tests paths between all users using constrained path algorithm, |
126
|
|
|
with the ownership constraint set to B. |
127
|
|
|
""" |
128
|
|
|
self.assertTrue(self.paths_between_all_users("S8:6", {'ownership': "B"})) |
129
|
|
|
|
130
|
|
|
def test_path3_1_0(self): |
131
|
|
|
"""Tests paths between all users using constrained path algorithm, |
132
|
|
|
with the ownership constraint set to B. |
133
|
|
|
""" |
134
|
|
|
self.assertTrue(self.paths_between_all_users("S10:2", {'ownership': "B"})) |
135
|
|
|
|
136
|
|
|
def test_path3_1_1(self): |
137
|
|
|
"""Tests paths between all users using constrained path algorithm, |
138
|
|
|
with the ownership constraint set to B. |
139
|
|
|
""" |
140
|
|
|
self.assertTrue(self.paths_between_all_users("S10:3", {'ownership': "B"})) |
141
|
|
|
|
142
|
|
|
def test_path3_1_2(self): |
143
|
|
|
"""Tests paths between all users using constrained path algorithm, |
144
|
|
|
with the ownership constraint set to B. |
145
|
|
|
""" |
146
|
|
|
self.assertTrue(self.paths_between_all_users("User2:1", {'ownership': "B"})) |
147
|
|
|
|
148
|
|
|
def test_path4_1(self): |
149
|
|
|
"""Tests paths between all users using constrained path algorithm, |
150
|
|
|
with the reliability constraint set to 3. |
151
|
|
|
""" |
152
|
|
|
self.assertTrue(self.paths_between_all_users("S4:1", {'reliability': 3})) |
153
|
|
|
|
154
|
|
|
def test_path4_2(self): |
155
|
|
|
"""Tests paths between all users using constrained path algorithm, |
156
|
|
|
with the reliability constraint set to 3. |
157
|
|
|
""" |
158
|
|
|
self.assertTrue(self.paths_between_all_users("S5:2", {'reliability': 3})) |
159
|
|
|
|
160
|
|
|
def test_path4_3(self): |
161
|
|
|
"""Tests paths between all users using constrained path algorithm, |
162
|
|
|
with the reliability constraint set to 3. |
163
|
|
|
""" |
164
|
|
|
self.assertTrue(self.paths_between_all_users("S5:3", {'reliability': 3})) |
165
|
|
|
|
166
|
|
|
def test_path4_4(self): |
167
|
|
|
"""Tests paths between all users using constrained path algorithm, |
168
|
|
|
with the reliability constraint set to 3. |
169
|
|
|
""" |
170
|
|
|
self.assertTrue(self.paths_between_all_users("S6:1", {'reliability': 3})) |
171
|
|
|
|
172
|
|
|
def test_path5_1(self): |
173
|
|
|
"""Tests paths between all users using constrained path algorithm, |
174
|
|
|
with the reliability constraint set to 3. |
175
|
|
|
""" |
176
|
|
|
self.assertTrue(self.paths_between_all_users("S3:1", {'bandwidth': 100})) |
177
|
|
|
|
178
|
|
|
def test_path5_2(self): |
179
|
|
|
"""Tests paths between all users using constrained path algorithm, |
180
|
|
|
with the reliability constraint set to 3. |
181
|
|
|
""" |
182
|
|
|
self.assertTrue(self.paths_between_all_users("S5:1", {'bandwidth': 100})) |
183
|
|
|
|
184
|
|
|
def test_path5_3(self): |
185
|
|
|
"""Tests paths between all users using constrained path algorithm, |
186
|
|
|
with the reliability constraint set to 3. |
187
|
|
|
""" |
188
|
|
|
self.assertTrue(self.paths_between_all_users("User1:4", {'bandwidth': 100})) |
189
|
|
|
|
190
|
|
|
def test_path5_4(self): |
191
|
|
|
"""Tests paths between all users using constrained path algorithm, |
192
|
|
|
with the reliability constraint set to 3. |
193
|
|
|
""" |
194
|
|
|
self.assertTrue(self.paths_between_all_users("User4:3", {'bandwidth': 100})) |
195
|
|
|
|
196
|
|
|
def test_path6_1(self): |
197
|
|
|
"""Tests paths between all users using constrained path algorithm, |
198
|
|
|
with the delay constraint set to 50. |
199
|
|
|
""" |
200
|
|
|
self.assertTrue(self.paths_between_all_users("S1:1", {'delay': 50})) |
201
|
|
|
|
202
|
|
|
def test_path6_2(self): |
203
|
|
|
"""Tests paths between all users using constrained path algorithm, |
204
|
|
|
with the delay constraint set to 50. |
205
|
|
|
""" |
206
|
|
|
self.assertTrue(self.paths_between_all_users("S2:1", {'delay': 50})) |
207
|
|
|
|
208
|
|
|
def test_path6_3(self): |
209
|
|
|
"""Tests paths between all users using constrained path algorithm, |
210
|
|
|
with the delay constraint set to 50. |
211
|
|
|
""" |
212
|
|
|
self.assertTrue(self.paths_between_all_users("S3:1", {'delay': 50})) |
213
|
|
|
|
214
|
|
|
def test_path6_4(self): |
215
|
|
|
"""Tests paths between all users using constrained path algorithm, |
216
|
|
|
with the delay constraint set to 50. |
217
|
|
|
""" |
218
|
|
|
self.assertTrue(self.paths_between_all_users("S5:1", {'delay': 50})) |
219
|
|
|
|
220
|
|
|
def test_path6_5(self): |
221
|
|
|
"""Tests paths between all users using constrained path algorithm, |
222
|
|
|
with the delay constraint set to 50. |
223
|
|
|
""" |
224
|
|
|
self.assertTrue(self.paths_between_all_users("S4:2", {'delay': 50})) |
225
|
|
|
|
226
|
|
|
def test_path6_6(self): |
227
|
|
|
"""Tests paths between all users using constrained path algorithm, |
228
|
|
|
with the delay constraint set to 50. |
229
|
|
|
""" |
230
|
|
|
self.assertTrue(self.paths_between_all_users("User1:2", {'delay': 50})) |
231
|
|
|
|
232
|
|
|
def test_path6_7(self): |
233
|
|
|
"""Tests paths between all users using constrained path algorithm, |
234
|
|
|
with the delay constraint set to 50. |
235
|
|
|
""" |
236
|
|
|
self.assertTrue(self.paths_between_all_users("S5:5", {'delay': 50})) |
237
|
|
|
|
238
|
|
|
def test_path6_8(self): |
239
|
|
|
"""Tests paths between all users using constrained path algorithm, |
240
|
|
|
with the delay constraint set to 50. |
241
|
|
|
""" |
242
|
|
|
self.assertTrue(self.paths_between_all_users("S8:2", {'delay': 50})) |
243
|
|
|
|
244
|
|
|
def test_path6_9(self): |
245
|
|
|
"""Tests paths between all users using constrained path algorithm, |
246
|
|
|
with the delay constraint set to 50. |
247
|
|
|
""" |
248
|
|
|
self.assertTrue(self.paths_between_all_users("S5:6", {'delay': 50})) |
249
|
|
|
|
250
|
|
|
def test_path6_1_0(self): |
251
|
|
|
"""Tests paths between all users using constrained path algorithm, |
252
|
|
|
with the delay constraint set to 50. |
253
|
|
|
""" |
254
|
|
|
self.assertTrue(self.paths_between_all_users("User1:3", {'delay': 50})) |
255
|
|
|
|
256
|
|
|
def test_path6_1_1(self): |
257
|
|
|
"""Tests paths between all users using constrained path algorithm, |
258
|
|
|
with the delay constraint set to 50. |
259
|
|
|
""" |
260
|
|
|
self.assertTrue(self.paths_between_all_users("S6:3", {'delay': 50})) |
261
|
|
|
|
262
|
|
|
def test_path6_1_2(self): |
263
|
|
|
"""Tests paths between all users using constrained path algorithm, |
264
|
|
|
with the delay constraint set to 50. |
265
|
|
|
""" |
266
|
|
|
self.assertTrue(self.paths_between_all_users("S9:1", {'delay': 50})) |
267
|
|
|
|
268
|
|
|
def test_path6_1_3(self): |
269
|
|
|
"""Tests paths between all users using constrained path algorithm, |
270
|
|
|
with the delay constraint set to 50. |
271
|
|
|
""" |
272
|
|
|
self.assertTrue(self.paths_between_all_users("S6:4", {'delay': 50})) |
273
|
|
|
|
274
|
|
|
def test_path6_1_4(self): |
275
|
|
|
"""Tests paths between all users using constrained path algorithm, |
276
|
|
|
with the delay constraint set to 50. |
277
|
|
|
""" |
278
|
|
|
self.assertTrue(self.paths_between_all_users("S9:2", {'delay': 50})) |
279
|
|
|
|
280
|
|
|
def test_path6_1_5(self): |
281
|
|
|
"""Tests paths between all users using constrained path algorithm, |
282
|
|
|
with the delay constraint set to 50. |
283
|
|
|
""" |
284
|
|
|
self.assertTrue(self.paths_between_all_users("S6:5", {'delay': 50})) |
285
|
|
|
|
286
|
|
|
def test_path6_1_6(self): |
287
|
|
|
"""Tests paths between all users using constrained path algorithm, |
288
|
|
|
with the delay constraint set to 50. |
289
|
|
|
""" |
290
|
|
|
self.assertTrue(self.paths_between_all_users("S6:5", {'delay': 50})) |
291
|
|
|
|
292
|
|
|
def test_path6_1_7(self): |
293
|
|
|
"""Tests paths between all users using constrained path algorithm, |
294
|
|
|
with the delay constraint set to 50. |
295
|
|
|
""" |
296
|
|
|
self.assertTrue(self.paths_between_all_users("S10:1", {'delay': 50})) |
297
|
|
|
|
298
|
|
|
def test_path6_1_8(self): |
299
|
|
|
"""Tests paths between all users using constrained path algorithm, |
300
|
|
|
with the delay constraint set to 50. |
301
|
|
|
""" |
302
|
|
|
self.assertTrue(self.paths_between_all_users("S8:5", {'delay': 50})) |
303
|
|
|
|
304
|
|
|
def test_path6_1_9(self): |
305
|
|
|
"""Tests paths between all users using constrained path algorithm, |
306
|
|
|
with the delay constraint set to 50. |
307
|
|
|
""" |
308
|
|
|
self.assertTrue(self.paths_between_all_users("S9:4", {'delay': 50})) |
309
|
|
|
|
310
|
|
|
def test_path6_2_0(self): |
311
|
|
|
"""Tests paths between all users using constrained path algorithm, |
312
|
|
|
with the delay constraint set to 50. |
313
|
|
|
""" |
314
|
|
|
self.assertTrue(self.paths_between_all_users("User1:4", {'delay': 50})) |
315
|
|
|
|
316
|
|
|
def test_path6_2_1(self): |
317
|
|
|
"""Tests paths between all users using constrained path algorithm, |
318
|
|
|
with the delay constraint set to 50. |
319
|
|
|
""" |
320
|
|
|
self.assertTrue(self.paths_between_all_users("User4:3", {'delay': 50})) |
321
|
|
|
|
322
|
|
|
def test_path7_1(self): |
323
|
|
|
"""Tests paths between all users using constrained path algorithm, |
324
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
325
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
326
|
|
|
constraint set to 'B' |
327
|
|
|
""" |
328
|
|
|
# delay = 50 |
329
|
|
|
self.assertTrue(self.paths_between_all_users("S1:1", {'delay': 50, |
330
|
|
|
'bandwidth': 100, |
331
|
|
|
'ownership': "B"})) |
332
|
|
|
|
333
|
|
|
def test_path7_2(self): |
334
|
|
|
"""Tests paths between all users using constrained path algorithm, |
335
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
336
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
337
|
|
|
constraint set to 'B' |
338
|
|
|
""" |
339
|
|
|
# delay = 50 |
340
|
|
|
self.assertTrue(self.paths_between_all_users("S2:1", {'delay': 50, |
341
|
|
|
'bandwidth': 100, |
342
|
|
|
'ownership': "B"})) |
343
|
|
|
|
344
|
|
|
def test_path7_3(self): |
345
|
|
|
"""Tests paths between all users using constrained path algorithm, |
346
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
347
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
348
|
|
|
constraint set to 'B' |
349
|
|
|
""" |
350
|
|
|
# delay = 50 |
351
|
|
|
self.assertTrue(self.paths_between_all_users("S3:1", {'delay': 50, |
352
|
|
|
'bandwidth': 100, |
353
|
|
|
'ownership': "B"})) |
354
|
|
|
|
355
|
|
|
def test_path7_4(self): |
356
|
|
|
"""Tests paths between all users using constrained path algorithm, |
357
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
358
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
359
|
|
|
constraint set to 'B' |
360
|
|
|
""" |
361
|
|
|
# delay = 50 |
362
|
|
|
self.assertTrue(self.paths_between_all_users("S5:1", {'delay': 50, |
363
|
|
|
'bandwidth': 100, |
364
|
|
|
'ownership': "B"})) |
365
|
|
|
|
366
|
|
|
def test_path7_5(self): |
367
|
|
|
"""Tests paths between all users using constrained path algorithm, |
368
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
369
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
370
|
|
|
constraint set to 'B' |
371
|
|
|
""" |
372
|
|
|
# delay = 50 |
373
|
|
|
self.assertTrue(self.paths_between_all_users("S4:2", {'delay': 50, |
374
|
|
|
'bandwidth': 100, |
375
|
|
|
'ownership': "B"})) |
376
|
|
|
|
377
|
|
|
def test_path7_6(self): |
378
|
|
|
"""Tests paths between all users using constrained path algorithm, |
379
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
380
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
381
|
|
|
constraint set to 'B' |
382
|
|
|
""" |
383
|
|
|
# delay = 50 |
384
|
|
|
self.assertTrue(self.paths_between_all_users("User1:2", {'delay': 50, |
385
|
|
|
'bandwidth': 100, |
386
|
|
|
'ownership': "B"})) |
387
|
|
|
|
388
|
|
|
def test_path7_7(self): |
389
|
|
|
"""Tests paths between all users using constrained path algorithm, |
390
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
391
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
392
|
|
|
constraint set to 'B' |
393
|
|
|
""" |
394
|
|
|
# delay = 50 |
395
|
|
|
self.assertTrue(self.paths_between_all_users("S5:5", {'delay': 50, |
396
|
|
|
'bandwidth': 100, |
397
|
|
|
'ownership': "B"})) |
398
|
|
|
|
399
|
|
|
def test_path7_8(self): |
400
|
|
|
"""Tests paths between all users using constrained path algorithm, |
401
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
402
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
403
|
|
|
constraint set to 'B' |
404
|
|
|
""" |
405
|
|
|
# delay = 50 |
406
|
|
|
self.assertTrue(self.paths_between_all_users("S8:2", {'delay': 50, |
407
|
|
|
'bandwidth': 100, |
408
|
|
|
'ownership': "B"})) |
409
|
|
|
|
410
|
|
|
def test_path7_9(self): |
411
|
|
|
"""Tests paths between all users using constrained path algorithm, |
412
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
413
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
414
|
|
|
constraint set to 'B' |
415
|
|
|
""" |
416
|
|
|
# delay = 50 |
417
|
|
|
self.assertTrue(self.paths_between_all_users("S5:6", {'delay': 50, |
418
|
|
|
'bandwidth': 100, |
419
|
|
|
'ownership': "B"})) |
420
|
|
|
|
421
|
|
|
def test_path7_1_0(self): |
422
|
|
|
"""Tests paths between all users using constrained path algorithm, |
423
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
424
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
425
|
|
|
constraint set to 'B' |
426
|
|
|
""" |
427
|
|
|
# delay = 50 |
428
|
|
|
self.assertTrue(self.paths_between_all_users("User1:3", {'delay': 50, |
429
|
|
|
'bandwidth': 100, |
430
|
|
|
'ownership': "B"})) |
431
|
|
|
|
432
|
|
|
def test_path7_1_1(self): |
433
|
|
|
"""Tests paths between all users using constrained path algorithm, |
434
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
435
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
436
|
|
|
constraint set to 'B' |
437
|
|
|
""" |
438
|
|
|
# delay = 50 |
439
|
|
|
self.assertTrue(self.paths_between_all_users("S6:3", {'delay': 50, |
440
|
|
|
'bandwidth': 100, |
441
|
|
|
'ownership': "B"})) |
442
|
|
|
|
443
|
|
|
def test_path7_1_2(self): |
444
|
|
|
"""Tests paths between all users using constrained path algorithm, |
445
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
446
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
447
|
|
|
constraint set to 'B' |
448
|
|
|
""" |
449
|
|
|
# delay = 50 |
450
|
|
|
self.assertTrue(self.paths_between_all_users("S9:1", {'delay': 50, |
451
|
|
|
'bandwidth': 100, |
452
|
|
|
'ownership': "B"})) |
453
|
|
|
|
454
|
|
|
def test_path7_1_3(self): |
455
|
|
|
"""Tests paths between all users using constrained path algorithm, |
456
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
457
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
458
|
|
|
constraint set to 'B' |
459
|
|
|
""" |
460
|
|
|
# delay = 50 |
461
|
|
|
self.assertTrue(self.paths_between_all_users("S6:4", {'delay': 50, |
462
|
|
|
'bandwidth': 100, |
463
|
|
|
'ownership': "B"})) |
464
|
|
|
|
465
|
|
|
def test_path7_1_4(self): |
466
|
|
|
"""Tests paths between all users using constrained path algorithm, |
467
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
468
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
469
|
|
|
constraint set to 'B' |
470
|
|
|
""" |
471
|
|
|
# delay = 50 |
472
|
|
|
self.assertTrue(self.paths_between_all_users("S9:2", {'delay': 50, |
473
|
|
|
'bandwidth': 100, |
474
|
|
|
'ownership': "B"})) |
475
|
|
|
|
476
|
|
|
def test_path7_1_5(self): |
477
|
|
|
"""Tests paths between all users using constrained path algorithm, |
478
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
479
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
480
|
|
|
constraint set to 'B' |
481
|
|
|
""" |
482
|
|
|
# delay = 50 |
483
|
|
|
self.assertTrue(self.paths_between_all_users("S6:5", {'delay': 50, |
484
|
|
|
'bandwidth': 100, |
485
|
|
|
'ownership': "B"})) |
486
|
|
|
|
487
|
|
|
def test_path7_1_6(self): |
488
|
|
|
"""Tests paths between all users using constrained path algorithm, |
489
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
490
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
491
|
|
|
constraint set to 'B' |
492
|
|
|
""" |
493
|
|
|
# delay = 50 |
494
|
|
|
self.assertTrue(self.paths_between_all_users("S10:1", {'delay': 50, |
495
|
|
|
'bandwidth': 100, |
496
|
|
|
'ownership': "B"})) |
497
|
|
|
|
498
|
|
|
def test_path7_1_7(self): |
499
|
|
|
"""Tests paths between all users using constrained path algorithm, |
500
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
501
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
502
|
|
|
constraint set to 'B' |
503
|
|
|
""" |
504
|
|
|
# delay = 50 |
505
|
|
|
self.assertTrue(self.paths_between_all_users("S8:5", {'delay': 50, |
506
|
|
|
'bandwidth': 100, |
507
|
|
|
'ownership': "B"})) |
508
|
|
|
|
509
|
|
|
def test_path7_1_8(self): |
510
|
|
|
"""Tests paths between all users using constrained path algorithm, |
511
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
512
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
513
|
|
|
constraint set to 'B' |
514
|
|
|
""" |
515
|
|
|
# delay = 50 |
516
|
|
|
self.assertTrue(self.paths_between_all_users("S9:4", {'delay': 50, |
517
|
|
|
'bandwidth': 100, |
518
|
|
|
'ownership': "B"})) |
519
|
|
|
|
520
|
|
|
def test_path7_1_9(self): |
521
|
|
|
"""Tests paths between all users using constrained path algorithm, |
522
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
523
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
524
|
|
|
constraint set to 'B' |
525
|
|
|
""" |
526
|
|
|
# delay = 50 |
527
|
|
|
self.assertTrue(self.paths_between_all_users("User1:4", {'delay': 50, |
528
|
|
|
'bandwidth': 100, |
529
|
|
|
'ownership': "B"})) |
530
|
|
|
|
531
|
|
|
def test_path7_2_0(self): |
532
|
|
|
"""Tests paths between all users using constrained path algorithm, |
533
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
534
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
535
|
|
|
constraint set to 'B' |
536
|
|
|
""" |
537
|
|
|
# delay = 50 |
538
|
|
|
self.assertTrue(self.paths_between_all_users("User4:3", {'delay': 50, |
539
|
|
|
'bandwidth': 100, |
540
|
|
|
'ownership': "B"})) |
541
|
|
|
|
542
|
|
|
def test_path7_2_1(self): |
543
|
|
|
"""Tests paths between all users using constrained path algorithm, |
544
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
545
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
546
|
|
|
constraint set to 'B' |
547
|
|
|
""" |
548
|
|
|
# bandwidth = 100 |
549
|
|
|
self.assertTrue(self.paths_between_all_users("S3:1", {'delay': 50, |
550
|
|
|
'bandwidth': 100, |
551
|
|
|
'ownership': "B"})) |
552
|
|
|
|
553
|
|
|
def test_path7_2_2(self): |
554
|
|
|
"""Tests paths between all users using constrained path algorithm, |
555
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
556
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
557
|
|
|
constraint set to 'B' |
558
|
|
|
""" |
559
|
|
|
# bandwidth = 100 |
560
|
|
|
self.assertTrue(self.paths_between_all_users("S5:1", {'delay': 50, |
561
|
|
|
'bandwidth': 100, |
562
|
|
|
'ownership': "B"})) |
563
|
|
|
|
564
|
|
|
def test_path7_2_3(self): |
565
|
|
|
"""Tests paths between all users using constrained path algorithm, |
566
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
567
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
568
|
|
|
constraint set to 'B' |
569
|
|
|
""" |
570
|
|
|
# bandwidth = 100 |
571
|
|
|
self.assertTrue(self.paths_between_all_users("User1:4", {'delay': 50, |
572
|
|
|
'bandwidth': 100, |
573
|
|
|
'ownership': "B"})) |
574
|
|
|
|
575
|
|
|
def test_path7_2_4(self): |
576
|
|
|
"""Tests paths between all users using constrained path algorithm, |
577
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
578
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
579
|
|
|
constraint set to 'B' |
580
|
|
|
""" |
581
|
|
|
# bandwidth = 100 |
582
|
|
|
self.assertTrue(self.paths_between_all_users("User4:3", {'delay': 50, |
583
|
|
|
'bandwidth': 100, |
584
|
|
|
'ownership': "B"})) |
585
|
|
|
|
586
|
|
|
def test_path7_2_5(self): |
587
|
|
|
"""Tests paths between all users using constrained path algorithm, |
588
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
589
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
590
|
|
|
constraint set to 'B' |
591
|
|
|
""" |
592
|
|
|
# reliability = 3 |
593
|
|
|
self.assertTrue(self.paths_between_all_users("S4:1", {'delay': 50, |
594
|
|
|
'bandwidth': 100, |
595
|
|
|
'ownership': "B"})) |
596
|
|
|
|
597
|
|
|
def test_path7_2_6(self): |
598
|
|
|
"""Tests paths between all users using constrained path algorithm, |
599
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
600
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
601
|
|
|
constraint set to 'B' |
602
|
|
|
""" |
603
|
|
|
# reliability = 3 |
604
|
|
|
self.assertTrue(self.paths_between_all_users("S5:2", {'delay': 50, |
605
|
|
|
'bandwidth': 100, |
606
|
|
|
'ownership': "B"})) |
607
|
|
|
|
608
|
|
|
def test_path7_2_7(self): |
609
|
|
|
"""Tests paths between all users using constrained path algorithm, |
610
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
611
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
612
|
|
|
constraint set to 'B' |
613
|
|
|
""" |
614
|
|
|
# reliability = 3 |
615
|
|
|
self.assertTrue(self.paths_between_all_users("S5:3", {'delay': 50, |
616
|
|
|
'bandwidth': 100, |
617
|
|
|
'ownership': "B"})) |
618
|
|
|
|
619
|
|
|
def test_path7_2_8(self): |
620
|
|
|
"""Tests paths between all users using constrained path algorithm, |
621
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
622
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
623
|
|
|
constraint set to 'B' |
624
|
|
|
""" |
625
|
|
|
# reliability = 3 |
626
|
|
|
self.assertTrue(self.paths_between_all_users("S6:1", {'delay': 50, |
627
|
|
|
'bandwidth': 100, |
628
|
|
|
'ownership': "B"})) |
629
|
|
|
|
630
|
|
|
def test_path7_2_9(self): |
631
|
|
|
"""Tests paths between all users using constrained path algorithm, |
632
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
633
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
634
|
|
|
constraint set to 'B' |
635
|
|
|
""" |
636
|
|
|
# ownership = "B" |
637
|
|
|
self.assertTrue(self.paths_between_all_users("S4:1", {'delay': 50, |
638
|
|
|
'bandwidth': 100, |
639
|
|
|
'ownership': "B"})) |
640
|
|
|
|
641
|
|
|
def test_path7_3_0(self): |
642
|
|
|
"""Tests paths between all users using constrained path algorithm, |
643
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
644
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
645
|
|
|
constraint set to 'B' |
646
|
|
|
""" |
647
|
|
|
# ownership = "B" |
648
|
|
|
self.assertTrue(self.paths_between_all_users("S5:2", {'delay': 50, |
649
|
|
|
'bandwidth': 100, |
650
|
|
|
'ownership': "B"})) |
651
|
|
|
|
652
|
|
|
def test_path7_3_1(self): |
653
|
|
|
"""Tests paths between all users using constrained path algorithm, |
654
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
655
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
656
|
|
|
constraint set to 'B' |
657
|
|
|
""" |
658
|
|
|
# ownership = "B" |
659
|
|
|
self.assertTrue(self.paths_between_all_users("S4:2", {'delay': 50, |
660
|
|
|
'bandwidth': 100, |
661
|
|
|
'ownership': "B"})) |
662
|
|
|
|
663
|
|
|
def test_path7_3_2(self): |
664
|
|
|
"""Tests paths between all users using constrained path algorithm, |
665
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
666
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
667
|
|
|
constraint set to 'B' |
668
|
|
|
""" |
669
|
|
|
# ownership = "B" |
670
|
|
|
self.assertTrue(self.paths_between_all_users("User1:2", {'delay': 50, |
671
|
|
|
'bandwidth': 100, |
672
|
|
|
'ownership': "B"})) |
673
|
|
|
|
674
|
|
|
def test_path7_3_3(self): |
675
|
|
|
"""Tests paths between all users using constrained path algorithm, |
676
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
677
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
678
|
|
|
constraint set to 'B' |
679
|
|
|
""" |
680
|
|
|
# ownership = "B" |
681
|
|
|
self.assertTrue(self.paths_between_all_users("S5:4", {'delay': 50, |
682
|
|
|
'bandwidth': 100, |
683
|
|
|
'ownership': "B"})) |
684
|
|
|
|
685
|
|
|
def test_path7_3_4(self): |
686
|
|
|
"""Tests paths between all users using constrained path algorithm, |
687
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
688
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
689
|
|
|
constraint set to 'B' |
690
|
|
|
""" |
691
|
|
|
# ownership = "B" |
692
|
|
|
self.assertTrue(self.paths_between_all_users("S6:2", {'delay': 50, |
693
|
|
|
'bandwidth': 100, |
694
|
|
|
'ownership': "B"})) |
695
|
|
|
|
696
|
|
|
def test_path7_3_5(self): |
697
|
|
|
"""Tests paths between all users using constrained path algorithm, |
698
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
699
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
700
|
|
|
constraint set to 'B' |
701
|
|
|
""" |
702
|
|
|
# ownership = "B" |
703
|
|
|
self.assertTrue(self.paths_between_all_users("S6:5", {'delay': 50, |
704
|
|
|
'bandwidth': 100, |
705
|
|
|
'ownership': "B"})) |
706
|
|
|
|
707
|
|
|
def test_path7_3_6(self): |
708
|
|
|
"""Tests paths between all users using constrained path algorithm, |
709
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
710
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
711
|
|
|
constraint set to 'B' |
712
|
|
|
""" |
713
|
|
|
# ownership = "B" |
714
|
|
|
self.assertTrue(self.paths_between_all_users("S10:1", {'delay': 50, |
715
|
|
|
'bandwidth': 100, |
716
|
|
|
'ownership': "B"})) |
717
|
|
|
|
718
|
|
|
def test_path7_3_7(self): |
719
|
|
|
"""Tests paths between all users using constrained path algorithm, |
720
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
721
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
722
|
|
|
constraint set to 'B' |
723
|
|
|
""" |
724
|
|
|
# ownership = "B" |
725
|
|
|
self.assertTrue(self.paths_between_all_users("S8:6", {'delay': 50, |
726
|
|
|
'bandwidth': 100, |
727
|
|
|
'ownership': "B"})) |
728
|
|
|
|
729
|
|
|
def test_path7_3_8(self): |
730
|
|
|
"""Tests paths between all users using constrained path algorithm, |
731
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
732
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
733
|
|
|
constraint set to 'B' |
734
|
|
|
""" |
735
|
|
|
# ownership = "B" |
736
|
|
|
self.assertTrue(self.paths_between_all_users("S10:2", {'delay': 50, |
737
|
|
|
'bandwidth': 100, |
738
|
|
|
'ownership': "B"})) |
739
|
|
|
|
740
|
|
|
def test_path7_3_9(self): |
741
|
|
|
"""Tests paths between all users using constrained path algorithm, |
742
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
743
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
744
|
|
|
constraint set to 'B' |
745
|
|
|
""" |
746
|
|
|
# ownership = "B" |
747
|
|
|
self.assertTrue(self.paths_between_all_users("S10:3", {'delay': 50, |
748
|
|
|
'bandwidth': 100, |
749
|
|
|
'ownership': "B"})) |
750
|
|
|
|
751
|
|
|
def test_path7_4_0(self): |
752
|
|
|
"""Tests paths between all users using constrained path algorithm, |
753
|
|
|
with the delay constraint set to 50, the bandwidth constraint set |
754
|
|
|
to 100, the reliability constraint set to 3, and the ownership |
755
|
|
|
constraint set to 'B' |
756
|
|
|
""" |
757
|
|
|
# ownership = "B" |
758
|
|
|
self.assertTrue(self.paths_between_all_users("User2:1", {'delay': 50, |
759
|
|
|
'bandwidth': 100, |
760
|
|
|
'ownership': "B"})) |
761
|
|
|
|
762
|
|
|
# def test_path7(self): |
763
|
|
|
# """Tests paths between all users using constrained path algorithm, |
764
|
|
|
# with the delay constraint set to 50, the bandwidth constraint set |
765
|
|
|
# to 100, the reliability constraint set to 3, and the ownership |
766
|
|
|
# constraint set to 'B' |
767
|
|
|
# """ |
768
|
|
|
# combos = combinations(["User1", "User2", "User3", "User4"], 2) |
769
|
|
|
# self.initializer() |
770
|
|
|
# |
771
|
|
|
# for point_a, point_b in combos: |
772
|
|
|
# results = self.get_path_constrained( |
773
|
|
|
# point_a, point_b, base=dict(delay=50, bandwidth=100, |
774
|
|
|
# reliability=3, |
775
|
|
|
# ownership="B")) |
776
|
|
|
# for result in results: |
777
|
|
|
# for path in result["paths"]: |
778
|
|
|
# # delay = 50 checks |
779
|
|
|
# # self.assertNotIn("S1:1", path) |
780
|
|
|
# # self.assertNotIn("S2:1", path) |
781
|
|
|
# # self.assertNotIn("S3:1", path) |
782
|
|
|
# # self.assertNotIn("S5:1", path) |
783
|
|
|
# # self.assertNotIn("S4:2", path) |
784
|
|
|
# # self.assertNotIn("User1:2", path) |
785
|
|
|
# # self.assertNotIn("S5:5", path) |
786
|
|
|
# # self.assertNotIn("S8:2", path) |
787
|
|
|
# # self.assertNotIn("S5:6", path) |
788
|
|
|
# # self.assertNotIn("User1:3", path) |
789
|
|
|
# # self.assertNotIn("S6:3", path) |
790
|
|
|
# # self.assertNotIn("S9:1", path) |
791
|
|
|
# # self.assertNotIn("S6:4", path) |
792
|
|
|
# # self.assertNotIn("S9:2", path) |
793
|
|
|
# # self.assertNotIn("S6:5", path) |
794
|
|
|
# # self.assertNotIn("S10:1", path) |
795
|
|
|
# # self.assertNotIn("S8:5", path) |
796
|
|
|
# # self.assertNotIn("S9:4", path) |
797
|
|
|
# # self.assertNotIn("User1:4", path) |
798
|
|
|
# # self.assertNotIn("User4:3", path) |
799
|
|
|
# |
800
|
|
|
# # bandwidth = 100 checks |
801
|
|
|
# |
802
|
|
|
# # self.assertNotIn("S3:1", path) |
803
|
|
|
# # self.assertNotIn("S5:1", path) |
804
|
|
|
# # self.assertNotIn("User1:4", path) |
805
|
|
|
# # self.assertNotIn("User4:3", path) |
806
|
|
|
# |
807
|
|
|
# # reliability = 3 checks |
808
|
|
|
# |
809
|
|
|
# # self.assertNotIn("S4:1", path) |
810
|
|
|
# # self.assertNotIn("S5:2", path) |
811
|
|
|
# # self.assertNotIn("S5:3", path) |
812
|
|
|
# # self.assertNotIn("S6:1", path) |
813
|
|
|
# |
814
|
|
|
# # ownership = "B" checks |
815
|
|
|
# |
816
|
|
|
# # self.assertNotIn("S4:1", path) |
817
|
|
|
# # self.assertNotIn("S5:2", path) |
818
|
|
|
# # self.assertNotIn("S4:2", path) |
819
|
|
|
# # self.assertNotIn("User1:2", path) |
820
|
|
|
# # self.assertNotIn("S5:4", path) |
821
|
|
|
# # self.assertNotIn("S6:2", path) |
822
|
|
|
# # self.assertNotIn("S6:5", path) |
823
|
|
|
# # self.assertNotIn("S10:1", path) |
824
|
|
|
# # self.assertNotIn("S8:6", path) |
825
|
|
|
# # self.assertNotIn("S10:2", path) |
826
|
|
|
# # self.assertNotIn("S10:3", path) |
827
|
|
|
# self.assertNotIn("User2:1", path) |
828
|
|
|
|
829
|
|
|
def test_path8(self): |
830
|
|
|
"""Tests paths between all users using constrained path algorithm, |
831
|
|
|
with the delay constraint set to 50, the bandwidth constraint |
832
|
|
|
set to 100, the reliability constraint set to 3, and the ownership |
833
|
|
|
constraint set to 'B' |
834
|
|
|
|
835
|
|
|
Tests conducted with flexibility enabled |
836
|
|
|
""" |
837
|
|
|
combos = combinations(["User1", "User2", "User3", "User4"], 2) |
838
|
|
|
self.initializer() |
839
|
|
|
|
840
|
|
|
for point_a, point_b in combos: |
841
|
|
|
results = self.get_path_constrained( |
842
|
|
|
point_a, point_b, flexible=dict(delay=50, bandwidth=100, |
843
|
|
|
reliability=3, |
844
|
|
|
ownership="B")) |
845
|
|
|
for result in results: |
846
|
|
|
# delay = 50 checks |
847
|
|
View Code Duplication |
if "delay" in result["metrics"]: |
|
|
|
|
848
|
|
|
for path in result["paths"]: |
849
|
|
|
self.assertNotIn("S1:1", path) |
850
|
|
|
self.assertNotIn("S2:1", path) |
851
|
|
|
self.assertNotIn("S3:1", path) |
852
|
|
|
self.assertNotIn("S5:1", path) |
853
|
|
|
self.assertNotIn("S4:2", path) |
854
|
|
|
self.assertNotIn("User1:2", path) |
855
|
|
|
self.assertNotIn("S5:5", path) |
856
|
|
|
self.assertNotIn("S8:2", path) |
857
|
|
|
self.assertNotIn("S5:6", path) |
858
|
|
|
self.assertNotIn("User1:3", path) |
859
|
|
|
self.assertNotIn("S6:3", path) |
860
|
|
|
self.assertNotIn("S9:1", path) |
861
|
|
|
self.assertNotIn("S6:4", path) |
862
|
|
|
self.assertNotIn("S9:2", path) |
863
|
|
|
self.assertNotIn("S6:5", path) |
864
|
|
|
self.assertNotIn("S10:1", path) |
865
|
|
|
self.assertNotIn("S8:5", path) |
866
|
|
|
self.assertNotIn("S9:4", path) |
867
|
|
|
self.assertNotIn("User1:4", path) |
868
|
|
|
self.assertNotIn("User4:3", path) |
869
|
|
|
|
870
|
|
|
# bandwidth = 100 checks |
871
|
|
|
if "bandwidth" in result["metrics"]: |
872
|
|
|
for path in result["paths"]: |
873
|
|
|
self.assertNotIn("S3:1", path) |
874
|
|
|
self.assertNotIn("S5:1", path) |
875
|
|
|
self.assertNotIn("User1:4", path) |
876
|
|
|
self.assertNotIn("User4:3", path) |
877
|
|
|
|
878
|
|
|
# reliability = 3 checks |
879
|
|
|
if "reliability" in result["metrics"]: |
880
|
|
|
for path in result["paths"]: |
881
|
|
|
self.assertNotIn("S4:1", path) |
882
|
|
|
self.assertNotIn("S5:2", path) |
883
|
|
|
self.assertNotIn("S5:3", path) |
884
|
|
|
self.assertNotIn("S6:1", path) |
885
|
|
|
|
886
|
|
|
# ownership = "B" checks |
887
|
|
|
if "ownership" in result["metrics"]: |
888
|
|
|
for path in result["paths"]: |
889
|
|
|
self.assertNotIn("S4:1", path) |
890
|
|
|
self.assertNotIn("S5:2", path) |
891
|
|
|
self.assertNotIn("S4:2", path) |
892
|
|
|
self.assertNotIn("User1:2", path) |
893
|
|
|
self.assertNotIn("S5:4", path) |
894
|
|
|
self.assertNotIn("S6:2", path) |
895
|
|
|
self.assertNotIn("S6:5", path) |
896
|
|
|
self.assertNotIn("S10:1", path) |
897
|
|
|
self.assertNotIn("S8:6", path) |
898
|
|
|
self.assertNotIn("S10:2", path) |
899
|
|
|
self.assertNotIn("S10:3", path) |
900
|
|
|
self.assertNotIn("User2:1", path) |
901
|
|
|
|
902
|
|
|
def test_path9(self): |
903
|
|
|
"""Tests paths between all users using constrained path algorithm, |
904
|
|
|
with the delay constraint set to 50, the bandwidth constraint |
905
|
|
|
set to 100, the reliability constraint set to 3, and the ownership |
906
|
|
|
constraint set to 'B' |
907
|
|
|
|
908
|
|
|
Tests conducted with all but ownership flexible |
909
|
|
|
""" |
910
|
|
|
combos = combinations(["User1", "User2", "User3", "User4"], 2) |
911
|
|
|
self.initializer() |
912
|
|
|
|
913
|
|
|
for point_a, point_b in combos: |
914
|
|
|
results = self.get_path_constrained(point_a, point_b, |
915
|
|
|
base={"ownership": "B"}, |
916
|
|
|
flexible={"delay": 50, |
917
|
|
|
"bandwidth": 100, |
918
|
|
|
"reliability": 3}) |
919
|
|
|
for result in results: |
920
|
|
|
# delay = 50 checks |
921
|
|
View Code Duplication |
if "delay" in result["metrics"]: |
|
|
|
|
922
|
|
|
for path in result["paths"]: |
923
|
|
|
self.assertNotIn("S1:1", path) |
924
|
|
|
self.assertNotIn("S2:1", path) |
925
|
|
|
self.assertNotIn("S3:1", path) |
926
|
|
|
self.assertNotIn("S5:1", path) |
927
|
|
|
self.assertNotIn("S4:2", path) |
928
|
|
|
self.assertNotIn("User1:2", path) |
929
|
|
|
self.assertNotIn("S5:5", path) |
930
|
|
|
self.assertNotIn("S8:2", path) |
931
|
|
|
self.assertNotIn("S5:6", path) |
932
|
|
|
self.assertNotIn("User1:3", path) |
933
|
|
|
self.assertNotIn("S6:3", path) |
934
|
|
|
self.assertNotIn("S9:1", path) |
935
|
|
|
self.assertNotIn("S6:4", path) |
936
|
|
|
self.assertNotIn("S9:2", path) |
937
|
|
|
self.assertNotIn("S6:5", path) |
938
|
|
|
self.assertNotIn("S10:1", path) |
939
|
|
|
self.assertNotIn("S8:5", path) |
940
|
|
|
self.assertNotIn("S9:4", path) |
941
|
|
|
self.assertNotIn("User1:4", path) |
942
|
|
|
self.assertNotIn("User4:3", path) |
943
|
|
|
|
944
|
|
|
# bandwidth = 100 checks |
945
|
|
|
if "bandwidth" in result["metrics"]: |
946
|
|
|
for path in result["paths"]: |
947
|
|
|
self.assertNotIn("S3:1", path) |
948
|
|
|
self.assertNotIn("S5:1", path) |
949
|
|
|
self.assertNotIn("User1:4", path) |
950
|
|
|
self.assertNotIn("User4:3", path) |
951
|
|
|
|
952
|
|
|
# reliability = 3 checks |
953
|
|
|
if "reliability" in result["metrics"]: |
954
|
|
|
for path in result["paths"]: |
955
|
|
|
self.assertNotIn("S4:1", path) |
956
|
|
|
self.assertNotIn("S5:2", path) |
957
|
|
|
self.assertNotIn("S5:3", path) |
958
|
|
|
self.assertNotIn("S6:1", path) |
959
|
|
|
|
960
|
|
|
# ownership = "B" checks |
961
|
|
|
self.assertIn("ownership", result["metrics"]) |
962
|
|
|
for path in result["paths"]: |
963
|
|
|
self.assertNotIn("S4:1", path) |
964
|
|
|
self.assertNotIn("S5:2", path) |
965
|
|
|
self.assertNotIn("S4:2", path) |
966
|
|
|
self.assertNotIn("User1:2", path) |
967
|
|
|
self.assertNotIn("S5:4", path) |
968
|
|
|
self.assertNotIn("S6:2", path) |
969
|
|
|
self.assertNotIn("S6:5", path) |
970
|
|
|
self.assertNotIn("S10:1", path) |
971
|
|
|
self.assertNotIn("S8:6", path) |
972
|
|
|
self.assertNotIn("S10:2", path) |
973
|
|
|
self.assertNotIn("S10:3", path) |
974
|
|
|
self.assertNotIn("User2:1", path) |
975
|
|
|
|
976
|
|
|
def test_path10(self): |
977
|
|
|
"""Tests that TypeError is generated by get_path_constrained |
978
|
|
|
|
979
|
|
|
Tests with ownership using an int type rather than string |
980
|
|
|
""" |
981
|
|
|
self.initializer() |
982
|
|
|
|
983
|
|
|
with self.assertRaises(TypeError): |
984
|
|
|
self.get_path_constrained( |
985
|
|
|
"User1", "User2", base={"ownership": 1}) |
986
|
|
|
|
987
|
|
|
@staticmethod |
988
|
|
|
def generate_topology(): |
989
|
|
|
"""Generates a predetermined topology""" |
990
|
|
|
switches = {} |
991
|
|
|
interfaces = {} |
992
|
|
|
links = {} |
993
|
|
|
|
994
|
|
|
TestResults.create_switch("S1", switches) |
995
|
|
|
TestResults.add_interfaces(2, switches["S1"], interfaces) |
996
|
|
|
|
997
|
|
|
TestResults.create_switch("S2", switches) |
998
|
|
|
TestResults.add_interfaces(2, switches["S2"], interfaces) |
999
|
|
|
|
1000
|
|
|
TestResults.create_switch("S3", switches) |
1001
|
|
|
TestResults.add_interfaces(6, switches["S3"], interfaces) |
1002
|
|
|
|
1003
|
|
|
TestResults.create_switch("S4", switches) |
1004
|
|
|
TestResults.add_interfaces(2, switches["S4"], interfaces) |
1005
|
|
|
|
1006
|
|
|
TestResults.create_switch("S5", switches) |
1007
|
|
|
TestResults.add_interfaces(6, switches["S5"], interfaces) |
1008
|
|
|
|
1009
|
|
|
TestResults.create_switch("S6", switches) |
1010
|
|
|
TestResults.add_interfaces(5, switches["S6"], interfaces) |
1011
|
|
|
|
1012
|
|
|
TestResults.create_switch("S7", switches) |
1013
|
|
|
TestResults.add_interfaces(2, switches["S7"], interfaces) |
1014
|
|
|
|
1015
|
|
|
TestResults.create_switch("S8", switches) |
1016
|
|
|
TestResults.add_interfaces(8, switches["S8"], interfaces) |
1017
|
|
|
|
1018
|
|
|
TestResults.create_switch("S9", switches) |
1019
|
|
|
TestResults.add_interfaces(4, switches["S9"], interfaces) |
1020
|
|
|
|
1021
|
|
|
TestResults.create_switch("S10", switches) |
1022
|
|
|
TestResults.add_interfaces(3, switches["S10"], interfaces) |
1023
|
|
|
|
1024
|
|
|
TestResults.create_switch("S11", switches) |
1025
|
|
|
TestResults.add_interfaces(3, switches["S11"], interfaces) |
1026
|
|
|
|
1027
|
|
|
TestResults.create_switch("User1", switches) |
1028
|
|
|
TestResults.add_interfaces(4, switches["User1"], interfaces) |
1029
|
|
|
|
1030
|
|
|
TestResults.create_switch("User2", switches) |
1031
|
|
|
TestResults.add_interfaces(2, switches["User2"], interfaces) |
1032
|
|
|
|
1033
|
|
|
TestResults.create_switch("User3", switches) |
1034
|
|
|
TestResults.add_interfaces(2, switches["User3"], interfaces) |
1035
|
|
|
|
1036
|
|
|
TestResults.create_switch("User4", switches) |
1037
|
|
|
TestResults.add_interfaces(3, switches["User4"], interfaces) |
1038
|
|
|
|
1039
|
|
|
TestResultsEdges._fill_links(links, interfaces) |
1040
|
|
|
|
1041
|
|
|
TestResultsEdges._add_metadata_to_links(links) |
1042
|
|
|
|
1043
|
|
|
return switches, links |
1044
|
|
|
|
1045
|
|
|
@staticmethod |
1046
|
|
|
def _add_metadata_to_links(links): |
1047
|
|
|
links["S1:1<->S2:1"].extend_metadata( |
1048
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 105}) |
1049
|
|
|
|
1050
|
|
|
links["S1:2<->User1:1"].extend_metadata( |
1051
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 1}) |
1052
|
|
|
|
1053
|
|
|
links["S2:2<->User4:1"].extend_metadata( |
1054
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 10}) |
1055
|
|
|
|
1056
|
|
|
links["S3:1<->S5:1"].extend_metadata( |
1057
|
|
|
{"reliability": 5, "bandwidth": 10, "delay": 112}) |
1058
|
|
|
|
1059
|
|
|
links["S3:2<->S7:1"].extend_metadata( |
1060
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 1}) |
1061
|
|
|
|
1062
|
|
|
links["S3:3<->S8:1"].extend_metadata( |
1063
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 1}) |
1064
|
|
|
|
1065
|
|
|
links["S3:4<->S11:1"].extend_metadata( |
1066
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 6}) |
1067
|
|
|
|
1068
|
|
|
links["S3:5<->User3:1"].extend_metadata( |
1069
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 1}) |
1070
|
|
|
|
1071
|
|
|
links["S3:6<->User4:2"].extend_metadata( |
1072
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 10}) |
1073
|
|
|
|
1074
|
|
|
links["S4:1<->S5:2"].extend_metadata( |
1075
|
|
|
{"reliability": 1, "bandwidth": 100, "delay": 30, |
1076
|
|
|
"ownership": "A"}) |
1077
|
|
|
|
1078
|
|
|
links["S4:2<->User1:2"].extend_metadata( |
1079
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 110, |
1080
|
|
|
"ownership": "A"}) |
1081
|
|
|
|
1082
|
|
|
links["S5:3<->S6:1"].extend_metadata( |
1083
|
|
|
{"reliability": 1, "bandwidth": 100, "delay": 40}) |
1084
|
|
|
|
1085
|
|
|
links["S5:4<->S6:2"].extend_metadata( |
1086
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 40, |
1087
|
|
|
"ownership": "A"}) |
1088
|
|
|
|
1089
|
|
|
links["S5:5<->S8:2"].extend_metadata( |
1090
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 112}) |
1091
|
|
|
|
1092
|
|
|
links["S5:6<->User1:3"].extend_metadata( |
1093
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 60}) |
1094
|
|
|
|
1095
|
|
|
links["S6:3<->S9:1"].extend_metadata( |
1096
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 60}) |
1097
|
|
|
|
1098
|
|
|
links["S6:4<->S9:2"].extend_metadata( |
1099
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 62}) |
1100
|
|
|
|
1101
|
|
|
links["S6:5<->S10:1"].extend_metadata( |
1102
|
|
|
{"bandwidth": 100, "delay": 108, "ownership": "A"}) |
1103
|
|
|
|
1104
|
|
|
links["S7:2<->S8:3"].extend_metadata( |
1105
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 1}) |
1106
|
|
|
|
1107
|
|
|
links["S8:4<->S9:3"].extend_metadata( |
1108
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 32}) |
1109
|
|
|
|
1110
|
|
|
links["S8:5<->S9:4"].extend_metadata( |
1111
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 110}) |
1112
|
|
|
|
1113
|
|
|
links["S8:6<->S10:2"].extend_metadata( |
1114
|
|
|
{"reliability": 5, "bandwidth": 100, "ownership": "A"}) |
1115
|
|
|
|
1116
|
|
|
links["S8:7<->S11:2"].extend_metadata( |
1117
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 7}) |
1118
|
|
|
|
1119
|
|
|
links["S8:8<->User3:2"].extend_metadata( |
1120
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 1}) |
1121
|
|
|
|
1122
|
|
|
links["S10:3<->User2:1"].extend_metadata( |
1123
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 10, |
1124
|
|
|
"ownership": "A"}) |
1125
|
|
|
|
1126
|
|
|
links["S11:3<->User2:2"].extend_metadata( |
1127
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 6}) |
1128
|
|
|
|
1129
|
|
|
links["User1:4<->User4:3"].extend_metadata( |
1130
|
|
|
{"reliability": 5, "bandwidth": 10, "delay": 105}) |
1131
|
|
|
|
1132
|
|
|
@staticmethod |
1133
|
|
|
def _fill_links(links, interfaces): |
1134
|
|
|
links["S1:1<->S2:1"] = Link(interfaces["S1:1"], interfaces["S2:1"]) |
1135
|
|
|
|
1136
|
|
|
links["S1:2<->User1:1"] = Link(interfaces["S1:2"], interfaces["User1:1"]) |
1137
|
|
|
|
1138
|
|
|
links["S2:2<->User4:1"] = Link(interfaces["S2:2"], interfaces["User4:1"]) |
1139
|
|
|
|
1140
|
|
|
links["S3:1<->S5:1"] = Link(interfaces["S3:1"], interfaces["S5:1"]) |
1141
|
|
|
|
1142
|
|
|
links["S3:2<->S7:1"] = Link(interfaces["S3:2"], interfaces["S7:1"]) |
1143
|
|
|
|
1144
|
|
|
links["S3:3<->S8:1"] = Link(interfaces["S3:3"], interfaces["S8:1"]) |
1145
|
|
|
|
1146
|
|
|
links["S3:4<->S11:1"] = Link(interfaces["S3:4"], interfaces["S11:1"]) |
1147
|
|
|
|
1148
|
|
|
links["S3:5<->User3:1"] = Link(interfaces["S3:5"], interfaces["User3:1"]) |
1149
|
|
|
|
1150
|
|
|
links["S3:6<->User4:2"] = Link(interfaces["S3:6"], interfaces["User4:2"]) |
1151
|
|
|
|
1152
|
|
|
links["S4:1<->S5:2"] = Link(interfaces["S4:1"], interfaces["S5:2"]) |
1153
|
|
|
|
1154
|
|
|
links["S4:2<->User1:2"] = Link(interfaces["S4:2"], interfaces["User1:2"]) |
1155
|
|
|
|
1156
|
|
|
links["S5:3<->S6:1"] = Link(interfaces["S5:3"], interfaces["S6:1"]) |
1157
|
|
|
|
1158
|
|
|
links["S5:4<->S6:2"] = Link(interfaces["S5:4"], interfaces["S6:2"]) |
1159
|
|
|
|
1160
|
|
|
links["S5:5<->S8:2"] = Link(interfaces["S5:5"], interfaces["S8:2"]) |
1161
|
|
|
|
1162
|
|
|
links["S5:6<->User1:3"] = Link(interfaces["S5:6"], interfaces["User1:3"]) |
1163
|
|
|
|
1164
|
|
|
links["S6:3<->S9:1"] = Link(interfaces["S6:3"], interfaces["S9:1"]) |
1165
|
|
|
|
1166
|
|
|
links["S6:4<->S9:2"] = Link(interfaces["S6:4"], interfaces["S9:2"]) |
1167
|
|
|
|
1168
|
|
|
links["S6:5<->S10:1"] = Link(interfaces["S6:5"], interfaces["S10:1"]) |
1169
|
|
|
|
1170
|
|
|
links["S7:2<->S8:3"] = Link(interfaces["S7:2"], interfaces["S8:3"]) |
1171
|
|
|
|
1172
|
|
|
links["S8:4<->S9:3"] = Link(interfaces["S8:4"], interfaces["S9:3"]) |
1173
|
|
|
|
1174
|
|
|
links["S8:5<->S9:4"] = Link(interfaces["S8:5"], interfaces["S9:4"]) |
1175
|
|
|
|
1176
|
|
|
links["S8:6<->S10:2"] = Link(interfaces["S8:6"], interfaces["S10:2"]) |
1177
|
|
|
|
1178
|
|
|
links["S8:7<->S11:2"] = Link(interfaces["S8:7"], interfaces["S11:2"]) |
1179
|
|
|
|
1180
|
|
|
links["S8:8<->User3:2"] = Link(interfaces["S8:8"], interfaces["User3:2"]) |
1181
|
|
|
|
1182
|
|
|
links["S10:3<->User2:1"] = Link(interfaces["S10:3"], interfaces["User2:1"]) |
1183
|
|
|
|
1184
|
|
|
links["S11:3<->User2:2"] = Link(interfaces["S11:3"], interfaces["User2:2"]) |
1185
|
|
|
|
1186
|
|
|
links["User1:4<->User4:3"] = Link(interfaces["User1:4"], interfaces["User4:3"]) |
1187
|
|
|
|