Passed
Pull Request — master (#169)
by Vinicius
04:52
created

test_flow_builder_inter_evc   B

Complexity

Total Complexity 14

Size/Duplication

Total Lines 2409
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 1737
dl 0
loc 2409
ccs 211
cts 211
cp 1
rs 8.8
c 0
b 0
f 0
wmc 14

5 Functions

Rating   Name   Duplication   Size   Complexity  
B test_build_int_flows_inter_evpl_no_proxy_ports() 0 414 2
B test_build_int_flows_inter_evpl_range() 0 1282 3
A test_bulkd_inter_sink_flows_cases() 0 45 2
B test_build_int_flows_inter_evpl() 0 517 4
B test_build_int_flows_inter_evpl_flows_count_evc_metadata_proxy_port_enabled() 0 123 3
1
"""Test flow_builder."""
2
3 1
import pytest
4
5 1
from unittest.mock import MagicMock
6 1
from napps.kytos.telemetry_int.managers.flow_builder import FlowBuilder
7 1
from napps.kytos.telemetry_int.managers.int import INTManager
8 1
from napps.kytos.telemetry_int.utils import get_cookie
9 1
from napps.kytos.telemetry_int.proxy_port import ProxyPort
10 1
from napps.kytos.telemetry_int.exceptions import ProxyPortMetadataNotFound
11 1
from napps.kytos.telemetry_int import settings
12 1
from napps.kytos.telemetry_int.kytos_api_helper import _map_stored_flows_by_cookies
13 1
from kytos.lib.helpers import get_controller_mock, get_switch_mock, get_interface_mock
14 1
from kytos.core.common import EntityStatus
15
16
# pylint: disable=too-many-lines, too-many-statements
17
18
19 1
def test_build_int_flows_inter_evpl(
20
    evcs_data, inter_evc_evpl_set_queue_flows_data
21
) -> None:
22
    """Test build INT flows inter EVPL.
23
24
               +----+                                              +----+
25
              5|    |6                                            5|    |6
26
           +---+----v---+            +------------+           +----+----v---+
27
        1  |            |            |            |           |             |1
28
    -------+            |3         2 |            |3        2 |             +-------
29
     vlan  |     s1     +------------+    s2      +-----------+    s3       | vlan
30
     101   |            |            |            |           |             | 102
31
           |            |            |            |           |             |
32
           +------------+            +------------+           +-------------+
33
34
    """
35 1
    controller = get_controller_mock()
36 1
    int_manager = INTManager(controller)
37 1
    get_proxy_port_or_raise = MagicMock()
38 1
    int_manager.get_proxy_port_or_raise = get_proxy_port_or_raise
39
40 1
    evc_id = "16a76ae61b2f46"
41 1
    dpid_a = "00:00:00:00:00:00:00:01"
42 1
    mock_switch_a = get_switch_mock(dpid_a, 0x04)
43 1
    mock_interface_a1 = get_interface_mock("s1-eth1", 1, mock_switch_a)
44 1
    mock_interface_a1.id = f"{dpid_a}:{mock_interface_a1.port_number}"
45 1
    mock_interface_a5 = get_interface_mock("s1-eth5", 5, mock_switch_a)
46 1
    mock_interface_a1.metadata = {"proxy_port": mock_interface_a5.port_number}
47 1
    mock_interface_a5.status = EntityStatus.UP
48 1
    mock_interface_a6 = get_interface_mock("s1-eth6", 6, mock_switch_a)
49 1
    mock_interface_a6.status = EntityStatus.UP
50 1
    mock_interface_a5.metadata = {
51
        "looped": {
52
            "port_numbers": [
53
                mock_interface_a5.port_number,
54
                mock_interface_a6.port_number,
55
            ]
56
        }
57
    }
58
59 1
    dpid_z = "00:00:00:00:00:00:00:03"
60 1
    mock_switch_z = get_switch_mock(dpid_z, 0x04)
61 1
    mock_interface_z1 = get_interface_mock("s1-eth1", 1, mock_switch_z)
62 1
    mock_interface_z1.status = EntityStatus.UP
63 1
    mock_interface_z1.id = f"{dpid_z}:{mock_interface_z1.port_number}"
64 1
    mock_interface_z5 = get_interface_mock("s1-eth5", 5, mock_switch_z)
65 1
    mock_interface_z1.metadata = {"proxy_port": mock_interface_z5.port_number}
66 1
    mock_interface_z5.status = EntityStatus.UP
67 1
    mock_interface_z6 = get_interface_mock("s1-eth6", 6, mock_switch_z)
68 1
    mock_interface_z6.status = EntityStatus.UP
69 1
    mock_interface_z5.metadata = {
70
        "looped": {
71
            "port_numbers": [
72
                mock_interface_z5.port_number,
73
                mock_interface_z6.port_number,
74
            ]
75
        }
76
    }
77
78 1
    mock_switch_a.get_interface_by_port_no = lambda port_no: {
79
        mock_interface_a5.port_number: mock_interface_a5,
80
        mock_interface_a6.port_number: mock_interface_a6,
81
    }[port_no]
82
83 1
    mock_switch_z.get_interface_by_port_no = lambda port_no: {
84
        mock_interface_z5.port_number: mock_interface_z5,
85
        mock_interface_z6.port_number: mock_interface_z6,
86
    }[port_no]
87
88 1
    pp_a = ProxyPort(source=mock_interface_a5)
89 1
    assert pp_a.source == mock_interface_a5
90 1
    assert pp_a.destination == mock_interface_a6
91 1
    pp_z = ProxyPort(source=mock_interface_z5)
92 1
    assert pp_z.source == mock_interface_z5
93 1
    assert pp_z.destination == mock_interface_z6
94
95 1
    get_proxy_port_or_raise.side_effect = [pp_a, pp_z]
96 1
    evcs_data = {evc_id: evcs_data[evc_id]}
97 1
    evcs_data = int_manager._validate_map_enable_evcs(evcs_data)
98 1
    stored_flows = _map_stored_flows_by_cookies(inter_evc_evpl_set_queue_flows_data)
99
100 1
    cookie = get_cookie(evc_id, settings.MEF_COOKIE_PREFIX)
101 1
    flows = FlowBuilder().build_int_flows(evcs_data, stored_flows)[cookie]
102
103 1
    n_expected_source_flows, n_expected_hop_flows, n_expected_sink_flows = 3, 2, 4
104 1
    assert (
105
        len(flows)
106
        == (n_expected_source_flows + n_expected_hop_flows + n_expected_sink_flows) * 2
107
    )
108
109 1
    expected_uni_a_source_flows = [
110
        {
111
            "flow": {
112
                "owner": "telemetry_int",
113
                "cookie": int(0xA816A76AE61B2F46),
114
                "match": {"in_port": 1, "dl_vlan": 101, "dl_type": 2048, "nw_proto": 6},
115
                "table_id": 0,
116
                "table_group": "evpl",
117
                "priority": 20100,
118
                "idle_timeout": 0,
119
                "hard_timeout": 0,
120
                "instructions": [
121
                    {
122
                        "instruction_type": "apply_actions",
123
                        "actions": [{"action_type": "push_int"}],
124
                    },
125
                    {"instruction_type": "goto_table", "table_id": 2},
126
                ],
127
            }
128
        },
129
        {
130
            "flow": {
131
                "owner": "telemetry_int",
132
                "cookie": int(0xA816A76AE61B2F46),
133
                "match": {
134
                    "in_port": 1,
135
                    "dl_vlan": 101,
136
                    "dl_type": 2048,
137
                    "nw_proto": 17,
138
                },
139
                "table_id": 0,
140
                "table_group": "evpl",
141
                "priority": 20100,
142
                "idle_timeout": 0,
143
                "hard_timeout": 0,
144
                "instructions": [
145
                    {
146
                        "instruction_type": "apply_actions",
147
                        "actions": [{"action_type": "push_int"}],
148
                    },
149
                    {"instruction_type": "goto_table", "table_id": 2},
150
                ],
151
            },
152
        },
153
        {
154
            "flow": {
155
                "owner": "telemetry_int",
156
                "cookie": int(0xA816A76AE61B2F46),
157
                "match": {"in_port": 1, "dl_vlan": 101},
158
                "table_id": 2,
159
                "table_group": "evpl",
160
                "priority": 20000,
161
                "idle_timeout": 0,
162
                "hard_timeout": 0,
163
                "instructions": [
164
                    {
165
                        "instruction_type": "apply_actions",
166
                        "actions": [
167
                            {"action_type": "add_int_metadata"},
168
                            {"action_type": "set_vlan", "vlan_id": 102},
169
                            {"action_type": "push_vlan", "tag_type": "s"},
170
                            {"action_type": "set_vlan", "vlan_id": 1},
171
                            {"action_type": "set_queue", "queue_id": 1},
172
                            {"action_type": "output", "port": 3},
173
                        ],
174
                    }
175
                ],
176
            },
177
        },
178
    ]
179
180 1
    expected_uni_z_source_flows = [
181
        {
182
            "flow": {
183
                "owner": "telemetry_int",
184
                "cookie": int(0xA816A76AE61B2F46),
185
                "match": {"in_port": 1, "dl_vlan": 102, "dl_type": 2048, "nw_proto": 6},
186
                "table_id": 0,
187
                "table_group": "evpl",
188
                "priority": 20100,
189
                "idle_timeout": 0,
190
                "hard_timeout": 0,
191
                "instructions": [
192
                    {
193
                        "instruction_type": "apply_actions",
194
                        "actions": [{"action_type": "push_int"}],
195
                    },
196
                    {"instruction_type": "goto_table", "table_id": 2},
197
                ],
198
            },
199
        },
200
        {
201
            "flow": {
202
                "owner": "telemetry_int",
203
                "cookie": int(0xA816A76AE61B2F46),
204
                "match": {
205
                    "in_port": 1,
206
                    "dl_vlan": 102,
207
                    "dl_type": 2048,
208
                    "nw_proto": 17,
209
                },
210
                "table_id": 0,
211
                "table_group": "evpl",
212
                "priority": 20100,
213
                "idle_timeout": 0,
214
                "hard_timeout": 0,
215
                "instructions": [
216
                    {
217
                        "instruction_type": "apply_actions",
218
                        "actions": [{"action_type": "push_int"}],
219
                    },
220
                    {"instruction_type": "goto_table", "table_id": 2},
221
                ],
222
            },
223
        },
224
        {
225
            "flow": {
226
                "owner": "telemetry_int",
227
                "cookie": int(0xA816A76AE61B2F46),
228
                "match": {"in_port": 1, "dl_vlan": 102},
229
                "table_id": 2,
230
                "table_group": "evpl",
231
                "priority": 20000,
232
                "idle_timeout": 0,
233
                "hard_timeout": 0,
234
                "instructions": [
235
                    {
236
                        "instruction_type": "apply_actions",
237
                        "actions": [
238
                            {"action_type": "add_int_metadata"},
239
                            {"action_type": "set_vlan", "vlan_id": 101},
240
                            {"action_type": "push_vlan", "tag_type": "s"},
241
                            {"action_type": "set_vlan", "vlan_id": 1},
242
                            {"action_type": "set_queue", "queue_id": 1},
243
                            {"action_type": "output", "port": 2},
244
                        ],
245
                    }
246
                ],
247
            },
248
        },
249
    ]
250
251 1
    expected_hop_flows = [
252
        {
253
            "flow": {
254
                "owner": "telemetry_int",
255
                "cookie": int(0xA816A76AE61B2F46),
256
                "match": {"in_port": 2, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 6},
257
                "table_id": 0,
258
                "table_group": "evpl",
259
                "priority": 20100,
260
                "idle_timeout": 0,
261
                "hard_timeout": 0,
262
                "instructions": [
263
                    {
264
                        "instruction_type": "apply_actions",
265
                        "actions": [
266
                            {"action_type": "add_int_metadata"},
267
                            {"action_type": "set_vlan", "vlan_id": 1},
268
                            {"action_type": "set_queue", "queue_id": 1},
269
                            {"action_type": "output", "port": 3},
270
                        ],
271
                    }
272
                ],
273
            },
274
        },
275
        {
276
            "flow": {
277
                "owner": "telemetry_int",
278
                "cookie": int(0xA816A76AE61B2F46),
279
                "match": {"in_port": 2, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 17},
280
                "table_id": 0,
281
                "table_group": "evpl",
282
                "priority": 20100,
283
                "idle_timeout": 0,
284
                "hard_timeout": 0,
285
                "instructions": [
286
                    {
287
                        "instruction_type": "apply_actions",
288
                        "actions": [
289
                            {"action_type": "add_int_metadata"},
290
                            {"action_type": "set_vlan", "vlan_id": 1},
291
                            {"action_type": "set_queue", "queue_id": 1},
292
                            {"action_type": "output", "port": 3},
293
                        ],
294
                    }
295
                ],
296
            },
297
        },
298
        {
299
            "flow": {
300
                "owner": "telemetry_int",
301
                "cookie": int(0xA816A76AE61B2F46),
302
                "match": {"in_port": 3, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 6},
303
                "table_id": 0,
304
                "table_group": "evpl",
305
                "priority": 20100,
306
                "idle_timeout": 0,
307
                "hard_timeout": 0,
308
                "instructions": [
309
                    {
310
                        "instruction_type": "apply_actions",
311
                        "actions": [
312
                            {"action_type": "add_int_metadata"},
313
                            {"action_type": "set_vlan", "vlan_id": 1},
314
                            {"action_type": "set_queue", "queue_id": 1},
315
                            {"action_type": "output", "port": 2},
316
                        ],
317
                    }
318
                ],
319
            },
320
        },
321
        {
322
            "flow": {
323
                "owner": "telemetry_int",
324
                "cookie": int(0xA816A76AE61B2F46),
325
                "match": {"in_port": 3, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 17},
326
                "table_id": 0,
327
                "table_group": "evpl",
328
                "priority": 20100,
329
                "idle_timeout": 0,
330
                "hard_timeout": 0,
331
                "instructions": [
332
                    {
333
                        "instruction_type": "apply_actions",
334
                        "actions": [
335
                            {"action_type": "add_int_metadata"},
336
                            {"action_type": "set_vlan", "vlan_id": 1},
337
                            {"action_type": "set_queue", "queue_id": 1},
338
                            {"action_type": "output", "port": 2},
339
                        ],
340
                    }
341
                ],
342
            },
343
        },
344
    ]
345
346 1
    expected_uni_z_sink_flows = [
347
        {
348
            "flow": {
349
                "owner": "telemetry_int",
350
                "cookie": int(0xA816A76AE61B2F46),
351
                "match": {"in_port": 2, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 6},
352
                "table_id": 0,
353
                "table_group": "evpl",
354
                "priority": 20100,
355
                "idle_timeout": 0,
356
                "hard_timeout": 0,
357
                "instructions": [
358
                    {
359
                        "instruction_type": "apply_actions",
360
                        "actions": [
361
                            {"action_type": "add_int_metadata"},
362
                            {"action_type": "set_vlan", "vlan_id": 102},
363
                            {"action_type": "set_queue", "queue_id": 1},
364
                            {"action_type": "output", "port": 5},
365
                        ],
366
                    }
367
                ],
368
            },
369
        },
370
        {
371
            "flow": {
372
                "owner": "telemetry_int",
373
                "cookie": int(0xA816A76AE61B2F46),
374
                "match": {"in_port": 2, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 17},
375
                "table_id": 0,
376
                "table_group": "evpl",
377
                "priority": 20100,
378
                "idle_timeout": 0,
379
                "hard_timeout": 0,
380
                "instructions": [
381
                    {
382
                        "instruction_type": "apply_actions",
383
                        "actions": [
384
                            {"action_type": "add_int_metadata"},
385
                            {"action_type": "set_vlan", "vlan_id": 102},
386
                            {"action_type": "set_queue", "queue_id": 1},
387
                            {"action_type": "output", "port": 5},
388
                        ],
389
                    }
390
                ],
391
            },
392
        },
393
        {
394
            "flow": {
395
                "owner": "telemetry_int",
396
                "cookie": int(0xA816A76AE61B2F46),
397
                "match": {"in_port": 6, "dl_vlan": 102},
398
                "table_id": 0,
399
                "table_group": "evpl",
400
                "priority": 20000,
401
                "idle_timeout": 0,
402
                "hard_timeout": 0,
403
                "instructions": [
404
                    {
405
                        "instruction_type": "apply_actions",
406
                        "actions": [{"action_type": "send_report"}],
407
                    },
408
                    {"instruction_type": "goto_table", "table_id": 2},
409
                ],
410
            },
411
        },
412
        {
413
            "flow": {
414
                "owner": "telemetry_int",
415
                "cookie": int(0xA816A76AE61B2F46),
416
                "match": {"in_port": 6, "dl_vlan": 102},
417
                "table_id": 2,
418
                "table_group": "evpl",
419
                "priority": 20000,
420
                "idle_timeout": 0,
421
                "hard_timeout": 0,
422
                "instructions": [
423
                    {
424
                        "instruction_type": "apply_actions",
425
                        "actions": [
426
                            {"action_type": "pop_int"},
427
                            {"action_type": "set_queue", "queue_id": 1},
428
                            {"action_type": "output", "port": 1},
429
                        ],
430
                    }
431
                ],
432
            }
433
        },
434
    ]
435
436 1
    expected_uni_a_sink_flows = [
437
        {
438
            "flow": {
439
                "owner": "telemetry_int",
440
                "cookie": int(0xA816A76AE61B2F46),
441
                "match": {"in_port": 3, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 6},
442
                "table_id": 0,
443
                "table_group": "evpl",
444
                "priority": 20100,
445
                "idle_timeout": 0,
446
                "hard_timeout": 0,
447
                "instructions": [
448
                    {
449
                        "instruction_type": "apply_actions",
450
                        "actions": [
451
                            {"action_type": "add_int_metadata"},
452
                            {"action_type": "set_vlan", "vlan_id": 101},
453
                            {"action_type": "set_queue", "queue_id": 1},
454
                            {"action_type": "output", "port": 5},
455
                        ],
456
                    }
457
                ],
458
            },
459
        },
460
        {
461
            "flow": {
462
                "owner": "telemetry_int",
463
                "cookie": int(0xA816A76AE61B2F46),
464
                "match": {"in_port": 3, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 17},
465
                "table_id": 0,
466
                "table_group": "evpl",
467
                "priority": 20100,
468
                "idle_timeout": 0,
469
                "hard_timeout": 0,
470
                "instructions": [
471
                    {
472
                        "instruction_type": "apply_actions",
473
                        "actions": [
474
                            {"action_type": "add_int_metadata"},
475
                            {"action_type": "set_vlan", "vlan_id": 101},
476
                            {"action_type": "set_queue", "queue_id": 1},
477
                            {"action_type": "output", "port": 5},
478
                        ],
479
                    }
480
                ],
481
            },
482
        },
483
        {
484
            "flow": {
485
                "owner": "telemetry_int",
486
                "cookie": int(0xA816A76AE61B2F46),
487
                "match": {"in_port": 6, "dl_vlan": 101},
488
                "table_id": 0,
489
                "table_group": "evpl",
490
                "priority": 20000,
491
                "idle_timeout": 0,
492
                "hard_timeout": 0,
493
                "instructions": [
494
                    {
495
                        "instruction_type": "apply_actions",
496
                        "actions": [{"action_type": "send_report"}],
497
                    },
498
                    {"instruction_type": "goto_table", "table_id": 2},
499
                ],
500
            },
501
        },
502
        {
503
            "flow": {
504
                "owner": "telemetry_int",
505
                "cookie": int(0xA816A76AE61B2F46),
506
                "match": {"in_port": 6, "dl_vlan": 101},
507
                "table_id": 2,
508
                "table_group": "evpl",
509
                "priority": 20000,
510
                "idle_timeout": 0,
511
                "hard_timeout": 0,
512
                "instructions": [
513
                    {
514
                        "instruction_type": "apply_actions",
515
                        "actions": [
516
                            {"action_type": "pop_int"},
517
                            {"action_type": "set_queue", "queue_id": 1},
518
                            {"action_type": "output", "port": 1},
519
                        ],
520
                    }
521
                ],
522
            },
523
        },
524
    ]
525
526 1
    expected_flows = (
527
        expected_uni_a_source_flows
528
        + expected_uni_z_source_flows
529
        + expected_hop_flows
530
        + expected_uni_z_sink_flows
531
        + expected_uni_a_sink_flows
532
    )
533
534 1
    for i, flow in enumerate(flows):
535 1
        assert (i, flow["flow"]) == (i, expected_flows[i]["flow"])
536
537
538 1
def test_build_int_flows_inter_evpl_flows_count_evc_metadata_proxy_port_enabled(
539
    evcs_data, inter_evc_evpl_set_queue_flows_data
540
) -> None:
541
    """Test build INT flows inter EVPL with proxy_port_enabled EVC metadata.
542
543
               +----+                                              +----+
544
              5|    |6                                            5|    |6
545
           +---+----v---+            +------------+           +----+----v---+
546
        1  |            |            |            |           |             |1
547
    -------+            |3         2 |            |3        2 |             +-------
548
     vlan  |     s1     +------------+    s2      +-----------+    s3       | vlan
549
     101   |            |            |            |           |             | 102
550
           |            |            |            |           |             |
551
           +------------+            +------------+           +-------------+
552
553
    """
554 1
    controller = get_controller_mock()
555 1
    int_manager = INTManager(controller)
556 1
    get_proxy_port_or_raise = MagicMock()
557 1
    int_manager.get_proxy_port_or_raise = get_proxy_port_or_raise
558
559 1
    evc_id = "16a76ae61b2f46"
560 1
    dpid_a = "00:00:00:00:00:00:00:01"
561 1
    mock_switch_a = get_switch_mock(dpid_a, 0x04)
562 1
    mock_interface_a1 = get_interface_mock("s1-eth1", 1, mock_switch_a)
563 1
    mock_interface_a1.id = f"{dpid_a}:{mock_interface_a1.port_number}"
564 1
    mock_interface_a5 = get_interface_mock("s1-eth5", 5, mock_switch_a)
565 1
    mock_interface_a1.metadata = {"proxy_port": mock_interface_a5.port_number}
566 1
    mock_interface_a5.status = EntityStatus.UP
567 1
    mock_interface_a6 = get_interface_mock("s1-eth6", 6, mock_switch_a)
568 1
    mock_interface_a6.status = EntityStatus.UP
569 1
    mock_interface_a5.metadata = {
570
        "looped": {
571
            "port_numbers": [
572
                mock_interface_a5.port_number,
573
                mock_interface_a6.port_number,
574
            ]
575
        }
576
    }
577
578 1
    dpid_z = "00:00:00:00:00:00:00:03"
579 1
    mock_switch_z = get_switch_mock(dpid_z, 0x04)
580 1
    mock_interface_z1 = get_interface_mock("s1-eth1", 1, mock_switch_z)
581 1
    mock_interface_z1.status = EntityStatus.UP
582 1
    mock_interface_z1.id = f"{dpid_z}:{mock_interface_z1.port_number}"
583 1
    mock_interface_z5 = get_interface_mock("s1-eth5", 5, mock_switch_z)
584 1
    mock_interface_z1.metadata = {"proxy_port": mock_interface_z5.port_number}
585 1
    mock_interface_z5.status = EntityStatus.UP
586 1
    mock_interface_z6 = get_interface_mock("s1-eth6", 6, mock_switch_z)
587 1
    mock_interface_z6.status = EntityStatus.UP
588 1
    mock_interface_z5.metadata = {
589
        "looped": {
590
            "port_numbers": [
591
                mock_interface_z5.port_number,
592
                mock_interface_z6.port_number,
593
            ]
594
        }
595
    }
596
597 1
    mock_switch_a.get_interface_by_port_no = lambda port_no: {
598
        mock_interface_a5.port_number: mock_interface_a5,
599
        mock_interface_a6.port_number: mock_interface_a6,
600
    }[port_no]
601
602 1
    mock_switch_z.get_interface_by_port_no = lambda port_no: {
603
        mock_interface_z5.port_number: mock_interface_z5,
604
        mock_interface_z6.port_number: mock_interface_z6,
605
    }[port_no]
606
607 1
    pp_a = ProxyPort(source=mock_interface_a5)
608 1
    assert pp_a.source == mock_interface_a5
609 1
    assert pp_a.destination == mock_interface_a6
610 1
    pp_z = ProxyPort(source=mock_interface_z5)
611 1
    assert pp_z.source == mock_interface_z5
612 1
    assert pp_z.destination == mock_interface_z6
613
614 1
    get_proxy_port_or_raise.side_effect = [pp_a, pp_z]
615
616
    # This will overwrite not to use proxy_port from the interface metadata
617 1
    evcs_data[evc_id]["metadata"]["proxy_port_enabled"] = False
618
619 1
    evcs_data = {evc_id: evcs_data[evc_id]}
620 1
    evcs_data = int_manager._validate_map_enable_evcs(evcs_data)
621 1
    stored_flows = _map_stored_flows_by_cookies(inter_evc_evpl_set_queue_flows_data)
622
623 1
    cookie = get_cookie(evc_id, settings.MEF_COOKIE_PREFIX)
624 1
    flows = FlowBuilder().build_int_flows(evcs_data, stored_flows)[cookie]
625
626
    # This test case is only asserting expected flows numbers to avoid repetition,
627
    # similar test cases already assert the expected flow contents
628
629 1
    n_expected_source_flows, n_expected_hop_flows, n_expected_sink_flows = 3, 2, 3
630 1
    assert (
631
        len(flows)
632
        == (n_expected_source_flows + n_expected_hop_flows + n_expected_sink_flows) * 2
633
    )
634
635
    # This will no longer overwrite, so the proxy_port flows will be built
636 1
    evcs_data[evc_id]["metadata"].pop("proxy_port_enabled")
637 1
    get_proxy_port_or_raise.side_effect = [pp_a, pp_z]
638
639 1
    evcs_data = int_manager._validate_map_enable_evcs(evcs_data)
640 1
    stored_flows = _map_stored_flows_by_cookies(inter_evc_evpl_set_queue_flows_data)
641 1
    flows = FlowBuilder().build_int_flows(evcs_data, stored_flows)[cookie]
642
643 1
    n_expected_source_flows, n_expected_hop_flows, n_expected_sink_flows = 3, 2, 4
644 1
    assert (
645
        len(flows)
646
        == (n_expected_source_flows + n_expected_hop_flows + n_expected_sink_flows) * 2
647
    )
648
649
    # This will no longer overwrite too, so the proxy_port flows will be built
650 1
    evcs_data[evc_id]["metadata"]["proxy_port_enabled"] = True
651 1
    get_proxy_port_or_raise.side_effect = [pp_a, pp_z]
652
653 1
    evcs_data = int_manager._validate_map_enable_evcs(evcs_data)
654 1
    stored_flows = _map_stored_flows_by_cookies(inter_evc_evpl_set_queue_flows_data)
655 1
    flows = FlowBuilder().build_int_flows(evcs_data, stored_flows)[cookie]
656
657 1
    n_expected_source_flows, n_expected_hop_flows, n_expected_sink_flows = 3, 2, 4
658 1
    assert (
659
        len(flows)
660
        == (n_expected_source_flows + n_expected_hop_flows + n_expected_sink_flows) * 2
661
    )
662
663
664 1
def test_build_int_flows_inter_evpl_no_proxy_ports(
665
    evcs_data, inter_evc_evpl_flows_data
666
) -> None:
667
    """Test build INT flows inter EVPL.
668
669
           +---+----v---+            +------------+           +----+----v---+
670
        1  |            |            |            |           |             |1
671
    -------+            |3         2 |            |3        2 |             +-------
672
     vlan  |     s1     +------------+    s2      +-----------+    s3       | vlan
673
     101   |            |            |            |           |             | 102
674
           |            |            |            |           |             |
675
           +------------+            +------------+           +-------------+
676
677
    """
678 1
    controller = get_controller_mock()
679 1
    int_manager = INTManager(controller)
680 1
    get_proxy_port_or_raise = MagicMock()
681 1
    exc = ProxyPortMetadataNotFound("evc_id", "not found")
682 1
    get_proxy_port_or_raise.side_effect = exc
683 1
    int_manager.get_proxy_port_or_raise = get_proxy_port_or_raise
684
685 1
    evc_id = "16a76ae61b2f46"
686 1
    dpid_a = "00:00:00:00:00:00:00:01"
687 1
    mock_switch_a = get_switch_mock(dpid_a, 0x04)
688 1
    mock_interface_a1 = get_interface_mock("s1-eth1", 1, mock_switch_a)
689 1
    mock_interface_a1.status = EntityStatus.UP
690 1
    mock_interface_a1.id = f"{dpid_a}:{mock_interface_a1.port_number}"
691
692 1
    dpid_z = "00:00:00:00:00:00:00:03"
693 1
    mock_switch_z = get_switch_mock(dpid_z, 0x04)
694 1
    mock_interface_z1 = get_interface_mock("s1-eth1", 1, mock_switch_z)
695 1
    mock_interface_z1.status = EntityStatus.UP
696 1
    mock_interface_z1.id = f"{dpid_z}:{mock_interface_z1.port_number}"
697
698 1
    evcs_data = {evc_id: evcs_data[evc_id]}
699 1
    evcs_data = int_manager._validate_map_enable_evcs(evcs_data)
700 1
    stored_flows = _map_stored_flows_by_cookies(inter_evc_evpl_flows_data)
701
702 1
    cookie = get_cookie(evc_id, settings.MEF_COOKIE_PREFIX)
703 1
    flows = FlowBuilder().build_int_flows(evcs_data, stored_flows)[cookie]
704
705 1
    n_expected_source_flows, n_expected_hop_flows, n_expected_sink_flows = 3, 2, 3
706 1
    assert (
707
        len(flows)
708
        == (n_expected_source_flows + n_expected_hop_flows + n_expected_sink_flows) * 2
709
    )
710
711 1
    expected_uni_a_source_flows = [
712
        {
713
            "flow": {
714
                "owner": "telemetry_int",
715
                "cookie": int(0xA816A76AE61B2F46),
716
                "match": {"in_port": 1, "dl_vlan": 101, "dl_type": 2048, "nw_proto": 6},
717
                "table_id": 0,
718
                "table_group": "evpl",
719
                "priority": 20100,
720
                "idle_timeout": 0,
721
                "hard_timeout": 0,
722
                "instructions": [
723
                    {
724
                        "instruction_type": "apply_actions",
725
                        "actions": [{"action_type": "push_int"}],
726
                    },
727
                    {"instruction_type": "goto_table", "table_id": 2},
728
                ],
729
            }
730
        },
731
        {
732
            "flow": {
733
                "owner": "telemetry_int",
734
                "cookie": int(0xA816A76AE61B2F46),
735
                "match": {
736
                    "in_port": 1,
737
                    "dl_vlan": 101,
738
                    "dl_type": 2048,
739
                    "nw_proto": 17,
740
                },
741
                "table_id": 0,
742
                "table_group": "evpl",
743
                "priority": 20100,
744
                "idle_timeout": 0,
745
                "hard_timeout": 0,
746
                "instructions": [
747
                    {
748
                        "instruction_type": "apply_actions",
749
                        "actions": [{"action_type": "push_int"}],
750
                    },
751
                    {"instruction_type": "goto_table", "table_id": 2},
752
                ],
753
            },
754
        },
755
        {
756
            "flow": {
757
                "owner": "telemetry_int",
758
                "cookie": int(0xA816A76AE61B2F46),
759
                "match": {"in_port": 1, "dl_vlan": 101},
760
                "table_id": 2,
761
                "table_group": "evpl",
762
                "priority": 20000,
763
                "idle_timeout": 0,
764
                "hard_timeout": 0,
765
                "instructions": [
766
                    {
767
                        "instruction_type": "apply_actions",
768
                        "actions": [
769
                            {"action_type": "add_int_metadata"},
770
                            {"action_type": "set_vlan", "vlan_id": 102},
771
                            {"action_type": "push_vlan", "tag_type": "s"},
772
                            {"action_type": "set_vlan", "vlan_id": 1},
773
                            {"action_type": "output", "port": 3},
774
                        ],
775
                    }
776
                ],
777
            },
778
        },
779
    ]
780
781 1
    expected_uni_z_source_flows = [
782
        {
783
            "flow": {
784
                "owner": "telemetry_int",
785
                "cookie": int(0xA816A76AE61B2F46),
786
                "match": {"in_port": 1, "dl_vlan": 102, "dl_type": 2048, "nw_proto": 6},
787
                "table_id": 0,
788
                "table_group": "evpl",
789
                "priority": 20100,
790
                "idle_timeout": 0,
791
                "hard_timeout": 0,
792
                "instructions": [
793
                    {
794
                        "instruction_type": "apply_actions",
795
                        "actions": [{"action_type": "push_int"}],
796
                    },
797
                    {"instruction_type": "goto_table", "table_id": 2},
798
                ],
799
            },
800
        },
801
        {
802
            "flow": {
803
                "owner": "telemetry_int",
804
                "cookie": int(0xA816A76AE61B2F46),
805
                "match": {
806
                    "in_port": 1,
807
                    "dl_vlan": 102,
808
                    "dl_type": 2048,
809
                    "nw_proto": 17,
810
                },
811
                "table_id": 0,
812
                "table_group": "evpl",
813
                "priority": 20100,
814
                "idle_timeout": 0,
815
                "hard_timeout": 0,
816
                "instructions": [
817
                    {
818
                        "instruction_type": "apply_actions",
819
                        "actions": [{"action_type": "push_int"}],
820
                    },
821
                    {"instruction_type": "goto_table", "table_id": 2},
822
                ],
823
            },
824
        },
825
        {
826
            "flow": {
827
                "owner": "telemetry_int",
828
                "cookie": int(0xA816A76AE61B2F46),
829
                "match": {"in_port": 1, "dl_vlan": 102},
830
                "table_id": 2,
831
                "table_group": "evpl",
832
                "priority": 20000,
833
                "idle_timeout": 0,
834
                "hard_timeout": 0,
835
                "instructions": [
836
                    {
837
                        "instruction_type": "apply_actions",
838
                        "actions": [
839
                            {"action_type": "add_int_metadata"},
840
                            {"action_type": "set_vlan", "vlan_id": 101},
841
                            {"action_type": "push_vlan", "tag_type": "s"},
842
                            {"action_type": "set_vlan", "vlan_id": 1},
843
                            {"action_type": "output", "port": 2},
844
                        ],
845
                    }
846
                ],
847
            },
848
        },
849
    ]
850
851 1
    expected_hop_flows = [
852
        {
853
            "flow": {
854
                "owner": "telemetry_int",
855
                "cookie": int(0xA816A76AE61B2F46),
856
                "match": {"in_port": 2, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 6},
857
                "table_id": 0,
858
                "table_group": "evpl",
859
                "priority": 20100,
860
                "idle_timeout": 0,
861
                "hard_timeout": 0,
862
                "instructions": [
863
                    {
864
                        "instruction_type": "apply_actions",
865
                        "actions": [
866
                            {"action_type": "add_int_metadata"},
867
                            {"action_type": "set_vlan", "vlan_id": 1},
868
                            {"action_type": "output", "port": 3},
869
                        ],
870
                    }
871
                ],
872
            },
873
        },
874
        {
875
            "flow": {
876
                "owner": "telemetry_int",
877
                "cookie": int(0xA816A76AE61B2F46),
878
                "match": {"in_port": 2, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 17},
879
                "table_id": 0,
880
                "table_group": "evpl",
881
                "priority": 20100,
882
                "idle_timeout": 0,
883
                "hard_timeout": 0,
884
                "instructions": [
885
                    {
886
                        "instruction_type": "apply_actions",
887
                        "actions": [
888
                            {"action_type": "add_int_metadata"},
889
                            {"action_type": "set_vlan", "vlan_id": 1},
890
                            {"action_type": "output", "port": 3},
891
                        ],
892
                    }
893
                ],
894
            },
895
        },
896
        {
897
            "flow": {
898
                "owner": "telemetry_int",
899
                "cookie": int(0xA816A76AE61B2F46),
900
                "match": {"in_port": 3, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 6},
901
                "table_id": 0,
902
                "table_group": "evpl",
903
                "priority": 20100,
904
                "idle_timeout": 0,
905
                "hard_timeout": 0,
906
                "instructions": [
907
                    {
908
                        "instruction_type": "apply_actions",
909
                        "actions": [
910
                            {"action_type": "add_int_metadata"},
911
                            {"action_type": "set_vlan", "vlan_id": 1},
912
                            {"action_type": "output", "port": 2},
913
                        ],
914
                    }
915
                ],
916
            },
917
        },
918
        {
919
            "flow": {
920
                "owner": "telemetry_int",
921
                "cookie": int(0xA816A76AE61B2F46),
922
                "match": {"in_port": 3, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 17},
923
                "table_id": 0,
924
                "table_group": "evpl",
925
                "priority": 20100,
926
                "idle_timeout": 0,
927
                "hard_timeout": 0,
928
                "instructions": [
929
                    {
930
                        "instruction_type": "apply_actions",
931
                        "actions": [
932
                            {"action_type": "add_int_metadata"},
933
                            {"action_type": "set_vlan", "vlan_id": 1},
934
                            {"action_type": "output", "port": 2},
935
                        ],
936
                    }
937
                ],
938
            },
939
        },
940
    ]
941
942 1
    expected_uni_z_sink_flows = [
943
        {
944
            "flow": {
945
                "owner": "telemetry_int",
946
                "cookie": int(0xA816A76AE61B2F46),
947
                "match": {"in_port": 2, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 6},
948
                "table_id": 0,
949
                "table_group": "evpl",
950
                "priority": 20100,
951
                "idle_timeout": 0,
952
                "hard_timeout": 0,
953
                "instructions": [
954
                    {
955
                        "instruction_type": "apply_actions",
956
                        "actions": [{"action_type": "send_report"}],
957
                    },
958
                    {"instruction_type": "goto_table", "table_id": 2},
959
                ],
960
            },
961
        },
962
        {
963
            "flow": {
964
                "owner": "telemetry_int",
965
                "cookie": int(0xA816A76AE61B2F46),
966
                "match": {"in_port": 2, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 17},
967
                "table_id": 0,
968
                "table_group": "evpl",
969
                "priority": 20100,
970
                "idle_timeout": 0,
971
                "hard_timeout": 0,
972
                "instructions": [
973
                    {
974
                        "instruction_type": "apply_actions",
975
                        "actions": [{"action_type": "send_report"}],
976
                    },
977
                    {"instruction_type": "goto_table", "table_id": 2},
978
                ],
979
            },
980
        },
981
        {
982
            "flow": {
983
                "owner": "telemetry_int",
984
                "cookie": int(0xA816A76AE61B2F46),
985
                "match": {"in_port": 2, "dl_vlan": 1},
986
                "table_id": 2,
987
                "table_group": "evpl",
988
                "priority": 20000,
989
                "idle_timeout": 0,
990
                "hard_timeout": 0,
991
                "instructions": [
992
                    {
993
                        "instruction_type": "apply_actions",
994
                        "actions": [
995
                            {"action_type": "pop_int"},
996
                            {"action_type": "pop_vlan"},
997
                            {"action_type": "output", "port": 1},
998
                        ],
999
                    }
1000
                ],
1001
            }
1002
        },
1003
    ]
1004
1005 1
    expected_uni_a_sink_flows = [
1006
        {
1007
            "flow": {
1008
                "owner": "telemetry_int",
1009
                "cookie": int(0xA816A76AE61B2F46),
1010
                "match": {"in_port": 3, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 6},
1011
                "table_id": 0,
1012
                "table_group": "evpl",
1013
                "priority": 20100,
1014
                "idle_timeout": 0,
1015
                "hard_timeout": 0,
1016
                "instructions": [
1017
                    {
1018
                        "instruction_type": "apply_actions",
1019
                        "actions": [{"action_type": "send_report"}],
1020
                    },
1021
                    {"instruction_type": "goto_table", "table_id": 2},
1022
                ],
1023
            },
1024
        },
1025
        {
1026
            "flow": {
1027
                "owner": "telemetry_int",
1028
                "cookie": int(0xA816A76AE61B2F46),
1029
                "match": {"in_port": 3, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 17},
1030
                "table_id": 0,
1031
                "table_group": "evpl",
1032
                "priority": 20100,
1033
                "idle_timeout": 0,
1034
                "hard_timeout": 0,
1035
                "instructions": [
1036
                    {
1037
                        "instruction_type": "apply_actions",
1038
                        "actions": [{"action_type": "send_report"}],
1039
                    },
1040
                    {"instruction_type": "goto_table", "table_id": 2},
1041
                ],
1042
            },
1043
        },
1044
        {
1045
            "flow": {
1046
                "owner": "telemetry_int",
1047
                "cookie": int(0xA816A76AE61B2F46),
1048
                "match": {"in_port": 3, "dl_vlan": 1},
1049
                "table_id": 2,
1050
                "table_group": "evpl",
1051
                "priority": 20000,
1052
                "idle_timeout": 0,
1053
                "hard_timeout": 0,
1054
                "instructions": [
1055
                    {
1056
                        "instruction_type": "apply_actions",
1057
                        "actions": [
1058
                            {"action_type": "pop_int"},
1059
                            {"action_type": "pop_vlan"},
1060
                            {"action_type": "output", "port": 1},
1061
                        ],
1062
                    }
1063
                ],
1064
            },
1065
        },
1066
    ]
1067
1068 1
    expected_flows = (
1069
        expected_uni_a_source_flows
1070
        + expected_uni_z_source_flows
1071
        + expected_hop_flows
1072
        + expected_uni_z_sink_flows
1073
        + expected_uni_a_sink_flows
1074
    )
1075
1076 1
    for i, flow in enumerate(flows):
1077 1
        assert (i, flow["flow"]) == (i, expected_flows[i]["flow"])
1078
1079
1080 1
@pytest.mark.parametrize(
1081
    "evc,uni_key,expected_method",
1082
    [
1083
        ({"uni_a": {"proxy_port": 1}, "metadata": {}}, "uni_a", "proxy_flows"),
1084
        ({"uni_a": {}, "metadata": {}}, "uni_a", "no_proxy_flows"),
1085
        (
1086
            {"uni_a": {"proxy_port": 1}, "metadata": {"proxy_port_enabled": False}},
1087
            "uni_a",
1088
            "no_proxy_flows",
1089
        ),
1090
        (
1091
            {"uni_a": {"proxy_port": 1}, "metadata": {"proxy_port_enabled": True}},
1092
            "uni_a",
1093
            "proxy_flows",
1094
        ),
1095
        (
1096
            {"uni_a": {}, "metadata": {"proxy_port_enabled": True}},
1097
            "uni_a",
1098
            "proxy_flows",
1099
        ),
1100
        (
1101
            {"uni_a": {}, "metadata": {}},
1102
            "uni_a",
1103
            "no_proxy_flows",
1104
        ),
1105
    ],
1106
)
1107 1
def test_bulkd_inter_sink_flows_cases(evc, uni_key, expected_method) -> None:
1108
    """Test build_int_sink_flows for inter EVCs.
1109
1110
    By default inter EVC build not flows without proxy, and proxy metadata
1111
    at the EVC level has higher precedence than derived proxy_port interface metadata
1112
    """
1113 1
    controller = get_controller_mock()
1114 1
    int_manager = INTManager(controller)
1115 1
    no_proxy_port_method, proxy_port_method = MagicMock(), MagicMock()
1116 1
    int_manager.flow_builder._build_int_sink_flows_no_proxy_port = no_proxy_port_method
1117 1
    int_manager.flow_builder._build_int_sink_flows_proxy_port = proxy_port_method
1118 1
    int_manager.flow_builder._build_int_sink_flows(uni_key, evc, {})
1119 1
    if expected_method == "proxy_flows":
1120 1
        assert proxy_port_method.call_count == 1
1121 1
        assert not no_proxy_port_method.call_count
1122
    else:
1123 1
        assert no_proxy_port_method.call_count == 1
1124 1
        assert not proxy_port_method.call_count
1125
1126
1127 1
def test_build_int_flows_inter_evpl_range(inter_evc_evpl_range_flows_data) -> None:
1128
    """Test build INT flows inter EVPL range.
1129
1130
               +----+                                              +----+
1131
              5|    |6                                            5|    |6
1132
           +---+----v---+            +------------+           +----+----v---+
1133
        1  |            |            |            |           |             |1
1134
    -------+            |3         2 |            |3        2 |             +-------
1135
     vlan  |     s1     +------------+    s2      +-----------+    s3       | vlan
1136
     910   |            |            |            |           |             | 910
1137
     920   |            |            |            |           |             | 920
1138
           +------------+            +------------+           +-------------+
1139
1140
    """
1141 1
    controller = get_controller_mock()
1142 1
    int_manager = INTManager(controller)
1143 1
    get_proxy_port_or_raise = MagicMock()
1144 1
    int_manager.get_proxy_port_or_raise = get_proxy_port_or_raise
1145
1146 1
    evc_id = "81657703389347"
1147 1
    dpid_a = "00:00:00:00:00:00:00:01"
1148 1
    mock_switch_a = get_switch_mock(dpid_a, 0x04)
1149 1
    mock_interface_a1 = get_interface_mock("s1-eth1", 1, mock_switch_a)
1150 1
    mock_interface_a1.id = f"{dpid_a}:{mock_interface_a1.port_number}"
1151 1
    mock_interface_a5 = get_interface_mock("s1-eth5", 5, mock_switch_a)
1152 1
    mock_interface_a1.metadata = {"proxy_port": mock_interface_a5.port_number}
1153 1
    mock_interface_a5.status = EntityStatus.UP
1154 1
    mock_interface_a6 = get_interface_mock("s1-eth6", 6, mock_switch_a)
1155 1
    mock_interface_a6.status = EntityStatus.UP
1156 1
    mock_interface_a5.metadata = {
1157
        "looped": {
1158
            "port_numbers": [
1159
                mock_interface_a5.port_number,
1160
                mock_interface_a6.port_number,
1161
            ]
1162
        }
1163
    }
1164
1165 1
    dpid_z = "00:00:00:00:00:00:00:03"
1166 1
    mock_switch_z = get_switch_mock(dpid_z, 0x04)
1167 1
    mock_interface_z1 = get_interface_mock("s1-eth1", 1, mock_switch_z)
1168 1
    mock_interface_z1.status = EntityStatus.UP
1169 1
    mock_interface_z1.id = f"{dpid_z}:{mock_interface_z1.port_number}"
1170 1
    mock_interface_z5 = get_interface_mock("s1-eth5", 5, mock_switch_z)
1171 1
    mock_interface_z1.metadata = {"proxy_port": mock_interface_z5.port_number}
1172 1
    mock_interface_z5.status = EntityStatus.UP
1173 1
    mock_interface_z6 = get_interface_mock("s1-eth6", 6, mock_switch_z)
1174 1
    mock_interface_z6.status = EntityStatus.UP
1175 1
    mock_interface_z5.metadata = {
1176
        "looped": {
1177
            "port_numbers": [
1178
                mock_interface_z5.port_number,
1179
                mock_interface_z6.port_number,
1180
            ]
1181
        }
1182
    }
1183
1184 1
    mock_switch_a.get_interface_by_port_no = lambda port_no: {
1185
        mock_interface_a5.port_number: mock_interface_a5,
1186
        mock_interface_a6.port_number: mock_interface_a6,
1187
    }[port_no]
1188
1189 1
    mock_switch_z.get_interface_by_port_no = lambda port_no: {
1190
        mock_interface_z5.port_number: mock_interface_z5,
1191
        mock_interface_z6.port_number: mock_interface_z6,
1192
    }[port_no]
1193
1194 1
    pp_a = ProxyPort(source=mock_interface_a5)
1195 1
    assert pp_a.source == mock_interface_a5
1196 1
    assert pp_a.destination == mock_interface_a6
1197 1
    pp_z = ProxyPort(source=mock_interface_z5)
1198 1
    assert pp_z.source == mock_interface_z5
1199 1
    assert pp_z.destination == mock_interface_z6
1200
1201 1
    evc_data = {
1202
        "active": True,
1203
        "archived": False,
1204
        "backup_path": [],
1205
        "bandwidth": 0,
1206
        "circuit_scheduler": [],
1207
        "current_path": [
1208
            {
1209
                "id": "78282c4",
1210
                "endpoint_a": {
1211
                    "id": "00:00:00:00:00:00:00:01:3",
1212
                    "name": "s1-eth3",
1213
                    "port_number": 3,
1214
                    "mac": "f6:64:bd:5f:c2:84",
1215
                    "switch": "00:00:00:00:00:00:00:01",
1216
                    "type": "interface",
1217
                    "nni": True,
1218
                    "uni": False,
1219
                    "speed": 1250000000.0,
1220
                    "metadata": {},
1221
                    "lldp": True,
1222
                    "active": True,
1223
                    "enabled": True,
1224
                    "status": "UP",
1225
                    "status_reason": [],
1226
                    "link": "78282c4",
1227
                },
1228
                "endpoint_b": {
1229
                    "id": "00:00:00:00:00:00:00:02:2",
1230
                    "name": "s2-eth2",
1231
                    "port_number": 2,
1232
                    "mac": "b6:5a:82:c0:0d:c3",
1233
                    "switch": "00:00:00:00:00:00:00:02",
1234
                    "type": "interface",
1235
                    "nni": True,
1236
                    "uni": False,
1237
                    "speed": 1250000000.0,
1238
                    "metadata": {},
1239
                    "lldp": True,
1240
                    "active": True,
1241
                    "enabled": True,
1242
                    "status": "UP",
1243
                    "status_reason": [],
1244
                    "link": "78282c4",
1245
                },
1246
                "metadata": {"s_vlan": {"tag_type": "vlan", "value": 1}},
1247
                "active": True,
1248
                "enabled": True,
1249
                "status": "UP",
1250
                "status_reason": [],
1251
            },
1252
            {
1253
                "id": "4d42dc0",
1254
                "endpoint_a": {
1255
                    "id": "00:00:00:00:00:00:00:02:3",
1256
                    "name": "s2-eth3",
1257
                    "port_number": 3,
1258
                    "mac": "7e:44:4a:8b:d4:06",
1259
                    "switch": "00:00:00:00:00:00:00:02",
1260
                    "type": "interface",
1261
                    "nni": True,
1262
                    "uni": False,
1263
                    "speed": 1250000000.0,
1264
                    "metadata": {},
1265
                    "lldp": True,
1266
                    "active": True,
1267
                    "enabled": True,
1268
                    "status": "UP",
1269
                    "status_reason": [],
1270
                    "link": "4d42dc0",
1271
                },
1272
                "endpoint_b": {
1273
                    "id": "00:00:00:00:00:00:00:03:2",
1274
                    "name": "s3-eth2",
1275
                    "port_number": 2,
1276
                    "mac": "ba:02:51:63:a5:4d",
1277
                    "switch": "00:00:00:00:00:00:00:03",
1278
                    "type": "interface",
1279
                    "nni": True,
1280
                    "uni": False,
1281
                    "speed": 1250000000.0,
1282
                    "metadata": {},
1283
                    "lldp": True,
1284
                    "active": True,
1285
                    "enabled": True,
1286
                    "status": "UP",
1287
                    "status_reason": [],
1288
                    "link": "4d42dc0",
1289
                },
1290
                "metadata": {"s_vlan": {"tag_type": "vlan", "value": 1}},
1291
                "active": True,
1292
                "enabled": True,
1293
                "status": "UP",
1294
                "status_reason": [],
1295
            },
1296
        ],
1297
        "dynamic_backup_path": True,
1298
        "enabled": True,
1299
        "failover_path": [],
1300
        "id": "81657703389347",
1301
        "max_paths": 2,
1302
        "metadata": {},
1303
        "name": "inter_evpl_range",
1304
        "primary_path": [],
1305
        "service_level": 6,
1306
        "uni_a": {
1307
            "tag": {
1308
                "tag_type": "vlan",
1309
                "value": [[910, 920]],
1310
                "mask_list": ["910/4094", "912/4088", 920],
1311
            },
1312
            "interface_id": "00:00:00:00:00:00:00:01:1",
1313
        },
1314
        "uni_z": {
1315
            "tag": {
1316
                "tag_type": "vlan",
1317
                "value": [[910, 920]],
1318
                "mask_list": ["910/4094", "912/4088", 920],
1319
            },
1320
            "interface_id": "00:00:00:00:00:00:00:03:1",
1321
        },
1322
        "sb_priority": None,
1323
        "execution_rounds": 0,
1324
        "owner": None,
1325
        "queue_id": -1,
1326
        "primary_constraints": {},
1327
        "secondary_constraints": {},
1328
        "primary_links": [],
1329
        "backup_links": [],
1330
        "start_date": "2025-11-23T23:12:31",
1331
        "creation_time": "2025-11-23T23:12:31",
1332
        "request_time": "2025-11-23T23:12:31",
1333
        "end_date": None,
1334
        "flow_removed_at": None,
1335
        "updated_at": "2025-11-23T23:16:49",
1336
    }
1337
1338 1
    get_proxy_port_or_raise.side_effect = [pp_a, pp_z]
1339 1
    evcs_data = {evc_id: evc_data}
1340 1
    evcs_data = int_manager._validate_map_enable_evcs(evcs_data)
1341 1
    stored_flows = _map_stored_flows_by_cookies(inter_evc_evpl_range_flows_data)
1342
1343 1
    cookie = get_cookie(evc_id, settings.MEF_COOKIE_PREFIX)
1344 1
    flows = FlowBuilder().build_int_flows(evcs_data, stored_flows)[cookie]
1345 1
    assert len(flows) == 38
1346 1
    expected_flows = [
1347
        {
1348
            "flow": {
1349
                "table_id": 0,
1350
                "owner": "telemetry_int",
1351
                "table_group": "evpl",
1352
                "priority": 20100,
1353
                "cookie": 12142097632197120839,
1354
                "idle_timeout": 0,
1355
                "hard_timeout": 0,
1356
                "match": {
1357
                    "in_port": 1,
1358
                    "dl_vlan": "910/4094",
1359
                    "dl_type": 2048,
1360
                    "nw_proto": 6,
1361
                },
1362
                "instructions": [
1363
                    {
1364
                        "instruction_type": "apply_actions",
1365
                        "actions": [{"action_type": "push_int"}],
1366
                    },
1367
                    {"instruction_type": "goto_table", "table_id": 3},
1368
                ],
1369
            },
1370
            "flow_id": "79a9fcff6ed57319028344a9f16f0750",
1371
            "id": "a4eadd6870e0a67df0d13950d4399408",
1372
            "inserted_at": "2025-11-23T23:12:32.025000",
1373
            "state": "installed",
1374
            "switch": "00:00:00:00:00:00:00:01",
1375
            "updated_at": "2025-11-23T23:12:32.057000",
1376
        },
1377
        {
1378
            "flow": {
1379
                "table_id": 0,
1380
                "owner": "telemetry_int",
1381
                "table_group": "evpl",
1382
                "priority": 20100,
1383
                "cookie": 12142097632197120839,
1384
                "idle_timeout": 0,
1385
                "hard_timeout": 0,
1386
                "match": {
1387
                    "in_port": 1,
1388
                    "dl_vlan": "910/4094",
1389
                    "dl_type": 2048,
1390
                    "nw_proto": 17,
1391
                },
1392
                "instructions": [
1393
                    {
1394
                        "instruction_type": "apply_actions",
1395
                        "actions": [{"action_type": "push_int"}],
1396
                    },
1397
                    {"instruction_type": "goto_table", "table_id": 3},
1398
                ],
1399
            },
1400
            "flow_id": "79a9fcff6ed57319028344a9f16f0750",
1401
            "id": "a4eadd6870e0a67df0d13950d4399408",
1402
            "inserted_at": "2025-11-23T23:12:32.025000",
1403
            "state": "installed",
1404
            "switch": "00:00:00:00:00:00:00:01",
1405
            "updated_at": "2025-11-23T23:12:32.057000",
1406
        },
1407
        {
1408
            "flow": {
1409
                "table_id": 3,
1410
                "owner": "telemetry_int",
1411
                "table_group": "evpl",
1412
                "priority": 20000,
1413
                "cookie": 12142097632197120839,
1414
                "idle_timeout": 0,
1415
                "hard_timeout": 0,
1416
                "match": {"in_port": 1, "dl_vlan": "910/4094"},
1417
                "instructions": [
1418
                    {
1419
                        "instruction_type": "apply_actions",
1420
                        "actions": [
1421
                            {"action_type": "add_int_metadata"},
1422
                            {"action_type": "push_vlan", "tag_type": "s"},
1423
                            {"action_type": "set_vlan", "vlan_id": 1},
1424
                            {"action_type": "output", "port": 3},
1425
                        ],
1426
                    }
1427
                ],
1428
            },
1429
            "flow_id": "79a9fcff6ed57319028344a9f16f0750",
1430
            "id": "a4eadd6870e0a67df0d13950d4399408",
1431
            "inserted_at": "2025-11-23T23:12:32.025000",
1432
            "state": "installed",
1433
            "switch": "00:00:00:00:00:00:00:01",
1434
            "updated_at": "2025-11-23T23:12:32.057000",
1435
        },
1436
        {
1437
            "flow": {
1438
                "table_id": 0,
1439
                "owner": "telemetry_int",
1440
                "table_group": "evpl",
1441
                "priority": 20100,
1442
                "cookie": 12142097632197120839,
1443
                "idle_timeout": 0,
1444
                "hard_timeout": 0,
1445
                "match": {
1446
                    "in_port": 1,
1447
                    "dl_vlan": "912/4088",
1448
                    "dl_type": 2048,
1449
                    "nw_proto": 6,
1450
                },
1451
                "instructions": [
1452
                    {
1453
                        "instruction_type": "apply_actions",
1454
                        "actions": [{"action_type": "push_int"}],
1455
                    },
1456
                    {"instruction_type": "goto_table", "table_id": 3},
1457
                ],
1458
            },
1459
            "flow_id": "8bc800502e21f8194e3394e6be6cb791",
1460
            "id": "6609d458334243a561b252a27d8a5096",
1461
            "inserted_at": "2025-11-23T23:12:32.025000",
1462
            "state": "installed",
1463
            "switch": "00:00:00:00:00:00:00:01",
1464
            "updated_at": "2025-11-23T23:12:32.057000",
1465
        },
1466
        {
1467
            "flow": {
1468
                "table_id": 0,
1469
                "owner": "telemetry_int",
1470
                "table_group": "evpl",
1471
                "priority": 20100,
1472
                "cookie": 12142097632197120839,
1473
                "idle_timeout": 0,
1474
                "hard_timeout": 0,
1475
                "match": {
1476
                    "in_port": 1,
1477
                    "dl_vlan": "912/4088",
1478
                    "dl_type": 2048,
1479
                    "nw_proto": 17,
1480
                },
1481
                "instructions": [
1482
                    {
1483
                        "instruction_type": "apply_actions",
1484
                        "actions": [{"action_type": "push_int"}],
1485
                    },
1486
                    {"instruction_type": "goto_table", "table_id": 3},
1487
                ],
1488
            },
1489
            "flow_id": "8bc800502e21f8194e3394e6be6cb791",
1490
            "id": "6609d458334243a561b252a27d8a5096",
1491
            "inserted_at": "2025-11-23T23:12:32.025000",
1492
            "state": "installed",
1493
            "switch": "00:00:00:00:00:00:00:01",
1494
            "updated_at": "2025-11-23T23:12:32.057000",
1495
        },
1496
        {
1497
            "flow": {
1498
                "table_id": 3,
1499
                "owner": "telemetry_int",
1500
                "table_group": "evpl",
1501
                "priority": 20000,
1502
                "cookie": 12142097632197120839,
1503
                "idle_timeout": 0,
1504
                "hard_timeout": 0,
1505
                "match": {"in_port": 1, "dl_vlan": "912/4088"},
1506
                "instructions": [
1507
                    {
1508
                        "instruction_type": "apply_actions",
1509
                        "actions": [
1510
                            {"action_type": "add_int_metadata"},
1511
                            {"action_type": "push_vlan", "tag_type": "s"},
1512
                            {"action_type": "set_vlan", "vlan_id": 1},
1513
                            {"action_type": "output", "port": 3},
1514
                        ],
1515
                    }
1516
                ],
1517
            },
1518
            "flow_id": "8bc800502e21f8194e3394e6be6cb791",
1519
            "id": "6609d458334243a561b252a27d8a5096",
1520
            "inserted_at": "2025-11-23T23:12:32.025000",
1521
            "state": "installed",
1522
            "switch": "00:00:00:00:00:00:00:01",
1523
            "updated_at": "2025-11-23T23:12:32.057000",
1524
        },
1525
        {
1526
            "flow": {
1527
                "table_id": 0,
1528
                "owner": "telemetry_int",
1529
                "table_group": "evpl",
1530
                "priority": 20100,
1531
                "cookie": 12142097632197120839,
1532
                "idle_timeout": 0,
1533
                "hard_timeout": 0,
1534
                "match": {"in_port": 1, "dl_vlan": 920, "dl_type": 2048, "nw_proto": 6},
1535
                "instructions": [
1536
                    {
1537
                        "instruction_type": "apply_actions",
1538
                        "actions": [{"action_type": "push_int"}],
1539
                    },
1540
                    {"instruction_type": "goto_table", "table_id": 2},
1541
                ],
1542
            },
1543
            "flow_id": "38091c16e47763e9b0eda48931c22863",
1544
            "id": "77dbdc01cd081e10c96a494c56448500",
1545
            "inserted_at": "2025-11-23T23:12:32.025000",
1546
            "state": "installed",
1547
            "switch": "00:00:00:00:00:00:00:01",
1548
            "updated_at": "2025-11-23T23:12:32.057000",
1549
        },
1550
        {
1551
            "flow": {
1552
                "table_id": 0,
1553
                "owner": "telemetry_int",
1554
                "table_group": "evpl",
1555
                "priority": 20100,
1556
                "cookie": 12142097632197120839,
1557
                "idle_timeout": 0,
1558
                "hard_timeout": 0,
1559
                "match": {
1560
                    "in_port": 1,
1561
                    "dl_vlan": 920,
1562
                    "dl_type": 2048,
1563
                    "nw_proto": 17,
1564
                },
1565
                "instructions": [
1566
                    {
1567
                        "instruction_type": "apply_actions",
1568
                        "actions": [{"action_type": "push_int"}],
1569
                    },
1570
                    {"instruction_type": "goto_table", "table_id": 2},
1571
                ],
1572
            },
1573
            "flow_id": "38091c16e47763e9b0eda48931c22863",
1574
            "id": "77dbdc01cd081e10c96a494c56448500",
1575
            "inserted_at": "2025-11-23T23:12:32.025000",
1576
            "state": "installed",
1577
            "switch": "00:00:00:00:00:00:00:01",
1578
            "updated_at": "2025-11-23T23:12:32.057000",
1579
        },
1580
        {
1581
            "flow": {
1582
                "table_id": 2,
1583
                "owner": "telemetry_int",
1584
                "table_group": "evpl",
1585
                "priority": 20000,
1586
                "cookie": 12142097632197120839,
1587
                "idle_timeout": 0,
1588
                "hard_timeout": 0,
1589
                "match": {"in_port": 1, "dl_vlan": 920},
1590
                "instructions": [
1591
                    {
1592
                        "instruction_type": "apply_actions",
1593
                        "actions": [
1594
                            {"action_type": "add_int_metadata"},
1595
                            {"action_type": "push_vlan", "tag_type": "s"},
1596
                            {"action_type": "set_vlan", "vlan_id": 1},
1597
                            {"action_type": "output", "port": 3},
1598
                        ],
1599
                    }
1600
                ],
1601
            },
1602
            "flow_id": "38091c16e47763e9b0eda48931c22863",
1603
            "id": "77dbdc01cd081e10c96a494c56448500",
1604
            "inserted_at": "2025-11-23T23:12:32.025000",
1605
            "state": "installed",
1606
            "switch": "00:00:00:00:00:00:00:01",
1607
            "updated_at": "2025-11-23T23:12:32.057000",
1608
        },
1609
        {
1610
            "flow": {
1611
                "table_id": 0,
1612
                "owner": "telemetry_int",
1613
                "table_group": "evpl",
1614
                "priority": 20100,
1615
                "cookie": 12142097632197120839,
1616
                "idle_timeout": 0,
1617
                "hard_timeout": 0,
1618
                "match": {
1619
                    "in_port": 1,
1620
                    "dl_vlan": "910/4094",
1621
                    "dl_type": 2048,
1622
                    "nw_proto": 6,
1623
                },
1624
                "instructions": [
1625
                    {
1626
                        "instruction_type": "apply_actions",
1627
                        "actions": [{"action_type": "push_int"}],
1628
                    },
1629
                    {"instruction_type": "goto_table", "table_id": 3},
1630
                ],
1631
            },
1632
            "flow_id": "7ab2e21394a6a1c4e0821ccfea58fdb1",
1633
            "id": "166fd19e9d1de0cab8e78e3d2a6e5e3f",
1634
            "inserted_at": "2025-11-23T23:12:32.025000",
1635
            "state": "installed",
1636
            "switch": "00:00:00:00:00:00:00:03",
1637
            "updated_at": "2025-11-23T23:12:32.057000",
1638
        },
1639
        {
1640
            "flow": {
1641
                "table_id": 0,
1642
                "owner": "telemetry_int",
1643
                "table_group": "evpl",
1644
                "priority": 20100,
1645
                "cookie": 12142097632197120839,
1646
                "idle_timeout": 0,
1647
                "hard_timeout": 0,
1648
                "match": {
1649
                    "in_port": 1,
1650
                    "dl_vlan": "910/4094",
1651
                    "dl_type": 2048,
1652
                    "nw_proto": 17,
1653
                },
1654
                "instructions": [
1655
                    {
1656
                        "instruction_type": "apply_actions",
1657
                        "actions": [{"action_type": "push_int"}],
1658
                    },
1659
                    {"instruction_type": "goto_table", "table_id": 3},
1660
                ],
1661
            },
1662
            "flow_id": "7ab2e21394a6a1c4e0821ccfea58fdb1",
1663
            "id": "166fd19e9d1de0cab8e78e3d2a6e5e3f",
1664
            "inserted_at": "2025-11-23T23:12:32.025000",
1665
            "state": "installed",
1666
            "switch": "00:00:00:00:00:00:00:03",
1667
            "updated_at": "2025-11-23T23:12:32.057000",
1668
        },
1669
        {
1670
            "flow": {
1671
                "table_id": 3,
1672
                "owner": "telemetry_int",
1673
                "table_group": "evpl",
1674
                "priority": 20000,
1675
                "cookie": 12142097632197120839,
1676
                "idle_timeout": 0,
1677
                "hard_timeout": 0,
1678
                "match": {"in_port": 1, "dl_vlan": "910/4094"},
1679
                "instructions": [
1680
                    {
1681
                        "instruction_type": "apply_actions",
1682
                        "actions": [
1683
                            {"action_type": "add_int_metadata"},
1684
                            {"action_type": "push_vlan", "tag_type": "s"},
1685
                            {"action_type": "set_vlan", "vlan_id": 1},
1686
                            {"action_type": "output", "port": 2},
1687
                        ],
1688
                    }
1689
                ],
1690
            },
1691
            "flow_id": "7ab2e21394a6a1c4e0821ccfea58fdb1",
1692
            "id": "166fd19e9d1de0cab8e78e3d2a6e5e3f",
1693
            "inserted_at": "2025-11-23T23:12:32.025000",
1694
            "state": "installed",
1695
            "switch": "00:00:00:00:00:00:00:03",
1696
            "updated_at": "2025-11-23T23:12:32.057000",
1697
        },
1698
        {
1699
            "flow": {
1700
                "table_id": 0,
1701
                "owner": "telemetry_int",
1702
                "table_group": "evpl",
1703
                "priority": 20100,
1704
                "cookie": 12142097632197120839,
1705
                "idle_timeout": 0,
1706
                "hard_timeout": 0,
1707
                "match": {
1708
                    "in_port": 1,
1709
                    "dl_vlan": "912/4088",
1710
                    "dl_type": 2048,
1711
                    "nw_proto": 6,
1712
                },
1713
                "instructions": [
1714
                    {
1715
                        "instruction_type": "apply_actions",
1716
                        "actions": [{"action_type": "push_int"}],
1717
                    },
1718
                    {"instruction_type": "goto_table", "table_id": 3},
1719
                ],
1720
            },
1721
            "flow_id": "5e9b1a8aafab5335758399b46a878c57",
1722
            "id": "ee4176ac148d69ec3fd0dc97e783622d",
1723
            "inserted_at": "2025-11-23T23:12:32.025000",
1724
            "state": "installed",
1725
            "switch": "00:00:00:00:00:00:00:03",
1726
            "updated_at": "2025-11-23T23:12:32.057000",
1727
        },
1728
        {
1729
            "flow": {
1730
                "table_id": 0,
1731
                "owner": "telemetry_int",
1732
                "table_group": "evpl",
1733
                "priority": 20100,
1734
                "cookie": 12142097632197120839,
1735
                "idle_timeout": 0,
1736
                "hard_timeout": 0,
1737
                "match": {
1738
                    "in_port": 1,
1739
                    "dl_vlan": "912/4088",
1740
                    "dl_type": 2048,
1741
                    "nw_proto": 17,
1742
                },
1743
                "instructions": [
1744
                    {
1745
                        "instruction_type": "apply_actions",
1746
                        "actions": [{"action_type": "push_int"}],
1747
                    },
1748
                    {"instruction_type": "goto_table", "table_id": 3},
1749
                ],
1750
            },
1751
            "flow_id": "5e9b1a8aafab5335758399b46a878c57",
1752
            "id": "ee4176ac148d69ec3fd0dc97e783622d",
1753
            "inserted_at": "2025-11-23T23:12:32.025000",
1754
            "state": "installed",
1755
            "switch": "00:00:00:00:00:00:00:03",
1756
            "updated_at": "2025-11-23T23:12:32.057000",
1757
        },
1758
        {
1759
            "flow": {
1760
                "table_id": 3,
1761
                "owner": "telemetry_int",
1762
                "table_group": "evpl",
1763
                "priority": 20000,
1764
                "cookie": 12142097632197120839,
1765
                "idle_timeout": 0,
1766
                "hard_timeout": 0,
1767
                "match": {"in_port": 1, "dl_vlan": "912/4088"},
1768
                "instructions": [
1769
                    {
1770
                        "instruction_type": "apply_actions",
1771
                        "actions": [
1772
                            {"action_type": "add_int_metadata"},
1773
                            {"action_type": "push_vlan", "tag_type": "s"},
1774
                            {"action_type": "set_vlan", "vlan_id": 1},
1775
                            {"action_type": "output", "port": 2},
1776
                        ],
1777
                    }
1778
                ],
1779
            },
1780
            "flow_id": "5e9b1a8aafab5335758399b46a878c57",
1781
            "id": "ee4176ac148d69ec3fd0dc97e783622d",
1782
            "inserted_at": "2025-11-23T23:12:32.025000",
1783
            "state": "installed",
1784
            "switch": "00:00:00:00:00:00:00:03",
1785
            "updated_at": "2025-11-23T23:12:32.057000",
1786
        },
1787
        {
1788
            "flow": {
1789
                "table_id": 0,
1790
                "owner": "telemetry_int",
1791
                "table_group": "evpl",
1792
                "priority": 20100,
1793
                "cookie": 12142097632197120839,
1794
                "idle_timeout": 0,
1795
                "hard_timeout": 0,
1796
                "match": {"in_port": 1, "dl_vlan": 920, "dl_type": 2048, "nw_proto": 6},
1797
                "instructions": [
1798
                    {
1799
                        "instruction_type": "apply_actions",
1800
                        "actions": [{"action_type": "push_int"}],
1801
                    },
1802
                    {"instruction_type": "goto_table", "table_id": 2},
1803
                ],
1804
            },
1805
            "flow_id": "554030a54c59a68e831048df718e6a1b",
1806
            "id": "da4add0aa529458cb4161d3ed54349f7",
1807
            "inserted_at": "2025-11-23T23:12:32.025000",
1808
            "state": "installed",
1809
            "switch": "00:00:00:00:00:00:00:03",
1810
            "updated_at": "2025-11-23T23:12:32.057000",
1811
        },
1812
        {
1813
            "flow": {
1814
                "table_id": 0,
1815
                "owner": "telemetry_int",
1816
                "table_group": "evpl",
1817
                "priority": 20100,
1818
                "cookie": 12142097632197120839,
1819
                "idle_timeout": 0,
1820
                "hard_timeout": 0,
1821
                "match": {
1822
                    "in_port": 1,
1823
                    "dl_vlan": 920,
1824
                    "dl_type": 2048,
1825
                    "nw_proto": 17,
1826
                },
1827
                "instructions": [
1828
                    {
1829
                        "instruction_type": "apply_actions",
1830
                        "actions": [{"action_type": "push_int"}],
1831
                    },
1832
                    {"instruction_type": "goto_table", "table_id": 2},
1833
                ],
1834
            },
1835
            "flow_id": "554030a54c59a68e831048df718e6a1b",
1836
            "id": "da4add0aa529458cb4161d3ed54349f7",
1837
            "inserted_at": "2025-11-23T23:12:32.025000",
1838
            "state": "installed",
1839
            "switch": "00:00:00:00:00:00:00:03",
1840
            "updated_at": "2025-11-23T23:12:32.057000",
1841
        },
1842
        {
1843
            "flow": {
1844
                "table_id": 2,
1845
                "owner": "telemetry_int",
1846
                "table_group": "evpl",
1847
                "priority": 20000,
1848
                "cookie": 12142097632197120839,
1849
                "idle_timeout": 0,
1850
                "hard_timeout": 0,
1851
                "match": {"in_port": 1, "dl_vlan": 920},
1852
                "instructions": [
1853
                    {
1854
                        "instruction_type": "apply_actions",
1855
                        "actions": [
1856
                            {"action_type": "add_int_metadata"},
1857
                            {"action_type": "push_vlan", "tag_type": "s"},
1858
                            {"action_type": "set_vlan", "vlan_id": 1},
1859
                            {"action_type": "output", "port": 2},
1860
                        ],
1861
                    }
1862
                ],
1863
            },
1864
            "flow_id": "554030a54c59a68e831048df718e6a1b",
1865
            "id": "da4add0aa529458cb4161d3ed54349f7",
1866
            "inserted_at": "2025-11-23T23:12:32.025000",
1867
            "state": "installed",
1868
            "switch": "00:00:00:00:00:00:00:03",
1869
            "updated_at": "2025-11-23T23:12:32.057000",
1870
        },
1871
        {
1872
            "flow": {
1873
                "table_id": 0,
1874
                "owner": "telemetry_int",
1875
                "table_group": "evpl",
1876
                "priority": 20100,
1877
                "cookie": 12142097632197120839,
1878
                "idle_timeout": 0,
1879
                "hard_timeout": 0,
1880
                "match": {"in_port": 2, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 6},
1881
                "instructions": [
1882
                    {
1883
                        "instruction_type": "apply_actions",
1884
                        "actions": [
1885
                            {"action_type": "add_int_metadata"},
1886
                            {"action_type": "set_vlan", "vlan_id": 1},
1887
                            {"action_type": "output", "port": 3},
1888
                        ],
1889
                    }
1890
                ],
1891
            },
1892
            "flow_id": "6846b3a98ad0c96999c3b828d79d551f",
1893
            "id": "b700ac5ee60a5b2592822b72cab7caac",
1894
            "inserted_at": "2025-11-23T01:56:13.499000",
1895
            "state": "installed",
1896
            "switch": "00:00:00:00:00:00:00:02",
1897
            "updated_at": "2025-11-23T23:12:32.055000",
1898
        },
1899
        {
1900
            "flow": {
1901
                "table_id": 0,
1902
                "owner": "telemetry_int",
1903
                "table_group": "evpl",
1904
                "priority": 20100,
1905
                "cookie": 12142097632197120839,
1906
                "idle_timeout": 0,
1907
                "hard_timeout": 0,
1908
                "match": {"in_port": 2, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 17},
1909
                "instructions": [
1910
                    {
1911
                        "instruction_type": "apply_actions",
1912
                        "actions": [
1913
                            {"action_type": "add_int_metadata"},
1914
                            {"action_type": "set_vlan", "vlan_id": 1},
1915
                            {"action_type": "output", "port": 3},
1916
                        ],
1917
                    }
1918
                ],
1919
            },
1920
            "flow_id": "6846b3a98ad0c96999c3b828d79d551f",
1921
            "id": "b700ac5ee60a5b2592822b72cab7caac",
1922
            "inserted_at": "2025-11-23T01:56:13.499000",
1923
            "state": "installed",
1924
            "switch": "00:00:00:00:00:00:00:02",
1925
            "updated_at": "2025-11-23T23:12:32.055000",
1926
        },
1927
        {
1928
            "flow": {
1929
                "table_id": 0,
1930
                "owner": "telemetry_int",
1931
                "table_group": "evpl",
1932
                "priority": 20100,
1933
                "cookie": 12142097632197120839,
1934
                "idle_timeout": 0,
1935
                "hard_timeout": 0,
1936
                "match": {"in_port": 3, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 6},
1937
                "instructions": [
1938
                    {
1939
                        "instruction_type": "apply_actions",
1940
                        "actions": [
1941
                            {"action_type": "add_int_metadata"},
1942
                            {"action_type": "set_vlan", "vlan_id": 1},
1943
                            {"action_type": "output", "port": 2},
1944
                        ],
1945
                    }
1946
                ],
1947
            },
1948
            "flow_id": "cf2a85c8497e542e5fa45d70df26c7f2",
1949
            "id": "0f401a64a89d45f5296aa35a28d2fe82",
1950
            "inserted_at": "2025-11-23T23:12:32.025000",
1951
            "state": "installed",
1952
            "switch": "00:00:00:00:00:00:00:02",
1953
            "updated_at": "2025-11-23T23:12:32.055000",
1954
        },
1955
        {
1956
            "flow": {
1957
                "table_id": 0,
1958
                "owner": "telemetry_int",
1959
                "table_group": "evpl",
1960
                "priority": 20100,
1961
                "cookie": 12142097632197120839,
1962
                "idle_timeout": 0,
1963
                "hard_timeout": 0,
1964
                "match": {"in_port": 3, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 17},
1965
                "instructions": [
1966
                    {
1967
                        "instruction_type": "apply_actions",
1968
                        "actions": [
1969
                            {"action_type": "add_int_metadata"},
1970
                            {"action_type": "set_vlan", "vlan_id": 1},
1971
                            {"action_type": "output", "port": 2},
1972
                        ],
1973
                    }
1974
                ],
1975
            },
1976
            "flow_id": "cf2a85c8497e542e5fa45d70df26c7f2",
1977
            "id": "0f401a64a89d45f5296aa35a28d2fe82",
1978
            "inserted_at": "2025-11-23T23:12:32.025000",
1979
            "state": "installed",
1980
            "switch": "00:00:00:00:00:00:00:02",
1981
            "updated_at": "2025-11-23T23:12:32.055000",
1982
        },
1983
        {
1984
            "flow": {
1985
                "table_id": 0,
1986
                "owner": "telemetry_int",
1987
                "table_group": "evpl",
1988
                "priority": 20100,
1989
                "cookie": 12142097632197120839,
1990
                "idle_timeout": 0,
1991
                "hard_timeout": 0,
1992
                "match": {"in_port": 2, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 6},
1993
                "instructions": [
1994
                    {
1995
                        "instruction_type": "apply_actions",
1996
                        "actions": [
1997
                            {"action_type": "add_int_metadata"},
1998
                            {"action_type": "pop_vlan"},
1999
                            {"action_type": "output", "port": 5},
2000
                        ],
2001
                    }
2002
                ],
2003
            },
2004
            "flow_id": "e71b15954dba0cd57095dfc715f37dbf",
2005
            "id": "0d9c46bc386bf5944555ab724cf70133",
2006
            "inserted_at": "2025-11-23T23:12:32.025000",
2007
            "state": "installed",
2008
            "switch": "00:00:00:00:00:00:00:03",
2009
            "updated_at": "2025-11-23T23:12:32.057000",
2010
        },
2011
        {
2012
            "flow": {
2013
                "table_id": 0,
2014
                "owner": "telemetry_int",
2015
                "table_group": "evpl",
2016
                "priority": 20100,
2017
                "cookie": 12142097632197120839,
2018
                "idle_timeout": 0,
2019
                "hard_timeout": 0,
2020
                "match": {"in_port": 2, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 17},
2021
                "instructions": [
2022
                    {
2023
                        "instruction_type": "apply_actions",
2024
                        "actions": [
2025
                            {"action_type": "add_int_metadata"},
2026
                            {"action_type": "pop_vlan"},
2027
                            {"action_type": "output", "port": 5},
2028
                        ],
2029
                    }
2030
                ],
2031
            },
2032
            "flow_id": "e71b15954dba0cd57095dfc715f37dbf",
2033
            "id": "0d9c46bc386bf5944555ab724cf70133",
2034
            "inserted_at": "2025-11-23T23:12:32.025000",
2035
            "state": "installed",
2036
            "switch": "00:00:00:00:00:00:00:03",
2037
            "updated_at": "2025-11-23T23:12:32.057000",
2038
        },
2039
        {
2040
            "flow": {
2041
                "table_id": 0,
2042
                "owner": "telemetry_int",
2043
                "table_group": "evpl",
2044
                "priority": 20000,
2045
                "cookie": 12142097632197120839,
2046
                "idle_timeout": 0,
2047
                "hard_timeout": 0,
2048
                "match": {"in_port": 6, "dl_vlan": "910/4094"},
2049
                "instructions": [
2050
                    {
2051
                        "instruction_type": "apply_actions",
2052
                        "actions": [{"action_type": "send_report"}],
2053
                    },
2054
                    {"instruction_type": "goto_table", "table_id": 3},
2055
                ],
2056
            },
2057
            "flow_id": "e71b15954dba0cd57095dfc715f37dbf",
2058
            "id": "0d9c46bc386bf5944555ab724cf70133",
2059
            "inserted_at": "2025-11-23T23:12:32.025000",
2060
            "state": "installed",
2061
            "switch": "00:00:00:00:00:00:00:03",
2062
            "updated_at": "2025-11-23T23:12:32.057000",
2063
        },
2064
        {
2065
            "flow": {
2066
                "table_id": 3,
2067
                "owner": "telemetry_int",
2068
                "table_group": "evpl",
2069
                "priority": 20000,
2070
                "cookie": 12142097632197120839,
2071
                "idle_timeout": 0,
2072
                "hard_timeout": 0,
2073
                "match": {"in_port": 6, "dl_vlan": "910/4094"},
2074
                "instructions": [
2075
                    {
2076
                        "instruction_type": "apply_actions",
2077
                        "actions": [
2078
                            {"action_type": "pop_int"},
2079
                            {"action_type": "output", "port": 1},
2080
                        ],
2081
                    }
2082
                ],
2083
            },
2084
            "flow_id": "e71b15954dba0cd57095dfc715f37dbf",
2085
            "id": "0d9c46bc386bf5944555ab724cf70133",
2086
            "inserted_at": "2025-11-23T23:12:32.025000",
2087
            "state": "installed",
2088
            "switch": "00:00:00:00:00:00:00:03",
2089
            "updated_at": "2025-11-23T23:12:32.057000",
2090
        },
2091
        {
2092
            "flow": {
2093
                "table_id": 0,
2094
                "owner": "telemetry_int",
2095
                "table_group": "evpl",
2096
                "priority": 20000,
2097
                "cookie": 12142097632197120839,
2098
                "idle_timeout": 0,
2099
                "hard_timeout": 0,
2100
                "match": {"in_port": 6, "dl_vlan": "912/4088"},
2101
                "instructions": [
2102
                    {
2103
                        "instruction_type": "apply_actions",
2104
                        "actions": [{"action_type": "send_report"}],
2105
                    },
2106
                    {"instruction_type": "goto_table", "table_id": 3},
2107
                ],
2108
            },
2109
            "flow_id": "e71b15954dba0cd57095dfc715f37dbf",
2110
            "id": "0d9c46bc386bf5944555ab724cf70133",
2111
            "inserted_at": "2025-11-23T23:12:32.025000",
2112
            "state": "installed",
2113
            "switch": "00:00:00:00:00:00:00:03",
2114
            "updated_at": "2025-11-23T23:12:32.057000",
2115
        },
2116
        {
2117
            "flow": {
2118
                "table_id": 3,
2119
                "owner": "telemetry_int",
2120
                "table_group": "evpl",
2121
                "priority": 20000,
2122
                "cookie": 12142097632197120839,
2123
                "idle_timeout": 0,
2124
                "hard_timeout": 0,
2125
                "match": {"in_port": 6, "dl_vlan": "912/4088"},
2126
                "instructions": [
2127
                    {
2128
                        "instruction_type": "apply_actions",
2129
                        "actions": [
2130
                            {"action_type": "pop_int"},
2131
                            {"action_type": "output", "port": 1},
2132
                        ],
2133
                    }
2134
                ],
2135
            },
2136
            "flow_id": "e71b15954dba0cd57095dfc715f37dbf",
2137
            "id": "0d9c46bc386bf5944555ab724cf70133",
2138
            "inserted_at": "2025-11-23T23:12:32.025000",
2139
            "state": "installed",
2140
            "switch": "00:00:00:00:00:00:00:03",
2141
            "updated_at": "2025-11-23T23:12:32.057000",
2142
        },
2143
        {
2144
            "flow": {
2145
                "table_id": 0,
2146
                "owner": "telemetry_int",
2147
                "table_group": "evpl",
2148
                "priority": 20000,
2149
                "cookie": 12142097632197120839,
2150
                "idle_timeout": 0,
2151
                "hard_timeout": 0,
2152
                "match": {"in_port": 6, "dl_vlan": 920},
2153
                "instructions": [
2154
                    {
2155
                        "instruction_type": "apply_actions",
2156
                        "actions": [{"action_type": "send_report"}],
2157
                    },
2158
                    {"instruction_type": "goto_table", "table_id": 3},
2159
                ],
2160
            },
2161
            "flow_id": "e71b15954dba0cd57095dfc715f37dbf",
2162
            "id": "0d9c46bc386bf5944555ab724cf70133",
2163
            "inserted_at": "2025-11-23T23:12:32.025000",
2164
            "state": "installed",
2165
            "switch": "00:00:00:00:00:00:00:03",
2166
            "updated_at": "2025-11-23T23:12:32.057000",
2167
        },
2168
        {
2169
            "flow": {
2170
                "table_id": 3,
2171
                "owner": "telemetry_int",
2172
                "table_group": "evpl",
2173
                "priority": 20000,
2174
                "cookie": 12142097632197120839,
2175
                "idle_timeout": 0,
2176
                "hard_timeout": 0,
2177
                "match": {"in_port": 6, "dl_vlan": 920},
2178
                "instructions": [
2179
                    {
2180
                        "instruction_type": "apply_actions",
2181
                        "actions": [
2182
                            {"action_type": "pop_int"},
2183
                            {"action_type": "output", "port": 1},
2184
                        ],
2185
                    }
2186
                ],
2187
            },
2188
            "flow_id": "e71b15954dba0cd57095dfc715f37dbf",
2189
            "id": "0d9c46bc386bf5944555ab724cf70133",
2190
            "inserted_at": "2025-11-23T23:12:32.025000",
2191
            "state": "installed",
2192
            "switch": "00:00:00:00:00:00:00:03",
2193
            "updated_at": "2025-11-23T23:12:32.057000",
2194
        },
2195
        {
2196
            "flow": {
2197
                "table_id": 0,
2198
                "owner": "telemetry_int",
2199
                "table_group": "evpl",
2200
                "priority": 20100,
2201
                "cookie": 12142097632197120839,
2202
                "idle_timeout": 0,
2203
                "hard_timeout": 0,
2204
                "match": {"in_port": 3, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 6},
2205
                "instructions": [
2206
                    {
2207
                        "instruction_type": "apply_actions",
2208
                        "actions": [
2209
                            {"action_type": "add_int_metadata"},
2210
                            {"action_type": "pop_vlan"},
2211
                            {"action_type": "output", "port": 5},
2212
                        ],
2213
                    }
2214
                ],
2215
            },
2216
            "flow_id": "b2ac5ff0819d76e696cae81474c4ddc1",
2217
            "id": "ff01974b200b34572a59ca88d92c907b",
2218
            "inserted_at": "2025-11-23T23:12:32.025000",
2219
            "state": "installed",
2220
            "switch": "00:00:00:00:00:00:00:01",
2221
            "updated_at": "2025-11-23T23:12:32.057000",
2222
        },
2223
        {
2224
            "flow": {
2225
                "table_id": 0,
2226
                "owner": "telemetry_int",
2227
                "table_group": "evpl",
2228
                "priority": 20100,
2229
                "cookie": 12142097632197120839,
2230
                "idle_timeout": 0,
2231
                "hard_timeout": 0,
2232
                "match": {"in_port": 3, "dl_vlan": 1, "dl_type": 2048, "nw_proto": 17},
2233
                "instructions": [
2234
                    {
2235
                        "instruction_type": "apply_actions",
2236
                        "actions": [
2237
                            {"action_type": "add_int_metadata"},
2238
                            {"action_type": "pop_vlan"},
2239
                            {"action_type": "output", "port": 5},
2240
                        ],
2241
                    }
2242
                ],
2243
            },
2244
            "flow_id": "b2ac5ff0819d76e696cae81474c4ddc1",
2245
            "id": "ff01974b200b34572a59ca88d92c907b",
2246
            "inserted_at": "2025-11-23T23:12:32.025000",
2247
            "state": "installed",
2248
            "switch": "00:00:00:00:00:00:00:01",
2249
            "updated_at": "2025-11-23T23:12:32.057000",
2250
        },
2251
        {
2252
            "flow": {
2253
                "table_id": 0,
2254
                "owner": "telemetry_int",
2255
                "table_group": "evpl",
2256
                "priority": 20000,
2257
                "cookie": 12142097632197120839,
2258
                "idle_timeout": 0,
2259
                "hard_timeout": 0,
2260
                "match": {"in_port": 6, "dl_vlan": "910/4094"},
2261
                "instructions": [
2262
                    {
2263
                        "instruction_type": "apply_actions",
2264
                        "actions": [{"action_type": "send_report"}],
2265
                    },
2266
                    {"instruction_type": "goto_table", "table_id": 3},
2267
                ],
2268
            },
2269
            "flow_id": "b2ac5ff0819d76e696cae81474c4ddc1",
2270
            "id": "ff01974b200b34572a59ca88d92c907b",
2271
            "inserted_at": "2025-11-23T23:12:32.025000",
2272
            "state": "installed",
2273
            "switch": "00:00:00:00:00:00:00:01",
2274
            "updated_at": "2025-11-23T23:12:32.057000",
2275
        },
2276
        {
2277
            "flow": {
2278
                "table_id": 3,
2279
                "owner": "telemetry_int",
2280
                "table_group": "evpl",
2281
                "priority": 20000,
2282
                "cookie": 12142097632197120839,
2283
                "idle_timeout": 0,
2284
                "hard_timeout": 0,
2285
                "match": {"in_port": 6, "dl_vlan": "910/4094"},
2286
                "instructions": [
2287
                    {
2288
                        "instruction_type": "apply_actions",
2289
                        "actions": [
2290
                            {"action_type": "pop_int"},
2291
                            {"action_type": "output", "port": 1},
2292
                        ],
2293
                    }
2294
                ],
2295
            },
2296
            "flow_id": "b2ac5ff0819d76e696cae81474c4ddc1",
2297
            "id": "ff01974b200b34572a59ca88d92c907b",
2298
            "inserted_at": "2025-11-23T23:12:32.025000",
2299
            "state": "installed",
2300
            "switch": "00:00:00:00:00:00:00:01",
2301
            "updated_at": "2025-11-23T23:12:32.057000",
2302
        },
2303
        {
2304
            "flow": {
2305
                "table_id": 0,
2306
                "owner": "telemetry_int",
2307
                "table_group": "evpl",
2308
                "priority": 20000,
2309
                "cookie": 12142097632197120839,
2310
                "idle_timeout": 0,
2311
                "hard_timeout": 0,
2312
                "match": {"in_port": 6, "dl_vlan": "912/4088"},
2313
                "instructions": [
2314
                    {
2315
                        "instruction_type": "apply_actions",
2316
                        "actions": [{"action_type": "send_report"}],
2317
                    },
2318
                    {"instruction_type": "goto_table", "table_id": 3},
2319
                ],
2320
            },
2321
            "flow_id": "b2ac5ff0819d76e696cae81474c4ddc1",
2322
            "id": "ff01974b200b34572a59ca88d92c907b",
2323
            "inserted_at": "2025-11-23T23:12:32.025000",
2324
            "state": "installed",
2325
            "switch": "00:00:00:00:00:00:00:01",
2326
            "updated_at": "2025-11-23T23:12:32.057000",
2327
        },
2328
        {
2329
            "flow": {
2330
                "table_id": 3,
2331
                "owner": "telemetry_int",
2332
                "table_group": "evpl",
2333
                "priority": 20000,
2334
                "cookie": 12142097632197120839,
2335
                "idle_timeout": 0,
2336
                "hard_timeout": 0,
2337
                "match": {"in_port": 6, "dl_vlan": "912/4088"},
2338
                "instructions": [
2339
                    {
2340
                        "instruction_type": "apply_actions",
2341
                        "actions": [
2342
                            {"action_type": "pop_int"},
2343
                            {"action_type": "output", "port": 1},
2344
                        ],
2345
                    }
2346
                ],
2347
            },
2348
            "flow_id": "b2ac5ff0819d76e696cae81474c4ddc1",
2349
            "id": "ff01974b200b34572a59ca88d92c907b",
2350
            "inserted_at": "2025-11-23T23:12:32.025000",
2351
            "state": "installed",
2352
            "switch": "00:00:00:00:00:00:00:01",
2353
            "updated_at": "2025-11-23T23:12:32.057000",
2354
        },
2355
        {
2356
            "flow": {
2357
                "table_id": 0,
2358
                "owner": "telemetry_int",
2359
                "table_group": "evpl",
2360
                "priority": 20000,
2361
                "cookie": 12142097632197120839,
2362
                "idle_timeout": 0,
2363
                "hard_timeout": 0,
2364
                "match": {"in_port": 6, "dl_vlan": 920},
2365
                "instructions": [
2366
                    {
2367
                        "instruction_type": "apply_actions",
2368
                        "actions": [{"action_type": "send_report"}],
2369
                    },
2370
                    {"instruction_type": "goto_table", "table_id": 3},
2371
                ],
2372
            },
2373
            "flow_id": "b2ac5ff0819d76e696cae81474c4ddc1",
2374
            "id": "ff01974b200b34572a59ca88d92c907b",
2375
            "inserted_at": "2025-11-23T23:12:32.025000",
2376
            "state": "installed",
2377
            "switch": "00:00:00:00:00:00:00:01",
2378
            "updated_at": "2025-11-23T23:12:32.057000",
2379
        },
2380
        {
2381
            "flow": {
2382
                "table_id": 3,
2383
                "owner": "telemetry_int",
2384
                "table_group": "evpl",
2385
                "priority": 20000,
2386
                "cookie": 12142097632197120839,
2387
                "idle_timeout": 0,
2388
                "hard_timeout": 0,
2389
                "match": {"in_port": 6, "dl_vlan": 920},
2390
                "instructions": [
2391
                    {
2392
                        "instruction_type": "apply_actions",
2393
                        "actions": [
2394
                            {"action_type": "pop_int"},
2395
                            {"action_type": "output", "port": 1},
2396
                        ],
2397
                    }
2398
                ],
2399
            },
2400
            "flow_id": "b2ac5ff0819d76e696cae81474c4ddc1",
2401
            "id": "ff01974b200b34572a59ca88d92c907b",
2402
            "inserted_at": "2025-11-23T23:12:32.025000",
2403
            "state": "installed",
2404
            "switch": "00:00:00:00:00:00:00:01",
2405
            "updated_at": "2025-11-23T23:12:32.057000",
2406
        },
2407
    ]
2408
    assert flows == expected_flows
2409