summaryrefslogtreecommitdiff
path: root/tests/vtep-ctl.at
blob: f4a7edf0262382d0d395725556e479e4cd1fada5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
dnl VTEP_OVSDB_INIT([$1])
dnl
dnl Creates an empty database named $1.
m4_define([VTEP_OVSDB_INIT],
  [AT_CHECK(
     [ovsdb-tool create $1 $abs_top_srcdir/vtep/vtep.ovsschema],
     [0], [stdout], [ignore])
   AT_CHECK(
     [[ovsdb-tool transact $1 \
        '["hardware_vtep",
          {"op": "insert",
           "table": "Global",
           "row": {}}]']],
     [0], [ignore], [ignore])])

dnl VTEP_CTL_SETUP
dnl
dnl Creates an empty database in the current directory and then starts
dnl an ovsdb-server on it for vtep-ctl to connect to.
m4_define([VTEP_CTL_SETUP],
  [VTEP_OVSDB_INIT([db])
   AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db >/dev/null 2>&1], [0], [ignore], [ignore])])

dnl VTEP_CTL_CLEANUP
dnl
dnl Kills off the database server.
m4_define([VTEP_CTL_CLEANUP], [OVSDB_SERVER_SHUTDOWN])

dnl RUN_VTEP_CTL(COMMAND, ...)
dnl
dnl Executes each vtep-ctl COMMAND.
m4_define([RUN_VTEP_CTL],
  [m4_foreach([command], [$@], [vtep-ctl --timeout=5 -vreconnect:emer --db=unix:socket command
])])
m4_define([RUN_VTEP_CTL_ONELINE],
  [m4_foreach([command], [$@], [vtep-ctl --timeout=5 -vreconnect:emer --db=unix:socket --oneline -- command
])])

dnl RUN_VTEP_CTL_TOGETHER(COMMAND, ...)
dnl
dnl Executes each vtep-ctl COMMAND in a single run of vtep-ctl.
m4_define([RUN_VTEP_CTL_TOGETHER],
  [vtep-ctl --timeout=5 -vreconnect:emer --db=unix:socket --oneline dnl
m4_foreach([command], [$@], [ -- command])])

dnl CHECK_PSWITCHES([PSWITCH], ...)
dnl
dnl Verifies that "vtep-ctl list-ps" prints the specified list of
dnl physical switches, which must be in alphabetical order.
m4_define([CHECK_PSWITCHES],
  [dnl Check that the pswitches appear on list-ps, without --oneline.
   AT_CHECK(
     [RUN_VTEP_CTL([list-ps])],
     [0],
     [m4_foreach([psinfo], [$@], [m4_car(psinfo)
])],
     [],
     [VTEP_CTL_CLEANUP])

   dnl Check that the pswitches appear on list-ps, with --oneline.
   AT_CHECK(
     [RUN_VTEP_CTL_ONELINE([list-ps])],
     [0],
     [m4_join([\n], m4_foreach([psinfo], [$@], [m4_car(psinfo),]))
],
     [],
     [VTEP_CTL_CLEANUP])

   dnl Check that each pswitch exists according to ps-exists and that
   dnl a pswitch that should not exist does not.
   m4_foreach([psinfo], [$@],
              [AT_CHECK([RUN_VTEP_CTL([ps-exists m4_car(psinfo)])], [0], [],
                        [], [VTEP_CTL_CLEANUP])])
   AT_CHECK([RUN_VTEP_CTL([ps-exists nonexistent])], [2], [], [],
            [VTEP_CTL_CLEANUP])])

dnl CHECK_PORTS(PSWITCH, PORT[, PORT...])
dnl
dnl Verifies that "vtep-ctl list-ports PSWITCH" prints the specified
dnl list of ports, which must be in alphabetical order.
m4_define([CHECK_PORTS],
  [dnl Check ports without --oneline.
   AT_CHECK(
     [RUN_VTEP_CTL([list-ports $1])],
     [0],
     [m4_foreach([port], m4_cdr($@), [port
])],
     [],
     [VTEP_CTL_CLEANUP])

   dnl Check ports with --oneline.
   AT_CHECK(
     [RUN_VTEP_CTL_ONELINE([list-ports $1])],
     [0],
     [m4_join([\n], m4_shift($@))
],
     [],
     [VTEP_CTL_CLEANUP])])


dnl CHECK_LSWITCHES([LSWITCH], ...)
dnl
dnl Verifies that "vtep-ctl list-ls" prints the specified list of
dnl logical switches, which must be in alphabetical order.
m4_define([CHECK_LSWITCHES],
  [dnl Check that the lswitches appear on list-ls, without --oneline.
   AT_CHECK(
     [RUN_VTEP_CTL([list-ls])],
     [0],
     [m4_foreach([lsinfo], [$@], [m4_car(lsinfo)
])],
     [],
     [VTEP_CTL_CLEANUP])

   dnl Check that the lswitches appear on list-ls, with --oneline.
   AT_CHECK(
     [RUN_VTEP_CTL_ONELINE([list-ls])],
     [0],
     [m4_join([\n], m4_foreach([lsinfo], [$@], [m4_car(lsinfo),]))
],
     [],
     [VTEP_CTL_CLEANUP])

   dnl Check that each lswitch exists according to ls-exists and that
   dnl a pswitch that should not exist does not.
   m4_foreach([lsinfo], [$@],
              [AT_CHECK([RUN_VTEP_CTL([ls-exists m4_car(lsinfo)])], [0], [],
                        [], [VTEP_CTL_CLEANUP])])
   AT_CHECK([RUN_VTEP_CTL([ls-exists nonexistent])], [2], [], [],
            [VTEP_CTL_CLEANUP])])

dnl ----------------------------------------------------------------------
AT_BANNER([vtep-ctl unit tests -- physical switch tests])

AT_SETUP([add-ps a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL([add-ps a])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_PSWITCHES([a])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ps a, add-ps a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL([add-ps a])], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([add-ps a])], [1], [],
  [vtep-ctl: cannot create physical switch a because it already exists
], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ps a, add-ps b])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL([add-ps a], [add-ps b])], [0], [], [],
         [VTEP_CTL_CLEANUP])
CHECK_PSWITCHES([a], [b])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ps a, add-ps b, del-ps a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL([add-ps a], [add-ps b], [del-ps a])], [0], [], [],
         [VTEP_CTL_CLEANUP])
CHECK_PSWITCHES([b])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ps a, del-ps a, add-ps a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL_TOGETHER(
  [add-ps a],
  [del-ps a],
  [add-ps a])], [0], [


], [], [VTEP_CTL_CLEANUP])
CHECK_PSWITCHES([a])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ps a, add-port a a1, add-port a a2])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ps a],
   [--if-exists del-ps b],
   [add-port a a1],
   [add-port a a2])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_PSWITCHES([a])
CHECK_PORTS([a], [a1], [a2])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ps a, add-port a a1, add-port a a1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ps a],
   [add-port a a1])], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([add-port a a1])], [1], [],
  [vtep-ctl: cannot create a port named a1 on a because a port with that name already exists
], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ps a b, add-port a a1, add-port b b1, del-ps a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL_TOGETHER(
   [add-ps a],
   [add-ps b],
   [add-port a a1],
   [add-port b b1],
   [--if-exists del-port b b2],
   [del-ps a])], [0], [





], [], [VTEP_CTL_CLEANUP])
CHECK_PSWITCHES([b])
CHECK_PORTS([b], [b1])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ps a b, add-port a a1, add-port b b1, del-port a a1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
  [add-ps a],
  [add-ps b],
  [add-port a a1],
  [--may-exist add-port b b1],
  [del-port a a1])], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([--may-exist add-port b b1])], [0], [], [],
  [VTEP_CTL_CLEANUP])
CHECK_PSWITCHES([a], [b])
CHECK_PORTS([a])
CHECK_PORTS([b], [b1])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ps a b, add-port a p1, add-port b p1, del-port a p1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
  [add-ps a],
  [add-ps b],
  [add-port a p1],
  [add-port b p1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_PSWITCHES([a], [b])
CHECK_PORTS([a], [p1])
CHECK_PORTS([b], [p1])
AT_CHECK([RUN_VTEP_CTL([del-port a p1])], [0], [], [],
  [VTEP_CTL_CLEANUP])
CHECK_PSWITCHES([a], [b])
CHECK_PORTS([a])
CHECK_PORTS([b], [p1])
VTEP_CTL_CLEANUP
AT_CLEANUP


dnl ----------------------------------------------------------------------
AT_BANNER([vtep-ctl unit tests -- logical switch tests])

AT_SETUP([add-ls a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL([add-ls a])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([a])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ls a, add-ls a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL([add-ls a])], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([add-ls a])], [1], [],
  [vtep-ctl: cannot create logical switch a because it already exists
], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ls a, add-ls b])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL([add-ls a], [add-ls b])], [0], [], [],
         [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([a], [b])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ls a, add-ls b, del-ls a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL([add-ls a], [add-ls b], [del-ls a])], [0], [], [],
         [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([b])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ls a, del-ls a, add-ls a])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL_TOGETHER(
  [add-ls a],
  [del-ls a],
  [add-ls a])], [0], [


], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([a])
VTEP_CTL_CLEANUP
AT_CLEANUP


dnl ----------------------------------------------------------------------
AT_BANNER([vtep-ctl unit tests -- logical binding tests])

AT_SETUP([bind-ls ps1 pp1 300 ls1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ps ps1],
   [add-port ps1 pp1],
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_PSWITCHES([ps1])
CHECK_PORTS([ps1], [pp1])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [bind-ls ps1 pp1 300 ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-bindings ps1 pp1])], [0],
   [0300 ls1
], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([bind-ls ps1 pp1 300 ls1, bind-ls ps1 pp1 400 ls2])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ps ps1],
   [add-port ps1 pp1],
   [add-ls ls1],
   [add-ls ls2])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_PSWITCHES([ps1])
CHECK_PORTS([ps1], [pp1])
CHECK_LSWITCHES([ls1], [ls2])
AT_CHECK([RUN_VTEP_CTL(
   [bind-ls ps1 pp1 300 ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL(
   [bind-ls ps1 pp1 400 ls2])], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-bindings ps1 pp1])], [0],
   [0300 ls1
0400 ls2
], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([bind-ls ps1 pp1 300, bind-ls ps2 pp2 300 ls2])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ps ps1],
   [add-ps ps2],
   [add-port ps1 pp1],
   [add-port ps2 pp2],
   [add-ls ls1],
   [add-ls ls2])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_PSWITCHES([ps1], [ps2])
CHECK_PORTS([ps1], [pp1])
CHECK_PORTS([ps2], [pp2])
CHECK_LSWITCHES([ls1], [ls2])
AT_CHECK([RUN_VTEP_CTL(
   [bind-ls ps1 pp1 300 ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL(
   [bind-ls ps2 pp2 300 ls2])], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-bindings ps1 pp1])], [0],
   [0300 ls1
], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-bindings ps2 pp2])], [0],
   [0300 ls2
], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP


dnl ----------------------------------------------------------------------
AT_BANNER([vtep-ctl unit tests -- MAC binding tests])

AT_SETUP([add-ucast-local ls1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-ucast-local ls1 00:11:22:33:44:55 10.0.0.10],
   [add-ucast-local ls1 00:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

mcast-mac-local

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote

mcast-mac-remote

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ucast-local ls1, overwrite])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-ucast-local ls1 00:11:22:33:44:55 10.0.0.10],
   [add-ucast-local ls1 00:11:22:33:44:55 10.0.0.11])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11

mcast-mac-local

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ucast-local ls1, del-ucast-local ls1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-ucast-local ls1 00:11:22:33:44:55 10.0.0.10],
   [add-ucast-local ls1 00:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

mcast-mac-local

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL(
   [del-ucast-local ls1 00:11:22:33:44:55])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local
  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

mcast-mac-local

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ucast-remote ls1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-ucast-remote ls1 00:11:22:33:44:55 10.0.0.10],
   [add-ucast-remote ls1 00:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

mcast-mac-remote

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local

mcast-mac-local

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ucast-remote ls1, overwrite])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-ucast-remote ls1 00:11:22:33:44:55 10.0.0.10],
   [add-ucast-remote ls1 00:11:22:33:44:55 10.0.0.11])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.11

mcast-mac-remote

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ucast-remote ls1, del-ucast-remote ls1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-ucast-remote ls1 00:11:22:33:44:55 10.0.0.10],
   [add-ucast-remote ls1 00:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

mcast-mac-remote

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL(
   [del-ucast-remote ls1 00:11:22:33:44:55])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote
  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

mcast-mac-remote

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-ucast-local ls1, add-ucast-remote ls1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-ucast-local ls1 00:11:22:33:44:55 10.0.0.10],
   [add-ucast-local ls1 00:11:22:33:44:66 10.0.0.11],
   [add-ucast-remote ls1 02:11:22:33:44:55 10.0.0.10],
   [add-ucast-remote ls1 02:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  00:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

mcast-mac-local

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote
  02:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  02:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

mcast-mac-remote

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-mcast-local ls1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-mcast-local ls1 01:11:22:33:44:55 10.0.0.10],
   [add-mcast-local ls1 01:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11],
   [add-mcast-local ls1 01:11:22:33:44:55 10.0.0.12])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local

mcast-mac-local
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote

mcast-mac-remote

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-mcast-local ls1, del-mcast-local ls1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-mcast-local ls1 01:11:22:33:44:55 10.0.0.10],
   [add-mcast-local ls1 01:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11],
   [add-mcast-local ls1 01:11:22:33:44:55 10.0.0.12],
   [add-mcast-local ls1 01:11:22:33:44:55 10.0.0.13])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local

mcast-mac-local
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL(
   [del-mcast-local ls1 01:11:22:33:44:55 10.0.0.12])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local

mcast-mac-local
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-mcast-remote ls1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-mcast-remote ls1 01:11:22:33:44:55 10.0.0.10],
   [add-mcast-remote ls1 01:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11],
   [add-mcast-remote ls1 01:11:22:33:44:55 10.0.0.12])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote

mcast-mac-remote
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local

mcast-mac-local

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-mcast-remote ls1, del-mcast-remote ls1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-mcast-remote ls1 01:11:22:33:44:55 10.0.0.10],
   [add-mcast-remote ls1 01:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11],
   [add-mcast-remote ls1 01:11:22:33:44:55 10.0.0.12],
   [add-mcast-remote ls1 01:11:22:33:44:55 10.0.0.13])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote

mcast-mac-remote
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL(
   [del-mcast-remote ls1 01:11:22:33:44:55 10.0.0.12])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote

mcast-mac-remote
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.13
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add-mcast-local ls1, add-mcast-remote ls1])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-mcast-local ls1 01:11:22:33:44:55 10.0.0.10],
   [add-mcast-local ls1 01:11:22:33:44:66 10.0.0.11],
   [add-mcast-local ls1 01:11:22:33:44:55 10.0.0.12],
   [add-mcast-remote ls1 03:11:22:33:44:55 10.0.0.10],
   [add-mcast-remote ls1 03:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11],
   [add-mcast-remote ls1 03:11:22:33:44:55 10.0.0.12])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local

mcast-mac-local
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote

mcast-mac-remote
  03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  03:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12
  03:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add local and remote macs, clear-local-macs])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-ucast-local ls1 00:11:22:33:44:55 10.0.0.10],
   [add-mcast-local ls1 01:11:22:33:44:55 10.0.0.10],
   [add-mcast-local ls1 01:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11],
   [add-mcast-local ls1 01:11:22:33:44:55 10.0.0.12],
   [add-ucast-remote ls1 00:11:22:33:44:55 10.0.0.10],
   [add-mcast-remote ls1 01:11:22:33:44:55 10.0.0.10],
   [add-mcast-remote ls1 01:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11],
   [add-mcast-remote ls1 01:11:22:33:44:55 10.0.0.12])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10

mcast-mac-local
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10

mcast-mac-remote
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL(
   [clear-local-macs ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local

mcast-mac-local

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10

mcast-mac-remote
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([add local and remote macs, clear-remote-macs])
AT_KEYWORDS([vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
   [add-ls ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
CHECK_LSWITCHES([ls1])
AT_CHECK([RUN_VTEP_CTL(
   [add-ucast-local ls1 00:11:22:33:44:55 10.0.0.10],
   [add-mcast-local ls1 01:11:22:33:44:55 10.0.0.10],
   [add-mcast-local ls1 01:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11],
   [add-mcast-local ls1 01:11:22:33:44:55 10.0.0.12],
   [add-ucast-remote ls1 00:11:22:33:44:55 10.0.0.10],
   [add-mcast-remote ls1 01:11:22:33:44:55 10.0.0.10],
   [add-mcast-remote ls1 01:11:22:33:44:66 vxlan_over_ipv4 10.0.0.11],
   [add-mcast-remote ls1 01:11:22:33:44:55 10.0.0.12])
], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10

mcast-mac-local
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10

mcast-mac-remote
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL(
   [clear-remote-macs ls1])], [0], [], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-local-macs ls1])], [0],
   [ucast-mac-local
  00:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10

mcast-mac-local
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.10
  01:11:22:33:44:55 -> vxlan_over_ipv4/10.0.0.12
  01:11:22:33:44:66 -> vxlan_over_ipv4/10.0.0.11

], [], [VTEP_CTL_CLEANUP])
AT_CHECK([RUN_VTEP_CTL([list-remote-macs ls1])], [0],
   [ucast-mac-remote

mcast-mac-remote

], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

dnl ----------------------------------------------------------------------
AT_BANNER([vtep-ctl unit tests -- manager commands])

AT_SETUP([managers])
AT_KEYWORDS([manager vtep-ctl])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL_TOGETHER(
  [del-manager],
  [get-manager],
  [set-manager tcp:4.5.6.7],
  [get-manager],
  [set-manager tcp:8.9.10.11 tcp:5.4.3.2],
  [get-manager],
  [del-manager],
  [get-manager])], [0], [


tcp:4.5.6.7

tcp:5.4.3.2\ntcp:8.9.10.11


], [], [VTEP_CTL_CLEANUP])
VTEP_CTL_CLEANUP
AT_CLEANUP

AT_SETUP([show command])
AT_KEYWORDS([vtep-ctl show])
VTEP_CTL_SETUP
AT_CHECK([RUN_VTEP_CTL(
  [set-manager tcp:4.5.6.7],
  [add-ps a],
  [add-port a a1],
  [add-ls ls1],
  [bind-ls a a1 100 ls1],
  [set Physical_Switch a management_ips=[[4.3.2.1]] tunnel_ips=[[1.2.3.4]]])], [0], [ignore], [], [VTEP_CTL_CLEANUP])

AT_CHECK([vtep-ctl --timeout=5 -vreconnect:emer --db=unix:socket show | tail -n+2 | sed 's/=[[a-f0-9-]][[a-f0-9-]]*\}/=<ls>\}/' ], [0], [dnl
    Manager "tcp:4.5.6.7"
    Physical_Switch a
        management_ips: [["4.3.2.1"]]
        tunnel_ips: [["1.2.3.4"]]
        Physical_Port "a1"
            vlan_bindings:
                100="ls1"
], [], [VTEP_CTL_CLEANUP])

VTEP_CTL_CLEANUP
AT_CLEANUP