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