]>
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) | |
54 | chassis_mappings=$(ovn-sbctl get Chassis ${sysid} external_ids:ovn-bridge-mappings | sed -e 's/\"//g') | |
55 | echo $local_mappings | |
56 | echo $chassis_mappings | |
57 | AT_CHECK([test "${local_mappings}" = "${chassis_mappings}"]) | |
58 | } | |
59 | ||
caad1387 BP |
60 | # Initially there should be no patch ports. |
61 | check_patches | |
62 | ||
e90aeb57 | 63 | # Configure two ovn-bridge mappings, but no patch ports should be created yet |
caad1387 | 64 | AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0,physnet2:br-eth1]) |
4250ee37 | 65 | check_bridge_mappings "physnet1:br-eth0,physnet2:br-eth1" |
e90aeb57 RB |
66 | check_patches |
67 | ||
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. | |
71 | ovn-sbctl \ | |
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 | |
75 | check_patches | |
caad1387 | 76 | |
e90aeb57 RB |
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. | |
79 | ovn-sbctl \ | |
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 | |
caad1387 | 85 | check_patches \ |
e90aeb57 RB |
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' | |
caad1387 | 88 | |
d387d24d BP |
89 | # Add logical patch ports. |
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 \ | |
95 | | ${PERL} $srcdir/uuidfilt.pl], [0], [<0> | |
96 | <1> | |
97 | <2> | |
98 | <3> | |
99 | ]) | |
100 | check_patches \ | |
e90aeb57 RB |
101 | 'br-int patch-br-int-to-localnet2 patch-localnet2-to-br-int' \ |
102 | 'br-eth0 patch-localnet2-to-br-int patch-br-int-to-localnet2' \ | |
d387d24d BP |
103 | 'br-int patch-foo-to-bar patch-bar-to-foo' \ |
104 | 'br-int patch-bar-to-foo patch-foo-to-bar' | |
105 | ||
106 | # Delete the mapping and the ovn-bridge-mapping patch ports should go away; | |
107 | # the ones from the logical patch port remain. | |
caad1387 | 108 | AT_CHECK([ovs-vsctl remove Open_vSwitch . external-ids ovn-bridge-mappings]) |
4250ee37 | 109 | check_bridge_mappings |
d387d24d BP |
110 | check_patches \ |
111 | 'br-int patch-foo-to-bar patch-bar-to-foo' \ | |
112 | 'br-int patch-bar-to-foo patch-foo-to-bar' | |
113 | ||
114 | # Change name of logical patch port, check that the OVS patch ports | |
115 | # get updated. | |
116 | AT_CHECK([ovn-sbctl \ | |
117 | -- set Port_Binding foo logical_port=quux options:peer=baz \ | |
118 | -- set Port_Binding bar logical_port=baz options:peer=quux]) | |
119 | check_patches \ | |
120 | 'br-int patch-quux-to-baz patch-baz-to-quux' \ | |
121 | 'br-int patch-baz-to-quux patch-quux-to-baz' | |
122 | ||
1b62572d RM |
123 | # Create an empty database, serve it and switch to it |
124 | # and verify that the OVS patch ports disappear | |
125 | # then put it back and verify that they reappear | |
126 | ||
127 | on_exit 'kill `cat $ovs_base/ovn-sb/ovsdb-server-2.pid`' | |
128 | ||
129 | ovsdb-tool create $ovs_base/ovn-sb/ovn-sb1.db "$abs_top_srcdir"/ovn/ovn-sb.ovsschema | |
8a16ab90 LR |
130 | as ovn-sb ovsdb-server --detach --pidfile=$ovs_base/ovn-sb/ovsdb-server-2.pid --remote=punix:$ovs_base/ovn-sb/ovn-sb1.sock $ovs_base/ovn-sb/ovn-sb1.db \ |
131 | --unixctl=$ovs_base/ovn-sb/ovsdb-server-2.ctl | |
1b62572d RM |
132 | AT_CHECK([ovs-vsctl -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb1.sock]) |
133 | check_patches | |
134 | AT_CHECK([ovs-vsctl -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock]) | |
135 | check_patches \ | |
136 | 'br-int patch-quux-to-baz patch-baz-to-quux' \ | |
137 | 'br-int patch-baz-to-quux patch-quux-to-baz' | |
138 | ||
d387d24d BP |
139 | # Change the logical patch ports to VIFs and verify that the OVS patch |
140 | # ports disappear. | |
141 | AT_CHECK([ovn-sbctl \ | |
142 | -- set Port_Binding quux type='""' options='{}' \ | |
143 | -- set Port_Binding baz type='""' options='{}']) | |
caad1387 BP |
144 | check_patches |
145 | ||
d9c8c57c | 146 | # Gracefully terminate daemons |
7a8f15e0 LR |
147 | OVN_CLEANUP_SBOX([hv]) |
148 | OVN_CLEANUP_VSWITCH([main]) | |
d9c8c57c | 149 | as ovn-sb |
8a16ab90 | 150 | OVS_APP_EXIT_AND_WAIT_BY_TARGET([$ovs_base/ovn-sb/ovsdb-server-2.ctl], [$ovs_base/ovn-sb/ovsdb-server-2.pid]) |
d9c8c57c LR |
151 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) |
152 | ||
caad1387 | 153 | AT_CLEANUP |
5236c73a NS |
154 | |
155 | # Checks that ovn-controller populates datapath-type and iface-types | |
156 | # correctly in the Chassis external-ids column. | |
157 | AT_SETUP([ovn-controller - Chassis external_ids]) | |
158 | AT_KEYWORDS([ovn]) | |
159 | ovn_init_db ovn-sb | |
160 | ||
161 | net_add n1 | |
162 | sim_add hv | |
163 | as hv | |
164 | ovs-vsctl \ | |
165 | -- add-br br-phys \ | |
166 | -- add-br br-eth0 \ | |
167 | -- add-br br-eth1 \ | |
168 | -- add-br br-eth2 | |
169 | ovn_attach n1 br-phys 192.168.0.1 | |
170 | ||
171 | sysid=$(ovs-vsctl get Open_vSwitch . external_ids:system-id) | |
172 | ||
173 | # Make sure that the datapath_type set in the Bridge table | |
174 | # is mirrored into the Chassis record in the OVN_Southbound db. | |
175 | check_datapath_type () { | |
176 | datapath_type=$1 | |
177 | chassis_datapath_type=$(ovn-sbctl get Chassis ${sysid} external_ids:datapath-type | sed -e 's/"//g') #" | |
178 | test "${datapath_type}" = "${chassis_datapath_type}" | |
179 | } | |
180 | ||
181 | OVS_WAIT_UNTIL([check_datapath_type ""]) | |
182 | ||
183 | ovs-vsctl set Bridge br-int datapath-type=foo | |
184 | OVS_WAIT_UNTIL([check_datapath_type foo]) | |
185 | ||
186 | # Change "ovn-bridge-mappings" value. It should not change the "datapath-type". | |
187 | ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-mappings=foo-mapping | |
188 | check_datapath_type foo | |
189 | ||
190 | ovs-vsctl set Bridge br-int datapath-type=bar | |
191 | OVS_WAIT_UNTIL([check_datapath_type bar]) | |
192 | ||
193 | ovs-vsctl set Bridge br-int datapath-type=\"\" | |
194 | OVS_WAIT_UNTIL([check_datapath_type ""]) | |
195 | ||
196 | # The following will need to be updated as OVS starts to support more | |
197 | # interface types. | |
198 | expected_iface_types="dummy,dummy-pmd,geneve,gre,internal,ipsec_gre,lisp,patch,stt,system,tap,vxlan" | |
199 | chassis_iface_types=$(ovn-sbctl get Chassis ${sysid} external_ids:iface-types | sed -e 's/\"//g') | |
200 | echo "chassis_iface_types = ${chassis_iface_types}" | |
201 | AT_CHECK([test "${expected_iface_types}" = "${chassis_iface_types}"]) | |
202 | ||
203 | # Change the value of external_ids:iface-types using ovn-sbctl. | |
204 | # ovn-controller should again set it back to proper one. | |
205 | ovn-sbctl set Chassis ${sysid} external_ids:iface-types="foo" | |
206 | OVS_WAIT_UNTIL([ | |
207 | chassis_iface_types=$(ovn-sbctl get Chassis ${sysid} external_ids:iface-types | sed -e 's/\"//g') | |
208 | echo "chassis_iface_types = ${chassis_iface_types}" | |
209 | test "${expected_iface_types}" = "${chassis_iface_types}" | |
210 | ]) | |
211 | ||
212 | # Gracefully terminate daemons | |
213 | OVN_CLEANUP_SBOX([hv]) | |
214 | OVN_CLEANUP_VSWITCH([main]) | |
215 | as ovn-sb | |
216 | OVS_APP_EXIT_AND_WAIT([ovsdb-server]) | |
217 | ||
218 | AT_CLEANUP |