build.tests.integration.edges_settings   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 278
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 155
dl 0
loc 278
ccs 100
cts 100
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
B EdgesSettings._fill_links() 0 79 2
A EdgesSettings.generate_topology() 0 55 1
B EdgesSettings._add_metadata_to_links() 0 128 1
1
"""Module to overwrite all the needed methods."""
2
3
# Core modules to import
4 1
from kytos.core.link import Link
5
6
# pylint: disable=E0401
7 1
from tests.integration.test_paths import TestPaths
8
9
10 1
class EdgesSettings(TestPaths):
11
    """Class to setups all the settings related to topology."""
12
13 1
    @staticmethod
14 1
    def generate_topology():
15
        """Generate a predetermined topology."""
16 1
        switches, interfaces, links = {}, {}, {}
17
18 1
        TestPaths.create_switch("S1", switches)
19 1
        TestPaths.add_interfaces(2, switches["S1"], interfaces)
20
21 1
        TestPaths.create_switch("S2", switches)
22 1
        TestPaths.add_interfaces(2, switches["S2"], interfaces)
23
24 1
        TestPaths.create_switch("S3", switches)
25 1
        TestPaths.add_interfaces(6, switches["S3"], interfaces)
26
27 1
        TestPaths.create_switch("S4", switches)
28 1
        TestPaths.add_interfaces(2, switches["S4"], interfaces)
29
30 1
        TestPaths.create_switch("S5", switches)
31 1
        TestPaths.add_interfaces(6, switches["S5"], interfaces)
32
33 1
        TestPaths.create_switch("S6", switches)
34 1
        TestPaths.add_interfaces(5, switches["S6"], interfaces)
35
36 1
        TestPaths.create_switch("S7", switches)
37 1
        TestPaths.add_interfaces(2, switches["S7"], interfaces)
38
39 1
        TestPaths.create_switch("S8", switches)
40 1
        TestPaths.add_interfaces(8, switches["S8"], interfaces)
41
42 1
        TestPaths.create_switch("S9", switches)
43 1
        TestPaths.add_interfaces(4, switches["S9"], interfaces)
44
45 1
        TestPaths.create_switch("S10", switches)
46 1
        TestPaths.add_interfaces(3, switches["S10"], interfaces)
47
48 1
        TestPaths.create_switch("S11", switches)
49 1
        TestPaths.add_interfaces(3, switches["S11"], interfaces)
50
51 1
        TestPaths.create_switch("User1", switches)
52 1
        TestPaths.add_interfaces(4, switches["User1"], interfaces)
53
54 1
        TestPaths.create_switch("User2", switches)
55 1
        TestPaths.add_interfaces(2, switches["User2"], interfaces)
56
57 1
        TestPaths.create_switch("User3", switches)
58 1
        TestPaths.add_interfaces(2, switches["User3"], interfaces)
59
60 1
        TestPaths.create_switch("User4", switches)
61 1
        TestPaths.add_interfaces(3, switches["User4"], interfaces)
62
63 1
        EdgesSettings._fill_links(links, interfaces)
64
65 1
        EdgesSettings._add_metadata_to_links(links)
66
67 1
        return switches, links
68
69 1
    @staticmethod
70 1
    def _add_metadata_to_links(links):
71 1
        links["S1:1<->S2:1"].extend_metadata(
72
            {"reliability": 5, "bandwidth": 100, "delay": 105}
73
        )
74
75 1
        links["S1:2<->User1:1"].extend_metadata(
76
            {"reliability": 5, "bandwidth": 100, "delay": 1}
77
        )
78
79 1
        links["S2:2<->User4:1"].extend_metadata(
80
            {"reliability": 5, "bandwidth": 100, "delay": 10}
81
        )
82
83 1
        links["S3:1<->S5:1"].extend_metadata(
84
            {"reliability": 5, "bandwidth": 10, "delay": 112}
85
        )
86
87 1
        links["S3:2<->S7:1"].extend_metadata(
88
            {"reliability": 5, "bandwidth": 100, "delay": 1}
89
        )
90
91 1
        links["S3:3<->S8:1"].extend_metadata(
92
            {"reliability": 5, "bandwidth": 100, "delay": 1}
93
        )
94
95 1
        links["S3:4<->S11:1"].extend_metadata(
96
            {"reliability": 3, "bandwidth": 100, "delay": 6}
97
        )
98
99 1
        links["S3:5<->User3:1"].extend_metadata(
100
            {"reliability": 5, "bandwidth": 100, "delay": 1}
101
        )
102
103 1
        links["S3:6<->User4:2"].extend_metadata(
104
            {"reliability": 5, "bandwidth": 100, "delay": 10}
105
        )
106
107 1
        links["S4:1<->S5:2"].extend_metadata(
108
            {
109
                "reliability": 1,
110
                "bandwidth": 100,
111
                "delay": 30,
112
                "ownership": {"A": {}},
113
            }
114
        )
115
116 1
        links["S4:2<->User1:2"].extend_metadata(
117
            {
118
                "reliability": 3,
119
                "bandwidth": 100,
120
                "delay": 110,
121
                "ownership": {"A": {}},
122
            }
123
        )
124
125 1
        links["S5:3<->S6:1"].extend_metadata(
126
            {"reliability": 1, "bandwidth": 100, "delay": 40}
127
        )
128
129 1
        links["S5:4<->S6:2"].extend_metadata(
130
            {
131
                "reliability": 3,
132
                "bandwidth": 100,
133
                "delay": 40,
134
                "ownership": {"A": {}},
135
            }
136
        )
137
138 1
        links["S5:5<->S8:2"].extend_metadata(
139
            {"reliability": 5, "bandwidth": 100, "delay": 112}
140
        )
141
142 1
        links["S5:6<->User1:3"].extend_metadata(
143
            {"reliability": 3, "bandwidth": 100, "delay": 60}
144
        )
145
146 1
        links["S6:3<->S9:1"].extend_metadata(
147
            {"reliability": 3, "bandwidth": 100, "delay": 60}
148
        )
149
150 1
        links["S6:4<->S9:2"].extend_metadata(
151
            {"reliability": 5, "bandwidth": 100, "delay": 62}
152
        )
153
154 1
        links["S6:5<->S10:1"].extend_metadata(
155
            {"bandwidth": 100, "delay": 108, "ownership": {"A": {}}}
156
        )
157
158 1
        links["S7:2<->S8:3"].extend_metadata(
159
            {"reliability": 5, "bandwidth": 100, "delay": 1}
160
        )
161
162 1
        links["S8:4<->S9:3"].extend_metadata(
163
            {"reliability": 3, "bandwidth": 100, "delay": 32}
164
        )
165
166 1
        links["S8:5<->S9:4"].extend_metadata(
167
            {"reliability": 3, "bandwidth": 100, "delay": 110}
168
        )
169
170 1
        links["S8:6<->S10:2"].extend_metadata(
171
            {"reliability": 5, "bandwidth": 100, "ownership": {"A": {}}}
172
        )
173
174 1
        links["S8:7<->S11:2"].extend_metadata(
175
            {"reliability": 3, "bandwidth": 100, "delay": 7}
176
        )
177
178 1
        links["S8:8<->User3:2"].extend_metadata(
179
            {"reliability": 5, "bandwidth": 100, "delay": 1}
180
        )
181
182 1
        links["S10:3<->User2:1"].extend_metadata(
183
            {
184
                "reliability": 3,
185
                "bandwidth": 100,
186
                "delay": 10,
187
                "ownership": {"A": {}},
188
            }
189
        )
190
191 1
        links["S11:3<->User2:2"].extend_metadata(
192
            {"reliability": 3, "bandwidth": 100, "delay": 6}
193
        )
194
195 1
        links["User1:4<->User4:3"].extend_metadata(
196
            {"reliability": 5, "bandwidth": 10, "delay": 105}
197
        )
198
199 1
    @staticmethod
200 1
    def _fill_links(links, interfaces):
201 1
        links["S1:1<->S2:1"] = Link(interfaces["S1:1"], interfaces["S2:1"])
202
203 1
        links["S1:2<->User1:1"] = Link(
204
            interfaces["S1:2"], interfaces["User1:1"]
205
        )
206
207 1
        links["S2:2<->User4:1"] = Link(
208
            interfaces["S2:2"], interfaces["User4:1"]
209
        )
210
211 1
        links["S3:1<->S5:1"] = Link(interfaces["S3:1"], interfaces["S5:1"])
212
213 1
        links["S3:2<->S7:1"] = Link(interfaces["S3:2"], interfaces["S7:1"])
214
215 1
        links["S3:3<->S8:1"] = Link(interfaces["S3:3"], interfaces["S8:1"])
216
217 1
        links["S3:4<->S11:1"] = Link(interfaces["S3:4"], interfaces["S11:1"])
218
219 1
        links["S3:5<->User3:1"] = Link(
220
            interfaces["S3:5"], interfaces["User3:1"]
221
        )
222
223 1
        links["S3:6<->User4:2"] = Link(
224
            interfaces["S3:6"], interfaces["User4:2"]
225
        )
226
227 1
        links["S4:1<->S5:2"] = Link(interfaces["S4:1"], interfaces["S5:2"])
228
229 1
        links["S4:2<->User1:2"] = Link(
230
            interfaces["S4:2"], interfaces["User1:2"]
231
        )
232
233 1
        links["S5:3<->S6:1"] = Link(interfaces["S5:3"], interfaces["S6:1"])
234
235 1
        links["S5:4<->S6:2"] = Link(interfaces["S5:4"], interfaces["S6:2"])
236
237 1
        links["S5:5<->S8:2"] = Link(interfaces["S5:5"], interfaces["S8:2"])
238
239 1
        links["S5:6<->User1:3"] = Link(
240
            interfaces["S5:6"], interfaces["User1:3"]
241
        )
242
243 1
        links["S6:3<->S9:1"] = Link(interfaces["S6:3"], interfaces["S9:1"])
244
245 1
        links["S6:4<->S9:2"] = Link(interfaces["S6:4"], interfaces["S9:2"])
246
247 1
        links["S6:5<->S10:1"] = Link(interfaces["S6:5"], interfaces["S10:1"])
248
249 1
        links["S7:2<->S8:3"] = Link(interfaces["S7:2"], interfaces["S8:3"])
250
251 1
        links["S8:4<->S9:3"] = Link(interfaces["S8:4"], interfaces["S9:3"])
252
253 1
        links["S8:5<->S9:4"] = Link(interfaces["S8:5"], interfaces["S9:4"])
254
255 1
        links["S8:6<->S10:2"] = Link(interfaces["S8:6"], interfaces["S10:2"])
256
257 1
        links["S8:7<->S11:2"] = Link(interfaces["S8:7"], interfaces["S11:2"])
258
259 1
        links["S8:8<->User3:2"] = Link(
260
            interfaces["S8:8"], interfaces["User3:2"]
261
        )
262
263 1
        links["S10:3<->User2:1"] = Link(
264
            interfaces["S10:3"], interfaces["User2:1"]
265
        )
266
267 1
        links["S11:3<->User2:2"] = Link(
268
            interfaces["S11:3"], interfaces["User2:2"]
269
        )
270
271 1
        links["User1:4<->User4:3"] = Link(
272
            interfaces["User1:4"], interfaces["User4:3"]
273
        )
274
275 1
        for link in links.values():
276 1
            link.enable()
277
            link.activate()
278