]> git.proxmox.com Git - ovs.git/blame - tests/ovn-controller.at
meta-flow.xml: Fix typos of flow-based tunnel command examples.
[ovs.git] / tests / ovn-controller.at
CommitLineData
caad1387
BP
1AT_BANNER([ovn-controller])
2
3AT_SETUP([ovn-controller - ovn-bridge-mappings])
dfef14ee 4AT_KEYWORDS([ovn])
caad1387
BP
5ovn_init_db ovn-sb
6net_add n1
7sim_add hv
8as hv
9ovs-vsctl \
10 -- add-br br-phys \
11 -- add-br br-eth0 \
12 -- add-br br-eth1 \
13 -- add-br br-eth2
14ovn_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.
18check_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
34patch
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.
51check_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.
58check_patches
59
e90aeb57 60# Configure two ovn-bridge mappings, but no patch ports should be created yet
caad1387 61AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0,physnet2:br-eth1])
4250ee37 62check_bridge_mappings "physnet1:br-eth0,physnet2:br-eth1"
e90aeb57
RB
63check_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.
68ovn-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
72check_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.
76ovn-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
81ovs-vsctl add-port br-int localvif2 -- set Interface localvif2 external_ids:iface-id=localvif2
caad1387 82check_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
90AT_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 102ovs-vsctl add-port br-int dp1vif -- set Interface dp1vif external_ids:iface-id=dp1vif
d387d24d 103check_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 108AT_CHECK([ovs-vsctl remove Open_vSwitch . external-ids ovn-bridge-mappings])
4250ee37 109check_bridge_mappings
caad1387
BP
110check_patches
111
d9c8c57c 112# Gracefully terminate daemons
7a8f15e0
LR
113OVN_CLEANUP_SBOX([hv])
114OVN_CLEANUP_VSWITCH([main])
d9c8c57c
LR
115as ovn-sb
116OVS_APP_EXIT_AND_WAIT([ovsdb-server])
117
caad1387 118AT_CLEANUP
5236c73a
NS
119
120# Checks that ovn-controller populates datapath-type and iface-types
121# correctly in the Chassis external-ids column.
122AT_SETUP([ovn-controller - Chassis external_ids])
123AT_KEYWORDS([ovn])
124ovn_init_db ovn-sb
125
126net_add n1
127sim_add hv
128as hv
129ovs-vsctl \
130 -- add-br br-phys \
131 -- add-br br-eth0 \
132 -- add-br br-eth1 \
133 -- add-br br-eth2
134ovn_attach n1 br-phys 192.168.0.1
135
136sysid=$(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.
140check_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
146OVS_WAIT_UNTIL([check_datapath_type ""])
147
148ovs-vsctl set Bridge br-int datapath-type=foo
149OVS_WAIT_UNTIL([check_datapath_type foo])
150
151# Change "ovn-bridge-mappings" value. It should not change the "datapath-type".
152ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-mappings=foo-mapping
153check_datapath_type foo
154
155ovs-vsctl set Bridge br-int datapath-type=bar
156OVS_WAIT_UNTIL([check_datapath_type bar])
157
158ovs-vsctl set Bridge br-int datapath-type=\"\"
159OVS_WAIT_UNTIL([check_datapath_type ""])
160
8ba510bf
NS
161# Set the datapath_type in external_ids:ovn-bridge-datapath-type.
162ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-datapath-type=foo
163OVS_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.
167ovs-vsctl set Bridge br-int datapath-type=bar
168OVS_WAIT_UNTIL([test foo=`ovs-vsctl get Bridge br-int datapath-type`])
169OVS_WAIT_UNTIL([check_datapath_type foo])
170
171ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-datapath-type=foobar
172OVS_WAIT_UNTIL([test foobar=`ovs-vsctl get Bridge br-int datapath-type`])
173OVS_WAIT_UNTIL([check_datapath_type foobar])
174
7dc18ae9
WT
175expected_iface_types=$(ovs-vsctl get Open_vSwitch . iface_types | tr -d '[[]] ""')
176echo "expected_iface_types = ${expected_iface_types}"
5236c73a
NS
177chassis_iface_types=$(ovn-sbctl get Chassis ${sysid} external_ids:iface-types | sed -e 's/\"//g')
178echo "chassis_iface_types = ${chassis_iface_types}"
179AT_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.
183ovn-sbctl set Chassis ${sysid} external_ids:iface-types="foo"
184OVS_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
191OVN_CLEANUP_SBOX([hv])
192OVN_CLEANUP_VSWITCH([main])
193as ovn-sb
194OVS_APP_EXIT_AND_WAIT([ovsdb-server])
195
196AT_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
200AT_SETUP([ovn-controller - change Encap properties])
201AT_KEYWORDS([ovn])
202ovn_init_db ovn-sb
203
204net_add n1
205sim_add hv
206as hv
207ovs-vsctl \
208 -- add-br br-phys \
209 -- add-br br-eth0 \
210 -- add-br br-eth1 \
211 -- add-br br-eth2
212ovn_attach n1 br-phys 192.168.0.1
213
214check_tunnel_property () {
215 test "`ovs-vsctl get interface ovn-fakech-0 $1`" = "$2"
216}
217
218# Start off with a remote chassis supporting STT
219ovn-sbctl chassis-add fakechassis stt 192.168.0.2
220OVS_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.
230encap_uuid=$(ovn-sbctl add chassis fakechassis encaps @encap -- --id=@encap create encap type=geneve ip="192.168.0.2")
9263ceaf
JG
231OVS_WAIT_UNTIL([check_tunnel_property type geneve])
232
233# Check that changes within an encap row are propagated
234ovn-sbctl set encap ${encap_uuid} ip=192.168.0.2
235OVS_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
238ovs-vsctl set interface ovn-fakech-0 type=vxlan
239OVS_WAIT_UNTIL([check_tunnel_property type geneve])
240
241# Delete the port entirely and it should be resurrected
242ovs-vsctl del-port ovn-fakech-0
243OVS_WAIT_UNTIL([check_tunnel_property type geneve])
244
245# Gracefully terminate daemons
246OVN_CLEANUP_SBOX([hv])
247OVN_CLEANUP_VSWITCH([main])
248as ovn-sb
249OVS_APP_EXIT_AND_WAIT([ovsdb-server])
250
251AT_CLEANUP
82b261b9
LB
252
253# Check ovn-controller connection status to Southbound database
254AT_SETUP([ovn-controller - check sbdb connection])
255AT_KEYWORDS([ovn])
256ovn_init_db ovn-sb
257
258net_add n1
259sim_add hv
260as hv
261ovs-vsctl \
262 -- add-br br-phys \
263 -- add-br br-eth0 \
264 -- add-br br-eth1 \
265 -- add-br br-eth2
266ovn_attach n1 br-phys 192.168.0.1
267
268check_sbdb_connection () {
269 test "$(ovs-appctl -t ovn-controller connection-status)" = "$1"
270}
271
272OVS_WAIT_UNTIL([check_sbdb_connection connected])
273
274ovs-vsctl set open . external_ids:ovn-remote=tcp:192.168.0.10:6642
275OVS_WAIT_UNTIL([check_sbdb_connection 'not connected'])
276
277# reset the remote for clean-up
278ovs-vsctl set open . external_ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock
279# Gracefully terminate daemons
280OVN_CLEANUP_SBOX([hv])
281OVN_CLEANUP_VSWITCH([main])
282as ovn-sb
283OVS_APP_EXIT_AND_WAIT([ovsdb-server])
284
285AT_CLEANUP