1
|
|
|
""" |
2
|
|
|
Test tracing.trace_entries |
3
|
|
|
""" |
4
|
|
|
from unittest import TestCase |
5
|
|
|
|
6
|
|
|
from napps.amlight.sdntrace.tracing.trace_entries import TraceEntries |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
class TestDpid(TestCase): |
10
|
|
|
"""Test all combinations for DPID""" |
11
|
|
|
|
12
|
|
|
def setUp(self): |
13
|
|
|
self.trace_entries = TraceEntries() |
14
|
|
|
|
15
|
|
|
def test_incorrect_dpid_int(self): |
16
|
|
|
"""DPID cannot be integer""" |
17
|
|
|
with self.assertRaises(ValueError): |
18
|
|
|
self.trace_entries.dpid = 0 |
19
|
|
|
|
20
|
|
|
def test_incorrect_dpid_empty_str(self): |
21
|
|
|
"""DPID cannot be an empty str""" |
22
|
|
|
with self.assertRaises(ValueError): |
23
|
|
|
self.trace_entries.dpid = "" |
24
|
|
|
|
25
|
|
|
def test_incorrect_dpid_invalid_characters_plus(self): |
26
|
|
|
"""DPID cannot be a special character (only ':' is allowed)""" |
27
|
|
|
with self.assertRaises(ValueError): |
28
|
|
|
self.trace_entries.dpid = "+" |
29
|
|
|
|
30
|
|
|
def test_incorrect_dpid_invalid_characters_comma(self): |
31
|
|
|
"""DPID cannot be a special character (only ':' is allowed)""" |
32
|
|
|
with self.assertRaises(ValueError): |
33
|
|
|
self.trace_entries.dpid = "," |
34
|
|
|
|
35
|
|
|
def test_incorrect_dpid_invalid_length(self): |
36
|
|
|
"""DPID cannot be longer than 16 without ':'""" |
37
|
|
|
with self.assertRaises(ValueError): |
38
|
|
|
self.trace_entries.dpid = "00000000000000001" |
39
|
|
|
|
40
|
|
|
def test_correct_dpid_char(self): |
41
|
|
|
"""Correct DPID with char""" |
42
|
|
|
self.trace_entries.dpid = "1" |
43
|
|
|
|
44
|
|
|
def test_read_dpid_char(self): |
45
|
|
|
"""Read DPID '1'""" |
46
|
|
|
self.test_correct_dpid_char() |
47
|
|
|
self.assertEqual(self.trace_entries.dpid, "1") |
48
|
|
|
|
49
|
|
|
def test_correct_dpid_complete(self): |
50
|
|
|
"""Correct DPID with colons, numbers, and letters""" |
51
|
|
|
self.trace_entries.dpid = "ab:cd:ef:ab:cd:ef:00:01" |
52
|
|
|
|
53
|
|
|
def test_read_dpid_complete(self): |
54
|
|
|
"""Read DPID '1'""" |
55
|
|
|
self.test_correct_dpid_complete() |
56
|
|
|
self.assertEqual(self.trace_entries.dpid, "ab:cd:ef:ab:cd:ef:00:01") |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
class TestInPort(TestCase): |
60
|
|
|
"""Test all combinations for IN_PORT""" |
61
|
|
|
|
62
|
|
|
def setUp(self): |
63
|
|
|
self.trace_entries = TraceEntries() |
64
|
|
|
|
65
|
|
|
def test_incorrect_in_port_char(self): |
66
|
|
|
"""IN_PORT cannot be a char""" |
67
|
|
|
with self.assertRaises(ValueError): |
68
|
|
|
self.trace_entries.in_port = "1" |
69
|
|
|
|
70
|
|
|
def test_incorrect_in_port_negative(self): |
71
|
|
|
"""IN_PORT cannot be negative""" |
72
|
|
|
with self.assertRaises(ValueError): |
73
|
|
|
self.trace_entries.in_port = -1 |
74
|
|
|
|
75
|
|
|
def test_correct_in_port(self): |
76
|
|
|
"""IN_PORT Correct""" |
77
|
|
|
self.trace_entries.in_port = 1 |
78
|
|
|
|
79
|
|
|
def test_read_in_port(self): |
80
|
|
|
"""Read DPID '1'""" |
81
|
|
|
self.test_correct_in_port() |
82
|
|
|
self.assertEqual(self.trace_entries.in_port, 1) |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
class TestDlSrc(TestCase): |
86
|
|
|
"""Test all combinations for DL_SRC""" |
87
|
|
|
|
88
|
|
|
def setUp(self): |
89
|
|
|
self.trace_entries = TraceEntries() |
90
|
|
|
|
91
|
|
|
def test_incorrect_dl_src_int(self): |
92
|
|
|
"""dl_src cannot be integer""" |
93
|
|
|
with self.assertRaises(ValueError): |
94
|
|
|
self.trace_entries.dl_src = 0 |
95
|
|
|
|
96
|
|
|
def test_incorrect_dl_src_empty_str(self): |
97
|
|
|
"""dl_src cannot be an empty str""" |
98
|
|
|
with self.assertRaises(ValueError): |
99
|
|
|
self.trace_entries.dl_src = "" |
100
|
|
|
|
101
|
|
|
def test_incorrect_dl_src_invalid_characters_plus(self): |
102
|
|
|
"""dl_src only accepts ':' snd '-'""" |
103
|
|
|
with self.assertRaises(ValueError): |
104
|
|
|
self.trace_entries.dl_src = "+" |
105
|
|
|
|
106
|
|
|
def test_incorrect_dl_src_invalid_characters_comma(self): |
107
|
|
|
"""dl_src cannot be a special character (only ':' is allowed)""" |
108
|
|
|
with self.assertRaises(ValueError): |
109
|
|
|
self.trace_entries.dl_src = "," |
110
|
|
|
|
111
|
|
|
def test_incorrect_dl_src_invalid_length(self): |
112
|
|
|
"""dl_src cannot be longer than 16 without ':'""" |
113
|
|
|
with self.assertRaises(ValueError): |
114
|
|
|
self.trace_entries.dl_src = "000000000000000001" |
115
|
|
|
|
116
|
|
|
def test_correct_dl_src_char(self): |
117
|
|
|
"""Correct dl_src with char""" |
118
|
|
|
self.trace_entries.dl_src = "ab:cd:ef:ab:cd:00" |
119
|
|
|
|
120
|
|
|
def test_read_dl_src_char(self): |
121
|
|
|
"""Read dl_src '1'""" |
122
|
|
|
self.test_correct_dl_src_char() |
123
|
|
|
self.assertEqual(self.trace_entries.dl_src, "ab:cd:ef:ab:cd:00") |
124
|
|
|
|
125
|
|
|
|
126
|
|
|
class TestDlDst(TestCase): |
127
|
|
|
"""Test all combinations for DL_DST""" |
128
|
|
|
|
129
|
|
|
def setUp(self): |
130
|
|
|
self.trace_entries = TraceEntries() |
131
|
|
|
|
132
|
|
|
def test_incorrect_dl_dst_int(self): |
133
|
|
|
"""dl_dst cannot be integer""" |
134
|
|
|
with self.assertRaises(ValueError): |
135
|
|
|
self.trace_entries.dl_dst = 0 |
136
|
|
|
|
137
|
|
|
def test_incorrect_dl_dst_empty_str(self): |
138
|
|
|
"""dl_dst cannot be an empty str""" |
139
|
|
|
with self.assertRaises(ValueError): |
140
|
|
|
self.trace_entries.dl_dst = "" |
141
|
|
|
|
142
|
|
|
def test_incorrect_dl_dst_invalid_characters_plus(self): |
143
|
|
|
"""dl_dst only accepts ':' snd '-'""" |
144
|
|
|
with self.assertRaises(ValueError): |
145
|
|
|
self.trace_entries.dl_dst = "+" |
146
|
|
|
|
147
|
|
|
def test_incorrect_dl_dst_invalid_characters_comma(self): |
148
|
|
|
"""dl_dst cannot be a special character (only ':' is allowed)""" |
149
|
|
|
with self.assertRaises(ValueError): |
150
|
|
|
self.trace_entries.dl_dst = "," |
151
|
|
|
|
152
|
|
|
def test_incorrect_dl_dst_invalid_length(self): |
153
|
|
|
"""dl_dst cannot be longer than 16 without ':'""" |
154
|
|
|
with self.assertRaises(ValueError): |
155
|
|
|
self.trace_entries.dl_dst = "000000000000000001" |
156
|
|
|
|
157
|
|
|
def test_correct_dl_dst_char(self): |
158
|
|
|
"""Correct dl_dst with char""" |
159
|
|
|
self.trace_entries.dl_dst = "ab:cd:ef:ab:cd:00" |
160
|
|
|
|
161
|
|
|
def test_read_dl_dst_char(self): |
162
|
|
|
"""Read dl_dst '1'""" |
163
|
|
|
self.test_correct_dl_dst_char() |
164
|
|
|
self.assertEqual(self.trace_entries.dl_dst, "ab:cd:ef:ab:cd:00") |
165
|
|
|
|
166
|
|
|
|
167
|
|
|
class TestDlVlan(TestCase): |
168
|
|
|
"""Test all combinations for DL_VLAN""" |
169
|
|
|
|
170
|
|
|
def setUp(self): |
171
|
|
|
self.trace_entries = TraceEntries() |
172
|
|
|
|
173
|
|
|
def test_incorrect_dl_vlan_char(self): |
174
|
|
|
"""dl_vlan cannot be a char""" |
175
|
|
|
with self.assertRaises(ValueError): |
176
|
|
|
self.trace_entries.dl_vlan = "1" |
177
|
|
|
|
178
|
|
|
def test_incorrect_dl_vlan_negative(self): |
179
|
|
|
"""dl_vlan cannot be negative""" |
180
|
|
|
with self.assertRaises(ValueError): |
181
|
|
|
self.trace_entries.dl_vlan = -1 |
182
|
|
|
|
183
|
|
|
def test_incorrect_dl_vlan_too_big(self): |
184
|
|
|
"""dl_vlan cannot be bigger than 4095""" |
185
|
|
|
with self.assertRaises(ValueError): |
186
|
|
|
self.trace_entries.dl_vlan = 4096 |
187
|
|
|
|
188
|
|
|
def test_correct_dl_vlan(self): |
189
|
|
|
"""dl_vlan Correct""" |
190
|
|
|
self.trace_entries.dl_vlan = 1 |
191
|
|
|
|
192
|
|
|
def test_read_dl_vlan(self): |
193
|
|
|
"""Read DPID '1'""" |
194
|
|
|
self.test_correct_dl_vlan() |
195
|
|
|
self.assertEqual(self.trace_entries.dl_vlan, 1) |
196
|
|
|
|
197
|
|
|
|
198
|
|
|
class TestDlType(TestCase): |
199
|
|
|
"""Test all combinations for dl_type""" |
200
|
|
|
|
201
|
|
|
def setUp(self): |
202
|
|
|
self.trace_entries = TraceEntries() |
203
|
|
|
|
204
|
|
|
def test_incorrect_dl_type_char(self): |
205
|
|
|
"""dl_type cannot be a char""" |
206
|
|
|
with self.assertRaises(ValueError): |
207
|
|
|
self.trace_entries.dl_type = "1" |
208
|
|
|
|
209
|
|
|
def test_incorrect_dl_type_negative(self): |
210
|
|
|
"""dl_type cannot be negative""" |
211
|
|
|
with self.assertRaises(ValueError): |
212
|
|
|
self.trace_entries.dl_type = -1 |
213
|
|
|
|
214
|
|
|
def test_incorrect_dl_type_too_big(self): |
215
|
|
|
"""dl_type cannot be bigger than 4095""" |
216
|
|
|
with self.assertRaises(ValueError): |
217
|
|
|
self.trace_entries.dl_type = 65536 |
218
|
|
|
|
219
|
|
|
def test_correct_dl_type(self): |
220
|
|
|
"""dl_type Correct""" |
221
|
|
|
self.trace_entries.dl_type = 1 |
222
|
|
|
|
223
|
|
|
def test_read_dl_type(self): |
224
|
|
|
"""Read DPID '1'""" |
225
|
|
|
self.test_correct_dl_type() |
226
|
|
|
self.assertEqual(self.trace_entries.dl_type, 1) |
227
|
|
|
|
228
|
|
|
|
229
|
|
|
class TestDlVlanPcp(TestCase): |
230
|
|
|
"""Test all combinations for dl_vlan_pcp""" |
231
|
|
|
|
232
|
|
|
def setUp(self): |
233
|
|
|
self.trace_entries = TraceEntries() |
234
|
|
|
|
235
|
|
|
def test_incorrect_dl_vlan_pcp_char(self): |
236
|
|
|
"""dl_vlan_pcp cannot be a char""" |
237
|
|
|
with self.assertRaises(ValueError): |
238
|
|
|
self.trace_entries.dl_vlan_pcp = "1" |
239
|
|
|
|
240
|
|
|
def test_incorrect_dl_vlan_pcp_negative(self): |
241
|
|
|
"""dl_vlan_pcp cannot be negative""" |
242
|
|
|
with self.assertRaises(ValueError): |
243
|
|
|
self.trace_entries.dl_vlan_pcp = -1 |
244
|
|
|
|
245
|
|
|
def test_incorrect_dl_vlan_pcp_too_big(self): |
246
|
|
|
"""dl_vlan_pcp cannot be bigger than 7""" |
247
|
|
|
with self.assertRaises(ValueError): |
248
|
|
|
self.trace_entries.dl_vlan_pcp = 8 |
249
|
|
|
|
250
|
|
|
def test_correct_dl_vlan_pcp(self): |
251
|
|
|
"""dl_vlan_pcp Correct""" |
252
|
|
|
self.trace_entries.dl_vlan_pcp = 1 |
253
|
|
|
|
254
|
|
|
def test_read_dl_vlan_pcp(self): |
255
|
|
|
"""Read DPID '1'""" |
256
|
|
|
self.test_correct_dl_vlan_pcp() |
257
|
|
|
self.assertEqual(self.trace_entries.dl_vlan_pcp, 1) |
258
|
|
|
|
259
|
|
|
|
260
|
|
|
class TestNwTos(TestCase): |
261
|
|
|
"""Test all combinations for nw_tos""" |
262
|
|
|
|
263
|
|
|
def setUp(self): |
264
|
|
|
self.trace_entries = TraceEntries() |
265
|
|
|
|
266
|
|
|
def test_incorrect_nw_tos_char(self): |
267
|
|
|
"""nw_tos cannot be a char""" |
268
|
|
|
with self.assertRaises(ValueError): |
269
|
|
|
self.trace_entries.nw_tos = "1" |
270
|
|
|
|
271
|
|
|
def test_incorrect_nw_tos_negative(self): |
272
|
|
|
"""nw_tos cannot be negative""" |
273
|
|
|
with self.assertRaises(ValueError): |
274
|
|
|
self.trace_entries.nw_tos = -1 |
275
|
|
|
|
276
|
|
|
def test_incorrect_nw_tos_too_big(self): |
277
|
|
|
"""nw_tos cannot be bigger than 7""" |
278
|
|
|
with self.assertRaises(ValueError): |
279
|
|
|
self.trace_entries.nw_tos = 8 |
280
|
|
|
|
281
|
|
|
def test_correct_nw_tos(self): |
282
|
|
|
"""nw_tos Correct""" |
283
|
|
|
self.trace_entries.nw_tos = 1 |
284
|
|
|
|
285
|
|
|
def test_read_nw_tos(self): |
286
|
|
|
"""Read DPID '1'""" |
287
|
|
|
self.test_correct_nw_tos() |
288
|
|
|
self.assertEqual(self.trace_entries.nw_tos, 1) |
289
|
|
|
|
290
|
|
|
|
291
|
|
|
class TestNwSrc(TestCase): |
292
|
|
|
"""Test all combinations for NW_SRC""" |
293
|
|
|
|
294
|
|
|
def setUp(self): |
295
|
|
|
self.trace_entries = TraceEntries() |
296
|
|
|
|
297
|
|
|
def test_incorrect_nw_src_int(self): |
298
|
|
|
"""nw_src cannot be integer""" |
299
|
|
|
with self.assertRaises(ValueError): |
300
|
|
|
self.trace_entries.nw_src = 0 |
301
|
|
|
|
302
|
|
|
def test_incorrect_nw_src_empty_str(self): |
303
|
|
|
"""nw_src cannot be an empty str""" |
304
|
|
|
with self.assertRaises(ValueError): |
305
|
|
|
self.trace_entries.nw_src = "" |
306
|
|
|
|
307
|
|
|
def test_incorrect_nw_src_invalid_characters_plus(self): |
308
|
|
|
"""nw_src only accepts '.'""" |
309
|
|
|
with self.assertRaises(ValueError): |
310
|
|
|
self.trace_entries.nw_src = "+" |
311
|
|
|
|
312
|
|
|
def test_incorrect_nw_src_256(self): |
313
|
|
|
"""Correct nw_src with char""" |
314
|
|
|
with self.assertRaises(ValueError): |
315
|
|
|
self.trace_entries.nw_src = "0.0.0.256" |
316
|
|
|
|
317
|
|
|
def test_correct_nw_src_zeroed(self): |
318
|
|
|
"""Correct nw_src with char""" |
319
|
|
|
self.trace_entries.nw_src = "0.0.0.0" |
320
|
|
|
|
321
|
|
|
def test_read_nw_src_char(self): |
322
|
|
|
"""Read nw_src '1'""" |
323
|
|
|
self.test_correct_nw_src_zeroed() |
324
|
|
|
self.assertEqual(self.trace_entries.nw_src, "0.0.0.0") |
325
|
|
|
|
326
|
|
|
def test_correct_nw_src_255(self): |
327
|
|
|
"""Correct nw_src with char""" |
328
|
|
|
self.trace_entries.nw_src = "255.255.255.255" |
329
|
|
|
|
330
|
|
|
def test_read_nw_src_char_255(self): |
331
|
|
|
"""Read nw_src '1'""" |
332
|
|
|
self.test_correct_nw_src_255() |
333
|
|
|
self.assertEqual(self.trace_entries.nw_src, "255.255.255.255") |
334
|
|
|
|
335
|
|
|
|
336
|
|
|
class TestNwDst(TestCase): |
337
|
|
|
"""Test all combinations for NW_DST""" |
338
|
|
|
|
339
|
|
|
def setUp(self): |
340
|
|
|
self.trace_entries = TraceEntries() |
341
|
|
|
|
342
|
|
|
def test_incorrect_nw_dst_int(self): |
343
|
|
|
"""nw_dst cannot be integer""" |
344
|
|
|
with self.assertRaises(ValueError): |
345
|
|
|
self.trace_entries.nw_dst = 0 |
346
|
|
|
|
347
|
|
|
def test_incorrect_nw_dst_empty_str(self): |
348
|
|
|
"""nw_dst cannot be an empty str""" |
349
|
|
|
with self.assertRaises(ValueError): |
350
|
|
|
self.trace_entries.nw_dst = "" |
351
|
|
|
|
352
|
|
|
def test_incorrect_nw_dst_invalid_characters_plus(self): |
353
|
|
|
"""nw_dst only accepts '.'""" |
354
|
|
|
with self.assertRaises(ValueError): |
355
|
|
|
self.trace_entries.nw_dst = "+" |
356
|
|
|
|
357
|
|
|
def test_incorrect_nw_dst_256(self): |
358
|
|
|
"""Correct nw_dst with char""" |
359
|
|
|
with self.assertRaises(ValueError): |
360
|
|
|
self.trace_entries.nw_dst = "0.0.0.256" |
361
|
|
|
|
362
|
|
|
def test_correct_nw_dst_zeroed(self): |
363
|
|
|
"""Correct nw_dst with char""" |
364
|
|
|
self.trace_entries.nw_dst = "0.0.0.0" |
365
|
|
|
|
366
|
|
|
def test_read_nw_dst_char(self): |
367
|
|
|
"""Read nw_dst '1'""" |
368
|
|
|
self.test_correct_nw_dst_zeroed() |
369
|
|
|
self.assertEqual(self.trace_entries.nw_dst, "0.0.0.0") |
370
|
|
|
|
371
|
|
|
def test_correct_nw_dst_255(self): |
372
|
|
|
"""Correct nw_dst with char""" |
373
|
|
|
self.trace_entries.nw_dst = "255.255.255.255" |
374
|
|
|
|
375
|
|
|
def test_read_nw_dst_char_255(self): |
376
|
|
|
"""Read nw_dst '1'""" |
377
|
|
|
self.test_correct_nw_dst_255() |
378
|
|
|
self.assertEqual(self.trace_entries.nw_dst, "255.255.255.255") |
379
|
|
|
|
380
|
|
|
|
381
|
|
|
class TestTpSrc(TestCase): |
382
|
|
|
"""Test all combinations for tp_src""" |
383
|
|
|
|
384
|
|
|
def setUp(self): |
385
|
|
|
self.trace_entries = TraceEntries() |
386
|
|
|
|
387
|
|
|
def test_incorrect_tp_src_char(self): |
388
|
|
|
"""tp_src cannot be a char""" |
389
|
|
|
with self.assertRaises(ValueError): |
390
|
|
|
self.trace_entries.tp_src = "1" |
391
|
|
|
|
392
|
|
|
def test_incorrect_tp_src_negative(self): |
393
|
|
|
"""tp_src cannot be negative""" |
394
|
|
|
with self.assertRaises(ValueError): |
395
|
|
|
self.trace_entries.tp_src = -1 |
396
|
|
|
|
397
|
|
|
def test_incorrect_tp_src_too_big(self): |
398
|
|
|
"""tp_src cannot be bigger than 4095""" |
399
|
|
|
with self.assertRaises(ValueError): |
400
|
|
|
self.trace_entries.tp_src = 65536 |
401
|
|
|
|
402
|
|
|
def test_correct_tp_src(self): |
403
|
|
|
"""tp_src Correct""" |
404
|
|
|
self.trace_entries.tp_src = 1 |
405
|
|
|
|
406
|
|
|
def test_read_tp_src(self): |
407
|
|
|
"""Read DPID '1'""" |
408
|
|
|
self.test_correct_tp_src() |
409
|
|
|
self.assertEqual(self.trace_entries.tp_src, 1) |
410
|
|
|
|
411
|
|
|
|
412
|
|
|
class TestTpDst(TestCase): |
413
|
|
|
"""Test all combinations for tp_dst""" |
414
|
|
|
|
415
|
|
|
def setUp(self): |
416
|
|
|
self.trace_entries = TraceEntries() |
417
|
|
|
|
418
|
|
|
def test_incorrect_tp_dst_char(self): |
419
|
|
|
"""tp_dst cannot be a char""" |
420
|
|
|
with self.assertRaises(ValueError): |
421
|
|
|
self.trace_entries.tp_dst = "1" |
422
|
|
|
|
423
|
|
|
def test_incorrect_tp_dst_negative(self): |
424
|
|
|
"""tp_dst cannot be negative""" |
425
|
|
|
with self.assertRaises(ValueError): |
426
|
|
|
self.trace_entries.tp_dst = -1 |
427
|
|
|
|
428
|
|
|
def test_incorrect_tp_dst_too_big(self): |
429
|
|
|
"""tp_dst cannot be bigger than 4095""" |
430
|
|
|
with self.assertRaises(ValueError): |
431
|
|
|
self.trace_entries.tp_dst = 65536 |
432
|
|
|
|
433
|
|
|
def test_correct_tp_dst(self): |
434
|
|
|
"""tp_dst Correct""" |
435
|
|
|
self.trace_entries.tp_dst = 1 |
436
|
|
|
|
437
|
|
|
def test_read_tp_dst(self): |
438
|
|
|
"""Read DPID '1'""" |
439
|
|
|
self.test_correct_tp_dst() |
440
|
|
|
self.assertEqual(self.trace_entries.tp_dst, 1) |
441
|
|
|
|
442
|
|
|
|
443
|
|
|
class TestLoadEntries(TestCase): |
444
|
|
|
"""Now, load all entries at once""" |
445
|
|
|
|
446
|
|
|
def setUp(self): |
447
|
|
|
self.trace_entries = TraceEntries() |
448
|
|
|
|
449
|
|
|
def test_missing_trace(self): |
450
|
|
|
"""key trace is mandatory""" |
451
|
|
|
with self.assertRaises(ValueError): |
452
|
|
|
entries = {} |
453
|
|
|
self.trace_entries.load_entries(entries) |
454
|
|
|
|
455
|
|
|
def test_trace_non_dict(self): |
456
|
|
|
"""key trace has to be a dict""" |
457
|
|
|
with self.assertRaises(ValueError): |
458
|
|
|
entries = {"trace:": 0} |
459
|
|
|
self.trace_entries.load_entries(entries) |
460
|
|
|
|
461
|
|
|
def test_missing_switch(self): |
462
|
|
|
"""key trace/switch is mandatory""" |
463
|
|
|
with self.assertRaises(ValueError): |
464
|
|
|
entries = {"trace": {}} |
465
|
|
|
self.trace_entries.load_entries(entries) |
466
|
|
|
|
467
|
|
|
def test_missing_dpid(self): |
468
|
|
|
"""key trace/switch is mandatory""" |
469
|
|
|
with self.assertRaises(ValueError): |
470
|
|
|
dpid = {} |
471
|
|
|
switch = {"switch": dpid} |
472
|
|
|
entries = {"trace": switch} |
473
|
|
|
self.trace_entries.load_entries(entries) |
474
|
|
|
|
475
|
|
|
def test_missing_in_port(self): |
476
|
|
|
"""key trace/switch is mandatory""" |
477
|
|
|
with self.assertRaises(ValueError): |
478
|
|
|
dpid = {"dpid": "a"} |
479
|
|
|
switch = {"switch": dpid} |
480
|
|
|
entries = {"trace": switch} |
481
|
|
|
self.trace_entries.load_entries(entries) |
482
|
|
|
|
483
|
|
|
def test_missing_eth(self): |
484
|
|
|
"""key trace/switch is mandatory""" |
485
|
|
|
with self.assertRaises(ValueError): |
486
|
|
|
eth = 0 |
487
|
|
|
dpid = {"dpid": "a", "in_port": 1} |
488
|
|
|
switch = {"switch": dpid, "eth": eth} |
489
|
|
|
entries = {"trace": switch} |
490
|
|
|
self.trace_entries.load_entries(entries) |
491
|
|
|
|
492
|
|
|
def test_minimally_correct(self): |
493
|
|
|
"""key trace/switch is mandatory""" |
494
|
|
|
eth = {"dl_vlan": 100} |
495
|
|
|
dpid = {"dpid": "a", "in_port": 1} |
496
|
|
|
switch = {"switch": dpid, "eth": eth} |
497
|
|
|
entries = {"trace": switch} |
498
|
|
|
self.trace_entries.load_entries(entries) |
499
|
|
|
|