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
|
AT_BANNER([ovn-nbctl])
# OVN_NBCTL_TEST_START
m4_define([OVN_NBCTL_TEST_START],
[dnl Create ovn-nb database.
AT_KEYWORDS([ovn])
AT_CHECK([ovsdb-tool create ovn-nb.db $abs_top_srcdir/ovn/ovn-nb.ovsschema])
dnl Start ovsdb-server.
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock ovn-nb.db], [0], [], [stderr])
on_exit "kill `cat ovsdb-server.pid`"
AT_CHECK([[sed < stderr '
/vlog|INFO|opened log file/d
/ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']])
AT_CAPTURE_FILE([ovsdb-server.log])
])
# OVN_NBCTL_TEST_STOP
m4_define([OVN_NBCTL_TEST_STOP],
[# removes all 'Broken pipe' warning logs from ovsdb-server.log. this is in
# that *ctl command (e.g. ovn-nbctl) exits right after committing the change
# to database. however, in reaction, some daemon (e.g. ovn-controller-vtep)
# may immediately update the database. this later update may cause database
# sending update back to *ctl command if *ctl has not proceeded to exit yet.
# and if *ctl command exits before database calling send, the send from
# database will fail with 'Broken pipe' error.
AT_CHECK([check_logs "$1
/Broken pipe/d"])
AT_CHECK([ovs-appctl -t ovsdb-server exit])])
AT_SETUP([ovn-nbctl - basic lswitch commands])
OVN_NBCTL_TEST_START
AT_CHECK([ovn-nbctl lswitch-add ls0])
AT_CHECK([ovn-nbctl lswitch-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
<0> (ls0)
])
AT_CHECK([ovn-nbctl lswitch-add ls1])
AT_CHECK([ovn-nbctl lswitch-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
<0> (ls0)
<1> (ls1)
])
AT_CHECK([ovn-nbctl lswitch-del ls0])
AT_CHECK([ovn-nbctl lswitch-list | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
<0> (ls1)
])
OVN_NBCTL_TEST_STOP
AT_CLEANUP
dnl ---------------------------------------------------------------------
AT_SETUP([ovn-nbctl - basic lport commands])
OVN_NBCTL_TEST_START
AT_CHECK([ovn-nbctl lswitch-add ls0])
AT_CHECK([ovn-nbctl lport-add ls0 lp0])
AT_CHECK([ovn-nbctl lport-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
<0> (lp0)
])
AT_CHECK([ovn-nbctl lport-add ls0 lp1])
AT_CHECK([ovn-nbctl lport-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
<0> (lp0)
<1> (lp1)
])
AT_CHECK([ovn-nbctl lport-del lp1])
AT_CHECK([ovn-nbctl lport-list ls0 | ${PERL} $srcdir/uuidfilt.pl], [0], [dnl
<0> (lp0)
])
OVN_NBCTL_TEST_STOP
AT_CLEANUP
dnl ---------------------------------------------------------------------
AT_SETUP([ovn-nbctl - addresses])
OVN_NBCTL_TEST_START
AT_CHECK([ovn-nbctl lswitch-add ls0])
AT_CHECK([ovn-nbctl lport-add ls0 lp0])
AT_CHECK([ovn-nbctl lport-get-addresses lp0], [0], [dnl
])
AT_CHECK([ovn-nbctl lport-set-addresses lp0 00:11:22:33:44:55 unknown])
AT_CHECK([ovn-nbctl lport-get-addresses lp0], [0], [dnl
00:11:22:33:44:55
unknown
])
AT_CHECK([ovn-nbctl lport-set-addresses lp0])
AT_CHECK([ovn-nbctl lport-get-addresses lp0], [0], [dnl
])
OVN_NBCTL_TEST_STOP
AT_CLEANUP
dnl ---------------------------------------------------------------------
AT_SETUP([ovn-nbctl - port security])
OVN_NBCTL_TEST_START
AT_CHECK([ovn-nbctl lswitch-add ls0])
AT_CHECK([ovn-nbctl lport-add ls0 lp0])
AT_CHECK([ovn-nbctl lport-get-addresses lp0], [0], [dnl
])
AT_CHECK([ovn-nbctl lport-set-port-security lp0 aa:bb:cc:dd:ee:ff 00:11:22:33:44:55])
AT_CHECK([ovn-nbctl lport-get-port-security lp0], [0], [dnl
00:11:22:33:44:55
aa:bb:cc:dd:ee:ff
])
AT_CHECK([ovn-nbctl lport-set-port-security lp0])
AT_CHECK([ovn-nbctl lport-get-port-security lp0], [0], [dnl
])
OVN_NBCTL_TEST_STOP
AT_CLEANUP
dnl ---------------------------------------------------------------------
AT_SETUP([ovn-nbctl - ACLs])
OVN_NBCTL_TEST_START
AT_CHECK([ovn-nbctl lswitch-add ls0])
AT_CHECK([ovn-nbctl --log acl-add ls0 from-lport 600 udp drop])
AT_CHECK([ovn-nbctl --log acl-add ls0 to-lport 500 udp drop])
AT_CHECK([ovn-nbctl acl-add ls0 from-lport 400 tcp drop])
AT_CHECK([ovn-nbctl acl-add ls0 to-lport 300 tcp drop])
AT_CHECK([ovn-nbctl acl-add ls0 from-lport 200 ip drop])
AT_CHECK([ovn-nbctl acl-add ls0 to-lport 100 ip drop])
AT_CHECK([ovn-nbctl acl-list ls0], [0], [dnl
from-lport 600 (udp) drop log
from-lport 400 (tcp) drop
from-lport 200 (ip) drop
to-lport 500 (udp) drop log
to-lport 300 (tcp) drop
to-lport 100 (ip) drop
])
dnl Delete in one direction.
AT_CHECK([ovn-nbctl acl-del ls0 to-lport])
AT_CHECK([ovn-nbctl acl-list ls0], [0], [dnl
from-lport 600 (udp) drop log
from-lport 400 (tcp) drop
from-lport 200 (ip) drop
])
dnl Delete all ACLs.
AT_CHECK([ovn-nbctl acl-del ls0])
AT_CHECK([ovn-nbctl acl-list ls0], [0], [dnl
])
AT_CHECK([ovn-nbctl acl-add ls0 from-lport 600 udp drop])
AT_CHECK([ovn-nbctl acl-add ls0 from-lport 400 tcp drop])
AT_CHECK([ovn-nbctl acl-add ls0 from-lport 200 ip drop])
dnl Delete a single flow.
AT_CHECK([ovn-nbctl acl-del ls0 from-lport 400 tcp])
AT_CHECK([ovn-nbctl acl-list ls0], [0], [dnl
from-lport 600 (udp) drop
from-lport 200 (ip) drop
])
OVN_NBCTL_TEST_STOP
AT_CLEANUP
|