1 AT_BANNER([ovn-controller])
3 AT_SETUP([ovn-controller - ovn-bridge-mappings])
14 ovn_attach n1 br-phys 192.168.0.1
16 # Waits until the OVS database contains exactly the specified patch ports.
17 # Each argument should be of the form BRIDGE PORT PEER.
19 # Generate code to check that the set of patch ports is exactly as
21 echo 'ovs-vsctl -f csv -d bare --no-headings --columns=name find Interface type=patch | sort' > query
25 done | cut -d' ' -f 2 | sort > expout
27 # Generate code to verify that the configuration of each patch
31 set $patch; bridge=$1 port=$2 peer=$3
32 echo >>query "ovs-vsctl iface-to-br $port -- get Interface $port type options"
33 echo >>expout "$bridge
38 # Run the query until we get the expected result (or until a timeout).
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])
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 () {
53 sysid=$(ovs-vsctl get Open_vSwitch . external_ids:system-id)
54 chassis_mappings=$(ovn-sbctl get Chassis ${sysid} external_ids:ovn-bridge-mappings | sed -e 's/\"//g')
56 echo $chassis_mappings
57 AT_CHECK([test "${local_mappings}" = "${chassis_mappings}"])
60 # Initially there should be no patch ports.
63 # Configure two ovn-bridge mappings, but no patch ports should be created yet
64 AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0,physnet2:br-eth1])
65 check_bridge_mappings "physnet1:br-eth0,physnet2:br-eth1"
68 # Create a localnet port, but we should still have no patch ports, as they
69 # won't be created until there's a localnet port on a logical switch with
70 # another logical port bound to this chassis.
72 -- --id=@dp101 create Datapath_Binding tunnel_key=101 \
73 -- create Port_Binding datapath=@dp101 logical_port=localnet1 tunnel_key=1 \
74 type=localnet options:network_name=physnet1
77 # Create a localnet port on a logical switch with a port bound to this chassis.
78 # Now we should get some patch ports created.
80 -- --id=@dp102 create Datapath_Binding tunnel_key=102 \
81 -- create Port_Binding datapath=@dp102 logical_port=localnet2 tunnel_key=1 \
82 type=localnet options:network_name=physnet1 \
83 -- create Port_Binding datapath=@dp102 logical_port=localvif2 tunnel_key=2
84 ovs-vsctl add-port br-int localvif2 -- set Interface localvif2 external_ids:iface-id=localvif2
86 'br-int patch-br-int-to-localnet2 patch-localnet2-to-br-int' \
87 'br-eth0 patch-localnet2-to-br-int patch-br-int-to-localnet2'
89 # Add logical patch ports to connect new logical datapath.
91 # OVN no longer uses OVS patch ports to implement logical patch ports, so
92 # the set of OVS patch ports doesn't change.
94 -- --id=@dp1 create Datapath_Binding tunnel_key=1 \
95 -- --id=@dp2 create Datapath_Binding tunnel_key=2 \
96 -- create Port_Binding datapath=@dp1 logical_port=foo tunnel_key=1 type=patch options:peer=bar \
97 -- create Port_Binding datapath=@dp2 logical_port=bar tunnel_key=2 type=patch options:peer=foo \
98 -- create Port_Binding datapath=@dp1 logical_port=dp1vif tunnel_key=3 \
99 | ${PERL} $srcdir/uuidfilt.pl], [0], [<0>
105 ovs-vsctl add-port br-int dp1vif -- set Interface dp1vif external_ids:iface-id=dp1vif
107 'br-int patch-br-int-to-localnet2 patch-localnet2-to-br-int' \
108 'br-eth0 patch-localnet2-to-br-int patch-br-int-to-localnet2'
110 # Delete the mapping and the ovn-bridge-mapping patch ports should go away.
111 AT_CHECK([ovs-vsctl remove Open_vSwitch . external-ids ovn-bridge-mappings])
112 check_bridge_mappings
115 # Gracefully terminate daemons
116 OVN_CLEANUP_SBOX([hv])
117 OVN_CLEANUP_VSWITCH([main])
119 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
123 # Checks that ovn-controller populates datapath-type and iface-types
124 # correctly in the Chassis external-ids column.
125 AT_SETUP([ovn-controller - Chassis external_ids])
137 ovn_attach n1 br-phys 192.168.0.1
139 sysid=$(ovs-vsctl get Open_vSwitch . external_ids:system-id)
141 # Make sure that the datapath_type set in the Bridge table
142 # is mirrored into the Chassis record in the OVN_Southbound db.
143 check_datapath_type () {
145 chassis_datapath_type=$(ovn-sbctl get Chassis ${sysid} external_ids:datapath-type | sed -e 's/"//g') #"
146 test "${datapath_type}" = "${chassis_datapath_type}"
149 OVS_WAIT_UNTIL([check_datapath_type ""])
151 ovs-vsctl set Bridge br-int datapath-type=foo
152 OVS_WAIT_UNTIL([check_datapath_type foo])
154 # Change "ovn-bridge-mappings" value. It should not change the "datapath-type".
155 ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-mappings=foo-mapping
156 check_datapath_type foo
158 ovs-vsctl set Bridge br-int datapath-type=bar
159 OVS_WAIT_UNTIL([check_datapath_type bar])
161 ovs-vsctl set Bridge br-int datapath-type=\"\"
162 OVS_WAIT_UNTIL([check_datapath_type ""])
164 expected_iface_types=$(ovs-vsctl get Open_vSwitch . iface_types|sed 's/[[]][[ ]]//g')
165 chassis_iface_types=$(ovn-sbctl get Chassis ${sysid} external_ids:iface-types | sed -e 's/\"//g')
166 echo "chassis_iface_types = ${chassis_iface_types}"
167 AT_CHECK([test "${expected_iface_types}" = "${chassis_iface_types}"])
169 # Change the value of external_ids:iface-types using ovn-sbctl.
170 # ovn-controller should again set it back to proper one.
171 ovn-sbctl set Chassis ${sysid} external_ids:iface-types="foo"
173 chassis_iface_types=$(ovn-sbctl get Chassis ${sysid} external_ids:iface-types | sed -e 's/\"//g')
174 echo "chassis_iface_types = ${chassis_iface_types}"
175 test "${expected_iface_types}" = "${chassis_iface_types}"
178 # Gracefully terminate daemons
179 OVN_CLEANUP_SBOX([hv])
180 OVN_CLEANUP_VSWITCH([main])
182 OVS_APP_EXIT_AND_WAIT([ovsdb-server])
186 # Checks that ovn-controller correctly maintains the mapping from the Encap
187 # table in the Southbound database to OVS in the face of changes on both sides
188 AT_SETUP([ovn-controller - change Encap properties])
200 ovn_attach n1 br-phys 192.168.0.1
202 check_tunnel_property () {
203 test "`ovs-vsctl get interface ovn-fakech-0 $1`" = "$2"
206 # Start off with a remote chassis supporting STT
207 ovn-sbctl chassis-add fakechassis stt 192.168.0.2
208 OVS_WAIT_UNTIL([check_tunnel_property type stt])
210 # See if we switch to Geneve as the first choice when it is available
211 encap_uuid=$(ovn-sbctl add chassis fakechassis encaps @encap -- --id=@encap create encap type=geneve ip="127.0.0.1")
212 OVS_WAIT_UNTIL([check_tunnel_property type geneve])
214 # Check that changes within an encap row are propagated
215 ovn-sbctl set encap ${encap_uuid} ip=192.168.0.2
216 OVS_WAIT_UNTIL([check_tunnel_property options:remote_ip "\"192.168.0.2\""])
218 # Change the type on the OVS side and check than OVN fixes it
219 ovs-vsctl set interface ovn-fakech-0 type=vxlan
220 OVS_WAIT_UNTIL([check_tunnel_property type geneve])
222 # Delete the port entirely and it should be resurrected
223 ovs-vsctl del-port ovn-fakech-0
224 OVS_WAIT_UNTIL([check_tunnel_property type geneve])
226 # Gracefully terminate daemons
227 OVN_CLEANUP_SBOX([hv])
228 OVN_CLEANUP_VSWITCH([main])
230 OVS_APP_EXIT_AND_WAIT([ovsdb-server])