]>
Commit | Line | Data |
---|---|---|
caad1387 BP |
1 | AT_BANNER([ovn-controller]) |
2 | ||
3 | AT_SETUP([ovn-controller - ovn-bridge-mappings]) | |
dfef14ee | 4 | AT_KEYWORDS([ovn]) |
caad1387 BP |
5 | ovn_init_db ovn-sb |
6 | net_add n1 | |
7 | sim_add hv | |
8 | as hv | |
9 | ovs-vsctl \ | |
10 | -- add-br br-phys \ | |
11 | -- add-br br-eth0 \ | |
12 | -- add-br br-eth1 \ | |
13 | -- add-br br-eth2 | |
14 | ovn_attach n1 br-phys 192.168.0.1 | |
15 | ||
16 | # Waits until the OVS database contains exactly the specified patch ports. | |
17 | # Each argument should be of the form BRIDGE PORT PEER. | |
18 | check_patches () { | |
19 | # Generate code to check that the set of patch ports is exactly as | |
20 | # specified. | |
21 | echo 'ovs-vsctl -f csv -d bare --no-headings --columns=name find Interface type=patch | sort' > query | |
22 | for patch | |
23 | do | |
269ecccc | 24 | echo $patch |
caad1387 BP |
25 | done | cut -d' ' -f 2 | sort > expout |
26 | ||
27 | # Generate code to verify that the configuration of each patch | |
28 | # port is correct. | |
29 | for patch | |
30 | do | |
269ecccc | 31 | set $patch; bridge=$1 port=$2 peer=$3 |
caad1387 BP |
32 | echo >>query "ovs-vsctl iface-to-br $port -- get Interface $port type options" |
33 | echo >>expout "$bridge | |
34 | patch | |
35 | {peer=$peer}" | |
36 | done | |
37 | ||
38 | # Run the query until we get the expected result (or until a timeout). | |
39 | # | |
40 | # (We use sed to drop all "s from output because ovs-vsctl quotes some | |
41 | # of the port names but not others.) | |
42 | AT_CAPTURE_FILE([query]) | |
43 | AT_CAPTURE_FILE([expout]) | |
44 | AT_CAPTURE_FILE([stdout]) | |
45 | OVS_WAIT_UNTIL([. ./query | sed 's/"//g' > stdout #" | |
46 | diff -u stdout expout >/dev/null]) | |
47 | } | |
48 | ||
4250ee37 RB |
49 | # Make sure that the configured bridge mappings in the Open_vSwitch db |
50 | # is mirrored into the Chassis record in the OVN_Southbound db. | |
51 | check_bridge_mappings () { | |
52 | local_mappings=$1 | |
53 | sysid=$(ovs-vsctl get Open_vSwitch . external_ids:system-id) | |
62c2b055 | 54 | OVS_WAIT_UNTIL([test x"${local_mappings}" = x$(ovn-sbctl get Chassis ${sysid} external_ids:ovn-bridge-mappings | sed -e 's/\"//g')]) |
4250ee37 RB |
55 | } |
56 | ||
caad1387 BP |
57 | # Initially there should be no patch ports. |
58 | check_patches | |
59 | ||
e90aeb57 | 60 | # Configure two ovn-bridge mappings, but no patch ports should be created yet |
caad1387 | 61 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0,physnet2:br-eth1]) |
4250ee37 | 62 | check_bridge_mappings "physnet1:br-eth0,physnet2:br-eth1" |
e90aeb57 RB |
63 | check_patches |
64 | ||
65 | # Create a localnet port, but we should still have no patch ports, as they | |
66 | # won't be created until there's a localnet port on a logical switch with | |
67 | # another logical port bound to this chassis. | |
68 | ovn-sbctl \ | |
69 | -- --id=@dp101 create Datapath_Binding tunnel_key=101 \ | |
70 | -- create Port_Binding datapath=@dp101 logical_port=localnet1 tunnel_key=1 \ | |
71 | type=localnet options:network_name=physnet1 | |
72 | check_patches | |
caad1387 | 73 | |
e90aeb57 RB |
74 | # Create a localnet port on a logical switch with a port bound to this chassis. |
75 | # Now we should get some patch ports created. | |
76 | ovn-sbctl \ | |
77 | -- --id=@dp102 create Datapath_Binding tunnel_key=102 \ | |
78 | -- create Port_Binding datapath=@dp102 logical_port=localnet2 tunnel_key=1 \ | |
79 | type=localnet options:network_name=physnet1 \ | |
80 | -- create Port_Binding datapath=@dp102 logical_port=localvif2 tunnel_key=2 | |
81 | ovs-vsctl add-port br-int localvif2 -- set Interface localvif2 external_ids:iface-id=localvif2 | |
caad1387 | 82 | check_patches \ |
e90aeb57 RB |
83 | 'br-int patch-br-int-to-localnet2 patch-localnet2-to-br-int' \ |
84 | 'br-eth0 patch-localnet2-to-br-int patch-br-int-to-localnet2' | |
caad1387 | 85 | |
1ea9b847 BP |
86 | # Add logical patch ports to connect new logical datapath. |
87 | # | |
f1a8bd06 BP |
88 | # OVN no longer uses OVS patch ports to implement logical patch ports, so |
89 | # the set of OVS patch ports doesn't change. | |
d387d24d BP |
90 | AT_CHECK([ovn-sbctl \ |
91 | -- --id=@dp1 create Datapath_Binding tunnel_key=1 \ | |
92 | -- --id=@dp2 create Datapath_Binding tunnel_key=2 \ | |
93 | -- create Port_Binding datapath=@dp1 logical_port=foo tunnel_key=1 type=patch options:peer=bar \ | |
94 | -- create Port_Binding datapath=@dp2 logical_port=bar tunnel_key=2 type=patch options:peer=foo \ | |
1ea9b847 | 95 | -- create Port_Binding datapath=@dp1 logical_port=dp1vif tunnel_key=3 \ |
c724bd67 | 96 | | uuidfilt], [0], [<0> |
d387d24d BP |
97 | <1> |
98 | <2> | |
99 | <3> | |
1ea9b847 | 100 | <4> |
d387d24d | 101 | ]) |
1ea9b847 | 102 | ovs-vsctl add-port br-int dp1vif -- set Interface dp1vif external_ids:iface-id=dp1vif |
d387d24d | 103 | check_patches \ |
e90aeb57 | 104 | 'br-int patch-br-int-to-localnet2 patch-localnet2-to-br-int' \ |
f1a8bd06 | 105 | 'br-eth0 patch-localnet2-to-br-int patch-br-int-to-localnet2' |
d387d24d | 106 | |
f1a8bd06 | 107 | # Delete the mapping and the ovn-bridge-mapping patch ports should go away. |
caad1387 | 108 | AT_CHECK([ovs-vsctl remove Open_vSwitch . external-ids ovn-bridge-mappings]) |
4250ee37 | 109 | check_bridge_mappings |
caad1387 BP |
110 | check_patches |
111 | ||
d9c8c57c | 112 | # Gracefully terminate daemons |
7a8f15e0 LR |
113 | OVN_CLEANUP_SBOX([hv]) |
114 | OVN_CLEANUP_VSWITCH([main]) | |
d9c8c57c LR |
115 | as ovn-sb |
116 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
117 | ||
caad1387 | 118 | AT_CLEANUP |
5236c73a NS |
119 | |
120 | # Checks that ovn-controller populates datapath-type and iface-types | |
121 | # correctly in the Chassis external-ids column. | |
122 | AT_SETUP([ovn-controller - Chassis external_ids]) | |
123 | AT_KEYWORDS([ovn]) | |
124 | ovn_init_db ovn-sb | |
125 | ||
126 | net_add n1 | |
127 | sim_add hv | |
128 | as hv | |
129 | ovs-vsctl \ | |
130 | -- add-br br-phys \ | |
131 | -- add-br br-eth0 \ | |
132 | -- add-br br-eth1 \ | |
133 | -- add-br br-eth2 | |
134 | ovn_attach n1 br-phys 192.168.0.1 | |
135 | ||
136 | sysid=$(ovs-vsctl get Open_vSwitch . external_ids:system-id) | |
137 | ||
138 | # Make sure that the datapath_type set in the Bridge table | |
139 | # is mirrored into the Chassis record in the OVN_Southbound db. | |
140 | check_datapath_type () { | |
141 | datapath_type=$1 | |
142 | chassis_datapath_type=$(ovn-sbctl get Chassis ${sysid} external_ids:datapath-type | sed -e 's/"//g') #" | |
143 | test "${datapath_type}" = "${chassis_datapath_type}" | |
144 | } | |
145 | ||
146 | OVS_WAIT_UNTIL([check_datapath_type ""]) | |
147 | ||
148 | ovs-vsctl set Bridge br-int datapath-type=foo | |
149 | OVS_WAIT_UNTIL([check_datapath_type foo]) | |
150 | ||
151 | # Change "ovn-bridge-mappings" value. It should not change the "datapath-type". | |
152 | ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-mappings=foo-mapping | |
153 | check_datapath_type foo | |
154 | ||
155 | ovs-vsctl set Bridge br-int datapath-type=bar | |
156 | OVS_WAIT_UNTIL([check_datapath_type bar]) | |
157 | ||
158 | ovs-vsctl set Bridge br-int datapath-type=\"\" | |
159 | OVS_WAIT_UNTIL([check_datapath_type ""]) | |
160 | ||
8ba510bf NS |
161 | # Set the datapath_type in external_ids:ovn-bridge-datapath-type. |
162 | ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-datapath-type=foo | |
163 | OVS_WAIT_UNTIL([check_datapath_type foo]) | |
164 | ||
165 | # Change the br-int's datapath type to bar. | |
166 | # It should be reset to foo since ovn-bridge-datapath-type is configured. | |
167 | ovs-vsctl set Bridge br-int datapath-type=bar | |
168 | OVS_WAIT_UNTIL([test foo=`ovs-vsctl get Bridge br-int datapath-type`]) | |
169 | OVS_WAIT_UNTIL([check_datapath_type foo]) | |
170 | ||
171 | ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-datapath-type=foobar | |
172 | OVS_WAIT_UNTIL([test foobar=`ovs-vsctl get Bridge br-int datapath-type`]) | |
173 | OVS_WAIT_UNTIL([check_datapath_type foobar]) | |
174 | ||
7dc18ae9 WT |
175 | expected_iface_types=$(ovs-vsctl get Open_vSwitch . iface_types | tr -d '[[]] ""') |
176 | echo "expected_iface_types = ${expected_iface_types}" | |
5236c73a NS |
177 | chassis_iface_types=$(ovn-sbctl get Chassis ${sysid} external_ids:iface-types | sed -e 's/\"//g') |
178 | echo "chassis_iface_types = ${chassis_iface_types}" | |
179 | AT_CHECK([test "${expected_iface_types}" = "${chassis_iface_types}"]) | |
180 | ||
181 | # Change the value of external_ids:iface-types using ovn-sbctl. | |
182 | # ovn-controller should again set it back to proper one. | |
183 | ovn-sbctl set Chassis ${sysid} external_ids:iface-types="foo" | |
184 | OVS_WAIT_UNTIL([ | |
185 | chassis_iface_types=$(ovn-sbctl get Chassis ${sysid} external_ids:iface-types | sed -e 's/\"//g') | |
186 | echo "chassis_iface_types = ${chassis_iface_types}" | |
187 | test "${expected_iface_types}" = "${chassis_iface_types}" | |
188 | ]) | |
189 | ||
190 | # Gracefully terminate daemons | |
191 | OVN_CLEANUP_SBOX([hv]) | |
192 | OVN_CLEANUP_VSWITCH([main]) | |
193 | as ovn-sb | |
194 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
195 | ||
196 | AT_CLEANUP | |
9263ceaf JG |
197 | |
198 | # Checks that ovn-controller correctly maintains the mapping from the Encap | |
199 | # table in the Southbound database to OVS in the face of changes on both sides | |
200 | AT_SETUP([ovn-controller - change Encap properties]) | |
201 | AT_KEYWORDS([ovn]) | |
202 | ovn_init_db ovn-sb | |
203 | ||
204 | net_add n1 | |
205 | sim_add hv | |
206 | as hv | |
207 | ovs-vsctl \ | |
208 | -- add-br br-phys \ | |
209 | -- add-br br-eth0 \ | |
210 | -- add-br br-eth1 \ | |
211 | -- add-br br-eth2 | |
212 | ovn_attach n1 br-phys 192.168.0.1 | |
213 | ||
214 | check_tunnel_property () { | |
215 | test "`ovs-vsctl get interface ovn-fakech-0 $1`" = "$2" | |
216 | } | |
217 | ||
218 | # Start off with a remote chassis supporting STT | |
219 | ovn-sbctl chassis-add fakechassis stt 192.168.0.2 | |
220 | OVS_WAIT_UNTIL([check_tunnel_property type stt]) | |
221 | ||
222 | # See if we switch to Geneve as the first choice when it is available | |
b520ca7c | 223 | # With multi-VTEP support we support tunnels with different IPs to the |
224 | # same chassis, and hence use the IP to annotate the tunnel (along with | |
225 | # the chassis-id in ovn-chassis-id); if we supply a different IP here | |
226 | # we won't be able to co-relate this to the tunnel port that was created | |
227 | # in the previous step and, as a result, will end up creating another tunnel, | |
228 | # ie. we can't just lookup using "ovn-fakech-0". So, need to use the same IP | |
229 | # as above, i.e 192.168.0.2, here. | |
230 | encap_uuid=$(ovn-sbctl add chassis fakechassis encaps @encap -- --id=@encap create encap type=geneve ip="192.168.0.2") | |
9263ceaf JG |
231 | OVS_WAIT_UNTIL([check_tunnel_property type geneve]) |
232 | ||
233 | # Check that changes within an encap row are propagated | |
234 | ovn-sbctl set encap ${encap_uuid} ip=192.168.0.2 | |
235 | OVS_WAIT_UNTIL([check_tunnel_property options:remote_ip "\"192.168.0.2\""]) | |
236 | ||
237 | # Change the type on the OVS side and check than OVN fixes it | |
238 | ovs-vsctl set interface ovn-fakech-0 type=vxlan | |
239 | OVS_WAIT_UNTIL([check_tunnel_property type geneve]) | |
240 | ||
241 | # Delete the port entirely and it should be resurrected | |
242 | ovs-vsctl del-port ovn-fakech-0 | |
243 | OVS_WAIT_UNTIL([check_tunnel_property type geneve]) | |
244 | ||
245 | # Gracefully terminate daemons | |
246 | OVN_CLEANUP_SBOX([hv]) | |
247 | OVN_CLEANUP_VSWITCH([main]) | |
248 | as ovn-sb | |
249 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
250 | ||
251 | AT_CLEANUP | |
82b261b9 LB |
252 | |
253 | # Check ovn-controller connection status to Southbound database | |
254 | AT_SETUP([ovn-controller - check sbdb connection]) | |
255 | AT_KEYWORDS([ovn]) | |
256 | ovn_init_db ovn-sb | |
257 | ||
258 | net_add n1 | |
259 | sim_add hv | |
260 | as hv | |
261 | ovs-vsctl \ | |
262 | -- add-br br-phys \ | |
263 | -- add-br br-eth0 \ | |
264 | -- add-br br-eth1 \ | |
265 | -- add-br br-eth2 | |
266 | ovn_attach n1 br-phys 192.168.0.1 | |
267 | ||
268 | check_sbdb_connection () { | |
269 | test "$(ovs-appctl -t ovn-controller connection-status)" = "$1" | |
270 | } | |
271 | ||
272 | OVS_WAIT_UNTIL([check_sbdb_connection connected]) | |
273 | ||
274 | ovs-vsctl set open . external_ids:ovn-remote=tcp:192.168.0.10:6642 | |
275 | OVS_WAIT_UNTIL([check_sbdb_connection 'not connected']) | |
276 | ||
277 | # reset the remote for clean-up | |
278 | ovs-vsctl set open . external_ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock | |
279 | # Gracefully terminate daemons | |
280 | OVN_CLEANUP_SBOX([hv]) | |
281 | OVN_CLEANUP_VSWITCH([main]) | |
282 | as ovn-sb | |
283 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
284 | ||
285 | AT_CLEANUP |