blob: 96142af68893480a95bb2e6e287d1df4aa8b4284 [file] [log] [blame]
Sean Condonf4f54a12018-10-10 23:25:46 +01001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the 'License');
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an 'AS IS' BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Sean Condonc13d9562019-04-18 13:24:42 +010016import {async, ComponentFixture, TestBed} from '@angular/core/testing';
Sean Condonf4f54a12018-10-10 23:25:46 +010017
Sean Condonc13d9562019-04-18 13:24:42 +010018import {ForceSvgComponent} from './forcesvg.component';
Sean Condon64060ff2019-05-30 15:48:11 +010019import {
20 FnService, IconService,
21 LionService,
22 LogService, SvgUtilService,
23 UrlFnService,
24 WebSocketService
Sean Condon3dd062f2020-04-14 09:25:00 +010025} from 'org_onosproject_onos/web/gui2-fw-lib/public_api';
Sean Condon0c577f62018-11-18 22:40:05 +000026import {DraggableDirective} from './draggable/draggable.directive';
27import {ActivatedRoute, Params} from '@angular/router';
28import {of} from 'rxjs';
Sean Condonff85fbe2019-03-16 14:28:46 +000029import {DeviceNodeSvgComponent} from './visuals/devicenodesvg/devicenodesvg.component';
30import {SubRegionNodeSvgComponent} from './visuals/subregionnodesvg/subregionnodesvg.component';
31import {HostNodeSvgComponent} from './visuals/hostnodesvg/hostnodesvg.component';
32import {LinkSvgComponent} from './visuals/linksvg/linksvg.component';
pierventre57f7bbb2021-10-20 17:37:52 +020033import {Device, Host, Link, LinkType, LinkHighlight, Region, Node} from './models';
Sean Condon64060ff2019-05-30 15:48:11 +010034import {ChangeDetectorRef, SimpleChange} from '@angular/core';
35import {TopologyService} from '../../topology.service';
Sean Condon590b34b2019-12-04 18:44:37 +000036import {BadgeSvgComponent} from './visuals/badgesvg/badgesvg.component';
Sean Condon0c577f62018-11-18 22:40:05 +000037
Sean Condon4ceeae72021-10-21 15:37:11 +010038export const test_module_topo2CurrentRegion = `{
39 "event": "topo2CurrentRegion",
40 "payload": {
41 "id": "(root)",
42 "subregions": [],
43 "links": [
44 {
45 "id": "00:AA:00:00:00:03/None~of:0000000000000205/6",
46 "epA": "00:AA:00:00:00:03/None",
47 "epB": "of:0000000000000205",
48 "type": "UiEdgeLink",
49 "portB": "6",
50 "rollup": [
51 {
52 "id": "00:AA:00:00:00:03/None~of:0000000000000205/6",
53 "epA": "00:AA:00:00:00:03/None",
54 "epB": "of:0000000000000205",
55 "type": "UiEdgeLink",
56 "portB": "6"
57 }
58 ]
59 },
60 {
61 "id": "of:0000000000000205/3~of:0000000000000227/5",
62 "epA": "of:0000000000000205/3",
63 "epB": "of:0000000000000227/5",
64 "type": "UiDeviceLink",
65 "portA": "3",
66 "portB": "5",
67 "rollup": [
68 {
69 "id": "of:0000000000000205/3~of:0000000000000227/5",
70 "epA": "of:0000000000000205/3",
71 "epB": "of:0000000000000227/5",
72 "type": "UiDeviceLink",
73 "portA": "3",
74 "portB": "5"
75 }
76 ]
77 },
78 {
79 "id": "of:0000000000000206/2~of:0000000000000226/8",
80 "epA": "of:0000000000000206/2",
81 "epB": "of:0000000000000226/8",
82 "type": "UiDeviceLink",
83 "portA": "2",
84 "portB": "8",
85 "rollup": [
86 {
87 "id": "of:0000000000000206/2~of:0000000000000226/8",
88 "epA": "of:0000000000000206/2",
89 "epB": "of:0000000000000226/8",
90 "type": "UiDeviceLink",
91 "portA": "2",
92 "portB": "8"
93 }
94 ]
95 },
96 {
97 "id": "00:BB:00:00:00:05/None~of:0000000000000203/7",
98 "epA": "00:BB:00:00:00:05/None",
99 "epB": "of:0000000000000203",
100 "type": "UiEdgeLink",
101 "portB": "7",
102 "rollup": [
103 {
104 "id": "00:BB:00:00:00:05/None~of:0000000000000203/7",
105 "epA": "00:BB:00:00:00:05/None",
106 "epB": "of:0000000000000203",
107 "type": "UiEdgeLink",
108 "portB": "7"
109 }
110 ]
111 },
112 {
113 "id": "00:DD:00:00:00:01/None~of:0000000000000207/3",
114 "epA": "00:DD:00:00:00:01/None",
115 "epB": "of:0000000000000207",
116 "type": "UiEdgeLink",
117 "portB": "3",
118 "rollup": [
119 {
120 "id": "00:DD:00:00:00:01/None~of:0000000000000207/3",
121 "epA": "00:DD:00:00:00:01/None",
122 "epB": "of:0000000000000207",
123 "type": "UiEdgeLink",
124 "portB": "3"
125 }
126 ]
127 },
128 {
129 "id": "of:0000000000000203/1~of:0000000000000226/1",
130 "epA": "of:0000000000000203/1",
131 "epB": "of:0000000000000226/1",
132 "type": "UiDeviceLink",
133 "portA": "1",
134 "portB": "1",
135 "rollup": [
136 {
137 "id": "of:0000000000000203/1~of:0000000000000226/1",
138 "epA": "of:0000000000000203/1",
139 "epB": "of:0000000000000226/1",
140 "type": "UiDeviceLink",
141 "portA": "1",
142 "portB": "1"
143 }
144 ]
145 },
146 {
147 "id": "of:0000000000000207/2~of:0000000000000247/1",
148 "epA": "of:0000000000000207/2",
149 "epB": "of:0000000000000247/1",
150 "type": "UiDeviceLink",
151 "portA": "2",
152 "portB": "1",
153 "rollup": [
154 {
155 "id": "of:0000000000000207/2~of:0000000000000247/1",
156 "epA": "of:0000000000000207/2",
157 "epB": "of:0000000000000247/1",
158 "type": "UiDeviceLink",
159 "portA": "2",
160 "portB": "1"
161 }
162 ]
163 },
164 {
165 "id": "00:99:66:00:00:01/None~of:0000000000000205/10",
166 "epA": "00:99:66:00:00:01/None",
167 "epB": "of:0000000000000205",
168 "type": "UiEdgeLink",
169 "portB": "10",
170 "rollup": [
171 {
172 "id": "00:99:66:00:00:01/None~of:0000000000000205/10",
173 "epA": "00:99:66:00:00:01/None",
174 "epB": "of:0000000000000205",
175 "type": "UiEdgeLink",
176 "portB": "10"
177 }
178 ]
179 },
180 {
181 "id": "of:0000000000000208/1~of:0000000000000246/2",
182 "epA": "of:0000000000000208/1",
183 "epB": "of:0000000000000246/2",
184 "type": "UiDeviceLink",
185 "portA": "1",
186 "portB": "2",
187 "rollup": [
188 {
189 "id": "of:0000000000000208/1~of:0000000000000246/2",
190 "epA": "of:0000000000000208/1",
191 "epB": "of:0000000000000246/2",
192 "type": "UiDeviceLink",
193 "portA": "1",
194 "portB": "2"
195 }
196 ]
197 },
198 {
199 "id": "of:0000000000000206/1~of:0000000000000226/7",
200 "epA": "of:0000000000000206/1",
201 "epB": "of:0000000000000226/7",
202 "type": "UiDeviceLink",
203 "portA": "1",
204 "portB": "7",
205 "rollup": [
206 {
207 "id": "of:0000000000000206/1~of:0000000000000226/7",
208 "epA": "of:0000000000000206/1",
209 "epB": "of:0000000000000226/7",
210 "type": "UiDeviceLink",
211 "portA": "1",
212 "portB": "7"
213 }
214 ]
215 },
216 {
217 "id": "of:0000000000000226/9~of:0000000000000246/3",
218 "epA": "of:0000000000000226/9",
219 "epB": "of:0000000000000246/3",
220 "type": "UiDeviceLink",
221 "portA": "9",
222 "portB": "3",
223 "rollup": [
224 {
225 "id": "of:0000000000000226/9~of:0000000000000246/3",
226 "epA": "of:0000000000000226/9",
227 "epB": "of:0000000000000246/3",
228 "type": "UiDeviceLink",
229 "portA": "9",
230 "portB": "3"
231 }
232 ]
233 },
234 {
235 "id": "00:AA:00:00:00:04/None~of:0000000000000205/7",
236 "epA": "00:AA:00:00:00:04/None",
237 "epB": "of:0000000000000205",
238 "type": "UiEdgeLink",
239 "portB": "7",
240 "rollup": [
241 {
242 "id": "00:AA:00:00:00:04/None~of:0000000000000205/7",
243 "epA": "00:AA:00:00:00:04/None",
244 "epB": "of:0000000000000205",
245 "type": "UiEdgeLink",
246 "portB": "7"
247 }
248 ]
249 },
250 {
251 "id": "00:88:00:00:00:03/110~of:0000000000000205/11",
252 "epA": "00:88:00:00:00:03/110",
253 "epB": "of:0000000000000205",
254 "type": "UiEdgeLink",
255 "portB": "11",
256 "rollup": [
257 {
258 "id": "00:88:00:00:00:03/110~of:0000000000000205/11",
259 "epA": "00:88:00:00:00:03/110",
260 "epB": "of:0000000000000205",
261 "type": "UiEdgeLink",
262 "portB": "11"
263 }
264 ]
265 },
266 {
267 "id": "of:0000000000000204/1~of:0000000000000226/3",
268 "epA": "of:0000000000000204/1",
269 "epB": "of:0000000000000226/3",
270 "type": "UiDeviceLink",
271 "portA": "1",
272 "portB": "3",
273 "rollup": [
274 {
275 "id": "of:0000000000000204/1~of:0000000000000226/3",
276 "epA": "of:0000000000000204/1",
277 "epB": "of:0000000000000226/3",
278 "type": "UiDeviceLink",
279 "portA": "1",
280 "portB": "3"
281 }
282 ]
283 },
284 {
285 "id": "of:0000000000000203/2~of:0000000000000226/2",
286 "epA": "of:0000000000000203/2",
287 "epB": "of:0000000000000226/2",
288 "type": "UiDeviceLink",
289 "portA": "2",
290 "portB": "2",
291 "rollup": [
292 {
293 "id": "of:0000000000000203/2~of:0000000000000226/2",
294 "epA": "of:0000000000000203/2",
295 "epB": "of:0000000000000226/2",
296 "type": "UiDeviceLink",
297 "portA": "2",
298 "portB": "2"
299 }
300 ]
301 },
302 {
303 "id": "00:88:00:00:00:01/None~of:0000000000000205/12",
304 "epA": "00:88:00:00:00:01/None",
305 "epB": "of:0000000000000205",
306 "type": "UiEdgeLink",
307 "portB": "12",
308 "rollup": [
309 {
310 "id": "00:88:00:00:00:01/None~of:0000000000000205/12",
311 "epA": "00:88:00:00:00:01/None",
312 "epB": "of:0000000000000205",
313 "type": "UiEdgeLink",
314 "portB": "12"
315 }
316 ]
317 },
318 {
319 "id": "00:88:00:00:00:04/160~of:0000000000000206/6",
320 "epA": "00:88:00:00:00:04/160",
321 "epB": "of:0000000000000206",
322 "type": "UiEdgeLink",
323 "portB": "6",
324 "rollup": [
325 {
326 "id": "00:88:00:00:00:04/160~of:0000000000000206/6",
327 "epA": "00:88:00:00:00:04/160",
328 "epB": "of:0000000000000206",
329 "type": "UiEdgeLink",
330 "portB": "6"
331 }
332 ]
333 },
334 {
335 "id": "00:DD:00:00:00:02/None~of:0000000000000208/3",
336 "epA": "00:DD:00:00:00:02/None",
337 "epB": "of:0000000000000208",
338 "type": "UiEdgeLink",
339 "portB": "3",
340 "rollup": [
341 {
342 "id": "00:DD:00:00:00:02/None~of:0000000000000208/3",
343 "epA": "00:DD:00:00:00:02/None",
344 "epB": "of:0000000000000208",
345 "type": "UiEdgeLink",
346 "portB": "3"
347 }
348 ]
349 },
350 {
351 "id": "of:0000000000000203/3~of:0000000000000227/1",
352 "epA": "of:0000000000000203/3",
353 "epB": "of:0000000000000227/1",
354 "type": "UiDeviceLink",
355 "portA": "3",
356 "portB": "1",
357 "rollup": [
358 {
359 "id": "of:0000000000000203/3~of:0000000000000227/1",
360 "epA": "of:0000000000000203/3",
361 "epB": "of:0000000000000227/1",
362 "type": "UiDeviceLink",
363 "portA": "3",
364 "portB": "1"
365 }
366 ]
367 },
368 {
369 "id": "of:0000000000000208/2~of:0000000000000247/2",
370 "epA": "of:0000000000000208/2",
371 "epB": "of:0000000000000247/2",
372 "type": "UiDeviceLink",
373 "portA": "2",
374 "portB": "2",
375 "rollup": [
376 {
377 "id": "of:0000000000000208/2~of:0000000000000247/2",
378 "epA": "of:0000000000000208/2",
379 "epB": "of:0000000000000247/2",
380 "type": "UiDeviceLink",
381 "portA": "2",
382 "portB": "2"
383 }
384 ]
385 },
386 {
387 "id": "of:0000000000000205/1~of:0000000000000226/5",
388 "epA": "of:0000000000000205/1",
389 "epB": "of:0000000000000226/5",
390 "type": "UiDeviceLink",
391 "portA": "1",
392 "portB": "5",
393 "rollup": [
394 {
395 "id": "of:0000000000000205/1~of:0000000000000226/5",
396 "epA": "of:0000000000000205/1",
397 "epB": "of:0000000000000226/5",
398 "type": "UiDeviceLink",
399 "portA": "1",
400 "portB": "5"
401 }
402 ]
403 },
404 {
405 "id": "of:0000000000000204/2~of:0000000000000226/4",
406 "epA": "of:0000000000000204/2",
407 "epB": "of:0000000000000226/4",
408 "type": "UiDeviceLink",
409 "portA": "2",
410 "portB": "4",
411 "rollup": [
412 {
413 "id": "of:0000000000000204/2~of:0000000000000226/4",
414 "epA": "of:0000000000000204/2",
415 "epB": "of:0000000000000226/4",
416 "type": "UiDeviceLink",
417 "portA": "2",
418 "portB": "4"
419 }
420 ]
421 },
422 {
423 "id": "00:AA:00:00:00:01/None~of:0000000000000204/6",
424 "epA": "00:AA:00:00:00:01/None",
425 "epB": "of:0000000000000204",
426 "type": "UiEdgeLink",
427 "portB": "6",
428 "rollup": [
429 {
430 "id": "00:AA:00:00:00:01/None~of:0000000000000204/6",
431 "epA": "00:AA:00:00:00:01/None",
432 "epB": "of:0000000000000204",
433 "type": "UiEdgeLink",
434 "portB": "6"
435 }
436 ]
437 },
438 {
439 "id": "00:BB:00:00:00:03/None~of:0000000000000205/8",
440 "epA": "00:BB:00:00:00:03/None",
441 "epB": "of:0000000000000205",
442 "type": "UiEdgeLink",
443 "portB": "8",
444 "rollup": [
445 {
446 "id": "00:BB:00:00:00:03/None~of:0000000000000205/8",
447 "epA": "00:BB:00:00:00:03/None",
448 "epB": "of:0000000000000205",
449 "type": "UiEdgeLink",
450 "portB": "8"
451 }
452 ]
453 },
454 {
455 "id": "of:0000000000000206/4~of:0000000000000227/8",
456 "epA": "of:0000000000000206/4",
457 "epB": "of:0000000000000227/8",
458 "type": "UiDeviceLink",
459 "portA": "4",
460 "portB": "8",
461 "rollup": [
462 {
463 "id": "of:0000000000000206/4~of:0000000000000227/8",
464 "epA": "of:0000000000000206/4",
465 "epB": "of:0000000000000227/8",
466 "type": "UiDeviceLink",
467 "portA": "4",
468 "portB": "8"
469 }
470 ]
471 },
472 {
473 "id": "00:AA:00:00:00:05/None~of:0000000000000203/6",
474 "epA": "00:AA:00:00:00:05/None",
475 "epB": "of:0000000000000203",
476 "type": "UiEdgeLink",
477 "portB": "6",
478 "rollup": [
479 {
480 "id": "00:AA:00:00:00:05/None~of:0000000000000203/6",
481 "epA": "00:AA:00:00:00:05/None",
482 "epB": "of:0000000000000203",
483 "type": "UiEdgeLink",
484 "portB": "6"
485 }
486 ]
487 },
488 {
489 "id": "of:0000000000000205/5~of:0000000000000206/5",
490 "epA": "of:0000000000000205/5",
491 "epB": "of:0000000000000206/5",
492 "type": "UiDeviceLink",
493 "portA": "5",
494 "portB": "5",
495 "rollup": [
496 {
497 "id": "of:0000000000000205/5~of:0000000000000206/5",
498 "epA": "of:0000000000000205/5",
499 "epB": "of:0000000000000206/5",
500 "type": "UiDeviceLink",
501 "portA": "5",
502 "portB": "5"
503 }
504 ]
505 },
506 {
507 "id": "00:BB:00:00:00:02/None~of:0000000000000204/9",
508 "epA": "00:BB:00:00:00:02/None",
509 "epB": "of:0000000000000204",
510 "type": "UiEdgeLink",
511 "portB": "9",
512 "rollup": [
513 {
514 "id": "00:BB:00:00:00:02/None~of:0000000000000204/9",
515 "epA": "00:BB:00:00:00:02/None",
516 "epB": "of:0000000000000204",
517 "type": "UiEdgeLink",
518 "portB": "9"
519 }
520 ]
521 },
522 {
523 "id": "of:0000000000000204/3~of:0000000000000227/3",
524 "epA": "of:0000000000000204/3",
525 "epB": "of:0000000000000227/3",
526 "type": "UiDeviceLink",
527 "portA": "3",
528 "portB": "3",
529 "rollup": [
530 {
531 "id": "of:0000000000000204/3~of:0000000000000227/3",
532 "epA": "of:0000000000000204/3",
533 "epB": "of:0000000000000227/3",
534 "type": "UiDeviceLink",
535 "portA": "3",
536 "portB": "3"
537 }
538 ]
539 },
540 {
541 "id": "00:EE:00:00:00:01/None~of:0000000000000207/4",
542 "epA": "00:EE:00:00:00:01/None",
543 "epB": "of:0000000000000207",
544 "type": "UiEdgeLink",
545 "portB": "4",
546 "rollup": [
547 {
548 "id": "00:EE:00:00:00:01/None~of:0000000000000207/4",
549 "epA": "00:EE:00:00:00:01/None",
550 "epB": "of:0000000000000207",
551 "type": "UiEdgeLink",
552 "portB": "4"
553 }
554 ]
555 },
556 {
557 "id": "of:0000000000000203/4~of:0000000000000227/2",
558 "epA": "of:0000000000000203/4",
559 "epB": "of:0000000000000227/2",
560 "type": "UiDeviceLink",
561 "portA": "4",
562 "portB": "2",
563 "rollup": [
564 {
565 "id": "of:0000000000000203/4~of:0000000000000227/2",
566 "epA": "of:0000000000000203/4",
567 "epB": "of:0000000000000227/2",
568 "type": "UiDeviceLink",
569 "portA": "4",
570 "portB": "2"
571 }
572 ]
573 },
574 {
575 "id": "of:0000000000000205/2~of:0000000000000226/6",
576 "epA": "of:0000000000000205/2",
577 "epB": "of:0000000000000226/6",
578 "type": "UiDeviceLink",
579 "portA": "2",
580 "portB": "6",
581 "rollup": [
582 {
583 "id": "of:0000000000000205/2~of:0000000000000226/6",
584 "epA": "of:0000000000000205/2",
585 "epB": "of:0000000000000226/6",
586 "type": "UiDeviceLink",
587 "portA": "2",
588 "portB": "6"
589 }
590 ]
591 },
592 {
593 "id": "00:99:00:00:00:01/None~of:0000000000000205/10",
594 "epA": "00:99:00:00:00:01/None",
595 "epB": "of:0000000000000205",
596 "type": "UiEdgeLink",
597 "portB": "10",
598 "rollup": [
599 {
600 "id": "00:99:00:00:00:01/None~of:0000000000000205/10",
601 "epA": "00:99:00:00:00:01/None",
602 "epB": "of:0000000000000205",
603 "type": "UiEdgeLink",
604 "portB": "10"
605 }
606 ]
607 },
608 {
609 "id": "of:0000000000000205/4~of:0000000000000227/6",
610 "epA": "of:0000000000000205/4",
611 "epB": "of:0000000000000227/6",
612 "type": "UiDeviceLink",
613 "portA": "4",
614 "portB": "6",
615 "rollup": [
616 {
617 "id": "of:0000000000000205/4~of:0000000000000227/6",
618 "epA": "of:0000000000000205/4",
619 "epB": "of:0000000000000227/6",
620 "type": "UiDeviceLink",
621 "portA": "4",
622 "portB": "6"
623 }
624 ]
625 },
626 {
627 "id": "of:0000000000000206/3~of:0000000000000227/7",
628 "epA": "of:0000000000000206/3",
629 "epB": "of:0000000000000227/7",
630 "type": "UiDeviceLink",
631 "portA": "3",
632 "portB": "7",
633 "rollup": [
634 {
635 "id": "of:0000000000000206/3~of:0000000000000227/7",
636 "epA": "of:0000000000000206/3",
637 "epB": "of:0000000000000227/7",
638 "type": "UiDeviceLink",
639 "portA": "3",
640 "portB": "7"
641 }
642 ]
643 },
644 {
645 "id": "00:BB:00:00:00:04/None~of:0000000000000205/9",
646 "epA": "00:BB:00:00:00:04/None",
647 "epB": "of:0000000000000205",
648 "type": "UiEdgeLink",
649 "portB": "9",
650 "rollup": [
651 {
652 "id": "00:BB:00:00:00:04/None~of:0000000000000205/9",
653 "epA": "00:BB:00:00:00:04/None",
654 "epB": "of:0000000000000205",
655 "type": "UiEdgeLink",
656 "portB": "9"
657 }
658 ]
659 },
660 {
661 "id": "00:AA:00:00:00:02/None~of:0000000000000204/7",
662 "epA": "00:AA:00:00:00:02/None",
663 "epB": "of:0000000000000204",
664 "type": "UiEdgeLink",
665 "portB": "7",
666 "rollup": [
667 {
668 "id": "00:AA:00:00:00:02/None~of:0000000000000204/7",
669 "epA": "00:AA:00:00:00:02/None",
670 "epB": "of:0000000000000204",
671 "type": "UiEdgeLink",
672 "portB": "7"
673 }
674 ]
675 },
676 {
677 "id": "00:BB:00:00:00:01/None~of:0000000000000204/8",
678 "epA": "00:BB:00:00:00:01/None",
679 "epB": "of:0000000000000204",
680 "type": "UiEdgeLink",
681 "portB": "8",
682 "rollup": [
683 {
684 "id": "00:BB:00:00:00:01/None~of:0000000000000204/8",
685 "epA": "00:BB:00:00:00:01/None",
686 "epB": "of:0000000000000204",
687 "type": "UiEdgeLink",
688 "portB": "8"
689 }
690 ]
691 },
692 {
693 "id": "of:0000000000000207/1~of:0000000000000246/1",
694 "epA": "of:0000000000000207/1",
695 "epB": "of:0000000000000246/1",
696 "type": "UiDeviceLink",
697 "portA": "1",
698 "portB": "1",
699 "rollup": [
700 {
701 "id": "of:0000000000000207/1~of:0000000000000246/1",
702 "epA": "of:0000000000000207/1",
703 "epB": "of:0000000000000246/1",
704 "type": "UiDeviceLink",
705 "portA": "1",
706 "portB": "1"
707 }
708 ]
709 },
710 {
711 "id": "00:88:00:00:00:02/None~of:0000000000000206/7",
712 "epA": "00:88:00:00:00:02/None",
713 "epB": "of:0000000000000206",
714 "type": "UiEdgeLink",
715 "portB": "7",
716 "rollup": [
717 {
718 "id": "00:88:00:00:00:02/None~of:0000000000000206/7",
719 "epA": "00:88:00:00:00:02/None",
720 "epB": "of:0000000000000206",
721 "type": "UiEdgeLink",
722 "portB": "7"
723 }
724 ]
725 },
726 {
727 "id": "00:EE:00:00:00:02/None~of:0000000000000208/4",
728 "epA": "00:EE:00:00:00:02/None",
729 "epB": "of:0000000000000208",
730 "type": "UiEdgeLink",
731 "portB": "4",
732 "rollup": [
733 {
734 "id": "00:EE:00:00:00:02/None~of:0000000000000208/4",
735 "epA": "00:EE:00:00:00:02/None",
736 "epB": "of:0000000000000208",
737 "type": "UiEdgeLink",
738 "portB": "4"
739 }
740 ]
741 },
742 {
743 "id": "of:0000000000000204/4~of:0000000000000227/4",
744 "epA": "of:0000000000000204/4",
745 "epB": "of:0000000000000227/4",
746 "type": "UiDeviceLink",
747 "portA": "4",
748 "portB": "4",
749 "rollup": [
750 {
751 "id": "of:0000000000000204/4~of:0000000000000227/4",
752 "epA": "of:0000000000000204/4",
753 "epB": "of:0000000000000227/4",
754 "type": "UiDeviceLink",
755 "portA": "4",
756 "portB": "4"
757 }
758 ]
759 },
760 {
761 "id": "of:0000000000000203/5~of:0000000000000204/5",
762 "epA": "of:0000000000000203/5",
763 "epB": "of:0000000000000204/5",
764 "type": "UiDeviceLink",
765 "portA": "5",
766 "portB": "5",
767 "rollup": [
768 {
769 "id": "of:0000000000000203/5~of:0000000000000204/5",
770 "epA": "of:0000000000000203/5",
771 "epB": "of:0000000000000204/5",
772 "type": "UiDeviceLink",
773 "portA": "5",
774 "portB": "5"
775 }
776 ]
777 },
778 {
779 "id": "of:0000000000000227/9~of:0000000000000247/3",
780 "epA": "of:0000000000000227/9",
781 "epB": "of:0000000000000247/3",
782 "type": "UiDeviceLink",
783 "portA": "9",
784 "portB": "3",
785 "rollup": [
786 {
787 "id": "of:0000000000000227/9~of:0000000000000247/3",
788 "epA": "of:0000000000000227/9",
789 "epB": "of:0000000000000247/3",
790 "type": "UiDeviceLink",
791 "portA": "9",
792 "portB": "3"
793 }
794 ]
795 }
796 ],
797 "devices": [
798 [],
799 [],
800 [
801 {
802 "id": "of:0000000000000246",
803 "nodeType": "device",
804 "type": "switch",
805 "online": true,
806 "master": "10.192.19.68",
807 "layer": "def",
808 "props": {
809 "managementAddress": "10.192.19.69",
810 "protocol": "OF_13",
811 "driver": "ofdpa-ovs",
812 "latitude": "40.15",
813 "name": "s246",
814 "locType": "geo",
815 "channelId": "10.192.19.69:59980",
816 "longitude": "-121.679"
817 },
818 "location": {
819 "locType": "geo",
820 "latOrY": 40.15,
821 "longOrX": -121.679
822 }
823 },
824 {
825 "id": "of:0000000000000206",
826 "nodeType": "device",
827 "type": "switch",
828 "online": true,
829 "master": "10.192.19.68",
830 "layer": "def",
831 "props": {
832 "managementAddress": "10.192.19.69",
833 "protocol": "OF_13",
834 "driver": "ofdpa-ovs",
835 "latitude": "36.766",
836 "name": "s206",
837 "locType": "geo",
838 "channelId": "10.192.19.69:59975",
839 "longitude": "-92.029"
840 },
841 "location": {
842 "locType": "geo",
843 "latOrY": 36.766,
844 "longOrX": -92.029
845 }
846 },
847 {
848 "id": "of:0000000000000227",
849 "nodeType": "device",
850 "type": "switch",
851 "online": true,
852 "master": "10.192.19.68",
853 "layer": "def",
854 "props": {
855 "managementAddress": "10.192.19.69",
856 "protocol": "OF_13",
857 "driver": "ofdpa-ovs",
858 "latitude": "44.205",
859 "name": "s227",
860 "locType": "geo",
861 "channelId": "10.192.19.69:59979",
862 "longitude": "-96.359"
863 },
864 "location": {
865 "locType": "geo",
866 "latOrY": 44.205,
867 "longOrX": -96.359
868 }
869 },
870 {
871 "id": "of:0000000000000208",
872 "nodeType": "device",
873 "type": "switch",
874 "online": true,
875 "master": "10.192.19.68",
876 "layer": "def",
877 "props": {
878 "managementAddress": "10.192.19.69",
879 "protocol": "OF_13",
880 "driver": "ofdpa-ovs",
881 "latitude": "36.766",
882 "name": "s208",
883 "locType": "geo",
884 "channelId": "10.192.19.69:59977",
885 "longitude": "-116.029"
886 },
887 "location": {
888 "locType": "geo",
889 "latOrY": 36.766,
890 "longOrX": -116.029
891 }
892 },
893 {
894 "id": "of:0000000000000205",
895 "nodeType": "device",
896 "type": "switch",
897 "online": true,
898 "master": "10.192.19.68",
899 "layer": "def",
900 "props": {
901 "managementAddress": "10.192.19.69",
902 "protocol": "OF_13",
903 "driver": "ofdpa-ovs",
904 "latitude": "36.766",
905 "name": "s205",
906 "locType": "geo",
907 "channelId": "10.192.19.69:59974",
908 "longitude": "-96.89"
909 },
910 "location": {
911 "locType": "geo",
912 "latOrY": 36.766,
913 "longOrX": -96.89
914 }
915 },
916 {
917 "id": "of:0000000000000247",
918 "nodeType": "device",
919 "type": "switch",
920 "online": true,
921 "master": "10.192.19.68",
922 "layer": "def",
923 "props": {
924 "managementAddress": "10.192.19.69",
925 "protocol": "OF_13",
926 "driver": "ofdpa-ovs",
927 "latitude": "40.205",
928 "name": "s247",
929 "locType": "geo",
930 "channelId": "10.192.19.69:59981",
931 "longitude": "-117.359"
932 },
933 "location": {
934 "locType": "geo",
935 "latOrY": 40.205,
936 "longOrX": -117.359
937 }
938 },
939 {
940 "id": "of:0000000000000226",
941 "nodeType": "device",
942 "type": "switch",
943 "online": true,
944 "master": "10.192.19.68",
945 "layer": "def",
946 "props": {
947 "managementAddress": "10.192.19.69",
948 "protocol": "OF_13",
949 "driver": "ofdpa-ovs",
950 "latitude": "44.15",
951 "name": "s226",
952 "locType": "geo",
953 "channelId": "10.192.19.69:59978",
954 "longitude": "-107.679"
955 },
956 "location": {
957 "locType": "geo",
958 "latOrY": 44.15,
959 "longOrX": -107.679
960 }
961 },
962 {
963 "id": "of:0000000000000203",
964 "nodeType": "device",
965 "type": "switch",
966 "online": true,
967 "master": "10.192.19.68",
968 "layer": "def",
969 "props": {
970 "managementAddress": "10.192.19.69",
971 "protocol": "OF_13",
972 "driver": "ofdpa-ovs",
973 "latitude": "36.766",
974 "name": "s203",
975 "locType": "geo",
976 "channelId": "10.192.19.69:59972",
977 "longitude": "-111.359"
978 },
979 "location": {
980 "locType": "geo",
981 "latOrY": 36.766,
982 "longOrX": -111.359
983 }
984 },
985 {
986 "id": "of:0000000000000204",
987 "nodeType": "device",
988 "type": "switch",
989 "online": true,
990 "master": "10.192.19.68",
991 "layer": "def",
992 "props": {
993 "managementAddress": "10.192.19.69",
994 "protocol": "OF_13",
995 "driver": "ofdpa-ovs",
996 "latitude": "36.766",
997 "name": "s204",
998 "locType": "geo",
999 "channelId": "10.192.19.69:59973",
1000 "longitude": "-106.359"
1001 },
1002 "location": {
1003 "locType": "geo",
1004 "latOrY": 36.766,
1005 "longOrX": -106.359
1006 }
1007 },
1008 {
1009 "id": "of:0000000000000207",
1010 "nodeType": "device",
1011 "type": "switch",
1012 "online": true,
1013 "master": "10.192.19.68",
1014 "layer": "def",
1015 "props": {
1016 "managementAddress": "10.192.19.69",
1017 "protocol": "OF_13",
1018 "driver": "ofdpa-ovs",
1019 "latitude": "36.766",
1020 "name": "s207",
1021 "locType": "geo",
1022 "channelId": "10.192.19.69:59976",
1023 "longitude": "-122.359"
1024 },
1025 "location": {
1026 "locType": "geo",
1027 "latOrY": 36.766,
1028 "longOrX": -122.359
1029 }
1030 }
1031 ]
1032 ],
1033 "hosts": [
1034 [],
1035 [],
1036 [
1037 {
1038 "id": "00:88:00:00:00:03/110",
1039 "nodeType": "host",
1040 "layer": "def",
1041 "ips": [
1042 "fe80::288:ff:fe00:3",
1043 "2000::102",
1044 "10.0.1.2"
1045 ],
1046 "props": {},
1047 "configured": false
1048 },
1049 {
1050 "id": "00:DD:00:00:00:01/None",
1051 "nodeType": "host",
1052 "layer": "def",
1053 "ips": [],
1054 "props": {},
1055 "configured": false
1056 },
1057 {
1058 "id": "00:88:00:00:00:04/160",
1059 "nodeType": "host",
1060 "layer": "def",
1061 "ips": [
1062 "fe80::288:ff:fe00:4",
1063 "10.0.6.2",
1064 "2000::602"
1065 ],
1066 "props": {},
1067 "configured": false
1068 },
1069 {
1070 "id": "00:BB:00:00:00:02/None",
1071 "nodeType": "host",
1072 "layer": "def",
1073 "ips": [
1074 "fe80::2bb:ff:fe00:2"
1075 ],
1076 "props": {},
1077 "configured": false
1078 },
1079 {
1080 "id": "00:AA:00:00:00:05/None",
1081 "nodeType": "host",
1082 "layer": "def",
1083 "ips": [],
1084 "props": {},
1085 "configured": false
1086 },
1087 {
1088 "id": "00:88:00:00:00:01/None",
1089 "nodeType": "host",
1090 "layer": "def",
1091 "ips": [
1092 "fe80::288:ff:fe00:1",
1093 "2000::101",
1094 "10.0.1.1"
1095 ],
1096 "props": {},
1097 "configured": false
1098 },
1099 {
1100 "id": "00:AA:00:00:00:01/None",
1101 "nodeType": "host",
1102 "layer": "def",
1103 "ips": [],
1104 "props": {},
1105 "configured": false
1106 },
1107 {
1108 "id": "00:AA:00:00:00:03/None",
1109 "nodeType": "host",
1110 "layer": "def",
1111 "ips": [],
1112 "props": {},
1113 "configured": false
1114 },
1115 {
1116 "id": "00:BB:00:00:00:04/None",
1117 "nodeType": "host",
1118 "layer": "def",
1119 "ips": [
1120 "fe80::2bb:ff:fe00:4"
1121 ],
1122 "props": {},
1123 "configured": false
1124 },
1125 {
1126 "id": "00:EE:00:00:00:02/None",
1127 "nodeType": "host",
1128 "layer": "def",
1129 "ips": [
1130 "fe80::2ee:ff:fe00:2"
1131 ],
1132 "props": {},
1133 "configured": false
1134 },
1135 {
1136 "id": "00:99:00:00:00:01/None",
1137 "nodeType": "host",
1138 "layer": "def",
1139 "ips": [
1140 "10.0.3.253",
1141 "fe80::299:ff:fe00:1"
1142 ],
1143 "props": {},
1144 "configured": false
1145 },
1146 {
1147 "id": "00:99:66:00:00:01/None",
1148 "nodeType": "host",
1149 "layer": "def",
1150 "ips": [
1151 "fe80::299:66ff:fe00:1",
1152 "2000::3fd"
1153 ],
1154 "props": {},
1155 "configured": false
1156 },
1157 {
1158 "id": "00:EE:00:00:00:01/None",
1159 "nodeType": "host",
1160 "layer": "def",
1161 "ips": [
1162 "fe80::2ee:ff:fe00:1"
1163 ],
1164 "props": {},
1165 "configured": false
1166 },
1167 {
1168 "id": "00:BB:00:00:00:01/None",
1169 "nodeType": "host",
1170 "layer": "def",
1171 "ips": [
1172 "fe80::2bb:ff:fe00:1"
1173 ],
1174 "props": {},
1175 "configured": false
1176 },
1177 {
1178 "id": "00:BB:00:00:00:03/None",
1179 "nodeType": "host",
1180 "layer": "def",
1181 "ips": [
1182 "fe80::2bb:ff:fe00:3"
1183 ],
1184 "props": {},
1185 "configured": false
1186 },
1187 {
1188 "id": "00:AA:00:00:00:04/None",
1189 "nodeType": "host",
1190 "layer": "def",
1191 "ips": [],
1192 "props": {},
1193 "configured": false
1194 },
1195 {
1196 "id": "00:BB:00:00:00:05/None",
1197 "nodeType": "host",
1198 "layer": "def",
1199 "ips": [
1200 "fe80::2bb:ff:fe00:5"
1201 ],
1202 "props": {},
1203 "configured": false
1204 },
1205 {
1206 "id": "00:88:00:00:00:02/None",
1207 "nodeType": "host",
1208 "layer": "def",
1209 "ips": [
1210 "fe80::288:ff:fe00:2",
1211 "2000::601",
1212 "10.0.6.1"
1213 ],
1214 "props": {},
1215 "configured": false
1216 },
1217 {
1218 "id": "00:AA:00:00:00:02/None",
1219 "nodeType": "host",
1220 "layer": "def",
1221 "ips": [],
1222 "props": {},
1223 "configured": false
1224 },
1225 {
1226 "id": "00:DD:00:00:00:02/None",
1227 "nodeType": "host",
1228 "layer": "def",
1229 "ips": [],
1230 "props": {},
1231 "configured": false
1232 }
1233 ]
1234 ],
1235 "layerOrder": [
1236 "opt",
1237 "pkt",
1238 "def"
1239 ]
1240 }
1241}`;
1242
1243const test_OdtnConfig_topo2CurrentRegion = `{
1244 "event": "topo2CurrentRegion",
1245 "payload": {
1246 "id": "(root)",
1247 "subregions": [],
1248 "links": [
1249 {
1250 "id": "netconf:127.0.0.1:11002/201~netconf:127.0.0.1:11003/201",
1251 "epA": "netconf:127.0.0.1:11002/201",
1252 "epB": "netconf:127.0.0.1:11003/201",
1253 "type": "UiDeviceLink",
1254 "portA": "201",
1255 "portB": "201",
1256 "rollup": [
1257 {
1258 "id": "netconf:127.0.0.1:11002/201~netconf:127.0.0.1:11003/201",
1259 "epA": "netconf:127.0.0.1:11002/201",
1260 "epB": "netconf:127.0.0.1:11003/201",
1261 "type": "UiDeviceLink",
1262 "portA": "201",
1263 "portB": "201"
1264 }
1265 ]
1266 },
1267 {
1268 "id": "netconf:127.0.0.1:11002/202~netconf:127.0.0.1:11003/202",
1269 "epA": "netconf:127.0.0.1:11002/202",
1270 "epB": "netconf:127.0.0.1:11003/202",
1271 "type": "UiDeviceLink",
1272 "portA": "202",
1273 "portB": "202",
1274 "rollup": [
1275 {
1276 "id": "netconf:127.0.0.1:11002/202~netconf:127.0.0.1:11003/202",
1277 "epA": "netconf:127.0.0.1:11002/202",
1278 "epB": "netconf:127.0.0.1:11003/202",
1279 "type": "UiDeviceLink",
1280 "portA": "202",
1281 "portB": "202"
1282 }
1283 ]
1284 },
1285 {
1286 "id": "netconf:127.0.0.1:11002/203~netconf:127.0.0.1:11003/203",
1287 "epA": "netconf:127.0.0.1:11002/203",
1288 "epB": "netconf:127.0.0.1:11003/203",
1289 "type": "UiDeviceLink",
1290 "portA": "203",
1291 "portB": "203",
1292 "rollup": [
1293 {
1294 "id": "netconf:127.0.0.1:11002/203~netconf:127.0.0.1:11003/203",
1295 "epA": "netconf:127.0.0.1:11002/203",
1296 "epB": "netconf:127.0.0.1:11003/203",
1297 "type": "UiDeviceLink",
1298 "portA": "203",
1299 "portB": "203"
1300 }
1301 ]
1302 },
1303 {
1304 "id": "netconf:127.0.0.1:11002/204~netconf:127.0.0.1:11003/204",
1305 "epA": "netconf:127.0.0.1:11002/204",
1306 "epB": "netconf:127.0.0.1:11003/204",
1307 "type": "UiDeviceLink",
1308 "portA": "204",
1309 "portB": "204",
1310 "rollup": [
1311 {
1312 "id": "netconf:127.0.0.1:11002/204~netconf:127.0.0.1:11003/204",
1313 "epA": "netconf:127.0.0.1:11002/204",
1314 "epB": "netconf:127.0.0.1:11003/204",
1315 "type": "UiDeviceLink",
1316 "portA": "204",
1317 "portB": "204"
1318 }
1319 ]
1320 },
1321 {
1322 "id": "netconf:127.0.0.1:11002/205~netconf:127.0.0.1:11003/205",
1323 "epA": "netconf:127.0.0.1:11002/205",
1324 "epB": "netconf:127.0.0.1:11003/205",
1325 "type": "UiDeviceLink",
1326 "portA": "205",
1327 "portB": "205",
1328 "rollup": [
1329 {
1330 "id": "netconf:127.0.0.1:11002/205~netconf:127.0.0.1:11003/205",
1331 "epA": "netconf:127.0.0.1:11002/205",
1332 "epB": "netconf:127.0.0.1:11003/205",
1333 "type": "UiDeviceLink",
1334 "portA": "205",
1335 "portB": "205"
1336 }
1337 ]
1338 },
1339 {
1340 "id": "netconf:127.0.0.1:11002/206~netconf:127.0.0.1:11003/206",
1341 "epA": "netconf:127.0.0.1:11002/206",
1342 "epB": "netconf:127.0.0.1:11003/206",
1343 "type": "UiDeviceLink",
1344 "portA": "206",
1345 "portB": "206",
1346 "rollup": [
1347 {
1348 "id": "netconf:127.0.0.1:11002/206~netconf:127.0.0.1:11003/206",
1349 "epA": "netconf:127.0.0.1:11002/206",
1350 "epB": "netconf:127.0.0.1:11003/206",
1351 "type": "UiDeviceLink",
1352 "portA": "206",
1353 "portB": "206"
1354 }
1355 ]
1356 }
1357 ],
1358 "devices": [
1359 [],
1360 [],
1361 [
1362 {
1363 "id": "netconf:127.0.0.1:11002",
1364 "nodeType": "device",
1365 "type": "terminal_device",
1366 "online": true,
1367 "master": "127.0.0.1",
1368 "layer": "def",
1369 "props": {
1370 "ipaddress": "127.0.0.1",
1371 "protocol": "NETCONF",
1372 "driver": "cassini-ocnos",
1373 "port": "11002",
1374 "name": "cassini2",
1375 "locType": "none"
1376 }
1377 },
1378 {
1379 "id": "netconf:127.0.0.1:11003",
1380 "nodeType": "device",
1381 "type": "terminal_device",
1382 "online": true,
1383 "master": "127.0.0.1",
1384 "layer": "def",
1385 "props": {
1386 "ipaddress": "127.0.0.1",
1387 "protocol": "NETCONF",
1388 "driver": "cassini-ocnos",
1389 "port": "11003",
1390 "name": "cassini1",
1391 "locType": "none"
1392 }
1393 }
1394 ]
1395 ],
1396 "hosts": [
1397 [],
1398 [],
1399 []
1400 ],
1401 "layerOrder": [
1402 "opt",
1403 "pkt",
1404 "def"
1405 ]
1406 }
1407}`;
1408
1409const topo2Highlights_base_data = `{
1410 "event": "topo2CurrentRegion",
1411 "payload": {
1412 "id": "(root)",
1413 "subregions": [],
1414 "links": [
1415 {
pierventre57f7bbb2021-10-20 17:37:52 +02001416 "id": "00:00:00:00:00:22/120~device:leaf4/[3/0](3)",
1417 "epA": "00:00:00:00:00:22/120",
1418 "epB": "device:leaf4",
1419 "type": "UiEdgeLink",
1420 "portB": "[3/0](3)",
1421 "rollup": [
1422 {
1423 "id": "00:00:00:00:00:22/120~device:leaf4/[3/0](3)",
1424 "epA": "00:00:00:00:00:22/120",
1425 "epB": "device:leaf4",
1426 "type": "UiEdgeLink",
1427 "portB": "[3/0](3)"
1428 }
1429 ]
1430 },
1431 {
1432 "id": "00:00:00:00:00:1E/None~device:leaf4/[2/0](2)",
1433 "epA": "00:00:00:00:00:1E/None",
1434 "epB": "device:leaf4",
1435 "type": "UiEdgeLink",
1436 "portB": "[2/0](2)",
1437 "rollup": [
1438 {
1439 "id": "00:00:00:00:00:1E/None~device:leaf4/[2/0](2)",
1440 "epA": "00:00:00:00:00:1E/None",
1441 "epB": "device:leaf4",
1442 "type": "UiEdgeLink",
1443 "portB": "[2/0](2)"
1444 }
1445 ]
1446 },
1447 {
1448 "id": "device:leaf4/[1/0](1)~device:spine1/[3/0](3)",
1449 "epA": "device:leaf4/[1/0](1)",
1450 "epB": "device:spine1/[3/0](3)",
1451 "type": "UiDeviceLink",
1452 "portA": "[1/0](1)",
1453 "portB": "[3/0](3)",
1454 "rollup": [
1455 {
1456 "id": "device:leaf4/[1/0](1)~device:spine1/[3/0](3)",
1457 "epA": "device:leaf4/[1/0](1)",
1458 "epB": "device:spine1/[3/0](3)",
1459 "type": "UiDeviceLink",
1460 "portA": "[1/0](1)",
1461 "portB": "[3/0](3)"
1462 }
1463 ]
1464 },
1465 {
1466 "id": "00:00:00:00:00:21/120~device:leaf3/[leaf3-eth3](3)",
1467 "epA": "00:00:00:00:00:21/120",
1468 "epB": "device:leaf3",
1469 "type": "UiEdgeLink",
1470 "portB": "[leaf3-eth3](3)",
1471 "rollup": [
1472 {
1473 "id": "00:00:00:00:00:21/120~device:leaf3/[leaf3-eth3](3)",
1474 "epA": "00:00:00:00:00:21/120",
1475 "epB": "device:leaf3",
1476 "type": "UiEdgeLink",
1477 "portB": "[leaf3-eth3](3)"
1478 }
1479 ]
1480 },
1481 {
1482 "id": "00:00:00:00:00:1D/None~device:leaf3/[leaf3-eth2](2)",
1483 "epA": "00:00:00:00:00:1D/None",
1484 "epB": "device:leaf3",
1485 "type": "UiEdgeLink",
1486 "portB": "[leaf3-eth2](2)",
1487 "rollup": [
1488 {
1489 "id": "00:00:00:00:00:1D/None~device:leaf3/[leaf3-eth2](2)",
1490 "epA": "00:00:00:00:00:1D/None",
1491 "epB": "device:leaf3",
1492 "type": "UiEdgeLink",
1493 "portB": "[leaf3-eth2](2)"
1494 }
1495 ]
1496 },
1497 {
1498 "id": "device:leaf3/[leaf3-eth1](1)~device:spine1/[spine1-eth3](3)",
1499 "epA": "device:leaf3/[leaf3-eth1](1)",
1500 "epB": "device:spine1/[spine1-eth3](3)",
1501 "type": "UiDeviceLink",
1502 "portA": "[leaf3-eth1](1)",
1503 "portB": "[spine1-eth3](3)",
1504 "rollup": [
1505 {
1506 "id": "device:leaf3/[leaf3-eth1](1)~device:spine1/[spine1-eth3](3)",
1507 "epA": "device:leaf3/[leaf3-eth1](1)",
1508 "epB": "device:spine1/[spine1-eth3](3)",
1509 "type": "UiDeviceLink",
1510 "portA": "[leaf3-eth1](1)",
1511 "portB": "[spine1-eth3](3)"
1512 }
1513 ]
1514 },
1515 {
1516 "id": "00:00:00:00:00:1F/120~device:leaf1/7",
1517 "epA": "00:00:00:00:00:1F/120",
1518 "epB": "device:leaf1",
1519 "type": "UiEdgeLink",
1520 "portB": "7",
1521 "rollup": [
1522 {
1523 "id": "00:00:00:00:00:1F/120~device:leaf1/7",
1524 "epA": "00:00:00:00:00:1F/120",
1525 "epB": "device:leaf1",
1526 "type": "UiEdgeLink",
1527 "portB": "7"
1528 }
1529 ]
1530 },
1531 {
Sean Condon4ceeae72021-10-21 15:37:11 +01001532 "id": "device:leaf1/1~device:spine1/1",
1533 "epA": "device:leaf1/1",
1534 "epB": "device:spine1/1",
1535 "type": "UiDeviceLink",
1536 "portA": "1",
1537 "portB": "1",
1538 "rollup": [
1539 {
1540 "id": "device:leaf1/1~device:spine1/1",
1541 "epA": "device:leaf1/1",
1542 "epB": "device:spine1/1",
1543 "type": "UiDeviceLink",
1544 "portA": "1",
1545 "portB": "1"
1546 }
1547 ]
1548 },
1549 {
1550 "id": "device:leaf2/2~device:spine2/2",
1551 "epA": "device:leaf2/2",
1552 "epB": "device:spine2/2",
1553 "type": "UiDeviceLink",
1554 "portA": "2",
1555 "portB": "2",
1556 "rollup": [
1557 {
1558 "id": "device:leaf2/2~device:spine2/2",
1559 "epA": "device:leaf2/2",
1560 "epB": "device:spine2/2",
1561 "type": "UiDeviceLink",
1562 "portA": "2",
1563 "portB": "2"
1564 }
1565 ]
1566 },
1567 {
1568 "id": "00:00:00:00:00:1A/None~device:leaf1/3",
1569 "epA": "00:00:00:00:00:1A/None",
1570 "epB": "device:leaf1",
1571 "type": "UiEdgeLink",
1572 "portB": "3",
1573 "rollup": [
1574 {
1575 "id": "00:00:00:00:00:1A/None~device:leaf1/3",
1576 "epA": "00:00:00:00:00:1A/None",
1577 "epB": "device:leaf1",
1578 "type": "UiEdgeLink",
1579 "portB": "3"
1580 }
1581 ]
1582 },
1583 {
1584 "id": "00:00:00:00:00:30/None~device:leaf2/3",
1585 "epA": "00:00:00:00:00:30/None",
1586 "epB": "device:leaf2",
1587 "type": "UiEdgeLink",
1588 "portB": "3",
1589 "rollup": [
1590 {
1591 "id": "00:00:00:00:00:30/None~device:leaf2/3",
1592 "epA": "00:00:00:00:00:30/None",
1593 "epB": "device:leaf2",
1594 "type": "UiEdgeLink",
1595 "portB": "3"
1596 }
1597 ]
1598 },
1599 {
1600 "id": "device:leaf1/2~device:spine2/1",
1601 "epA": "device:leaf1/2",
1602 "epB": "device:spine2/1",
1603 "type": "UiDeviceLink",
1604 "portA": "2",
1605 "portB": "1",
1606 "rollup": [
1607 {
1608 "id": "device:leaf1/2~device:spine2/1",
1609 "epA": "device:leaf1/2",
1610 "epB": "device:spine2/1",
1611 "type": "UiDeviceLink",
1612 "portA": "2",
1613 "portB": "1"
1614 }
1615 ]
1616 },
1617 {
1618 "id": "device:leaf2/1~device:spine1/2",
1619 "epA": "device:leaf2/1",
1620 "epB": "device:spine1/2",
1621 "type": "UiDeviceLink",
1622 "portA": "1",
1623 "portB": "2",
1624 "rollup": [
1625 {
1626 "id": "device:leaf2/1~device:spine1/2",
1627 "epA": "device:leaf2/1",
1628 "epB": "device:spine1/2",
1629 "type": "UiDeviceLink",
1630 "portA": "1",
1631 "portB": "2"
1632 }
1633 ]
1634 },
1635 {
1636 "id": "00:00:00:00:00:20/None~device:leaf1/6",
1637 "epA": "00:00:00:00:00:20/None",
1638 "epB": "device:leaf1",
1639 "type": "UiEdgeLink",
1640 "portB": "6",
1641 "rollup": [
1642 {
1643 "id": "00:00:00:00:00:20/None~device:leaf1/6",
1644 "epA": "00:00:00:00:00:20/None",
1645 "epB": "device:leaf1",
1646 "type": "UiEdgeLink",
1647 "portB": "6"
1648 }
1649 ]
1650 },
1651 {
1652 "id": "00:00:00:00:00:1C/None~device:leaf1/5",
1653 "epA": "00:00:00:00:00:1C/None",
1654 "epB": "device:leaf1",
1655 "type": "UiEdgeLink",
1656 "portB": "5",
1657 "rollup": [
1658 {
1659 "id": "00:00:00:00:00:1C/None~device:leaf1/5",
1660 "epA": "00:00:00:00:00:1C/None",
1661 "epB": "device:leaf1",
1662 "type": "UiEdgeLink",
1663 "portB": "5"
1664 }
1665 ]
1666 },
1667 {
1668 "id": "00:00:00:00:00:1B/None~device:leaf1/4",
1669 "epA": "00:00:00:00:00:1B/None",
1670 "epB": "device:leaf1",
1671 "type": "UiEdgeLink",
1672 "portB": "4",
1673 "rollup": [
1674 {
1675 "id": "00:00:00:00:00:1B/None~device:leaf1/4",
1676 "epA": "00:00:00:00:00:1B/None",
1677 "epB": "device:leaf1",
1678 "type": "UiEdgeLink",
1679 "portB": "4"
1680 }
1681 ]
1682 }
1683 ],
1684 "devices": [
1685 [],
1686 [],
1687 [
1688 {
pierventre57f7bbb2021-10-20 17:37:52 +02001689 "id": "device:leaf4",
1690 "nodeType": "device",
1691 "type": "switch",
1692 "online": true,
1693 "master": "172.24.0.3",
1694 "layer": "def",
1695 "props": {
1696 "managementAddress": "grpc://pippo:50003?device_id=1",
1697 "protocol": "P4Runtime, gNMI, gNOI",
1698 "gridX": "400.0",
1699 "gridY": "400.0",
1700 "driver": "stratum-tofino",
1701 "name": "device:leaf4",
1702 "p4DeviceId": "1",
1703 "locType": "grid"
1704 },
1705 "location": {
1706 "locType": "grid",
1707 "latOrY": 400.0,
1708 "longOrX": 400.0
1709 }
1710 },
1711 {
1712 "id": "device:leaf3",
1713 "nodeType": "device",
1714 "type": "switch",
1715 "online": true,
1716 "master": "172.24.0.3",
1717 "layer": "def",
1718 "props": {
1719 "managementAddress": "grpc://mininet:50003?device_id=1",
1720 "protocol": "P4Runtime, gNMI, gNOI",
1721 "gridX": "400.0",
1722 "gridY": "400.0",
1723 "driver": "stratum-bmv2",
1724 "name": "device:leaf3",
1725 "p4DeviceId": "1",
1726 "locType": "grid"
1727 },
1728 "location": {
1729 "locType": "grid",
1730 "latOrY": 400.0,
1731 "longOrX": 400.0
1732 }
1733 },
1734 {
Sean Condon4ceeae72021-10-21 15:37:11 +01001735 "id": "device:spine1",
1736 "nodeType": "device",
1737 "type": "switch",
1738 "online": true,
1739 "master": "172.24.0.3",
1740 "layer": "def",
1741 "props": {
1742 "managementAddress": "grpc://mininet:50003?device_id=1",
1743 "protocol": "P4Runtime, gNMI, gNOI",
1744 "gridX": "400.0",
1745 "gridY": "400.0",
1746 "driver": "stratum-bmv2",
1747 "name": "device:spine1",
1748 "p4DeviceId": "1",
1749 "locType": "grid"
1750 },
1751 "location": {
1752 "locType": "grid",
1753 "latOrY": 400.0,
1754 "longOrX": 400.0
1755 }
1756 },
1757 {
1758 "id": "device:spine2",
1759 "nodeType": "device",
1760 "type": "switch",
1761 "online": true,
1762 "master": "172.24.0.3",
1763 "layer": "def",
1764 "props": {
1765 "managementAddress": "grpc://mininet:50004?device_id=1",
1766 "protocol": "P4Runtime, gNMI, gNOI",
1767 "gridX": "600.0",
1768 "gridY": "400.0",
1769 "driver": "stratum-bmv2",
1770 "name": "device:spine2",
1771 "p4DeviceId": "1",
1772 "locType": "grid"
1773 },
1774 "location": {
1775 "locType": "grid",
1776 "latOrY": 400.0,
1777 "longOrX": 600.0
1778 }
1779 },
1780 {
1781 "id": "device:leaf2",
1782 "nodeType": "device",
1783 "type": "switch",
1784 "online": true,
1785 "master": "172.24.0.3",
1786 "layer": "def",
1787 "props": {
1788 "managementAddress": "grpc://mininet:50002?device_id=1",
1789 "protocol": "P4Runtime, gNMI, gNOI",
1790 "gridX": "800.0",
1791 "gridY": "600.0",
1792 "driver": "stratum-bmv2",
1793 "name": "device:leaf2",
1794 "p4DeviceId": "1",
1795 "locType": "grid"
1796 },
1797 "location": {
1798 "locType": "grid",
1799 "latOrY": 600.0,
1800 "longOrX": 800.0
1801 }
1802 },
1803 {
1804 "id": "device:leaf1",
1805 "nodeType": "device",
1806 "type": "switch",
1807 "online": true,
1808 "master": "172.24.0.3",
1809 "layer": "def",
1810 "props": {
1811 "managementAddress": "grpc://mininet:50001?device_id=1",
1812 "protocol": "P4Runtime, gNMI, gNOI",
1813 "gridX": "200.0",
1814 "gridY": "600.0",
1815 "driver": "stratum-bmv2",
1816 "name": "device:leaf1",
1817 "p4DeviceId": "1",
1818 "locType": "grid"
1819 },
1820 "location": {
1821 "locType": "grid",
1822 "latOrY": 600.0,
1823 "longOrX": 200.0
1824 }
1825 }
1826 ]
1827 ],
1828 "hosts": [
1829 [],
1830 [],
1831 [
1832 {
pierventre57f7bbb2021-10-20 17:37:52 +02001833 "id": "00:00:00:00:00:22/120",
1834 "nodeType": "host",
1835 "layer": "def",
1836 "ips": [
1837 "2001:2:3::1"
1838 ],
1839 "props": {
1840 "gridX": "750.0",
1841 "gridY": "700.0",
1842 "latitude": null,
1843 "name": "h3",
1844 "locType": "grid",
1845 "longitude": null
1846 },
1847 "location": {
1848 "locType": "grid",
1849 "latOrY": 700.0,
1850 "longOrX": 750.0
1851 },
1852 "configured": false
1853 },
1854 {
1855 "id": "00:00:00:00:00:21/120",
1856 "nodeType": "host",
1857 "layer": "def",
1858 "ips": [
1859 "2001:2:3::1"
1860 ],
1861 "props": {
1862 "gridX": "750.0",
1863 "gridY": "700.0",
1864 "latitude": null,
1865 "name": "h3",
1866 "locType": "grid",
1867 "longitude": null
1868 },
1869 "location": {
1870 "locType": "grid",
1871 "latOrY": 700.0,
1872 "longOrX": 750.0
1873 },
1874 "configured": false
1875 },
1876 {
1877 "id": "00:00:00:00:00:1F/120",
1878 "nodeType": "host",
1879 "layer": "def",
1880 "ips": [
1881 "2001:2:3::1"
1882 ],
1883 "props": {
1884 "gridX": "750.0",
1885 "gridY": "700.0",
1886 "latitude": null,
1887 "name": "h3",
1888 "locType": "grid",
1889 "longitude": null
1890 },
1891 "location": {
1892 "locType": "grid",
1893 "latOrY": 700.0,
1894 "longOrX": 750.0
1895 },
1896 "configured": false
1897 },
1898 {
1899 "id": "00:00:00:00:00:1E/None",
1900 "nodeType": "host",
1901 "layer": "def",
1902 "ips": [
1903 "2001:2:3::1"
1904 ],
1905 "props": {
1906 "gridX": "750.0",
1907 "gridY": "700.0",
1908 "latitude": null,
1909 "name": "h3",
1910 "locType": "grid",
1911 "longitude": null
1912 },
1913 "location": {
1914 "locType": "grid",
1915 "latOrY": 700.0,
1916 "longOrX": 750.0
1917 },
1918 "configured": false
1919 },
1920 {
1921 "id": "00:00:00:00:00:1D/None",
1922 "nodeType": "host",
1923 "layer": "def",
1924 "ips": [
1925 "2001:2:3::1"
1926 ],
1927 "props": {
1928 "gridX": "750.0",
1929 "gridY": "700.0",
1930 "latitude": null,
1931 "name": "h3",
1932 "locType": "grid",
1933 "longitude": null
1934 },
1935 "location": {
1936 "locType": "grid",
1937 "latOrY": 700.0,
1938 "longOrX": 750.0
1939 },
1940 "configured": false
1941 },
1942 {
Sean Condon4ceeae72021-10-21 15:37:11 +01001943 "id": "00:00:00:00:00:30/None",
1944 "nodeType": "host",
1945 "layer": "def",
1946 "ips": [
1947 "2001:2:3::1"
1948 ],
1949 "props": {
1950 "gridX": "750.0",
1951 "gridY": "700.0",
1952 "latitude": null,
1953 "name": "h3",
1954 "locType": "grid",
1955 "longitude": null
1956 },
1957 "location": {
1958 "locType": "grid",
1959 "latOrY": 700.0,
1960 "longOrX": 750.0
1961 },
1962 "configured": false
1963 },
1964 {
1965 "id": "00:00:00:00:00:1A/None",
1966 "nodeType": "host",
1967 "layer": "def",
1968 "ips": [
1969 "2001:1:1::a"
1970 ],
1971 "props": {
1972 "gridX": "100.0",
1973 "gridY": "700.0",
1974 "latitude": null,
1975 "name": "h1a",
1976 "locType": "grid",
1977 "longitude": null
1978 },
1979 "location": {
1980 "locType": "grid",
1981 "latOrY": 700.0,
1982 "longOrX": 100.0
1983 },
1984 "configured": false
1985 },
1986 {
1987 "id": "00:00:00:00:00:1B/None",
1988 "nodeType": "host",
1989 "layer": "def",
1990 "ips": [
1991 "2001:1:1::b"
1992 ],
1993 "props": {
1994 "gridX": "100.0",
1995 "gridY": "800.0",
1996 "latitude": null,
1997 "name": "h1b",
1998 "locType": "grid",
1999 "longitude": null
2000 },
2001 "location": {
2002 "locType": "grid",
2003 "latOrY": 800.0,
2004 "longOrX": 100.0
2005 },
2006 "configured": false
2007 },
2008 {
2009 "id": "00:00:00:00:00:1C/None",
2010 "nodeType": "host",
2011 "layer": "def",
2012 "ips": [
2013 "2001:1:1::c"
2014 ],
2015 "props": {
2016 "gridX": "250.0",
2017 "gridY": "800.0",
2018 "latitude": null,
2019 "name": "h1c",
2020 "locType": "grid",
2021 "longitude": null
2022 },
2023 "location": {
2024 "locType": "grid",
2025 "latOrY": 800.0,
2026 "longOrX": 250.0
2027 },
2028 "configured": false
2029 },
2030 {
2031 "id": "00:00:00:00:00:20/None",
2032 "nodeType": "host",
2033 "layer": "def",
2034 "ips": [
2035 "2001:1:2::1"
2036 ],
2037 "props": {
2038 "gridX": "400.0",
2039 "gridY": "700.0",
2040 "latitude": null,
2041 "name": "h2",
2042 "locType": "grid",
2043 "longitude": null
2044 },
2045 "location": {
2046 "locType": "grid",
2047 "latOrY": 700.0,
2048 "longOrX": 400.0
2049 },
2050 "configured": false
2051 }
2052 ]
2053 ],
2054 "layerOrder": [
2055 "opt",
2056 "pkt",
2057 "def"
2058 ]
2059 }
2060}`;
2061
2062const topo2Highlights_sample = `
2063{
2064 "event": "topo2Highlights",
2065 "payload": {
2066 "devices": [],
2067 "hosts": [],
2068 "links": [
2069 {
pierventre57f7bbb2021-10-20 17:37:52 +02002070 "id": "00:00:00:00:00:22/120~device:leaf4/[3/0](3)",
2071 "label": "964.91 Kbps",
2072 "css": "secondary port-traffic-green"
2073 },
2074 {
2075 "id": "00:00:00:00:00:1E/None~device:leaf4/[2/0](2)",
2076 "label": "964.91 Kbps",
2077 "css": "secondary port-traffic-green"
2078 },
2079 {
2080 "id": "device:leaf4/[1/0](1)~device:spine1/[3/0](3)",
2081 "label": "964.91 Kbps",
2082 "css": "secondary port-traffic-green"
2083 },
2084 {
2085 "id": "00:00:00:00:00:21/120~device:leaf3/[leaf3-eth3](3)",
2086 "label": "964.91 Kbps",
2087 "css": "secondary port-traffic-green"
2088 },
2089 {
2090 "id": "00:00:00:00:00:1D/None~device:leaf3/[leaf3-eth2](2)",
2091 "label": "964.91 Kbps",
2092 "css": "secondary port-traffic-green"
2093 },
2094 {
2095 "id": "device:leaf3/[leaf3-eth1](1)~device:spine1/[spine1-eth3](3)",
2096 "label": "964.91 Kbps",
2097 "css": "secondary port-traffic-green"
2098 },
2099 {
2100 "id": "00:00:00:00:00:1F/120~device:leaf1/7",
2101 "label": "964.91 Kbps",
2102 "css": "secondary port-traffic-green"
2103 },
2104 {
Sean Condon4ceeae72021-10-21 15:37:11 +01002105 "id": "device:leaf2/2~device:spine2/2",
2106 "label": "964.91 Kbps",
2107 "css": "secondary port-traffic-green"
2108 },
2109 {
2110 "id": "device:leaf1/1~device:spine1/1",
2111 "label": "3.92 Mbps",
2112 "css": "secondary port-traffic-yellow"
2113 },
2114 {
2115 "id": "00:00:00:00:00:30/None~device:leaf2/3",
2116 "label": "4.46 Mbps",
2117 "css": "secondary port-traffic-yellow"
2118 },
2119 {
2120 "id": "device:leaf2/1~device:spine1/2",
2121 "label": "3.53 Mbps",
2122 "css": "secondary port-traffic-yellow"
2123 },
2124 {
2125 "id": "device:leaf1/2~device:spine2/1",
2126 "label": "1.06 Mbps",
2127 "css": "secondary port-traffic-yellow"
2128 },
2129 {
2130 "id": "00:00:00:00:00:20/None~device:leaf1/6",
2131 "label": "4.98 Mbps",
2132 "css": "secondary port-traffic-yellow"
2133 }
2134 ]
2135 }
2136}`;
2137
pierventre57f7bbb2021-10-20 17:37:52 +02002138const topo2Highlights_sample2 = `
2139{
2140 "event": "topo2Highlights",
2141 "payload": {
2142 "devices": [],
2143 "hosts": [],
2144 "links": []
2145 }
2146}`;
2147
Sean Condon0c577f62018-11-18 22:40:05 +00002148class MockActivatedRoute extends ActivatedRoute {
2149 constructor(params: Params) {
2150 super();
2151 this.queryParams = of(params);
2152 }
2153}
2154
Sean Condon64060ff2019-05-30 15:48:11 +01002155class MockIconService {
2156 loadIconDef() { }
2157}
2158
2159class MockSvgUtilService {
2160
2161 cat7() {
2162 const tcid = 'd3utilTestCard';
2163
2164 function getColor(id, muted, theme) {
2165 // NOTE: since we are lazily assigning domain ids, we need to
2166 // get the color from all 4 scales, to keep the domains
2167 // in sync.
2168 const ln = '#5b99d2';
2169 const lm = '#9ebedf';
2170 const dn = '#5b99d2';
2171 const dm = '#9ebedf';
2172 if (theme === 'dark') {
2173 return muted ? dm : dn;
2174 } else {
2175 return muted ? lm : ln;
2176 }
2177 }
2178
2179 return {
2180 // testCard: testCard,
2181 getColor: getColor,
2182 };
2183 }
2184}
2185
2186class MockUrlFnService { }
2187
2188class MockWebSocketService {
2189 createWebSocket() { }
2190 isConnected() { return false; }
2191 unbindHandlers() { }
2192 bindHandlers() { }
2193}
2194
2195class MockTopologyService {
2196 public instancesIndex: Map<string, number>;
2197 constructor() {
2198 this.instancesIndex = new Map();
2199 }
2200}
2201
Sean Condonf4f54a12018-10-10 23:25:46 +01002202describe('ForceSvgComponent', () => {
Sean Condon71910542019-02-16 18:16:42 +00002203 let fs: FnService;
Sean Condon0c577f62018-11-18 22:40:05 +00002204 let ar: MockActivatedRoute;
2205 let windowMock: Window;
2206 let logServiceSpy: jasmine.SpyObj<LogService>;
Sean Condonf4f54a12018-10-10 23:25:46 +01002207 let component: ForceSvgComponent;
2208 let fixture: ComponentFixture<ForceSvgComponent>;
Sean Condon4ceeae72021-10-21 15:37:11 +01002209 const openflowSampleData = JSON.parse(test_module_topo2CurrentRegion);
Sean Condonb77768e2019-05-04 20:23:42 +01002210 const openflowRegionData: Region = <Region><unknown>(openflowSampleData.payload);
2211
Sean Condon4ceeae72021-10-21 15:37:11 +01002212 const odtnSampleData = JSON.parse(test_OdtnConfig_topo2CurrentRegion);
Sean Condonb77768e2019-05-04 20:23:42 +01002213 const odtnRegionData: Region = <Region><unknown>(odtnSampleData.payload);
2214
Sean Condon4ceeae72021-10-21 15:37:11 +01002215 const topo2BaseData = JSON.parse(topo2Highlights_base_data);
Sean Condonf9ff66a2020-03-23 08:40:55 +00002216 const topo2BaseRegionData: Region = <Region><unknown>(topo2BaseData.payload);
2217
Sean Condon4ceeae72021-10-21 15:37:11 +01002218 const highlightSampleData = JSON.parse(topo2Highlights_sample);
Sean Condonf9ff66a2020-03-23 08:40:55 +00002219 const linkHightlights: LinkHighlight[] = <LinkHighlight[]><unknown>(highlightSampleData.payload.links);
2220
Sean Condonc13d9562019-04-18 13:24:42 +01002221 const emptyRegion: Region = <Region>{devices: [ [], [], [] ], hosts: [ [], [], [] ], links: []};
Sean Condonf4f54a12018-10-10 23:25:46 +01002222
Sean Condon64060ff2019-05-30 15:48:11 +01002223 beforeEach(() => {
Sean Condon0c577f62018-11-18 22:40:05 +00002224 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
2225 ar = new MockActivatedRoute({ 'debug': 'txrx' });
2226
2227 windowMock = <any>{
2228 location: <any>{
2229 hostname: 'foo',
2230 host: 'foo',
2231 port: '80',
2232 protocol: 'http',
2233 search: { debug: 'true' },
2234 href: 'ws://foo:123/onos/ui/websock/path',
2235 absUrl: 'ws://foo:123/onos/ui/websock/path'
2236 }
2237 };
2238
Sean Condon64060ff2019-05-30 15:48:11 +01002239 const bundleObj = {
2240 'core.view.Topo': {
2241 test: 'test1'
2242 }
2243 };
2244 const mockLion = (key) => {
2245 return bundleObj[key] || '%' + key + '%';
2246 };
2247
Sean Condon71910542019-02-16 18:16:42 +00002248 fs = new FnService(ar, logSpy, windowMock);
2249
Sean Condonf4f54a12018-10-10 23:25:46 +01002250 TestBed.configureTestingModule({
Sean Condon0c577f62018-11-18 22:40:05 +00002251 declarations: [
2252 ForceSvgComponent,
2253 DeviceNodeSvgComponent,
2254 HostNodeSvgComponent,
2255 SubRegionNodeSvgComponent,
Sean Condon50855cf2018-12-23 15:37:42 +00002256 LinkSvgComponent,
Sean Condon590b34b2019-12-04 18:44:37 +00002257 DraggableDirective,
2258 BadgeSvgComponent
Sean Condon0c577f62018-11-18 22:40:05 +00002259 ],
2260 providers: [
2261 { provide: LogService, useValue: logSpy },
Sean Condon64060ff2019-05-30 15:48:11 +01002262 { provide: ActivatedRoute, useValue: ar },
2263 { provide: FnService, useValue: fs },
2264 { provide: ChangeDetectorRef, useClass: ChangeDetectorRef },
2265 { provide: UrlFnService, useClass: MockUrlFnService },
2266 { provide: WebSocketService, useClass: MockWebSocketService },
2267 { provide: LionService, useFactory: (() => {
2268 return {
2269 bundle: ((bundleId) => mockLion),
2270 ubercache: new Array(),
2271 loadCbs: new Map<string, () => void>([])
2272 };
2273 })
2274 },
2275 { provide: IconService, useClass: MockIconService },
2276 { provide: SvgUtilService, useClass: MockSvgUtilService },
2277 { provide: TopologyService, useClass: MockTopologyService },
Sean Condon71910542019-02-16 18:16:42 +00002278 { provide: 'Window', useValue: windowMock },
Sean Condon0c577f62018-11-18 22:40:05 +00002279 ]
Sean Condonf4f54a12018-10-10 23:25:46 +01002280 })
2281 .compileComponents();
Sean Condon0c577f62018-11-18 22:40:05 +00002282 logServiceSpy = TestBed.get(LogService);
Sean Condonf4f54a12018-10-10 23:25:46 +01002283
Sean Condonf4f54a12018-10-10 23:25:46 +01002284 fixture = TestBed.createComponent(ForceSvgComponent);
Sean Condon0c577f62018-11-18 22:40:05 +00002285 component = fixture.debugElement.componentInstance;
Sean Condonf4f54a12018-10-10 23:25:46 +01002286 fixture.detectChanges();
2287 });
2288
2289 it('should create', () => {
2290 expect(component).toBeTruthy();
2291 });
Sean Condonc13d9562019-04-18 13:24:42 +01002292
Sean Condonb77768e2019-05-04 20:23:42 +01002293 it('load sample files', () => {
2294 expect(openflowSampleData).toBeTruthy();
2295 expect(openflowSampleData.payload).toBeTruthy();
2296 expect(openflowSampleData.payload.id).toBe('(root)');
2297
2298 expect(odtnSampleData).toBeTruthy();
2299 expect(odtnSampleData.payload).toBeTruthy();
2300 expect(odtnSampleData.payload.id).toBe('(root)');
Sean Condonc13d9562019-04-18 13:24:42 +01002301 });
2302
2303 it('should read sample data payload as Region', () => {
Sean Condonb77768e2019-05-04 20:23:42 +01002304 expect(openflowRegionData).toBeTruthy();
Sean Condonc13d9562019-04-18 13:24:42 +01002305 // console.log(regionData);
Sean Condonb77768e2019-05-04 20:23:42 +01002306 expect(openflowRegionData.id).toBe('(root)');
2307 expect(openflowRegionData.devices).toBeTruthy();
2308 expect(openflowRegionData.devices.length).toBe(3);
2309 expect(openflowRegionData.devices[2].length).toBe(10);
2310 expect(openflowRegionData.hosts.length).toBe(3);
2311 expect(openflowRegionData.hosts[2].length).toBe(20);
2312 expect(openflowRegionData.links.length).toBe(44);
Sean Condonc13d9562019-04-18 13:24:42 +01002313 });
2314
2315 it('should read device246 correctly', () => {
Sean Condonb77768e2019-05-04 20:23:42 +01002316 const device246: Device = openflowRegionData.devices[2][0];
Sean Condonc13d9562019-04-18 13:24:42 +01002317 expect(device246.id).toBe('of:0000000000000246');
2318 expect(device246.nodeType).toBe('device');
2319 expect(device246.type).toBe('switch');
2320 expect(device246.online).toBe(true);
2321 expect(device246.master).toBe('10.192.19.68');
2322 expect(device246.layer).toBe('def');
2323
2324 expect(device246.props.managementAddress).toBe('10.192.19.69');
2325 expect(device246.props.protocol).toBe('OF_13');
2326 expect(device246.props.driver).toBe('ofdpa-ovs');
2327 expect(device246.props.latitude).toBe('40.15');
2328 expect(device246.props.name).toBe('s246');
2329 expect(device246.props.locType).toBe('geo');
2330 expect(device246.props.channelId).toBe('10.192.19.69:59980');
2331 expect(device246.props.longitude).toBe('-121.679');
2332
2333 expect(device246.location.locType).toBe('geo');
2334 expect(device246.location.latOrY).toBe(40.15);
2335 expect(device246.location.longOrX).toBe(-121.679);
2336 });
2337
2338 it('should read host 3 correctly', () => {
Sean Condonb77768e2019-05-04 20:23:42 +01002339 const host3: Host = openflowRegionData.hosts[2][0];
Sean Condonc13d9562019-04-18 13:24:42 +01002340 expect(host3.id).toBe('00:88:00:00:00:03/110');
2341 expect(host3.nodeType).toBe('host');
2342 expect(host3.layer).toBe('def');
2343 expect(host3.configured).toBe(false);
2344 expect(host3.ips.length).toBe(3);
2345 expect(host3.ips[0]).toBe('fe80::288:ff:fe00:3');
2346 expect(host3.ips[1]).toBe('2000::102');
2347 expect(host3.ips[2]).toBe('10.0.1.2');
2348 });
2349
2350 it('should read link 3-205 correctly', () => {
Sean Condonb77768e2019-05-04 20:23:42 +01002351 const link3_205: Link = openflowRegionData.links[0];
Sean Condonc13d9562019-04-18 13:24:42 +01002352 expect(link3_205.id).toBe('00:AA:00:00:00:03/None~of:0000000000000205/6');
2353 expect(link3_205.epA).toBe('00:AA:00:00:00:03/None');
2354 expect(link3_205.epB).toBe('of:0000000000000205');
2355 expect(String(LinkType[link3_205.type])).toBe('2');
2356 expect(link3_205.portA).toBe(undefined);
2357 expect(link3_205.portB).toBe('6');
2358
2359 expect(link3_205.rollup).toBeTruthy();
2360 expect(link3_205.rollup.length).toBe(1);
2361 expect(link3_205.rollup[0].id).toBe('00:AA:00:00:00:03/None~of:0000000000000205/6');
2362 expect(link3_205.rollup[0].epA).toBe('00:AA:00:00:00:03/None');
2363 expect(link3_205.rollup[0].epB).toBe('of:0000000000000205');
2364 expect(String(LinkType[link3_205.rollup[0].type])).toBe('2');
2365 expect(link3_205.rollup[0].portA).toBe(undefined);
2366 expect(link3_205.rollup[0].portB).toBe('6');
2367
2368 });
2369
2370 it('should handle regionData change - empty Region', () => {
2371 component.ngOnChanges(
2372 {'regionData' : new SimpleChange(<Region>{}, emptyRegion, true)});
2373
2374 expect(component.graph.nodes.length).toBe(0);
2375 });
2376
Sean Condonb77768e2019-05-04 20:23:42 +01002377 it('should know how to format names', () => {
2378 expect(ForceSvgComponent.extractNodeName('00:AA:00:00:00:03/None', undefined))
Sean Condonc13d9562019-04-18 13:24:42 +01002379 .toEqual('00:AA:00:00:00:03/None');
2380
Sean Condonb77768e2019-05-04 20:23:42 +01002381 expect(ForceSvgComponent.extractNodeName('00:AA:00:00:00:03/161', '161'))
2382 .toEqual('00:AA:00:00:00:03');
Sean Condonc13d9562019-04-18 13:24:42 +01002383
Sean Condonb77768e2019-05-04 20:23:42 +01002384 // Like epB of first example in sampleData file - endPtStr contains port number
2385 expect(ForceSvgComponent.extractNodeName('of:0000000000000206/6', '6'))
2386 .toEqual('of:0000000000000206');
2387
2388 // Like epB of second example in sampleData file - endPtStr does not contain port number
2389 expect(ForceSvgComponent.extractNodeName('of:0000000000000206', '6'))
Sean Condonc13d9562019-04-18 13:24:42 +01002390 .toEqual('of:0000000000000206');
pierventre57f7bbb2021-10-20 17:37:52 +02002391
2392 // bmv2 case - no port in the endpoint
2393 expect(ForceSvgComponent.extractNodeName('device:leaf1', '[leaf1-eth1](1)'))
2394 .toEqual('device:leaf1');
2395
2396 // bmv2 case - port in the endpoint
2397 expect(ForceSvgComponent.extractNodeName('device:leaf1/[leaf1-eth1](1)', '[leaf1-eth1](1)'))
2398 .toEqual('device:leaf1');
2399
2400 // tofino case - no port in the endpoint
2401 expect(ForceSvgComponent.extractNodeName('device:leaf1', '[1/0](1)'))
2402 .toEqual('device:leaf1');
2403
2404 // tofino case - port in the endpoint
2405 expect(ForceSvgComponent.extractNodeName('device:leaf1/[1/0](1)', '[1/0](1)'))
2406 .toEqual('device:leaf1');
2407
Sean Condonc13d9562019-04-18 13:24:42 +01002408 });
2409
Sean Condonb77768e2019-05-04 20:23:42 +01002410 it('should handle openflow regionData change - sample Region', () => {
2411 component.regionData = openflowRegionData;
Sean Condonc13d9562019-04-18 13:24:42 +01002412 component.ngOnChanges(
Sean Condonb77768e2019-05-04 20:23:42 +01002413 {'regionData' : new SimpleChange(<Region>{}, openflowRegionData, true)});
Sean Condonc13d9562019-04-18 13:24:42 +01002414
2415 expect(component.graph.nodes.length).toBe(30);
2416
2417 expect(component.graph.links.length).toBe(44);
2418
2419 });
Sean Condonb77768e2019-05-04 20:23:42 +01002420
2421 it('should handle odtn regionData change - sample odtn Region', () => {
2422 component.regionData = odtnRegionData;
2423 component.ngOnChanges(
2424 {'regionData' : new SimpleChange(<Region>{}, odtnRegionData, true)});
2425
2426 expect(component.graph.nodes.length).toBe(2);
2427
2428 expect(component.graph.links.length).toBe(6);
2429
2430 });
Sean Condonf9ff66a2020-03-23 08:40:55 +00002431
2432 it('should handle highlights and match them to existing links', () => {
2433 component.regionData = topo2BaseRegionData;
2434 component.ngOnChanges(
2435 {'regionData' : new SimpleChange(<Region>{}, topo2BaseRegionData, true)});
2436
pierventre57f7bbb2021-10-20 17:37:52 +02002437 expect(component.graph.links.length).toBe(16);
2438 expect(component.graph.nodes.length).toBe(16)
2439 expect(linkHightlights.length).toBe(13);
Sean Condonf9ff66a2020-03-23 08:40:55 +00002440
pierventre57f7bbb2021-10-20 17:37:52 +02002441 // sanitize deviceNameFromEp
2442 component.graph.links.forEach((l: Link) => {
2443 if (<LinkType><unknown>LinkType[l.type] === LinkType.UiEdgeLink) {
2444 // edge link has only one epoint valid (the other is not deviceId)
2445 const foundNode = component.graph.nodes.find((n: Node) => n.id === Link.deviceNameFromEp(l.epB));
2446 expect(foundNode).toBeDefined();
2447 } else {
2448 var foundNode = component.graph.nodes.find((n: Node) => n.id === Link.deviceNameFromEp(l.epA));
2449 expect(foundNode).toBeDefined();
2450 foundNode = component.graph.nodes.find((n: Node) => n.id === Link.deviceNameFromEp(l.epB));
2451 expect(foundNode).toBeDefined();
2452 }
2453 });
Sean Condonf9ff66a2020-03-23 08:40:55 +00002454
2455 // should be able to find all of the highlighted links in the original data set
2456 linkHightlights.forEach((lh: LinkHighlight) => {
2457 const foundLink = component.graph.links.find((l: Link) => l.id === Link.linkIdFromShowHighlights(lh.id));
2458 expect(foundLink).toBeDefined();
2459 });
2460 });
Sean Condonf4f54a12018-10-10 23:25:46 +01002461});