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
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
|
dnl OVS_VSCTL_SETUP
dnl
dnl Creates an empty database in the current directory and then starts
dnl an ovsdb-server on it for ovs-vsctl to connect to.
m4_define([OVS_VSCTL_SETUP],
[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 OVS_VSCTL_CLEANUP
dnl
dnl Kills off the database server.
m4_define([OVS_VSCTL_CLEANUP], [OVSDB_SERVER_SHUTDOWN])
dnl RUN_OVS_VSCTL(COMMAND, ...)
dnl
dnl Executes each ovs-vsctl COMMAND.
m4_define([RUN_OVS_VSCTL],
[m4_foreach([command], [$@], [ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket command
])])
m4_define([RUN_OVS_VSCTL_ONELINE],
[m4_foreach([command], [$@], [ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket --oneline -- command
])])
dnl RUN_OVS_VSCTL_TOGETHER(COMMAND, ...)
dnl
dnl Executes each ovs-vsctl COMMAND in a single run of ovs-vsctl.
m4_define([RUN_OVS_VSCTL_TOGETHER],
[ovs-vsctl --no-wait -vreconnect:emer --db=unix:socket --oneline dnl
m4_foreach([command], [$@], [ -- command])])
dnl CHECK_BRIDGES([BRIDGE, PARENT, VLAN], ...)
dnl
dnl Verifies that "ovs-vsctl list-br" prints the specified list of bridges,
dnl which must be in alphabetical order. Also checks that each BRIDGE has the
dnl specified PARENT and is on the given VLAN.
m4_define([_CHECK_BRIDGE],
[AT_CHECK([RUN_OVS_VSCTL([br-to-parent $1])], [0], [$2
], [], [OVS_VSCTL_CLEANUP])
# Check br-to-vlan, without --oneline.
AT_CHECK([RUN_OVS_VSCTL([br-to-vlan $1])], [0], [$3
], [], [OVS_VSCTL_CLEANUP])
# Check br-to-vlan, with --oneline.
# (This particular test is interesting with --oneline because it returns
# an integer instead of a string and that can cause type mismatches inside
# python if not done carefully.)
AT_CHECK([RUN_OVS_VSCTL_ONELINE([br-to-vlan $1])], [0], [$3
], [], [OVS_VSCTL_CLEANUP])
# Check multiple queries in a single run.
AT_CHECK([RUN_OVS_VSCTL_TOGETHER([br-to-parent $1], [br-to-vlan $1])], [0],
[$2
$3
], [], [OVS_VSCTL_CLEANUP])])
m4_define([CHECK_BRIDGES],
[dnl Check that the bridges appear on list-br, without --oneline.
AT_CHECK(
[RUN_OVS_VSCTL([list-br])],
[0],
[m4_foreach([brinfo], [$@], [m4_car(brinfo)
])],
[],
[OVS_VSCTL_CLEANUP])
dnl Check that the bridges appear on list-br, with --oneline.
AT_CHECK(
[RUN_OVS_VSCTL_ONELINE([list-br])],
[0],
[m4_join([\n], m4_foreach([brinfo], [$@], [m4_car(brinfo),]))
],
[],
[OVS_VSCTL_CLEANUP])
dnl Check that each bridge exists according to br-exists and that
dnl a bridge that should not exist does not.
m4_foreach([brinfo], [$@],
[AT_CHECK([RUN_OVS_VSCTL([br-exists m4_car(brinfo)])], [0], [],
[], [OVS_VSCTL_CLEANUP])])
AT_CHECK([RUN_OVS_VSCTL([br-exists nonexistent])], [2], [], [],
[OVS_VSCTL_CLEANUP])
dnl Check that each bridge has the expected parent and VLAN.
m4_map([_CHECK_BRIDGE], [$@])])
dnl CHECK_PORTS(BRIDGE, PORT[, PORT...])
dnl
dnl Verifies that "ovs-vsctl list-ports BRIDGE" prints the specified
dnl list of ports, which must be in alphabetical order. Also checks
dnl that "ovs-vsctl port-to-br" reports that each port is
dnl in BRIDGE.
m4_define([CHECK_PORTS],
[dnl Check ports without --oneline.
AT_CHECK(
[RUN_OVS_VSCTL([list-ports $1])],
[0],
[m4_foreach([port], m4_cdr($@), [port
])],
[],
[OVS_VSCTL_CLEANUP])
dnl Check ports with --oneline.
AT_CHECK(
[RUN_OVS_VSCTL_ONELINE([list-ports $1])],
[0],
[m4_join([\n], m4_shift($@))
],
[],
[OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([port-to-br $1])], [1], [],
[ovs-vsctl: no port named $1
],
[OVS_VSCTL_CLEANUP])
m4_foreach(
[port], m4_cdr($@),
[AT_CHECK([RUN_OVS_VSCTL([[port-to-br] port])], [0], [$1
], [], [OVS_VSCTL_CLEANUP])])])
dnl CHECK_IFACES(BRIDGE, IFACE[, IFACE...])
dnl
dnl Verifies that "ovs-vsctl list-ifaces BRIDGE" prints the specified
dnl list of ifaces, which must be in alphabetical order. Also checks
dnl that "ovs-vsctl iface-to-br" reports that each interface is
dnl in BRIDGE.
m4_define([CHECK_IFACES],
[AT_CHECK(
[RUN_OVS_VSCTL([list-ifaces $1])],
[0],
[m4_foreach([iface], m4_cdr($@), [iface
])],
[],
[OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([iface-to-br $1])], [1], [],
[ovs-vsctl: no interface named $1
],
[OVS_VSCTL_CLEANUP])
m4_foreach(
[iface], m4_cdr($@),
[AT_CHECK([RUN_OVS_VSCTL([[iface-to-br] iface])], [0], [$1
],
[], [OVS_VSCTL_CLEANUP])])])
dnl ----------------------------------------------------------------------
AT_BANNER([ovs-vsctl unit tests])
AT_SETUP([ovs-vsctl connection retry])
OVS_RUNDIR=$PWD; export OVS_RUNDIR
dnl Without --retry, there should be no retry for active connections.
AT_CHECK([ovs-vsctl --db=unix:foo --timeout=10 -vreconnect:emer -- init],
[1], [], [stderr])
AT_CHECK([[sed 's/([^()]*)/(...reason...)/' stderr]], [0],
[ovs-vsctl: unix:foo: database connection failed (...reason...)
])
dnl With --retry, we should retry for active connections.
AT_CHECK(
[ovs-vsctl --db=unix:foo --timeout=1 --retry -vreconnect:emer -vPATTERN:console:'%c|%p|%m' -- init
echo $? > status],
[0], [], [stderr])
AT_CHECK([grep -c 'terminating with signal' stderr], [0], [1
])
if test "$IS_WIN32" = "yes"; then
AT_CHECK([cat status], [0], [3
])
else
# 128 + SIGALRM
AT_CHECK([cat status], [0], [142
])
fi
dnl Without --retry, we should retry for passive connections.
AT_CHECK(
[ovs-vsctl --db=punix:foo --timeout=1 -vreconnect:emer -vPATTERN:console:'%c|%p|%m' -- init
echo $? > status],
[0], [], [stderr])
AT_CHECK([grep -c 'terminating with signal' stderr], [0], [1
])
if test "$IS_WIN32" = "yes"; then
AT_CHECK([cat status], [0], [3
])
else
# 128 + SIGALRM
AT_CHECK([cat status], [0], [142
])
fi
AT_CLEANUP
dnl ----------------------------------------------------------------------
AT_BANNER([ovs-vsctl unit tests -- real bridges])
AT_SETUP([add-br a])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL([add-br a])], [0], [], [], [OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([a, a, 0])
CHECK_PORTS([a])
CHECK_IFACES([a])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([add-br a, add-br a])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL([add-br a])], [0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([add-br a])], [1], [],
[ovs-vsctl: cannot create a bridge named a because a bridge named a already exists
], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([add-br a, add-br b])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b])], [0], [], [],
[OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br a b 9])], [1], [],
[ovs-vsctl: "--may-exist add-br a b 9" but a is not a VLAN bridge
],
[OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([a, a, 0], [b, b, 0])
CHECK_PORTS([a])
CHECK_IFACES([a])
CHECK_PORTS([b])
CHECK_IFACES([b])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([add-br a, add-br b, del-br a])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL([add-br a], [add-br b], [del-br a])], [0], [], [],
[OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([b, b, 0])
CHECK_PORTS([b])
CHECK_IFACES([b])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([add-br a, del-br a, add-br a])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
[add-br a],
[del-br a],
[add-br a],
[set Interface a other_config:key=value],
[get Interface a other_config:key])], [0], [
value
], [], [OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([a, a, 0])
CHECK_PORTS([a])
CHECK_IFACES([a])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([add-br a, add-port a a1, add-port a a2])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL(
[add-br a],
[--if-exists del-br b],
[add-port a a1],
[add-port a a2])], [0], [], [], [OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([a, a, 0])
CHECK_PORTS([a], [a1], [a2])
CHECK_IFACES([a], [a1], [a2])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([add-br a, add-port a a1, add-port a a1])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL(
[add-br a],
[add-port a a1])], [0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([add-port a a1])], [1], [],
[ovs-vsctl: cannot create a port named a1 because a port named a1 already exists on bridge a
], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-br a])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
[add-br a],
[add-br b],
[add-port a a1],
[add-port b b1],
[--if-exists del-port b b2],
[del-br a])], [0], [
], [], [OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([b, b, 0])
CHECK_PORTS([b], [b1])
CHECK_IFACES([b], [b1])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL(
[add-br a],
[add-bond a bond0 a1 a2 a3])], [0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond a bond0 a3 a1 a2])], [0], [], [],
[OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([--may-exist add-bond a bond0 a2 a1])], [1], [],
[ovs-vsctl: "--may-exist add-bond a bond0 a2 a1" but bond0 actually has interface(s) a1, a2, a3
],
[OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([a, a, 0])
CHECK_PORTS([a], [bond0])
CHECK_IFACES([a], [a1], [a2], [a3])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([add-br a b, add-port a a1, add-port b b1, del-port a a1])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL(
[add-br a],
[add-br b],
[add-port a a1 tag=9],
[get port a1 tag],
[--may-exist add-port b b1],
[del-port a a1])], [0], [9
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port b b1])], [0], [], [],
[OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([del-port a])], [1], [],
[ovs-vsctl: cannot delete port a because it is the local port for bridge a (deleting this port requires deleting the entire bridge)
],
[OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([--if-exists del-port a])], [0], [], [],
[OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port a b1])], [1], [],
[ovs-vsctl: "--may-exist add-port a b1" but b1 is actually attached to bridge b
],
[OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([a, a, 0], [b, b, 0])
CHECK_PORTS([a])
CHECK_IFACES([a])
CHECK_PORTS([b], [b1])
CHECK_IFACES([b], [b1])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([add-br a, add-bond a bond0 a1 a2 a3, del-port bond0])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
[add-br a],
[add-bond a bond0 a1 a2 a3 tag=9],
[get Port bond0 tag],
[del-port bond0])], [0], [
9
], [], [OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([a, a, 0])
CHECK_PORTS([a])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([external IDs])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL_ONELINE(
[add-br a],
[add-port a a1],
[add-bond a bond0 a2 a3],
[br-set-external-id a key0 value0],
[set port a1 external-ids:key1=value1],
[set interface a2 external-ids:key2=value2],
[set interface a2 external-ids:key3=value3],
[set interface a3 external-ids:key4=value4],
[br-get-external-id a],
[br-get-external-id a key0],
[br-get-external-id a key1],
[br-set-external-id a key0 othervalue],
[br-get-external-id a],
[br-set-external-id a key0],
[br-get-external-id a],
[get port a1 external-ids],
[get interface a2 external-ids],
[get interface a3 external-ids])], [0], [
key0=value0
value0
key0=othervalue
{"key1"="value1"}
{"key2"="value2", "key3"="value3"}
{"key4"="value4"}
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
[br-get-external-id a],
[get port a1 external-ids],
[get interface a2 external-ids],
[get interface a3 external-ids])], [0],
[
{"key1"="value1"}
{"key2"="value2", "key3"="value3"}
{"key4"="value4"}
], [], [OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([a, a, 0])
CHECK_PORTS([a], [a1], [bond0])
CHECK_IFACES([a], [a1], [a2], [a3])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([controllers])
AT_KEYWORDS([controller ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
[add-br br0],
[get-controller br0],
[set-controller br0 tcp:4.5.6.7],
[get-controller br0],
[del-controller br0],
[get-controller br0],
[set-controller br0 tcp:8.9.10.11 tcp:5.4.3.2],
[get-controller br0])], [0], [
tcp:4.5.6.7
tcp:5.4.3.2\ntcp:8.9.10.11
], [], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
dnl ----------------------------------------------------------------------
dnl OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([VLAN])
m4_define([OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF],
[AT_CHECK(
[RUN_OVS_VSCTL(
[add-br xenbr0],
[--may-exist add-br xenbr0],
[add-port xenbr0 eth0],
[--may-exist add-port xenbr0 eth0],
[add-br xapi1 xenbr0 $1],
[--may-exist add-br xapi1 xenbr0 $1],
[add-port xapi1 eth0.$1])],
[0], [], [], [OVS_VSCTL_CLEANUP])])
dnl OVS_VSCTL_FAKE_BRIDGE_TESTS([VLAN])
m4_define([OVS_VSCTL_FAKE_BRIDGE_TESTS], [
AT_BANNER([ovs-vsctl unit tests -- fake bridges (VLAN $1)])
AT_SETUP([simple fake bridge (VLAN $1)])
AT_KEYWORDS([ovs-vsctl fake-bridge])
OVS_VSCTL_SETUP
OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1])], [1], [],
[ovs-vsctl: "--may-exist add-br xapi1" but xapi1 is a VLAN bridge for VLAN $1
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xxx $1])], [1], [],
[ovs-vsctl: "--may-exist add-br xapi1 xxx $1" but xapi1 has the wrong parent xenbr0
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xenbr0 10])], [1], [],
[ovs-vsctl: "--may-exist add-br xapi1 xenbr0 10" but xapi1 is a VLAN bridge for the wrong VLAN $1
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br dup xenbr0 $1])], [1], [],
[ovs-vsctl: bridge xenbr0 already has a child VLAN bridge xapi1 on VLAN $1
], [OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([xapi1, xenbr0, $1], [xenbr0, xenbr0, 0])
CHECK_PORTS([xenbr0], [eth0])
CHECK_IFACES([xenbr0], [eth0])
CHECK_PORTS([xapi1], [eth0.$1])
CHECK_IFACES([xapi1], [eth0.$1])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([list bridges -- real and fake (VLAN $1)])
AT_KEYWORDS([ovs-vsctl fake-bridge])
OVS_VSCTL_SETUP
OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- list-br])], [0],
[xapi1\nxenbr0
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- --real list-br])], [0],
[xenbr0
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL_ONELINE([-- --fake list-br])], [0],
[xapi1
], [], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([simple fake bridge + del-br fake bridge (VLAN $1)])
AT_KEYWORDS([ovs-vsctl fake-bridge])
OVS_VSCTL_SETUP
OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])], [0], [], [], [OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([xenbr0, xenbr0, 0])
CHECK_PORTS([xenbr0], [eth0])
CHECK_IFACES([xenbr0], [eth0])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([simple fake bridge + del-br real bridge (VLAN $1)])
AT_KEYWORDS([ovs-vsctl fake-bridge])
OVS_VSCTL_SETUP
OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
AT_CHECK([RUN_OVS_VSCTL([del-br xenbr0])], [0], [], [], [OVS_VSCTL_CLEANUP])
CHECK_BRIDGES
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([simple fake bridge + external IDs (VLAN $1)])
AT_KEYWORDS([ovs-vsctl fake-bridge])
OVS_VSCTL_SETUP
OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([$1])
AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
[br-set-external-id xenbr0 key0 value0],
[br-set-external-id xapi1 key1 value1],
[br-get-external-id xenbr0],
[br-get-external-id xenbr0 key0],
[br-get-external-id xapi1],
[br-get-external-id xapi1 key1])], [0], [
key0=value0
value0
key1=value1
value1
], [], [OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([xapi1, xenbr0, $1], [xenbr0, xenbr0, 0])
CHECK_PORTS([xenbr0], [eth0])
CHECK_IFACES([xenbr0], [eth0])
CHECK_PORTS([xapi1], [eth0.$1])
CHECK_IFACES([xapi1], [eth0.$1])
OVS_VSCTL_CLEANUP
AT_CLEANUP
]) # OVS_VSCTL_FAKE_BRIDGE_TESTS
OVS_VSCTL_FAKE_BRIDGE_TESTS([9])
OVS_VSCTL_FAKE_BRIDGE_TESTS([0])
dnl OVS_VSCTL_SETUP_BOND_FAKE_CONF([VLAN])
m4_define([OVS_VSCTL_SETUP_BOND_FAKE_CONF],
[AT_CHECK(
[RUN_OVS_VSCTL(
[add-br xapi1],
[add-bond xapi1 bond0 eth0 eth1],
[add-br xapi2 xapi1 $1],
[add-port xapi2 bond0.$1])],
[0], [], [], [OVS_VSCTL_CLEANUP])])
AT_SETUP([fake bridge on bond])
AT_KEYWORDS([ovs-vsctl fake-bridge])
OVS_VSCTL_SETUP
OVS_VSCTL_SETUP_BOND_FAKE_CONF([11])
CHECK_BRIDGES([xapi1, xapi1, 0], [xapi2, xapi1, 11])
CHECK_PORTS([xapi1], [bond0])
CHECK_IFACES([xapi1], [eth0], [eth1])
CHECK_PORTS([xapi2], [bond0.11])
CHECK_IFACES([xapi2], [bond0.11])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([fake bridge on bond + del-br fake bridge])
AT_KEYWORDS([ovs-vsctl fake-bridge])
OVS_VSCTL_SETUP
OVS_VSCTL_SETUP_BOND_FAKE_CONF([11])
AT_CHECK([RUN_OVS_VSCTL_ONELINE([del-br xapi2])], [0], [
], [], [OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([xapi1, xapi1, 0])
CHECK_PORTS([xapi1], [bond0])
CHECK_IFACES([xapi1], [eth0], [eth1])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([fake bridge on bond + del-br real bridge])
AT_KEYWORDS([ovs-vsctl fake-bridge])
OVS_VSCTL_SETUP
OVS_VSCTL_SETUP_BOND_FAKE_CONF([11])
AT_CHECK([RUN_OVS_VSCTL([del-br xapi1])])
CHECK_BRIDGES
OVS_VSCTL_CLEANUP
AT_CLEANUP
dnl ----------------------------------------------------------------------
AT_BANNER([ovs-vsctl unit tests -- manager commands])
AT_SETUP([managers])
AT_KEYWORDS([manager ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL_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
], [], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
dnl ----------------------------------------------------------------------
AT_BANNER([ovs-vsctl unit tests -- database commands])
AT_SETUP([database commands -- positive checks])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK(
[RUN_OVS_VSCTL_TOGETHER([--id=@br0 create bridge name=br123],
[set b br123 name=br0],
[set o . bridges=@br0])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
cp stdout out1
AT_CHECK([RUN_OVS_VSCTL([list bridge], [get bridge br0 _uuid])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
cp stdout out2
AT_CHECK([${PERL} $srcdir/uuidfilt.pl out1 out2], [0],
[[<0>
_uuid : <0>
auto_attach : []
controller : []
datapath_id : []
datapath_type : ""
datapath_version : ""
external_ids : {}
fail_mode : []
flood_vlans : []
flow_tables : {}
ipfix : []
mcast_snooping_enable: false
mirrors : []
name : "br0"
netflow : []
other_config : {}
ports : []
protocols : []
rstp_enable : false
rstp_status : {}
sflow : []
status : {}
stp_enable : false
<0>
]], [ignore], [test ! -e pid || kill `cat pid`])
AT_CHECK(
[RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type list bridge])],
[0],
[[fail_mode : []
name : "br0"
datapath_type : ""
]], [ignore], [test ! -e pid || kill `cat pid`])
AT_CHECK(
[RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type find bridge])],
[0],
[[fail_mode : []
name : "br0"
datapath_type : ""
]], [ignore], [test ! -e pid || kill `cat pid`])
AT_CHECK([
RUN_OVS_VSCTL_TOGETHER([--id=@br1 create bridge name=br1 datapath_type="foo"],
[--id=@br2 create bridge name=br2 external-ids:bar=quux],
[add o . bridges @br1 @br2])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
AT_CHECK(
[RUN_OVS_VSCTL([--columns=name find bridge datapath_type!=foo])], [0], [stdout],
[ignore], [test ! -e pid || kill `cat pid`])
AT_CHECK([sed -n '/./p' stdout | sort], [0],
[[name : "br0"
name : "br2"
]])
AT_CHECK(
[RUN_OVS_VSCTL(
[set bridge br0 \
'other_config:datapath_id="0123456789ab"' \
'other_config:hwaddr="00:11:22:33:44:55"' \
'external-ids={"uuids"="9c45f225-a7cf-439d-976d-83db6271fda1"}' -- \
add bridge br0 external_ids '"roles"="local; remote; cloud"'])],
[0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL_ONELINE([get bridge br0 other_config external-ids])],
[0], [{datapath_id="0123456789ab", hwaddr="00:11:22:33:44:55"}\n{roles="local; remote; cloud", uuids="9c45f225-a7cf-439d-976d-83db6271fda1"}
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([get bridge br0 other_config:hwaddr -- --if-exists get bridge br0 other-config:nonexistent])],
[0], ["00:11:22:33:44:55"
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 other_config hwaddr 'datapath_id=""' -- get bridge br0 other_config])],
[0], [{datapath_id="0123456789ab"}
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 other_config 'datapath_id="0123456789ab"' -- get bridge br0 other_config])],
[0], [{}
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([clear bridge br0 external-ids -- get bridge br0 external_ids])],
[0], [{}
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL_TOGETHER([destroy bridge br0],
[destroy bridge br1],
[destroy bridge br2],
[clear o . bridges])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([list bridge])],
[0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([--if-exists get bridge x datapath_id])],
[0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([--if-exists list bridge x])],
[0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([--if-exists set controller x connection_mode=standalone])],
[0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK(
[RUN_OVS_VSCTL([--if-exists remove netflow x targets '"1.2.3.4:567"'])],
[0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK(
[RUN_OVS_VSCTL([--if-exists clear netflow x targets])],
[0], [], [], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([database commands -- negative checks])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([ovs-vsctl --may-exist],
[1], [ignore], [ovs-vsctl: missing command name (use --help for help)
], [OVS_VSCTL_CLEANUP])
AT_CHECK([ovs-vsctl --may-exist --],
[1], [ignore], [ovs-vsctl: missing command name (use --help for help)
], [OVS_VSCTL_CLEANUP])
AT_CHECK([ovs-vsctl -- --may-exist],
[1], [ignore], [ovs-vsctl: missing command name (use --help for help)
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([add-br br0])],
[0], [ignore], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([add-br br1])],
[0], [ignore], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([set-controller br1 tcp:127.0.0.1])],
[0], [ignore], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([
RUN_OVS_VSCTL_TOGETHER([--id=@n create netflow targets='"1.2.3.4:567"'],
[set bridge br0 netflow=@n])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
cp stdout netflow-uuid
AT_CHECK([RUN_OVS_VSCTL([list netflow `cat netflow-uuid`])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([${PERL} $srcdir/uuidfilt.pl netflow-uuid stdout], [0],
[[<0>
_uuid : <0>
active_timeout : 0
add_id_to_interface : false
engine_id : []
engine_type : []
external_ids : {}
targets : ["1.2.3.4:567"]
]], [ignore], [test ! -e pid || kill `cat pid`])
AT_CHECK([RUN_OVS_VSCTL([list interx x])],
[1], [], [ovs-vsctl: unknown table "interx"
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([list bridge x])],
[1], [], [ovs-vsctl: no row "x" in table Bridge
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([get bridge x datapath_id])],
[1], [], [ovs-vsctl: no row "x" in table Bridge
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([get bridge br0 d])],
[1], [], [ovs-vsctl: Bridge contains more than one column whose name matches "d"
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([get bridge br0 x])],
[1], [], [ovs-vsctl: Bridge does not contain a column whose name matches "x"
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([get bridge br0 :y=z])],
[1], [], [ovs-vsctl: :y=z: missing column name
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id:y=z])],
[1], [], [ovs-vsctl: datapath_id:y=z: trailing garbage "=z" in argument
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([set bridge br0 'datapath_id:y>=z'])],
[1], [], [ovs-vsctl: datapath_id:y>=z: argument does not end in "=" followed by a value.
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([set controller x connection_mode=standalone])],
[1], [], [ovs-vsctl: no row "x" in table Controller
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([wait-until bridge br0 datapath_id:y,z])],
[1], [], [ovs-vsctl: datapath_id:y,z: argument does not end in "=", "!=", "<", ">", "<=", ">=", "{=}", "{!=}", "{<}", "{>}", "{<=}", or "{>=}" followed by a value.
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id::])],
[1], [], [ovs-vsctl: datapath_id::: trailing garbage ":" in argument
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id:x])],
[1], [], [ovs-vsctl: cannot specify key to get for non-map column datapath_id
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([get bridge br0 external_ids:x])],
[1], [], [ovs-vsctl: no key "x" in Bridge record "br0" column external_ids
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([set bridge br0 flood_vlans=-1])],
[1], [], [ovs-vsctl: constraint violation: -1 is not in the valid range 0 to 4095 (inclusive)
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([set bridge br0 flood_vlans=4096])],
[1], [], [ovs-vsctl: constraint violation: 4096 is not in the valid range 0 to 4095 (inclusive)
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([set c br1 'connection-mode=xyz'])],
[1], [], [[ovs-vsctl: constraint violation: xyz is not one of the allowed values ([in-band, out-of-band])
]], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([set c br1 connection-mode:x=y])],
[1], [], [ovs-vsctl: cannot specify key to set for non-map column connection_mode
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([add bridge br1 datapath_id x y])],
[1], [], [ovs-vsctl: "add" operation would put 2 values in column datapath_id of table Bridge but the maximum number is 1
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([remove netflow `cat netflow-uuid` targets '"1.2.3.4:567"'])],
[1], [], [ovs-vsctl: "remove" operation would put 0 values in column targets of table NetFlow but the minimum number is 1
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([remove netflow x targets '"1.2.3.4:567"'])],
[1], [], [ovs-vsctl: no row "x" in table NetFlow
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([clear netflow x targets])],
[1], [], [ovs-vsctl: no row "x" in table NetFlow
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([clear netflow `cat netflow-uuid` targets])],
[1], [], [ovs-vsctl: "clear" operation cannot be applied to column targets of table NetFlow, which is not allowed to be empty
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([destroy bridge br2])],
[1], [], [ovs-vsctl: no row "br2" in table Bridge
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([add in br1 name x])],
[1], [], [ovs-vsctl: cannot modify read-only column name in table Interface
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([set port br0 name=br2])],
[1], [], [ovs-vsctl: cannot modify read-only column name in table Port
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 name br1])],
[1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([remove bridge br1 flood-vlans true])],
[1], [], [ovs-vsctl: "true" is not a valid integer
], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([clear bridge br1 name])],
[1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge
], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([database commands -- conditions])
AT_KEYWORDS([ovs-vsctl])
ON_EXIT([kill `cat pid`])
OVS_VSCTL_SETUP
AT_CHECK(
[RUN_OVS_VSCTL_TOGETHER(
[add-br br0],
[add-br br1], [set bridge br1 flood_vlans=0 other-config:x='""'],
[add-br br2], [set bridge br2 flood_vlans=1 other-config:x=y],
[add-br br3], [set bridge br3 flood_vlans=0,1 other-config:x=z],
[add-br br4], [set bridge br4 flood_vlans=2],
[add-br br5], [set bridge br5 flood_vlans=0,2],
[add-br br6], [set bridge br6 flood_vlans=1,2],
[add-br br7], [set bridge br7 flood_vlans=0,1,2])], [0], [
])
m4_define([VSCTL_CHECK_FIND],
[AT_CHECK([echo `ovs-vsctl --bare --no-wait -vreconnect:emer --db=unix:socket -- --columns=name find bridge '$1' | sort`], [0], [$2
])])
# Arithmetic relational operators without keys.
VSCTL_CHECK_FIND([flood_vlans=0], [br1])
VSCTL_CHECK_FIND([flood_vlans=1], [br2])
VSCTL_CHECK_FIND([flood_vlans=0,2], [br5])
VSCTL_CHECK_FIND([flood_vlans=0,1,2], [br7])
VSCTL_CHECK_FIND([flood_vlans=3], [])
VSCTL_CHECK_FIND([flood_vlans!=0], [br0 br2 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([flood_vlans!=1], [br0 br1 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([flood_vlans!=0,2], [br0 br1 br2 br3 br4 br6 br7])
VSCTL_CHECK_FIND([flood_vlans!=0,1,2], [br0 br1 br2 br3 br4 br5 br6])
VSCTL_CHECK_FIND([flood_vlans!=3], [br0 br1 br2 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([flood_vlans<2], [br0 br1 br2])
VSCTL_CHECK_FIND([flood_vlans<0,2], [br0 br1 br2 br3 br4])
VSCTL_CHECK_FIND([flood_vlans>1], [br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([flood_vlans>0,1], [br5 br6 br7])
VSCTL_CHECK_FIND([flood_vlans<=2], [br0 br1 br2 br4])
VSCTL_CHECK_FIND([flood_vlans<=0,2], [br0 br1 br2 br3 br4 br5])
VSCTL_CHECK_FIND([flood_vlans>=1], [br2 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([flood_vlans>=0,1], [br3 br5 br6 br7])
# Set relational operators without keys.
VSCTL_CHECK_FIND([flood_vlans{=}0], [br1])
VSCTL_CHECK_FIND([flood_vlans{=}1], [br2])
VSCTL_CHECK_FIND([flood_vlans{=}0,2], [br5])
VSCTL_CHECK_FIND([flood_vlans{=}0,1,2], [br7])
VSCTL_CHECK_FIND([flood_vlans{=}3], [])
VSCTL_CHECK_FIND([flood_vlans{!=}0], [br0 br2 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([flood_vlans{!=}1], [br0 br1 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([flood_vlans{!=}0,2], [br0 br1 br2 br3 br4 br6 br7])
VSCTL_CHECK_FIND([flood_vlans{!=}0,1,2], [br0 br1 br2 br3 br4 br5 br6])
VSCTL_CHECK_FIND([flood_vlans{!=}3], [br0 br1 br2 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([flood_vlans{<}[[]]], [])
VSCTL_CHECK_FIND([flood_vlans{<=}[[]]], [br0])
VSCTL_CHECK_FIND([flood_vlans{<}0], [br0])
VSCTL_CHECK_FIND([flood_vlans{<=}0], [br0 br1])
VSCTL_CHECK_FIND([flood_vlans{<}1,2], [br0 br2 br4])
VSCTL_CHECK_FIND([flood_vlans{<=}1,2], [br0 br2 br4 br6])
VSCTL_CHECK_FIND([flood_vlans{>}[[]]], [br1 br2 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([flood_vlans{>=}[[]]], [br0 br1 br2 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([flood_vlans{>}0], [br3 br5 br7])
VSCTL_CHECK_FIND([flood_vlans{>=}0], [br1 br3 br5 br7])
VSCTL_CHECK_FIND([flood_vlans{>}0,2], [br7])
VSCTL_CHECK_FIND([flood_vlans{>=}1,2], [br6 br7])
VSCTL_CHECK_FIND([flood_vlans{>=}0,2], [br5 br7])
# Arithmetic relational operators with keys.
VSCTL_CHECK_FIND([other-config:x=""], [br1])
VSCTL_CHECK_FIND([other-config:x=y], [br2])
VSCTL_CHECK_FIND([other-config:x=z], [br3])
VSCTL_CHECK_FIND([other-config:x!=""], [br2 br3])
VSCTL_CHECK_FIND([other-config:x!=y], [br1 br3])
VSCTL_CHECK_FIND([other-config:x!=z], [br1 br2])
VSCTL_CHECK_FIND([other-config:x>y], [br3])
VSCTL_CHECK_FIND([other-config:x>=y], [br2 br3])
VSCTL_CHECK_FIND([other-config:x<y], [br1])
VSCTL_CHECK_FIND([other-config:x<=y], [br1 br2])
# Set relational operators with keys.
VSCTL_CHECK_FIND([other-config:x{=}[[]]], [br0 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{=}""], [br1])
VSCTL_CHECK_FIND([other-config:x{=}y], [br2])
VSCTL_CHECK_FIND([other-config:x{=}z], [br3])
VSCTL_CHECK_FIND([other-config:x{!=}[[]]], [br1 br2 br3])
VSCTL_CHECK_FIND([other-config:x{!=}""], [br0 br2 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{!=}y], [br0 br1 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{!=}z], [br0 br1 br2 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{<=}[[]]], [br0 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{<=}x], [br0 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{<=}""], [br0 br1 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{<=}y], [br0 br2 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{<=}z], [br0 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{<=}x,y,z], [br0 br2 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{<}[[]]], [])
VSCTL_CHECK_FIND([other-config:x{<}x], [br0 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{<}""], [br0 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{<}y], [br0 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{<}z], [br0 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{>=}[[]]], [br0 br1 br2 br3 br4 br5 br6 br7])
VSCTL_CHECK_FIND([other-config:x{>=}x], [])
VSCTL_CHECK_FIND([other-config:x{>=}""], [br1])
VSCTL_CHECK_FIND([other-config:x{>=}y], [br2])
VSCTL_CHECK_FIND([other-config:x{>=}z], [br3])
VSCTL_CHECK_FIND([other-config:x{>}[[]]], [br1 br2 br3])
VSCTL_CHECK_FIND([other-config:x{>}x], [])
VSCTL_CHECK_FIND([other-config:x{>}""], [])
VSCTL_CHECK_FIND([other-config:x{>}y], [])
VSCTL_CHECK_FIND([other-config:x{>}z], [])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([database commands -- wait-until immediately true])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL(
[add-br br0],
[add-bond br0 bond0 eth0 eth1],
[set port bond0 bond_updelay=500 other-config:abc=def])],
[0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([[wait-until Open_vSwitch . manager_options=[]]])],
[0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([[wait-until Open_vSwitch . bridges!=[]]])],
[0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([[wait-until Port bond0 other-config:abc=def]])],
[0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' 'other-config:abc>d' 'other-config:abc<e']])],
[0], [], [], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([database commands -- wait-until must wait])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
# Start ovs-vsctls in background.
(RUN_OVS_VSCTL([[wait-until o . bridges!=[] -- get bridge br10 other-config:abc]])) > stdout1 &
(RUN_OVS_VSCTL([[wait-until bridge br1 -- get bridge br1 other-config:abc]])) > stdout2 &
(RUN_OVS_VSCTL([[wait-until bridge br1 other-config={abc=def} -- get bridge br1 other-config]])) > stdout3 &
(RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' -- get port bond0 bond-updelay]])) > stdout4 &
# Give the ovs-vsctls a chance to read the database
sleep 1
AT_CHECK([RUN_OVS_VSCTL([add-br br10 -- set bridge br10 other-config:abc=quux])
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])],
[0], [], [], [OVS_VSCTL_CLEANUP])
# Wait for the ovs-vsctls to finish.
wait
# Check output
AT_CHECK([cat stdout1], [0], [quux
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([cat stdout2], [0], [def
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([cat stdout3], [0], [{abc=def}
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([cat stdout4], [0], [500
], [], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([--id option on create, get commands])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL([add-br br0],
[add-port br0 eth0],
[add-port br0 eth1])])
AT_CHECK(
[RUN_OVS_VSCTL_TOGETHER(
[set bridge br0 mirrors=@m],
[--id=@eth0 get port eth0],
[--id=@eth1 get port eth1],
[--id=@m create mirror name=mymirror select-dst-port=@eth0 select-src-port=@eth0 output-port=@eth1])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
AT_CHECK(
[${PERL} $srcdir/uuidfilt.pl stdout], [0], [dnl
<0>
],
[], [OVS_VSCTL_CLEANUP])
AT_CHECK(
[RUN_OVS_VSCTL(
[list port eth0 eth1],
[list mirror],
[list bridge br0])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
AT_CHECK(
[sed -n -e '/uuid/p' -e '/name/p' -e '/mirrors/p' -e '/select/p' -e '/output/p' < stdout | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
[_uuid : <0>
name : "eth0"
_uuid : <1>
name : "eth1"
_uuid : <2>
name : mymirror
output_port : <1>
output_vlan : []
select_all : false
select_dst_port : [<0>]
select_src_port : [<0>]
select_vlan : []
_uuid : <3>
mirrors : [<2>]
name : "br0"
]],
[], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
AT_SETUP([unreferenced record warnings])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK(
[ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \
-- create Bridge name=br0 | ${PERL} $srcdir/uuidfilt.pl],
[0], [<0>
], [vsctl|WARN|applying "create" command to table Bridge without --id option will have no effect
], [OVS_VSCTL_CLEANUP])
AT_CHECK(
[ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \
-- --id=@br0 create Bridge name=br0 | ${PERL} $srcdir/uuidfilt.pl],
[0], [<0>
], [vsctl|WARN|row id "@br0" was created but no reference to it was inserted, so it will not actually appear in the database
], [OVS_VSCTL_CLEANUP])
AT_CHECK(
[ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \
-- --id=@eth0_iface create Interface name=eth0 \
-- --id=@eth0 create Port name=eth0 interfaces=@eth0_iface \
-- --id=@m0 create Mirror name=m0 output_port=@eth0 \
-- --id=@br0 create Bridge name=br0 mirrors=@m0 \
-- set Open_vSwitch . bridges=@br0 | ${PERL} $srcdir/uuidfilt.pl],
[0], [<0>
<1>
<2>
<3>
], [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
], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
dnl This test really shows a bug -- "create" followed by "list" in
dnl the same execution shows the wrong UUID on the "list" command.
dnl The bug is documented in ovs-vsctl.8.
AT_SETUP([created row UUID is wrong in same execution])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL([--id=@br0 create Bridge name=br0 -- add Open_vSwitch . bridges @br0 -- list bridge])],
[0], [stdout], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0],
[[<0>
_uuid : <1>
auto_attach : []
controller : []
datapath_id : []
datapath_type : ""
datapath_version : ""
external_ids : {}
fail_mode : []
flood_vlans : []
flow_tables : {}
ipfix : []
mcast_snooping_enable: false
mirrors : []
name : "br0"
netflow : []
other_config : {}
ports : []
protocols : []
rstp_enable : false
rstp_status : {}
sflow : []
status : {}
stp_enable : false
]], [ignore], [test ! -e pid || kill `cat pid`])
OVS_VSCTL_CLEANUP
AT_CLEANUP
dnl This test will create a linux-htb QoS record that
dnl points to a few queues and use it on a1 and a2 port.
dnl It also destroys all records from Qos and Queue table.
AT_SETUP([--all option on destroy command])
AT_KEYWORDS([ovs-vsctl])
OVS_VSCTL_SETUP
AT_CHECK([RUN_OVS_VSCTL(
[add-br a],
[add-port a a1],
[add-port a a2])], [0], [], [], [OVS_VSCTL_CLEANUP])
CHECK_BRIDGES([a, a, 0])
CHECK_PORTS([a], [a1], [a2])
CHECK_IFACES([a], [a1], [a2])
AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
[set Port a1 qos=@newqos],
[set Port a2 qos=@newqos],
[--id=@newqos create QoS type=linux-htb other-config:max-rate=1000000000 queues=0=@q0,1=@q1],
[--id=@q0 create Queue other-config:min-rate=100000000 other-config:max-rate=100000000],
[--id=@q1 create Queue other-config:min-rate=500000000])], [0], [ignore], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL(
[--columns=other_config,type list Qos])], [0],
[other_config : {max-rate="1000000000"}
type : linux-htb
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL(
[--columns=other_config list Queue | sort | sed '/^$/d'])], [0],
[other_config : {max-rate="100000000", min-rate="100000000"}
other_config : {min-rate="500000000"}
], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL(
[clear Port a1 qos],
[clear Port a2 qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL(
[--columns=qos list Port a1 a2])], [0],
[[qos : []
qos : []
]], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL(
[--all destroy Qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL(
[-- list Qos])], [0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL(
[--all destroy Queue])], [0], [], [], [OVS_VSCTL_CLEANUP])
AT_CHECK([RUN_OVS_VSCTL(
[-- list Queue])], [0], [], [], [OVS_VSCTL_CLEANUP])
OVS_VSCTL_CLEANUP
AT_CLEANUP
dnl ----------------------------------------------------------------------
AT_BANNER([ovs-vsctl add-port -- reserved port names])
AT_SETUP([add-port -- reserved names 1])
OVS_VSWITCHD_START
# Test creating all reserved port names
m4_foreach(
[reserved_name],
[[ovs-netdev],
[ovs-dummy],
[genev_sys],
[gre_sys],
[gre64_sys],
[lisp_sys],
[vxlan_sys]],
[
# Try creating the port
AT_CHECK([ovs-vsctl add-port br0 reserved_name], [0], [], [dnl
ovs-vsctl: Error detected while setting up 'reserved_name'. See ovs-vswitchd log for details.
])
# Prevent race.
OVS_WAIT_UNTIL([test `grep -- "|WARN|" ovs-vswitchd.log | wc -l` -ge 1])
# Detect the warning log message
AT_CHECK([sed -n "s/^.*\(|bridge|WARN|.*\)$/\1/p" ovs-vswitchd.log], [0], [dnl
|bridge|WARN|could not create interface reserved_name, name is reserved
])
# Delete the warning log message
AT_CHECK([sed "/|bridge|WARN|/d" ovs-vswitchd.log > ovs-vswitchd.log], [0], [], [])
# Delete the port
AT_CHECK([ovs-vsctl del-port br0 reserved_name], [0], [], [])])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([add-port -- reserved names 2])
# Creates all type of tunnel ports
OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \
options:remote_ip=1.1.1.1 ofport_request=1\
-- add-port br0 p2 -- set Interface p2 type=gre64 \
options:local_ip=2.2.2.2 options:remote_ip=1.1.1.1 \
ofport_request=2 \
-- add-port br0 p3 -- set Interface p3 type=lisp \
options:remote_ip=2.2.2.2 ofport_request=3 \
-- add-port br0 p4 -- set Interface p4 type=vxlan \
options:remote_ip=2.2.2.2 ofport_request=4 \
-- add-port br0 p5 -- set Interface p5 type=geneve \
options:remote_ip=2.2.2.2 ofport_request=5])
# Test creating all reserved tunnel port names
m4_foreach(
[reserved_name],
[[genev_sys],
[gre_sys],
[gre64_sys],
[lisp_sys],
[vxlan_sys]],
[
# Try creating the port
AT_CHECK([ovs-vsctl add-port br0 reserved_name], [0], [], [dnl
ovs-vsctl: Error detected while setting up 'reserved_name'. See ovs-vswitchd log for details.
])
# Prevent race.
OVS_WAIT_UNTIL([test `grep -- "|WARN|" ovs-vswitchd.log | wc -l` -ge 1])
# Detect the warning log message
AT_CHECK([sed -n "s/^.*\(|bridge|WARN|.*\)$/\1/p" ovs-vswitchd.log], [0], [dnl
|bridge|WARN|could not create interface reserved_name, name is reserved
])
# Delete the warning log message
AT_CHECK([sed "/|bridge|WARN|/d" ovs-vswitchd.log > ovs-vswitchd.log], [0], [], [])
# Delete the port
AT_CHECK([ovs-vsctl del-port br0 reserved_name], [0], [], [])])
OVS_VSWITCHD_STOP
AT_CLEANUP
AT_SETUP([naming in db commands])
OVS_VSCTL_SETUP
dnl First check that the database commands can refer to row by database UUID.
AT_CHECK([RUN_OVS_VSCTL([add-br br0])])
uuid=`[]RUN_OVS_VSCTL(get port br0 _uuid)`
AT_CHECK([RUN_OVS_VSCTL([get port $uuid name])], [0], ["br0"
])
dnl Next check that, if a database row is given a name that has the same form
dnl as the database UUIDs, the name can still be used to refer to rows.
AT_CHECK([RUN_OVS_VSCTL([add-br 0fcd11a1-2ba8-4b38-a358-4bccf2bf3057])])
AT_CHECK([RUN_OVS_VSCTL([get interface 0fcd11a1-2ba8-4b38-a358-4bccf2bf3057 type])], [0], [internal
])
OVS_VSCTL_CLEANUP
AT_CLEANUP
|