1
|
|
|
"""Module to overwrite all the needed methods to test the KytosGraph in graph.py""" |
2
|
|
|
from tests.integration.test_results import TestResults |
3
|
|
|
|
4
|
|
|
# Core modules to import |
5
|
|
|
from kytos.core.link import Link |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
class EdgesSettings(TestResults): |
9
|
|
|
"""Class to setups all the settings related to topology.""" |
10
|
|
|
|
11
|
|
|
@staticmethod |
12
|
|
|
def generate_topology(): |
13
|
|
|
"""Generates a predetermined topology""" |
14
|
|
|
switches = {} |
15
|
|
|
interfaces = {} |
16
|
|
|
links = {} |
17
|
|
|
|
18
|
|
|
TestResults.create_switch("S1", switches) |
19
|
|
|
TestResults.add_interfaces(2, switches["S1"], interfaces) |
20
|
|
|
|
21
|
|
|
TestResults.create_switch("S2", switches) |
22
|
|
|
TestResults.add_interfaces(2, switches["S2"], interfaces) |
23
|
|
|
|
24
|
|
|
TestResults.create_switch("S3", switches) |
25
|
|
|
TestResults.add_interfaces(6, switches["S3"], interfaces) |
26
|
|
|
|
27
|
|
|
TestResults.create_switch("S4", switches) |
28
|
|
|
TestResults.add_interfaces(2, switches["S4"], interfaces) |
29
|
|
|
|
30
|
|
|
TestResults.create_switch("S5", switches) |
31
|
|
|
TestResults.add_interfaces(6, switches["S5"], interfaces) |
32
|
|
|
|
33
|
|
|
TestResults.create_switch("S6", switches) |
34
|
|
|
TestResults.add_interfaces(5, switches["S6"], interfaces) |
35
|
|
|
|
36
|
|
|
TestResults.create_switch("S7", switches) |
37
|
|
|
TestResults.add_interfaces(2, switches["S7"], interfaces) |
38
|
|
|
|
39
|
|
|
TestResults.create_switch("S8", switches) |
40
|
|
|
TestResults.add_interfaces(8, switches["S8"], interfaces) |
41
|
|
|
|
42
|
|
|
TestResults.create_switch("S9", switches) |
43
|
|
|
TestResults.add_interfaces(4, switches["S9"], interfaces) |
44
|
|
|
|
45
|
|
|
TestResults.create_switch("S10", switches) |
46
|
|
|
TestResults.add_interfaces(3, switches["S10"], interfaces) |
47
|
|
|
|
48
|
|
|
TestResults.create_switch("S11", switches) |
49
|
|
|
TestResults.add_interfaces(3, switches["S11"], interfaces) |
50
|
|
|
|
51
|
|
|
TestResults.create_switch("User1", switches) |
52
|
|
|
TestResults.add_interfaces(4, switches["User1"], interfaces) |
53
|
|
|
|
54
|
|
|
TestResults.create_switch("User2", switches) |
55
|
|
|
TestResults.add_interfaces(2, switches["User2"], interfaces) |
56
|
|
|
|
57
|
|
|
TestResults.create_switch("User3", switches) |
58
|
|
|
TestResults.add_interfaces(2, switches["User3"], interfaces) |
59
|
|
|
|
60
|
|
|
TestResults.create_switch("User4", switches) |
61
|
|
|
TestResults.add_interfaces(3, switches["User4"], interfaces) |
62
|
|
|
|
63
|
|
|
EdgesSettings._fill_links(links, interfaces) |
64
|
|
|
|
65
|
|
|
EdgesSettings._add_metadata_to_links(links) |
66
|
|
|
|
67
|
|
|
return switches, links |
68
|
|
|
|
69
|
|
|
@staticmethod |
70
|
|
|
def _add_metadata_to_links(links): |
71
|
|
|
links["S1:1<->S2:1"].extend_metadata( |
72
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 105}) |
73
|
|
|
|
74
|
|
|
links["S1:2<->User1:1"].extend_metadata( |
75
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 1}) |
76
|
|
|
|
77
|
|
|
links["S2:2<->User4:1"].extend_metadata( |
78
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 10}) |
79
|
|
|
|
80
|
|
|
links["S3:1<->S5:1"].extend_metadata( |
81
|
|
|
{"reliability": 5, "bandwidth": 10, "delay": 112}) |
82
|
|
|
|
83
|
|
|
links["S3:2<->S7:1"].extend_metadata( |
84
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 1}) |
85
|
|
|
|
86
|
|
|
links["S3:3<->S8:1"].extend_metadata( |
87
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 1}) |
88
|
|
|
|
89
|
|
|
links["S3:4<->S11:1"].extend_metadata( |
90
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 6}) |
91
|
|
|
|
92
|
|
|
links["S3:5<->User3:1"].extend_metadata( |
93
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 1}) |
94
|
|
|
|
95
|
|
|
links["S3:6<->User4:2"].extend_metadata( |
96
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 10}) |
97
|
|
|
|
98
|
|
|
links["S4:1<->S5:2"].extend_metadata( |
99
|
|
|
{"reliability": 1, "bandwidth": 100, "delay": 30, |
100
|
|
|
"ownership": "A"}) |
101
|
|
|
|
102
|
|
|
links["S4:2<->User1:2"].extend_metadata( |
103
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 110, |
104
|
|
|
"ownership": "A"}) |
105
|
|
|
|
106
|
|
|
links["S5:3<->S6:1"].extend_metadata( |
107
|
|
|
{"reliability": 1, "bandwidth": 100, "delay": 40}) |
108
|
|
|
|
109
|
|
|
links["S5:4<->S6:2"].extend_metadata( |
110
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 40, |
111
|
|
|
"ownership": "A"}) |
112
|
|
|
|
113
|
|
|
links["S5:5<->S8:2"].extend_metadata( |
114
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 112}) |
115
|
|
|
|
116
|
|
|
links["S5:6<->User1:3"].extend_metadata( |
117
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 60}) |
118
|
|
|
|
119
|
|
|
links["S6:3<->S9:1"].extend_metadata( |
120
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 60}) |
121
|
|
|
|
122
|
|
|
links["S6:4<->S9:2"].extend_metadata( |
123
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 62}) |
124
|
|
|
|
125
|
|
|
links["S6:5<->S10:1"].extend_metadata( |
126
|
|
|
{"bandwidth": 100, "delay": 108, "ownership": "A"}) |
127
|
|
|
|
128
|
|
|
links["S7:2<->S8:3"].extend_metadata( |
129
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 1}) |
130
|
|
|
|
131
|
|
|
links["S8:4<->S9:3"].extend_metadata( |
132
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 32}) |
133
|
|
|
|
134
|
|
|
links["S8:5<->S9:4"].extend_metadata( |
135
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 110}) |
136
|
|
|
|
137
|
|
|
links["S8:6<->S10:2"].extend_metadata( |
138
|
|
|
{"reliability": 5, "bandwidth": 100, "ownership": "A"}) |
139
|
|
|
|
140
|
|
|
links["S8:7<->S11:2"].extend_metadata( |
141
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 7}) |
142
|
|
|
|
143
|
|
|
links["S8:8<->User3:2"].extend_metadata( |
144
|
|
|
{"reliability": 5, "bandwidth": 100, "delay": 1}) |
145
|
|
|
|
146
|
|
|
links["S10:3<->User2:1"].extend_metadata( |
147
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 10, |
148
|
|
|
"ownership": "A"}) |
149
|
|
|
|
150
|
|
|
links["S11:3<->User2:2"].extend_metadata( |
151
|
|
|
{"reliability": 3, "bandwidth": 100, "delay": 6}) |
152
|
|
|
|
153
|
|
|
links["User1:4<->User4:3"].extend_metadata( |
154
|
|
|
{"reliability": 5, "bandwidth": 10, "delay": 105}) |
155
|
|
|
|
156
|
|
|
@staticmethod |
157
|
|
|
def _fill_links(links, interfaces): |
158
|
|
|
links["S1:1<->S2:1"] = Link(interfaces["S1:1"], interfaces["S2:1"]) |
159
|
|
|
|
160
|
|
|
links["S1:2<->User1:1"] = Link(interfaces["S1:2"], interfaces["User1:1"]) |
161
|
|
|
|
162
|
|
|
links["S2:2<->User4:1"] = Link(interfaces["S2:2"], interfaces["User4:1"]) |
163
|
|
|
|
164
|
|
|
links["S3:1<->S5:1"] = Link(interfaces["S3:1"], interfaces["S5:1"]) |
165
|
|
|
|
166
|
|
|
links["S3:2<->S7:1"] = Link(interfaces["S3:2"], interfaces["S7:1"]) |
167
|
|
|
|
168
|
|
|
links["S3:3<->S8:1"] = Link(interfaces["S3:3"], interfaces["S8:1"]) |
169
|
|
|
|
170
|
|
|
links["S3:4<->S11:1"] = Link(interfaces["S3:4"], interfaces["S11:1"]) |
171
|
|
|
|
172
|
|
|
links["S3:5<->User3:1"] = Link(interfaces["S3:5"], interfaces["User3:1"]) |
173
|
|
|
|
174
|
|
|
links["S3:6<->User4:2"] = Link(interfaces["S3:6"], interfaces["User4:2"]) |
175
|
|
|
|
176
|
|
|
links["S4:1<->S5:2"] = Link(interfaces["S4:1"], interfaces["S5:2"]) |
177
|
|
|
|
178
|
|
|
links["S4:2<->User1:2"] = Link(interfaces["S4:2"], interfaces["User1:2"]) |
179
|
|
|
|
180
|
|
|
links["S5:3<->S6:1"] = Link(interfaces["S5:3"], interfaces["S6:1"]) |
181
|
|
|
|
182
|
|
|
links["S5:4<->S6:2"] = Link(interfaces["S5:4"], interfaces["S6:2"]) |
183
|
|
|
|
184
|
|
|
links["S5:5<->S8:2"] = Link(interfaces["S5:5"], interfaces["S8:2"]) |
185
|
|
|
|
186
|
|
|
links["S5:6<->User1:3"] = Link(interfaces["S5:6"], interfaces["User1:3"]) |
187
|
|
|
|
188
|
|
|
links["S6:3<->S9:1"] = Link(interfaces["S6:3"], interfaces["S9:1"]) |
189
|
|
|
|
190
|
|
|
links["S6:4<->S9:2"] = Link(interfaces["S6:4"], interfaces["S9:2"]) |
191
|
|
|
|
192
|
|
|
links["S6:5<->S10:1"] = Link(interfaces["S6:5"], interfaces["S10:1"]) |
193
|
|
|
|
194
|
|
|
links["S7:2<->S8:3"] = Link(interfaces["S7:2"], interfaces["S8:3"]) |
195
|
|
|
|
196
|
|
|
links["S8:4<->S9:3"] = Link(interfaces["S8:4"], interfaces["S9:3"]) |
197
|
|
|
|
198
|
|
|
links["S8:5<->S9:4"] = Link(interfaces["S8:5"], interfaces["S9:4"]) |
199
|
|
|
|
200
|
|
|
links["S8:6<->S10:2"] = Link(interfaces["S8:6"], interfaces["S10:2"]) |
201
|
|
|
|
202
|
|
|
links["S8:7<->S11:2"] = Link(interfaces["S8:7"], interfaces["S11:2"]) |
203
|
|
|
|
204
|
|
|
links["S8:8<->User3:2"] = Link(interfaces["S8:8"], interfaces["User3:2"]) |
205
|
|
|
|
206
|
|
|
links["S10:3<->User2:1"] = Link(interfaces["S10:3"], interfaces["User2:1"]) |
207
|
|
|
|
208
|
|
|
links["S11:3<->User2:2"] = Link(interfaces["S11:3"], interfaces["User2:2"]) |
209
|
|
|
|
210
|
|
|
links["User1:4<->User4:3"] = Link(interfaces["User1:4"], interfaces["User4:3"]) |