]> git.proxmox.com Git - ovs.git/blob - tests/ovs-vsctl.at
System-tests: Improve reliability of an icmp test.
[ovs.git] / tests / ovs-vsctl.at
1 dnl OVS_VSCTL_SETUP
2 dnl
3 dnl Creates an empty database in the current directory and then starts
4 dnl an ovsdb-server on it for ovs-vsctl to connect to.
5 m4_define([OVS_VSCTL_SETUP],
6 [OVSDB_INIT([db])
7 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db >/dev/null 2>&1], [0], [ignore], [ignore])
8 on_exit 'kill `cat ovsdb-server.pid`'])
9
10 dnl OVS_VSCTL_CLEANUP
11 dnl
12 dnl Kills off the database server.
13 m4_define([OVS_VSCTL_CLEANUP], [OVS_APP_EXIT_AND_WAIT_BY_TARGET([ovsdb-server], [ovsdb-server.pid])])
14
15 dnl RUN_OVS_VSCTL(COMMAND, ...)
16 dnl
17 dnl Executes each ovs-vsctl COMMAND.
18 m4_define([RUN_OVS_VSCTL],
19 [m4_foreach([command], [$@], [ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket command
20 ])])
21 m4_define([RUN_OVS_VSCTL_ONELINE],
22 [m4_foreach([command], [$@], [ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket --oneline -- command
23 ])])
24
25 dnl RUN_OVS_VSCTL_TOGETHER(COMMAND, ...)
26 dnl
27 dnl Executes each ovs-vsctl COMMAND in a single run of ovs-vsctl.
28 m4_define([RUN_OVS_VSCTL_TOGETHER],
29 [ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket --oneline dnl
30 m4_foreach([command], [$@], [ -- command])])
31
32 dnl CHECK_BRIDGES([BRIDGE, PARENT, VLAN], ...)
33 dnl
34 dnl Verifies that "ovs-vsctl list-br" prints the specified list of bridges,
35 dnl which must be in alphabetical order. Also checks that each BRIDGE has the
36 dnl specified PARENT and is on the given VLAN.
37 m4_define([_CHECK_BRIDGE],
38 [AT_CHECK([RUN_OVS_VSCTL([br-to-parent $1])], [0], [$2
39 ], [], [OVS_VSCTL_CLEANUP])
40
41 # Check br-to-vlan, without --oneline.
42 AT_CHECK([RUN_OVS_VSCTL([br-to-vlan $1])], [0], [$3
43 ], [], [OVS_VSCTL_CLEANUP])
44 # Check br-to-vlan, with --oneline.
45 # (This particular test is interesting with --oneline because it returns
46 # an integer instead of a string and that can cause type mismatches inside
47 # python if not done carefully.)
48 AT_CHECK([RUN_OVS_VSCTL_ONELINE([br-to-vlan $1])], [0], [$3
49 ], [], [OVS_VSCTL_CLEANUP])
50
51 # Check multiple queries in a single run.
52 AT_CHECK([RUN_OVS_VSCTL_TOGETHER([br-to-parent $1], [br-to-vlan $1])], [0],
53 [$2
54 $3
55 ], [], [OVS_VSCTL_CLEANUP])])
56 m4_define([CHECK_BRIDGES],
57 [dnl Check that the bridges appear on list-br, without --oneline.
58 AT_CHECK(
59 [RUN_OVS_VSCTL([list-br])],
60 [0],
61 [m4_foreach([brinfo], [$@], [m4_car(brinfo)
62 ])],
63 [],
64 [OVS_VSCTL_CLEANUP])
65
66 dnl Check that the bridges appear on list-br, with --oneline.
67 AT_CHECK(
68 [RUN_OVS_VSCTL_ONELINE([list-br])],
69 [0],
70 [m4_join([\n], m4_foreach([brinfo], [$@], [m4_car(brinfo),]))
71 ],
72 [],
73 [OVS_VSCTL_CLEANUP])
74
75 dnl Check that each bridge exists according to br-exists and that
76 dnl a bridge that should not exist does not.
77 m4_foreach([brinfo], [$@],
78 [AT_CHECK([RUN_OVS_VSCTL([br-exists m4_car(brinfo)])], [0], [],
79 [], [OVS_VSCTL_CLEANUP])])
80 AT_CHECK([RUN_OVS_VSCTL([br-exists nonexistent])], [2], [], [],
81 [OVS_VSCTL_CLEANUP])
82
83 dnl Check that each bridge has the expected parent and VLAN.
84 m4_map([_CHECK_BRIDGE], [$@])])
85
86 dnl CHECK_PORTS(BRIDGE, PORT[, PORT...])
87 dnl
88 dnl Verifies that "ovs-vsctl list-ports BRIDGE" prints the specified
89 dnl list of ports, which must be in alphabetical order. Also checks
90 dnl that "ovs-vsctl port-to-br" reports that each port is
91 dnl in BRIDGE.
92 m4_define([CHECK_PORTS],
93 [dnl Check ports without --oneline.
94 AT_CHECK(
95 [RUN_OVS_VSCTL([list-ports $1])],
96 [0],
97 [m4_foreach([port], m4_cdr($@), [port
98 ])],
99 [],
100 [OVS_VSCTL_CLEANUP])
101
102 dnl Check ports with --oneline.
103 AT_CHECK(
104 [RUN_OVS_VSCTL_ONELINE([list-ports $1])],
105 [0],
106 [m4_join([\n], m4_shift($@))
107 ],
108 [],
109 [OVS_VSCTL_CLEANUP])
110 AT_CHECK([RUN_OVS_VSCTL([port-to-br $1])], [1], [],
111 [ovs-vsctl: no port named $1
112 ],
113 [OVS_VSCTL_CLEANUP])
114 m4_foreach(
115 [port], m4_cdr($@),
116 [AT_CHECK([RUN_OVS_VSCTL([[port-to-br] port])], [0], [$1
117 ], [], [OVS_VSCTL_CLEANUP])])])
118
119 dnl CHECK_IFACES(BRIDGE, IFACE[, IFACE...])
120 dnl
121 dnl Verifies that "ovs-vsctl list-ifaces BRIDGE" prints the specified
122 dnl list of ifaces, which must be in alphabetical order. Also checks
123 dnl that "ovs-vsctl iface-to-br" reports that each interface is
124 dnl in BRIDGE.
125 m4_define([CHECK_IFACES],
126 [AT_CHECK(
127 [RUN_OVS_VSCTL([list-ifaces $1])],
128 [0],
129 [m4_foreach([iface], m4_cdr($@), [iface
130 ])],
131 [],
132 [OVS_VSCTL_CLEANUP])
133 AT_CHECK([RUN_OVS_VSCTL([iface-to-br $1])], [1], [],
134 [ovs-vsctl: no interface named $1
135 ],
136 [OVS_VSCTL_CLEANUP])
137 m4_foreach(
138 [iface], m4_cdr($@),
139 [AT_CHECK([RUN_OVS_VSCTL([[iface-to-br] iface])], [0], [$1
140 ],
141 [], [OVS_VSCTL_CLEANUP])])])
142
143 dnl ----------------------------------------------------------------------
144 AT_BANNER([ovs-vsctl unit tests])
145
146 AT_SETUP([ovs-vsctl connection retry])
147 dnl Without --retry, there should be no retry for active connections.
148 AT_CHECK([ovs-vsctl --db=unix:foo --timeout=10 -vreconnect:emer -- init],
149 [1], [], [stderr])
150 AT_CHECK([[sed 's/([^()]*)/(...reason...)/' stderr]], [0],
151 [ovs-vsctl: unix:foo: database connection failed (...reason...)
152 ])
153
154 dnl With --retry, we should retry for active connections.
155 AT_CHECK(
156 [ovs-vsctl --db=unix:foo --timeout=1 --retry -vreconnect:emer -vPATTERN:console:'%c|%p|%m' -- init
157 echo $? > status],
158 [0], [], [stderr])
159 AT_CHECK([grep -c 'terminating with signal' stderr], [0], [1
160 ])
161 if test "$IS_WIN32" = "yes"; then
162 AT_CHECK([cat status], [0], [3
163 ])
164 else
165 # 128 + SIGALRM
166 AT_CHECK([cat status], [0], [142
167 ])
168 fi
169
170 dnl Without --retry, we should retry for passive connections.
171 AT_CHECK(
172 [ovs-vsctl --db=punix:foo --timeout=1 -vreconnect:emer -vPATTERN:console:'%c|%p|%m' -- init
173 echo $? > status],
174 [0], [], [stderr])
175 AT_CHECK([grep -c 'terminating with signal' stderr], [0], [1
176 ])
177 if test "$IS_WIN32" = "yes"; then
178 AT_CHECK([cat status], [0], [3
179 ])
180 else
181 # 128 + SIGALRM
182 AT_CHECK([cat status], [0], [142
183 ])
184 fi
185 AT_CLEANUP
186
187 dnl ----------------------------------------------------------------------
188 AT_BANNER([ovs-vsctl unit tests -- real bridges])
189
190 AT_SETUP([add-br a])
191 AT_KEYWORDS([ovs-vsctl])
192 OVS_VSCTL_SETUP
193 AT_CHECK([RUN_OVS_VSCTL([add-br a])], [0], [], [], [OVS_VSCTL_CLEANUP])
194 CHECK_BRIDGES([a, a, 0])
195 CHECK_PORTS([a])
196 CHECK_IFACES([a])
197 OVS_VSCTL_CLEANUP
198 AT_CLEANUP
199
200 AT_SETUP([add-br a, add-br a])
201 AT_KEYWORDS([ovs-vsctl])
202 OVS_VSCTL_SETUP
203 AT_CHECK([RUN_OVS_VSCTL([add-br a])], [0], [], [], [OVS_VSCTL_CLEANUP])
204 AT_CHECK([RUN_OVS_VSCTL([add-br a])], [1], [],
205 [ovs-vsctl: cannot create a bridge named a because a bridge named a already exists
206 ], [OVS_VSCTL_CLEANUP])
207 AT_CHECK([RUN_OVS_VSCTL([add-br ''])], [1], [],
208 [ovs-vsctl: bridge name must not be empty string
209 ], [OVS_VSCTL_CLEANUP])
210 OVS_VSCTL_CLEANUP
211 AT_CLEANUP
212
213 AT_SETUP([add-br a, add-br b])
214 AT_KEYWORDS([ovs-vsctl])
215 OVS_VSCTL_SETUP
216 AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b])], [0], [], [],
217 [OVS_VSCTL_CLEANUP])
218 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br a b 9])], [1], [],
219 [ovs-vsctl: "--may-exist add-br a b 9" but a is not a VLAN bridge
220 ],
221 [OVS_VSCTL_CLEANUP])
222 CHECK_BRIDGES([a, a, 0], [b, b, 0])
223 CHECK_PORTS([a])
224 CHECK_IFACES([a])
225 CHECK_PORTS([b])
226 CHECK_IFACES([b])
227 OVS_VSCTL_CLEANUP
228 AT_CLEANUP
229
230 AT_SETUP([add-br a, add-br b, del-br a])
231 AT_KEYWORDS([ovs-vsctl])
232 OVS_VSCTL_SETUP
233 AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b], [del-br a])], [0], [], [],
234 [OVS_VSCTL_CLEANUP])
235 CHECK_BRIDGES([b, b, 0])
236 CHECK_PORTS([b])
237 CHECK_IFACES([b])
238 OVS_VSCTL_CLEANUP
239 AT_CLEANUP
240
241 AT_SETUP([add-br a, del-br a, add-br a])
242 AT_KEYWORDS([ovs-vsctl])
243 OVS_VSCTL_SETUP
244 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
245 [add-br a],
246 [del-br a],
247 [add-br a],
248 [set Interface a other_config:key=value],
249 [get Interface a other_config:key])], [0], [
250
251
252
253 value
254 ], [], [OVS_VSCTL_CLEANUP])
255 CHECK_BRIDGES([a, a, 0])
256 CHECK_PORTS([a])
257 CHECK_IFACES([a])
258 OVS_VSCTL_CLEANUP
259 AT_CLEANUP
260
261 AT_SETUP([add-br a, add-port a a1, add-port a a2])
262 AT_KEYWORDS([ovs-vsctl])
263 OVS_VSCTL_SETUP
264 AT_CHECK([RUN_OVS_VSCTL(
265 [add-br a],
266 [--if-exists del-br b],
267 [add-port a a1],
268 [add-port a a2])], [0], [], [], [OVS_VSCTL_CLEANUP])
269 CHECK_BRIDGES([a, a, 0])
270 CHECK_PORTS([a], [a1], [a2])
271 CHECK_IFACES([a], [a1], [a2])
272 OVS_VSCTL_CLEANUP
273 AT_CLEANUP
274
275 AT_SETUP([add-br a, add-port a a1, add-port a a1])
276 AT_KEYWORDS([ovs-vsctl])
277 OVS_VSCTL_SETUP
278 AT_CHECK([RUN_OVS_VSCTL(
279 [add-br a],
280 [add-port a a1])], [0], [], [], [OVS_VSCTL_CLEANUP])
281 AT_CHECK([RUN_OVS_VSCTL([add-port a a1])], [1], [],
282 [ovs-vsctl: cannot create a port named a1 because a port named a1 already exists on bridge a
283 ], [OVS_VSCTL_CLEANUP])
284 AT_CHECK([RUN_OVS_VSCTL([add-port a ''])], [1], [],
285 [ovs-vsctl: port name must not be empty string
286 ], [OVS_VSCTL_CLEANUP])
287 OVS_VSCTL_CLEANUP
288 AT_CLEANUP
289
290 AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-br a])
291 AT_KEYWORDS([ovs-vsctl])
292 OVS_VSCTL_SETUP
293 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
294 [add-br a],
295 [add-br b],
296 [add-port a a1],
297 [add-port b b1],
298 [--if-exists del-port b b2],
299 [del-br a])], [0], [
300
301
302
303
304
305 ], [], [OVS_VSCTL_CLEANUP])
306 CHECK_BRIDGES([b, b, 0])
307 CHECK_PORTS([b], [b1])
308 CHECK_IFACES([b], [b1])
309 OVS_VSCTL_CLEANUP
310 AT_CLEANUP
311
312 AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3])
313 AT_KEYWORDS([ovs-vsctl])
314 OVS_VSCTL_SETUP
315 AT_CHECK([RUN_OVS_VSCTL(
316 [add-br a],
317 [add-bond a bond0 a1 a2 a3])], [0], [], [], [OVS_VSCTL_CLEANUP])
318 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond a bond0 a3 a1 a2])], [0], [], [],
319 [OVS_VSCTL_CLEANUP])
320 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond a bond0 a2 a1])], [1], [],
321 [ovs-vsctl: "--may-exist add-bond a bond0 a2 a1" but bond0 actually has interface(s) a1, a2, a3
322 ],
323 [OVS_VSCTL_CLEANUP])
324 AT_CHECK([RUN_OVS_VSCTL([add-bond a '' x y z])], [1], [],
325 [ovs-vsctl: port name must not be empty string
326 ], [OVS_VSCTL_CLEANUP])
327 AT_CHECK([RUN_OVS_VSCTL([add-bond a x '' y z])], [1], [],
328 [ovs-vsctl: interface name must not be empty string
329 ], [OVS_VSCTL_CLEANUP])
330 CHECK_BRIDGES([a, a, 0])
331 CHECK_PORTS([a], [bond0])
332 CHECK_IFACES([a], [a1], [a2], [a3])
333 OVS_VSCTL_CLEANUP
334 AT_CLEANUP
335
336 AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-port a a1])
337 AT_KEYWORDS([ovs-vsctl])
338 OVS_VSCTL_SETUP
339 AT_CHECK([RUN_OVS_VSCTL(
340 [add-br a],
341 [add-br b],
342 [add-port a a1 tag=9],
343 [get port a1 tag],
344 [--may-exist add-port b b1],
345 [del-port a a1])], [0], [9
346 ], [], [OVS_VSCTL_CLEANUP])
347 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port b b1])], [0], [], [],
348 [OVS_VSCTL_CLEANUP])
349 AT_CHECK([RUN_OVS_VSCTL([del-port a])], [1], [],
350 [ovs-vsctl: cannot delete port a because it is the local port for bridge a (deleting this port requires deleting the entire bridge)
351 ],
352 [OVS_VSCTL_CLEANUP])
353 AT_CHECK([RUN_OVS_VSCTL([--if-exists del-port a])], [0], [], [],
354 [OVS_VSCTL_CLEANUP])
355 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port a b1])], [1], [],
356 [ovs-vsctl: "--may-exist add-port a b1" but b1 is actually attached to bridge b
357 ],
358 [OVS_VSCTL_CLEANUP])
359 CHECK_BRIDGES([a, a, 0], [b, b, 0])
360 CHECK_PORTS([a])
361 CHECK_IFACES([a])
362 CHECK_PORTS([b], [b1])
363 CHECK_IFACES([b], [b1])
364 OVS_VSCTL_CLEANUP
365 AT_CLEANUP
366
367 AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3, del-port bond0])
368 AT_KEYWORDS([ovs-vsctl])
369 OVS_VSCTL_SETUP
370 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
371 [add-br a],
372 [add-bond a bond0 a1 a2 a3 tag=9],
373 [get Port bond0 tag],
374 [del-port bond0])], [0], [
375
376 9
377
378 ], [], [OVS_VSCTL_CLEANUP])
379 CHECK_BRIDGES([a, a, 0])
380 CHECK_PORTS([a])
381 OVS_VSCTL_CLEANUP
382 AT_CLEANUP
383
384 AT_SETUP([external IDs])
385 AT_KEYWORDS([ovs-vsctl])
386 OVS_VSCTL_SETUP
387 AT_CHECK([RUN_OVS_VSCTL_ONELINE(
388 [add-br a],
389 [add-port a a1],
390 [add-bond a bond0 a2 a3],
391 [br-set-external-id a key0 value0],
392 [set port a1 external-ids:key1=value1],
393 [set interface a2 external-ids:key2=value2],
394 [set interface a2 external-ids:key3=value3],
395 [set interface a3 external-ids:key4=value4],
396 [br-get-external-id a],
397 [br-get-external-id a key0],
398 [br-get-external-id a key1],
399 [br-set-external-id a key0 othervalue],
400 [br-get-external-id a],
401 [br-set-external-id a key0],
402 [br-get-external-id a],
403 [get port a1 external-ids],
404 [get interface a2 external-ids],
405 [get interface a3 external-ids])], [0], [
406
407
408
409
410
411
412
413 key0=value0
414 value0
415
416
417 key0=othervalue
418
419
420 {"key1"="value1"}
421 {"key2"="value2", "key3"="value3"}
422 {"key4"="value4"}
423 ], [], [OVS_VSCTL_CLEANUP])
424 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
425 [br-get-external-id a],
426 [get port a1 external-ids],
427 [get interface a2 external-ids],
428 [get interface a3 external-ids])], [0],
429 [
430 {"key1"="value1"}
431 {"key2"="value2", "key3"="value3"}
432 {"key4"="value4"}
433 ], [], [OVS_VSCTL_CLEANUP])
434 CHECK_BRIDGES([a, a, 0])
435 CHECK_PORTS([a], [a1], [bond0])
436 CHECK_IFACES([a], [a1], [a2], [a3])
437 OVS_VSCTL_CLEANUP
438 AT_CLEANUP
439
440 AT_SETUP([controllers])
441 AT_KEYWORDS([controller ovs-vsctl])
442 OVS_VSCTL_SETUP
443 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
444 [add-br br0],
445
446 [get-controller br0],
447 [set-controller br0 tcp:4.5.6.7],
448 [get-controller br0],
449
450 [del-controller br0],
451 [get-controller br0],
452
453 [set-controller br0 tcp:8.9.10.11 tcp:5.4.3.2],
454 [get-controller br0])], [0], [
455
456
457 tcp:4.5.6.7
458
459
460
461 tcp:5.4.3.2\ntcp:8.9.10.11
462 ], [], [OVS_VSCTL_CLEANUP])
463 OVS_VSCTL_CLEANUP
464 AT_CLEANUP
465
466 dnl ----------------------------------------------------------------------
467 dnl OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([VLAN])
468 m4_define([OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF],
469 [AT_CHECK(
470 [RUN_OVS_VSCTL(
471 [add-br xenbr0],
472 [--may-exist add-br xenbr0],
473 [add-port xenbr0 eth0],
474 [--may-exist add-port xenbr0 eth0],
475 [add-br xapi1 xenbr0 $1],
476 [--may-exist add-br xapi1 xenbr0 $1],
477 [add-port xapi1 eth0.$1])],
478 [0], [], [], [OVS_VSCTL_CLEANUP])])
479
480 dnl OVS_VSCTL_FAKE_BRIDGE_TESTS([VLAN])
481 m4_define([OVS_VSCTL_FAKE_BRIDGE_TESTS], [
482 AT_BANNER([ovs-vsctl unit tests -- fake bridges (VLAN $1)])
483
484 AT_SETUP([simple fake bridge (VLAN $1)])
485 AT_KEYWORDS([ovs-vsctl fake-bridge])
486 OVS_VSCTL_SETUP
487 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
488 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1])], [1], [],
489 [ovs-vsctl: "--may-exist add-br xapi1" but xapi1 is a VLAN bridge for VLAN $1
490 ], [OVS_VSCTL_CLEANUP])
491 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xxx $1])], [1], [],
492 [ovs-vsctl: "--may-exist add-br xapi1 xxx $1" but xapi1 has the wrong parent xenbr0
493 ], [OVS_VSCTL_CLEANUP])
494 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xenbr0 10])], [1], [],
495 [ovs-vsctl: "--may-exist add-br xapi1 xenbr0 10" but xapi1 is a VLAN bridge for the wrong VLAN $1
496 ], [OVS_VSCTL_CLEANUP])
497 AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br dup xenbr0 $1])], [1], [],
498 [ovs-vsctl: bridge xenbr0 already has a child VLAN bridge xapi1 on VLAN $1
499 ], [OVS_VSCTL_CLEANUP])
500 CHECK_BRIDGES([xapi1, xenbr0, $1], [xenbr0, xenbr0, 0])
501 CHECK_PORTS([xenbr0], [eth0])
502 CHECK_IFACES([xenbr0], [eth0])
503 CHECK_PORTS([xapi1], [eth0.$1])
504 CHECK_IFACES([xapi1], [eth0.$1])
505 OVS_VSCTL_CLEANUP
506 AT_CLEANUP
507
508 AT_SETUP([list bridges -- real and fake (VLAN $1)])
509 AT_KEYWORDS([ovs-vsctl fake-bridge])
510 OVS_VSCTL_SETUP
511 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
512 AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- list-br])], [0],
513 [xapi1\nxenbr0
514 ], [], [OVS_VSCTL_CLEANUP])
515 AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- --real list-br])], [0],
516 [xenbr0
517 ], [], [OVS_VSCTL_CLEANUP])
518 AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- --fake list-br])], [0],
519 [xapi1
520 ], [], [OVS_VSCTL_CLEANUP])
521 OVS_VSCTL_CLEANUP
522 AT_CLEANUP
523
524 AT_SETUP([simple fake bridge + del-br fake bridge (VLAN $1)])
525 AT_KEYWORDS([ovs-vsctl fake-bridge])
526 OVS_VSCTL_SETUP
527 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
528 AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])], [0], [], [], [OVS_VSCTL_CLEANUP])
529 CHECK_BRIDGES([xenbr0, xenbr0, 0])
530 CHECK_PORTS([xenbr0], [eth0])
531 CHECK_IFACES([xenbr0], [eth0])
532 OVS_VSCTL_CLEANUP
533 AT_CLEANUP
534
535 AT_SETUP([simple fake bridge + del-br real bridge (VLAN $1)])
536 AT_KEYWORDS([ovs-vsctl fake-bridge])
537 OVS_VSCTL_SETUP
538 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
539 AT_CHECK([RUN_OVS_VSCTL([del-br xenbr0])], [0], [], [], [OVS_VSCTL_CLEANUP])
540 CHECK_BRIDGES
541 OVS_VSCTL_CLEANUP
542 AT_CLEANUP
543
544 AT_SETUP([simple fake bridge + external IDs (VLAN $1)])
545 AT_KEYWORDS([ovs-vsctl fake-bridge])
546 OVS_VSCTL_SETUP
547 OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
548 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
549 [br-set-external-id xenbr0 key0 value0],
550 [br-set-external-id xapi1 key1 value1],
551 [br-get-external-id xenbr0],
552 [br-get-external-id xenbr0 key0],
553 [br-get-external-id xapi1],
554 [br-get-external-id xapi1 key1])], [0], [
555
556 key0=value0
557 value0
558 key1=value1
559 value1
560 ], [], [OVS_VSCTL_CLEANUP])
561 CHECK_BRIDGES([xapi1, xenbr0, $1], [xenbr0, xenbr0, 0])
562 CHECK_PORTS([xenbr0], [eth0])
563 CHECK_IFACES([xenbr0], [eth0])
564 CHECK_PORTS([xapi1], [eth0.$1])
565 CHECK_IFACES([xapi1], [eth0.$1])
566 OVS_VSCTL_CLEANUP
567 AT_CLEANUP
568 ]) # OVS_VSCTL_FAKE_BRIDGE_TESTS
569
570 OVS_VSCTL_FAKE_BRIDGE_TESTS([9])
571 OVS_VSCTL_FAKE_BRIDGE_TESTS([0])
572
573 dnl OVS_VSCTL_SETUP_BOND_FAKE_CONF([VLAN])
574 m4_define([OVS_VSCTL_SETUP_BOND_FAKE_CONF],
575 [AT_CHECK(
576 [RUN_OVS_VSCTL(
577 [add-br xapi1],
578 [add-bond xapi1 bond0 eth0 eth1],
579 [add-br xapi2 xapi1 $1],
580 [add-port xapi2 bond0.$1])],
581 [0], [], [], [OVS_VSCTL_CLEANUP])])
582
583 AT_SETUP([fake bridge on bond])
584 AT_KEYWORDS([ovs-vsctl fake-bridge])
585 OVS_VSCTL_SETUP
586 OVS_VSCTL_SETUP_BOND_FAKE_CONF([11])
587 CHECK_BRIDGES([xapi1, xapi1, 0], [xapi2, xapi1, 11])
588 CHECK_PORTS([xapi1], [bond0])
589 CHECK_IFACES([xapi1], [eth0], [eth1])
590 CHECK_PORTS([xapi2], [bond0.11])
591 CHECK_IFACES([xapi2], [bond0.11])
592 OVS_VSCTL_CLEANUP
593 AT_CLEANUP
594
595 AT_SETUP([fake bridge on bond + del-br fake bridge])
596 AT_KEYWORDS([ovs-vsctl fake-bridge])
597 OVS_VSCTL_SETUP
598 OVS_VSCTL_SETUP_BOND_FAKE_CONF([11])
599 AT_CHECK([RUN_OVS_VSCTL_ONELINE([del-br xapi2])], [0], [
600 ], [], [OVS_VSCTL_CLEANUP])
601 CHECK_BRIDGES([xapi1, xapi1, 0])
602 CHECK_PORTS([xapi1], [bond0])
603 CHECK_IFACES([xapi1], [eth0], [eth1])
604 OVS_VSCTL_CLEANUP
605 AT_CLEANUP
606
607 AT_SETUP([fake bridge on bond + del-br real bridge])
608 AT_KEYWORDS([ovs-vsctl fake-bridge])
609 OVS_VSCTL_SETUP
610 OVS_VSCTL_SETUP_BOND_FAKE_CONF([11])
611 AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])])
612 CHECK_BRIDGES
613 OVS_VSCTL_CLEANUP
614 AT_CLEANUP
615
616 dnl ----------------------------------------------------------------------
617 AT_BANNER([ovs-vsctl unit tests -- manager commands])
618
619 AT_SETUP([managers])
620 AT_KEYWORDS([manager ovs-vsctl])
621 OVS_VSCTL_SETUP
622 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
623 [del-manager],
624 [get-manager],
625 [set-manager tcp:4.5.6.7],
626 [get-manager],
627 [set-manager tcp:8.9.10.11 tcp:5.4.3.2],
628 [get-manager],
629 [del-manager],
630 [get-manager])], [0], [
631
632
633 tcp:4.5.6.7
634
635 tcp:5.4.3.2\ntcp:8.9.10.11
636
637
638 ], [], [OVS_VSCTL_CLEANUP])
639 OVS_VSCTL_CLEANUP
640 AT_CLEANUP
641
642 dnl ----------------------------------------------------------------------
643 AT_BANNER([ovs-vsctl unit tests -- database commands])
644
645 AT_SETUP([database commands -- positive checks])
646 AT_KEYWORDS([ovs-vsctl])
647 OVS_VSCTL_SETUP
648 AT_CHECK(
649 [RUN_OVS_VSCTL_TOGETHER([--id=@br0 create bridge name=br123],
650 [set b br123 name=br0],
651 [set o . bridges=@br0])],
652 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
653 cp stdout out1
654 AT_CHECK([RUN_OVS_VSCTL([list bridge], [get bridge br0 _uuid])],
655 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
656 cp stdout out2
657 AT_CHECK([${PERL} $srcdir/uuidfilt.pl out1 out2], [0],
658 [[<0>
659
660
661 _uuid : <0>
662 auto_attach : []
663 controller : []
664 datapath_id : []
665 datapath_type : ""
666 datapath_version : ""
667 external_ids : {}
668 fail_mode : []
669 flood_vlans : []
670 flow_tables : {}
671 ipfix : []
672 mcast_snooping_enable: false
673 mirrors : []
674 name : "br0"
675 netflow : []
676 other_config : {}
677 ports : []
678 protocols : []
679 rstp_enable : false
680 rstp_status : {}
681 sflow : []
682 status : {}
683 stp_enable : false
684 <0>
685 ]], [ignore])
686 AT_CHECK(
687 [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type list bridge])],
688 [0],
689 [[fail_mode : []
690 name : "br0"
691 datapath_type : ""
692 ]], [ignore])
693 AT_CHECK(
694 [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type find bridge])],
695 [0],
696 [[fail_mode : []
697 name : "br0"
698 datapath_type : ""
699 ]], [ignore])
700 AT_CHECK([
701 RUN_OVS_VSCTL_TOGETHER([--id=@br1 create bridge name=br1 datapath_type="foo"],
702 [--id=@br2 create bridge name=br2 external-ids:bar=quux],
703 [add o . bridges @br1 @br2])],
704 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
705 AT_CHECK(
706 [RUN_OVS_VSCTL([--columns=name find bridge datapath_type!=foo])], [0], [stdout],
707 [ignore])
708 AT_CHECK([sed -n '/./p' stdout | sort], [0],
709 [[name : "br0"
710 name : "br2"
711 ]])
712 AT_CHECK(
713 [RUN_OVS_VSCTL(
714 [set bridge br0 \
715 'other_config:datapath_id="0123456789ab"' \
716 'other_config:hwaddr="00:11:22:33:44:55"' \
717 'external-ids={"uuids"="9c45f225-a7cf-439d-976d-83db6271fda1"}' -- \
718 add bridge br0 external_ids '"roles"="local; remote; cloud"'])],
719 [0], [], [], [OVS_VSCTL_CLEANUP])
720 AT_CHECK([RUN_OVS_VSCTL_ONELINE([get bridge br0 other_config external-ids])],
721 [0], [{datapath_id="0123456789ab", hwaddr="00:11:22:33:44:55"}\n{roles="local; remote; cloud", uuids="9c45f225-a7cf-439d-976d-83db6271fda1"}
722 ], [], [OVS_VSCTL_CLEANUP])
723 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 other_config:hwaddr -- --if-exists get bridge br0 other-config:nonexistent])],
724 [0], ["00:11:22:33:44:55"
725
726 ], [], [OVS_VSCTL_CLEANUP])
727 AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 other_config hwaddr 'datapath_id=""' -- get bridge br0 other_config])],
728 [0], [{datapath_id="0123456789ab"}
729 ], [], [OVS_VSCTL_CLEANUP])
730 AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 other_config 'datapath_id="0123456789ab"' -- get bridge br0 other_config])],
731 [0], [{}
732 ], [], [OVS_VSCTL_CLEANUP])
733 AT_CHECK([RUN_OVS_VSCTL([clear bridge br0 external-ids -- get bridge br0 external_ids])],
734 [0], [{}
735 ], [], [OVS_VSCTL_CLEANUP])
736 AT_CHECK([RUN_OVS_VSCTL_TOGETHER([destroy bridge br0],
737 [destroy bridge br1],
738 [destroy bridge br2],
739 [clear o . bridges])],
740 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
741 AT_CHECK([RUN_OVS_VSCTL([list bridge])],
742 [0], [], [], [OVS_VSCTL_CLEANUP])
743 AT_CHECK([RUN_OVS_VSCTL([--if-exists get bridge x datapath_id])],
744 [0], [], [], [OVS_VSCTL_CLEANUP])
745 AT_CHECK([RUN_OVS_VSCTL([--if-exists list bridge x])],
746 [0], [], [], [OVS_VSCTL_CLEANUP])
747 AT_CHECK([RUN_OVS_VSCTL([--if-exists set controller x connection_mode=standalone])],
748 [0], [], [], [OVS_VSCTL_CLEANUP])
749 AT_CHECK(
750 [RUN_OVS_VSCTL([--if-exists remove netflow x targets '"1.2.3.4:567"'])],
751 [0], [], [], [OVS_VSCTL_CLEANUP])
752 AT_CHECK(
753 [RUN_OVS_VSCTL([--if-exists clear netflow x targets])],
754 [0], [], [], [OVS_VSCTL_CLEANUP])
755 OVS_VSCTL_CLEANUP
756 AT_CLEANUP
757
758 AT_SETUP([database commands -- negative checks])
759 AT_KEYWORDS([ovs-vsctl])
760 OVS_VSCTL_SETUP
761
762 AT_CHECK([ovs-vsctl --may-exist],
763 [1], [ignore], [ovs-vsctl: missing command name (use --help for help)
764 ], [OVS_VSCTL_CLEANUP])
765 AT_CHECK([ovs-vsctl --may-exist --],
766 [1], [ignore], [ovs-vsctl: missing command name (use --help for help)
767 ], [OVS_VSCTL_CLEANUP])
768 AT_CHECK([ovs-vsctl -- --may-exist],
769 [1], [ignore], [ovs-vsctl: missing command name (use --help for help)
770 ], [OVS_VSCTL_CLEANUP])
771
772 AT_CHECK([RUN_OVS_VSCTL([add-br br0])],
773 [0], [ignore], [], [OVS_VSCTL_CLEANUP])
774 AT_CHECK([RUN_OVS_VSCTL([add-br br1])],
775 [0], [ignore], [], [OVS_VSCTL_CLEANUP])
776 AT_CHECK([RUN_OVS_VSCTL([set-controller br1 tcp:127.0.0.1])],
777 [0], [ignore], [], [OVS_VSCTL_CLEANUP])
778 AT_CHECK([RUN_OVS_VSCTL([list netflow br0])], [1], [],
779 [ovs-vsctl: no row "br0" in table NetFlow
780 ], [OVS_VSCTL_CLEANUP])
781 AT_CHECK([
782 RUN_OVS_VSCTL_TOGETHER([--id=@n create netflow targets='"1.2.3.4:567"'],
783 [set bridge br0 netflow=@n])],
784 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
785 cp stdout netflow-uuid
786 AT_CHECK([RUN_OVS_VSCTL([list netflow `cat netflow-uuid`])],
787 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
788 AT_CHECK([${PERL} $srcdir/uuidfilt.pl netflow-uuid stdout], [0],
789 [[<0>
790
791 _uuid : <0>
792 active_timeout : 0
793 add_id_to_interface : false
794 engine_id : []
795 engine_type : []
796 external_ids : {}
797 targets : ["1.2.3.4:567"]
798 ]], [ignore])
799 AT_CHECK([RUN_OVS_VSCTL([list interx x])],
800 [1], [], [ovs-vsctl: unknown table "interx"
801 ], [OVS_VSCTL_CLEANUP])
802 AT_CHECK([RUN_OVS_VSCTL([list bridge x])],
803 [1], [], [ovs-vsctl: no row "x" in table Bridge
804 ], [OVS_VSCTL_CLEANUP])
805 AT_CHECK([RUN_OVS_VSCTL([get bridge x datapath_id])],
806 [1], [], [ovs-vsctl: no row "x" in table Bridge
807 ], [OVS_VSCTL_CLEANUP])
808 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 d])],
809 [1], [], [ovs-vsctl: Bridge contains more than one column whose name matches "d"
810 ], [OVS_VSCTL_CLEANUP])
811 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 x])],
812 [1], [], [ovs-vsctl: Bridge does not contain a column whose name matches "x"
813 ], [OVS_VSCTL_CLEANUP])
814 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 :y=z])],
815 [1], [], [ovs-vsctl: :y=z: missing column name
816 ], [OVS_VSCTL_CLEANUP])
817 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id:y=z])],
818 [1], [], [ovs-vsctl: datapath_id:y=z: trailing garbage "=z" in argument
819 ], [OVS_VSCTL_CLEANUP])
820 AT_CHECK([RUN_OVS_VSCTL([set bridge br0 'datapath_id:y>=z'])],
821 [1], [], [ovs-vsctl: datapath_id:y>=z: argument does not end in "=" followed by a value.
822 ], [OVS_VSCTL_CLEANUP])
823 AT_CHECK([RUN_OVS_VSCTL([set controller x connection_mode=standalone])],
824 [1], [], [ovs-vsctl: no row "x" in table Controller
825 ], [OVS_VSCTL_CLEANUP])
826 AT_CHECK([RUN_OVS_VSCTL([wait-until bridge br0 datapath_id:y,z])],
827 [1], [], [ovs-vsctl: datapath_id:y,z: argument does not end in "=", "!=", "<", ">", "<=", ">=", "{=}", "{!=}", "{<}", "{>}", "{<=}", or "{>=}" followed by a value.
828 ], [OVS_VSCTL_CLEANUP])
829 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id::])],
830 [1], [], [ovs-vsctl: datapath_id::: trailing garbage ":" in argument
831 ], [OVS_VSCTL_CLEANUP])
832 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id:x])],
833 [1], [], [ovs-vsctl: cannot specify key to get for non-map column datapath_id
834 ], [OVS_VSCTL_CLEANUP])
835 AT_CHECK([RUN_OVS_VSCTL([get bridge br0 external_ids:x])],
836 [1], [], [ovs-vsctl: no key "x" in Bridge record "br0" column external_ids
837 ], [OVS_VSCTL_CLEANUP])
838 AT_CHECK([RUN_OVS_VSCTL([set bridge br0 flood_vlans=-1])],
839 [1], [], [ovs-vsctl: constraint violation: -1 is not in the valid range 0 to 4095 (inclusive)
840 ], [OVS_VSCTL_CLEANUP])
841 AT_CHECK([RUN_OVS_VSCTL([set bridge br0 flood_vlans=4096])],
842 [1], [], [ovs-vsctl: constraint violation: 4096 is not in the valid range 0 to 4095 (inclusive)
843 ], [OVS_VSCTL_CLEANUP])
844 AT_CHECK([RUN_OVS_VSCTL([set c br1 'connection-mode=xyz'])],
845 [1], [], [[ovs-vsctl: constraint violation: xyz is not one of the allowed values ([in-band, out-of-band])
846 ]], [OVS_VSCTL_CLEANUP])
847 AT_CHECK([RUN_OVS_VSCTL([set c br1 connection-mode:x=y])],
848 [1], [], [ovs-vsctl: cannot specify key to set for non-map column connection_mode
849 ], [OVS_VSCTL_CLEANUP])
850 AT_CHECK([RUN_OVS_VSCTL([add bridge br1 datapath_id x y])],
851 [1], [], [ovs-vsctl: "add" operation would put 2 values in column datapath_id of table Bridge but the maximum number is 1
852 ], [OVS_VSCTL_CLEANUP])
853 AT_CHECK([RUN_OVS_VSCTL([remove netflow `cat netflow-uuid` targets '"1.2.3.4:567"'])],
854 [1], [], [ovs-vsctl: "remove" operation would put 0 values in column targets of table NetFlow but the minimum number is 1
855 ], [OVS_VSCTL_CLEANUP])
856 AT_CHECK([RUN_OVS_VSCTL([remove netflow x targets '"1.2.3.4:567"'])],
857 [1], [], [ovs-vsctl: no row "x" in table NetFlow
858 ], [OVS_VSCTL_CLEANUP])
859 AT_CHECK([RUN_OVS_VSCTL([clear netflow x targets])],
860 [1], [], [ovs-vsctl: no row "x" in table NetFlow
861 ], [OVS_VSCTL_CLEANUP])
862 AT_CHECK([RUN_OVS_VSCTL([clear netflow `cat netflow-uuid` targets])],
863 [1], [], [ovs-vsctl: "clear" operation cannot be applied to column targets of table NetFlow, which is not allowed to be empty
864 ], [OVS_VSCTL_CLEANUP])
865 AT_CHECK([RUN_OVS_VSCTL([destroy bridge br2])],
866 [1], [], [ovs-vsctl: no row "br2" in table Bridge
867 ], [OVS_VSCTL_CLEANUP])
868 AT_CHECK([RUN_OVS_VSCTL([add in br1 name x])],
869 [1], [], [ovs-vsctl: cannot modify read-only column name in table Interface
870 ], [OVS_VSCTL_CLEANUP])
871 AT_CHECK([RUN_OVS_VSCTL([set port br0 name=br2])],
872 [1], [], [ovs-vsctl: cannot modify read-only column name in table Port
873 ], [OVS_VSCTL_CLEANUP])
874 AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 name br1])],
875 [1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge
876 ], [OVS_VSCTL_CLEANUP])
877 AT_CHECK([RUN_OVS_VSCTL([remove bridge br1 flood-vlans true])],
878 [1], [], [ovs-vsctl: "true" is not a valid integer or range
879 ], [OVS_VSCTL_CLEANUP])
880 AT_CHECK([RUN_OVS_VSCTL([clear bridge br1 name])],
881 [1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge
882 ], [OVS_VSCTL_CLEANUP])
883 OVS_VSCTL_CLEANUP
884 AT_CLEANUP
885
886 AT_SETUP([database commands -- conditions])
887 AT_KEYWORDS([ovs-vsctl])
888 OVS_VSCTL_SETUP
889 AT_CHECK(
890 [RUN_OVS_VSCTL_TOGETHER(
891 [add-br br0],
892 [add-br br1], [set bridge br1 flood_vlans=0 other-config:x='""'],
893 [add-br br2], [set bridge br2 flood_vlans=1 other-config:x=y],
894 [add-br br3], [set bridge br3 flood_vlans=0,1 other-config:x=z],
895 [add-br br4], [set bridge br4 flood_vlans=2],
896 [add-br br5], [set bridge br5 flood_vlans=0,2],
897 [add-br br6], [set bridge br6 flood_vlans=1,2],
898 [add-br br7], [set bridge br7 flood_vlans=0,1,2])], [0], [
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913 ])
914 m4_define([VSCTL_CHECK_FIND],
915 [AT_CHECK([echo `ovs-vsctl --bare --no-wait -vreconnect:emer --db=unix:socket -- --columns=name find bridge '$1' | sort`], [0], [$2
916 ])])
917
918 # Arithmetic relational operators without keys.
919 VSCTL_CHECK_FIND([flood_vlans=0], [br1])
920 VSCTL_CHECK_FIND([flood_vlans=1], [br2])
921 VSCTL_CHECK_FIND([flood_vlans=0,2], [br5])
922 VSCTL_CHECK_FIND([flood_vlans=0,1,2], [br7])
923 VSCTL_CHECK_FIND([flood_vlans=3], [])
924
925 VSCTL_CHECK_FIND([flood_vlans!=0], [br0 br2 br3 br4 br5 br6 br7])
926 VSCTL_CHECK_FIND([flood_vlans!=1], [br0 br1 br3 br4 br5 br6 br7])
927 VSCTL_CHECK_FIND([flood_vlans!=0,2], [br0 br1 br2 br3 br4 br6 br7])
928 VSCTL_CHECK_FIND([flood_vlans!=0,1,2], [br0 br1 br2 br3 br4 br5 br6])
929 VSCTL_CHECK_FIND([flood_vlans!=3], [br0 br1 br2 br3 br4 br5 br6 br7])
930
931 VSCTL_CHECK_FIND([flood_vlans<2], [br0 br1 br2])
932 VSCTL_CHECK_FIND([flood_vlans<0,2], [br0 br1 br2 br3 br4])
933 VSCTL_CHECK_FIND([flood_vlans>1], [br3 br4 br5 br6 br7])
934 VSCTL_CHECK_FIND([flood_vlans>0,1], [br5 br6 br7])
935 VSCTL_CHECK_FIND([flood_vlans<=2], [br0 br1 br2 br4])
936 VSCTL_CHECK_FIND([flood_vlans<=0,2], [br0 br1 br2 br3 br4 br5])
937 VSCTL_CHECK_FIND([flood_vlans>=1], [br2 br3 br4 br5 br6 br7])
938 VSCTL_CHECK_FIND([flood_vlans>=0,1], [br3 br5 br6 br7])
939
940 # Set relational operators without keys.
941 VSCTL_CHECK_FIND([flood_vlans{=}0], [br1])
942 VSCTL_CHECK_FIND([flood_vlans{=}1], [br2])
943 VSCTL_CHECK_FIND([flood_vlans{=}0,2], [br5])
944 VSCTL_CHECK_FIND([flood_vlans{=}0,1,2], [br7])
945 VSCTL_CHECK_FIND([flood_vlans{=}3], [])
946
947 VSCTL_CHECK_FIND([flood_vlans{!=}0], [br0 br2 br3 br4 br5 br6 br7])
948 VSCTL_CHECK_FIND([flood_vlans{!=}1], [br0 br1 br3 br4 br5 br6 br7])
949 VSCTL_CHECK_FIND([flood_vlans{!=}0,2], [br0 br1 br2 br3 br4 br6 br7])
950 VSCTL_CHECK_FIND([flood_vlans{!=}0,1,2], [br0 br1 br2 br3 br4 br5 br6])
951 VSCTL_CHECK_FIND([flood_vlans{!=}3], [br0 br1 br2 br3 br4 br5 br6 br7])
952
953 VSCTL_CHECK_FIND([flood_vlans{<}[[]]], [])
954 VSCTL_CHECK_FIND([flood_vlans{<=}[[]]], [br0])
955 VSCTL_CHECK_FIND([flood_vlans{<}0], [br0])
956 VSCTL_CHECK_FIND([flood_vlans{<=}0], [br0 br1])
957 VSCTL_CHECK_FIND([flood_vlans{<}1,2], [br0 br2 br4])
958 VSCTL_CHECK_FIND([flood_vlans{<=}1,2], [br0 br2 br4 br6])
959
960 VSCTL_CHECK_FIND([flood_vlans{>}[[]]], [br1 br2 br3 br4 br5 br6 br7])
961 VSCTL_CHECK_FIND([flood_vlans{>=}[[]]], [br0 br1 br2 br3 br4 br5 br6 br7])
962 VSCTL_CHECK_FIND([flood_vlans{>}0], [br3 br5 br7])
963 VSCTL_CHECK_FIND([flood_vlans{>=}0], [br1 br3 br5 br7])
964 VSCTL_CHECK_FIND([flood_vlans{>}0,2], [br7])
965 VSCTL_CHECK_FIND([flood_vlans{>=}1,2], [br6 br7])
966 VSCTL_CHECK_FIND([flood_vlans{>=}0,2], [br5 br7])
967
968 # Arithmetic relational operators with keys.
969 VSCTL_CHECK_FIND([other-config:x=""], [br1])
970 VSCTL_CHECK_FIND([other-config:x=y], [br2])
971 VSCTL_CHECK_FIND([other-config:x=z], [br3])
972
973 VSCTL_CHECK_FIND([other-config:x!=""], [br2 br3])
974 VSCTL_CHECK_FIND([other-config:x!=y], [br1 br3])
975 VSCTL_CHECK_FIND([other-config:x!=z], [br1 br2])
976
977 VSCTL_CHECK_FIND([other-config:x>y], [br3])
978 VSCTL_CHECK_FIND([other-config:x>=y], [br2 br3])
979 VSCTL_CHECK_FIND([other-config:x<y], [br1])
980 VSCTL_CHECK_FIND([other-config:x<=y], [br1 br2])
981
982 # Set relational operators with keys.
983 VSCTL_CHECK_FIND([other-config:x{=}[[]]], [br0 br4 br5 br6 br7])
984 VSCTL_CHECK_FIND([other-config:x{=}""], [br1])
985 VSCTL_CHECK_FIND([other-config:x{=}y], [br2])
986 VSCTL_CHECK_FIND([other-config:x{=}z], [br3])
987
988 VSCTL_CHECK_FIND([other-config:x{!=}[[]]], [br1 br2 br3])
989 VSCTL_CHECK_FIND([other-config:x{!=}""], [br0 br2 br3 br4 br5 br6 br7])
990 VSCTL_CHECK_FIND([other-config:x{!=}y], [br0 br1 br3 br4 br5 br6 br7])
991 VSCTL_CHECK_FIND([other-config:x{!=}z], [br0 br1 br2 br4 br5 br6 br7])
992
993 VSCTL_CHECK_FIND([other-config:x{<=}[[]]], [br0 br4 br5 br6 br7])
994 VSCTL_CHECK_FIND([other-config:x{<=}x], [br0 br4 br5 br6 br7])
995 VSCTL_CHECK_FIND([other-config:x{<=}""], [br0 br1 br4 br5 br6 br7])
996 VSCTL_CHECK_FIND([other-config:x{<=}y], [br0 br2 br4 br5 br6 br7])
997 VSCTL_CHECK_FIND([other-config:x{<=}z], [br0 br3 br4 br5 br6 br7])
998 VSCTL_CHECK_FIND([other-config:x{<=}x,y,z], [br0 br2 br3 br4 br5 br6 br7])
999
1000 VSCTL_CHECK_FIND([other-config:x{<}[[]]], [])
1001 VSCTL_CHECK_FIND([other-config:x{<}x], [br0 br4 br5 br6 br7])
1002 VSCTL_CHECK_FIND([other-config:x{<}""], [br0 br4 br5 br6 br7])
1003 VSCTL_CHECK_FIND([other-config:x{<}y], [br0 br4 br5 br6 br7])
1004 VSCTL_CHECK_FIND([other-config:x{<}z], [br0 br4 br5 br6 br7])
1005
1006 VSCTL_CHECK_FIND([other-config:x{>=}[[]]], [br0 br1 br2 br3 br4 br5 br6 br7])
1007 VSCTL_CHECK_FIND([other-config:x{>=}x], [])
1008 VSCTL_CHECK_FIND([other-config:x{>=}""], [br1])
1009 VSCTL_CHECK_FIND([other-config:x{>=}y], [br2])
1010 VSCTL_CHECK_FIND([other-config:x{>=}z], [br3])
1011
1012 VSCTL_CHECK_FIND([other-config:x{>}[[]]], [br1 br2 br3])
1013 VSCTL_CHECK_FIND([other-config:x{>}x], [])
1014 VSCTL_CHECK_FIND([other-config:x{>}""], [])
1015 VSCTL_CHECK_FIND([other-config:x{>}y], [])
1016 VSCTL_CHECK_FIND([other-config:x{>}z], [])
1017 OVS_VSCTL_CLEANUP
1018 AT_CLEANUP
1019
1020 AT_SETUP([database commands -- wait-until immediately true])
1021 AT_KEYWORDS([ovs-vsctl])
1022 OVS_VSCTL_SETUP
1023 AT_CHECK([RUN_OVS_VSCTL(
1024 [add-br br0],
1025 [add-bond br0 bond0 eth0 eth1],
1026 [set port bond0 bond_updelay=500 other-config:abc=def])],
1027 [0], [], [], [OVS_VSCTL_CLEANUP])
1028 AT_CHECK([RUN_OVS_VSCTL([[wait-until Open_vSwitch . manager_options=[]]])],
1029 [0], [], [], [OVS_VSCTL_CLEANUP])
1030 AT_CHECK([RUN_OVS_VSCTL([[wait-until Open_vSwitch . bridges!=[]]])],
1031 [0], [], [], [OVS_VSCTL_CLEANUP])
1032 AT_CHECK([RUN_OVS_VSCTL([[wait-until Port bond0 other-config:abc=def]])],
1033 [0], [], [], [OVS_VSCTL_CLEANUP])
1034 AT_CHECK([RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' 'other-config:abc>d' 'other-config:abc<e']])],
1035 [0], [], [], [OVS_VSCTL_CLEANUP])
1036 OVS_VSCTL_CLEANUP
1037 AT_CLEANUP
1038
1039 AT_SETUP([database commands -- wait-until must wait])
1040 AT_KEYWORDS([ovs-vsctl])
1041
1042 OVS_VSCTL_SETUP
1043
1044 # Start ovs-vsctls in background.
1045 (RUN_OVS_VSCTL([[wait-until o . bridges!=[] -- get bridge br10 other-config:abc]])) > stdout1 &
1046 (RUN_OVS_VSCTL([[wait-until bridge br1 -- get bridge br1 other-config:abc]])) > stdout2 &
1047 (RUN_OVS_VSCTL([[wait-until bridge br1 other-config={abc=def} -- get bridge br1 other-config]])) > stdout3 &
1048 (RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' -- get port bond0 bond-updelay]])) > stdout4 &
1049
1050 # Give the ovs-vsctls a chance to read the database
1051 sleep 1
1052
1053 AT_CHECK([RUN_OVS_VSCTL([add-br br10 -- set bridge br10 other-config:abc=quux])
1054 RUN_OVS_VSCTL([add-br br1 -- set bridge br1 other-config:abc=def -- add-bond br1 bond0 eth0 eth1 -- set port bond0 bond_updelay=500])],
1055 [0], [], [], [OVS_VSCTL_CLEANUP])
1056
1057 # Wait for the ovs-vsctls to finish.
1058 wait
1059
1060 # Check output
1061 AT_CHECK([cat stdout1], [0], [quux
1062 ], [], [OVS_VSCTL_CLEANUP])
1063 AT_CHECK([cat stdout2], [0], [def
1064 ], [], [OVS_VSCTL_CLEANUP])
1065 AT_CHECK([cat stdout3], [0], [{abc=def}
1066 ], [], [OVS_VSCTL_CLEANUP])
1067 AT_CHECK([cat stdout4], [0], [500
1068 ], [], [OVS_VSCTL_CLEANUP])
1069
1070 OVS_VSCTL_CLEANUP
1071 AT_CLEANUP
1072
1073 AT_SETUP([--id option on create, get commands])
1074 AT_KEYWORDS([ovs-vsctl])
1075 OVS_VSCTL_SETUP
1076 AT_CHECK([RUN_OVS_VSCTL([add-br br0],
1077 [add-port br0 eth0],
1078 [add-port br0 eth1])])
1079 AT_CHECK(
1080 [RUN_OVS_VSCTL_TOGETHER(
1081 [set bridge br0 mirrors=@m],
1082 [--id=@eth0 get port eth0],
1083 [--id=@eth1 get port eth1],
1084 [--id=@m create mirror name=mymirror select-dst-port=@eth0 select-src-port=@eth0 output-port=@eth1])],
1085 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
1086 AT_CHECK(
1087 [${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
1088
1089
1090
1091 <0>
1092 ],
1093 [], [OVS_VSCTL_CLEANUP])
1094 AT_CHECK(
1095 [RUN_OVS_VSCTL(
1096 [list port eth0 eth1],
1097 [list mirror],
1098 [list bridge br0])],
1099 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
1100 AT_CHECK(
1101 [sed -n -e '/uuid/p' -e '/name/p' -e '/mirrors/p' -e '/select/p' -e '/output/p' < stdout | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
1102 [_uuid : <0>
1103 name : "eth0"
1104 _uuid : <1>
1105 name : "eth1"
1106 _uuid : <2>
1107 name : mymirror
1108 output_port : <1>
1109 output_vlan : []
1110 select_all : false
1111 select_dst_port : [<0>]
1112 select_src_port : [<0>]
1113 select_vlan : []
1114 _uuid : <3>
1115 mirrors : [<2>]
1116 name : "br0"
1117 ]],
1118 [], [OVS_VSCTL_CLEANUP])
1119 OVS_VSCTL_CLEANUP
1120 AT_CLEANUP
1121
1122 AT_SETUP([unreferenced record warnings])
1123 AT_KEYWORDS([ovs-vsctl])
1124 OVS_VSCTL_SETUP
1125 AT_CHECK(
1126 [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \
1127 -- create Bridge name=br0 | ${PERL} $srcdir/uuidfilt.pl],
1128 [0], [<0>
1129 ], [db_ctl_base|WARN|applying "create" command to table Bridge without --id option will have no effect
1130 ], [OVS_VSCTL_CLEANUP])
1131 AT_CHECK(
1132 [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \
1133 -- --id=@br0 create Bridge name=br0 | ${PERL} $srcdir/uuidfilt.pl],
1134 [0], [<0>
1135 ], [vsctl|WARN|row id "@br0" was created but no reference to it was inserted, so it will not actually appear in the database
1136 ], [OVS_VSCTL_CLEANUP])
1137 AT_CHECK(
1138 [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \
1139 -- --id=@eth0_iface create Interface name=eth0 \
1140 -- --id=@eth0 create Port name=eth0 interfaces=@eth0_iface \
1141 -- --id=@m0 create Mirror name=m0 output_port=@eth0 \
1142 -- --id=@br0 create Bridge name=br0 mirrors=@m0 \
1143 -- set Open_vSwitch . bridges=@br0 | ${PERL} $srcdir/uuidfilt.pl],
1144 [0], [<0>
1145 <1>
1146 <2>
1147 <3>
1148 ], [vsctl|WARN|row id "@eth0" was created but only a weak reference to it was inserted, so it will not actually appear in the database
1149 ], [OVS_VSCTL_CLEANUP])
1150 OVS_VSCTL_CLEANUP
1151 AT_CLEANUP
1152
1153 dnl This test really shows a bug -- "create" followed by "list" in
1154 dnl the same execution shows the wrong UUID on the "list" command.
1155 dnl The bug is documented in ovs-vsctl.8.
1156 AT_SETUP([created row UUID is wrong in same execution])
1157 AT_KEYWORDS([ovs-vsctl])
1158 OVS_VSCTL_SETUP
1159 AT_CHECK([RUN_OVS_VSCTL([--id=@br0 create Bridge name=br0 -- add Open_vSwitch . bridges @br0 -- list bridge])],
1160 [0], [stdout], [], [OVS_VSCTL_CLEANUP])
1161 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0],
1162 [[<0>
1163 _uuid : <1>
1164 auto_attach : []
1165 controller : []
1166 datapath_id : []
1167 datapath_type : ""
1168 datapath_version : ""
1169 external_ids : {}
1170 fail_mode : []
1171 flood_vlans : []
1172 flow_tables : {}
1173 ipfix : []
1174 mcast_snooping_enable: false
1175 mirrors : []
1176 name : "br0"
1177 netflow : []
1178 other_config : {}
1179 ports : []
1180 protocols : []
1181 rstp_enable : false
1182 rstp_status : {}
1183 sflow : []
1184 status : {}
1185 stp_enable : false
1186 ]], [ignore])
1187 OVS_VSCTL_CLEANUP
1188 AT_CLEANUP
1189
1190 dnl This test will create a linux-htb QoS record that
1191 dnl points to a few queues and use it on a1 and a2 port.
1192 dnl It also destroys all records from Qos and Queue table.
1193 AT_SETUP([--all option on destroy command])
1194 AT_KEYWORDS([ovs-vsctl])
1195 OVS_VSCTL_SETUP
1196 AT_CHECK([RUN_OVS_VSCTL(
1197 [add-br a],
1198 [add-port a a1],
1199 [add-port a a2])], [0], [], [], [OVS_VSCTL_CLEANUP])
1200 CHECK_BRIDGES([a, a, 0])
1201 CHECK_PORTS([a], [a1], [a2])
1202 CHECK_IFACES([a], [a1], [a2])
1203 AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
1204 [set Port a1 qos=@newqos],
1205 [set Port a2 qos=@newqos],
1206 [--id=@newqos create QoS type=linux-htb other-config:max-rate=1000000000 queues=0=@q0,1=@q1],
1207 [--id=@q0 create Queue other-config:min-rate=100000000 other-config:max-rate=100000000],
1208 [--id=@q1 create Queue other-config:min-rate=500000000])], [0], [ignore], [], [OVS_VSCTL_CLEANUP])
1209 AT_CHECK([RUN_OVS_VSCTL(
1210 [--columns=other_config,type list Qos])], [0],
1211 [other_config : {max-rate="1000000000"}
1212 type : linux-htb
1213 ], [], [OVS_VSCTL_CLEANUP])
1214 AT_CHECK([RUN_OVS_VSCTL(
1215 [--columns=other_config list Queue | sort | sed '/^$/d'])], [0],
1216 [other_config : {max-rate="100000000", min-rate="100000000"}
1217 other_config : {min-rate="500000000"}
1218 ], [], [OVS_VSCTL_CLEANUP])
1219 AT_CHECK([RUN_OVS_VSCTL(
1220 [clear Port a1 qos],
1221 [clear Port a2 qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
1222 AT_CHECK([RUN_OVS_VSCTL(
1223 [--columns=qos list Port a1 a2])], [0],
1224 [[qos : []
1225
1226 qos : []
1227 ]], [], [OVS_VSCTL_CLEANUP])
1228 AT_CHECK([RUN_OVS_VSCTL(
1229 [--all destroy Qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
1230 AT_CHECK([RUN_OVS_VSCTL(
1231 [-- list Qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
1232 AT_CHECK([RUN_OVS_VSCTL(
1233 [--all destroy Queue])], [0], [], [], [OVS_VSCTL_CLEANUP])
1234 AT_CHECK([RUN_OVS_VSCTL(
1235 [-- list Queue])], [0], [], [], [OVS_VSCTL_CLEANUP])
1236 OVS_VSCTL_CLEANUP
1237 AT_CLEANUP
1238
1239 dnl ----------------------------------------------------------------------
1240 AT_BANNER([ovs-vsctl add-port -- reserved port names])
1241
1242 AT_SETUP([add-port -- reserved names 1])
1243 OVS_VSWITCHD_START
1244
1245 # Test creating all reserved port names
1246 m4_foreach(
1247 [reserved_name],
1248 [[ovs-netdev],
1249 [ovs-dummy],
1250 [genev_sys],
1251 [gre_sys],
1252 [lisp_sys],
1253 [vxlan_sys]],
1254 [
1255 # Try creating the port
1256 cat >experr <<EOF
1257 ovs-vsctl: Error detected while setting up 'reserved_name'. See ovs-vswitchd log for details.
1258 ovs-vsctl: The default log directory is "$OVS_RUNDIR".
1259 EOF
1260 AT_CHECK([ovs-vsctl add-port br0 reserved_name], [0], [], [experr])
1261 # Prevent race.
1262 OVS_WAIT_UNTIL([test `grep -- "|WARN|" ovs-vswitchd.log | wc -l` -ge 1])
1263 # Detect the warning log message
1264 AT_CHECK([sed -n "s/^.*\(|bridge|WARN|.*\)$/\1/p" ovs-vswitchd.log], [0], [dnl
1265 |bridge|WARN|could not create interface reserved_name, name is reserved
1266 ])
1267 # Delete the warning log message
1268 AT_CHECK([sed "/|bridge|WARN|/d" ovs-vswitchd.log > ovs-vswitchd.log], [0], [], [])
1269 # Delete the port
1270 AT_CHECK([ovs-vsctl del-port br0 reserved_name], [0], [], [])])
1271 OVS_VSWITCHD_STOP
1272 AT_CLEANUP
1273
1274 AT_SETUP([add-port -- reserved names 2])
1275 # Creates all type of tunnel ports
1276 OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
1277 options:remote_ip=1.1.1.1 ofport_request=1\
1278 -- add-port br0 p3 -- set Interface p3 type=lisp \
1279 options:remote_ip=2.2.2.2 ofport_request=3 \
1280 -- add-port br0 p4 -- set Interface p4 type=vxlan \
1281 options:remote_ip=2.2.2.2 ofport_request=4 \
1282 -- add-port br0 p5 -- set Interface p5 type=geneve \
1283 options:remote_ip=2.2.2.2 ofport_request=5])
1284
1285 # Test creating all reserved tunnel port names
1286 m4_foreach(
1287 [reserved_name],
1288 [[genev_sys],
1289 [gre_sys],
1290 [lisp_sys],
1291 [vxlan_sys]],
1292 [
1293 # Try creating the port
1294 cat >experr <<EOF
1295 ovs-vsctl: Error detected while setting up 'reserved_name'. See ovs-vswitchd log for details.
1296 ovs-vsctl: The default log directory is "$OVS_RUNDIR".
1297 EOF
1298 AT_CHECK([ovs-vsctl add-port br0 reserved_name], [0], [], [experr])
1299 # Prevent race.
1300 OVS_WAIT_UNTIL([test `grep -- "|WARN|" ovs-vswitchd.log | wc -l` -ge 1])
1301 # Detect the warning log message
1302 AT_CHECK([sed -n "s/^.*\(|bridge|WARN|.*\)$/\1/p" ovs-vswitchd.log], [0], [dnl
1303 |bridge|WARN|could not create interface reserved_name, name is reserved
1304 ])
1305 # Delete the warning log message
1306 AT_CHECK([sed "/|bridge|WARN|/d" ovs-vswitchd.log > ovs-vswitchd.log], [0], [], [])
1307 # Delete the port
1308 AT_CHECK([ovs-vsctl del-port br0 reserved_name], [0], [], [])])
1309 OVS_VSWITCHD_STOP
1310 AT_CLEANUP
1311
1312 AT_SETUP([naming in db commands])
1313 AT_KEYWORDS([ovs-vsctl])
1314 OVS_VSCTL_SETUP
1315
1316 dnl First check that the database commands can refer to row by database UUID.
1317 AT_CHECK([RUN_OVS_VSCTL([add-br br0])])
1318 uuid=`[]RUN_OVS_VSCTL(get port br0 _uuid)`
1319 AT_CHECK([RUN_OVS_VSCTL([get port $uuid name])], [0], ["br0"
1320 ])
1321
1322 dnl Next check that, if a database row is given a name that has the same form
1323 dnl as the database UUIDs, the name can still be used to refer to rows.
1324 AT_CHECK([RUN_OVS_VSCTL([add-br 0fcd11a1-2ba8-4b38-a358-4bccf2bf3057])])
1325 AT_CHECK([RUN_OVS_VSCTL([get interface 0fcd11a1-2ba8-4b38-a358-4bccf2bf3057 type])], [0], [internal
1326 ])
1327
1328 OVS_VSCTL_CLEANUP
1329 AT_CLEANUP
1330
1331 AT_SETUP([bootstrap ca cert])
1332 AT_KEYWORDS([ovs-vsctl ssl])
1333 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
1334 PKIDIR=`pwd`
1335 OVS_PKI="sh $abs_top_srcdir/utilities/ovs-pki.in --dir=$PKIDIR/pki --log=$PKIDIR/ovs-pki.log"
1336 AT_CHECK([$OVS_PKI -B 1024 init && $OVS_PKI -B 1024 req+sign vsctl switch && $OVS_PKI -B 1024 req ovsdbserver && $OVS_PKI self-sign ovsdbserver], [0], [ignore], [ignore])
1337
1338 dnl Create database.
1339 OVSDB_INIT([conf.db])
1340 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --private-key=$PKIDIR/ovsdbserver-privkey.pem --certificate=$PKIDIR/ovsdbserver-cert.pem --ca-cert=$PKIDIR/pki/switchca/cacert.pem --remote=pssl:0:127.0.0.1 --log-file="`pwd`"/ovsdb-server.log conf.db], [0], [ignore], [ignore])
1341 on_exit "kill `cat ovsdb-server.pid`"
1342 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
1343
1344 # During bootstrap, the connection gets torn down. So the o/p of ovs-vsctl is error.
1345 AT_CHECK([ovs-vsctl -t 5 --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem show], [1], [ignore], [ignore])
1346
1347 # If the bootstrap was successful, the following file should exist.
1348 OVS_WAIT_UNTIL([test -e $PKIDIR/cacert.pem])
1349
1350 # After bootstrap, the connection should be successful.
1351 AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem add-br br0], [0])
1352 AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem list-br], [0], [br0
1353 ])
1354
1355 OVS_VSCTL_CLEANUP
1356 AT_CLEANUP
1357
1358 AT_SETUP([peer ca cert])
1359 AT_KEYWORDS([ovs-vsctl ssl])
1360 AT_SKIP_IF([test "$HAVE_OPENSSL" = no])
1361 PKIDIR=`pwd`
1362 OVS_PKI="sh $abs_top_srcdir/utilities/ovs-pki.in --dir=$PKIDIR/pki --log=$PKIDIR/ovs-pki.log"
1363 AT_CHECK([$OVS_PKI -B 1024 init && $OVS_PKI -B 1024 req+sign vsctl switch && $OVS_PKI -B 1024 req+sign ovsdbserver controller], [0], [ignore], [ignore])
1364
1365 dnl Create database.
1366 OVSDB_INIT([conf.db])
1367 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --private-key=$PKIDIR/ovsdbserver-privkey.pem --certificate=$PKIDIR/ovsdbserver-cert.pem --ca-cert=$PKIDIR/pki/switchca/cacert.pem --peer-ca-cert=$PKIDIR/pki/controllerca/cacert.pem --remote=pssl:0:127.0.0.1 --log-file="`pwd`"/ovsdb-server.log conf.db], [0], [ignore], [ignore])
1368 on_exit "kill `cat ovsdb-server.pid`"
1369 PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT])
1370
1371 # During bootstrap, the connection gets torn down. So the o/p of ovs-vsctl is error.
1372 AT_CHECK([ovs-vsctl -t 5 --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem show], [1], [ignore], [ignore])
1373
1374 # If the bootstrap was successful, the following file should exist.
1375 OVS_WAIT_UNTIL([test -e $PKIDIR/cacert.pem])
1376
1377 # After bootstrap, the connection should be successful.
1378 AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem add-br br0], [0])
1379 AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem list-br], [0], [br0
1380 ])
1381
1382 OVS_VSCTL_CLEANUP
1383 AT_CLEANUP