ofproto: Implement OFPT_QUEUE_GET_CONFIG_REQUEST for OFPP_ANY in OF1.1+.
[cascardo/ovs.git] / tests / ovn-controller.at
1 AT_BANNER([ovn-controller])
2
3 AT_SETUP([ovn-controller - ovn-bridge-mappings])
4 AT_KEYWORDS([ovn])
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
24         echo $patch
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
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
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
49 # Initially there should be no patch ports.
50 check_patches
51
52 # Configure two ovn-bridge mappings to create two patch ports.
53 AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0,physnet2:br-eth1])
54 check_patches \
55     'br-eth0 patch-br-eth0-to-br-int patch-br-int-to-br-eth0' \
56     'br-int  patch-br-int-to-br-eth0 patch-br-eth0-to-br-int' \
57     'br-eth1 patch-br-eth1-to-br-int patch-br-int-to-br-eth1' \
58     'br-int  patch-br-int-to-br-eth1 patch-br-eth1-to-br-int'
59
60 # Change the mapping and the patch ports should change.
61 AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth2,physnet2:br-eth1])
62 check_patches \
63     'br-eth2 patch-br-eth2-to-br-int patch-br-int-to-br-eth2' \
64     'br-int  patch-br-int-to-br-eth2 patch-br-eth2-to-br-int' \
65     'br-eth1 patch-br-eth1-to-br-int patch-br-int-to-br-eth1' \
66     'br-int  patch-br-int-to-br-eth1 patch-br-eth1-to-br-int'
67
68 # Add logical patch ports.
69 AT_CHECK([ovn-sbctl \
70     -- --id=@dp1 create Datapath_Binding tunnel_key=1 \
71     -- --id=@dp2 create Datapath_Binding tunnel_key=2 \
72     -- create Port_Binding datapath=@dp1 logical_port=foo tunnel_key=1 type=patch options:peer=bar \
73     -- create Port_Binding datapath=@dp2 logical_port=bar tunnel_key=2 type=patch options:peer=foo \
74 | ${PERL} $srcdir/uuidfilt.pl], [0], [<0>
75 <1>
76 <2>
77 <3>
78 ])
79 check_patches \
80     'br-eth2 patch-br-eth2-to-br-int patch-br-int-to-br-eth2' \
81     'br-int  patch-br-int-to-br-eth2 patch-br-eth2-to-br-int' \
82     'br-eth1 patch-br-eth1-to-br-int patch-br-int-to-br-eth1' \
83     'br-int  patch-br-int-to-br-eth1 patch-br-eth1-to-br-int' \
84     'br-int  patch-foo-to-bar        patch-bar-to-foo' \
85     'br-int  patch-bar-to-foo        patch-foo-to-bar'
86
87 # Delete the mapping and the ovn-bridge-mapping patch ports should go away;
88 # the ones from the logical patch port remain.
89 AT_CHECK([ovs-vsctl remove Open_vSwitch . external-ids ovn-bridge-mappings])
90 check_patches \
91     'br-int patch-foo-to-bar patch-bar-to-foo' \
92     'br-int patch-bar-to-foo patch-foo-to-bar'
93
94 # Change name of logical patch port, check that the OVS patch ports
95 # get updated.
96 AT_CHECK([ovn-sbctl \
97     -- set Port_Binding foo logical_port=quux options:peer=baz \
98     -- set Port_Binding bar logical_port=baz  options:peer=quux])
99 check_patches \
100     'br-int patch-quux-to-baz patch-baz-to-quux' \
101     'br-int patch-baz-to-quux patch-quux-to-baz'
102
103 # Change the logical patch ports to VIFs and verify that the OVS patch
104 # ports disappear.
105 AT_CHECK([ovn-sbctl \
106     -- set Port_Binding quux type='""' options='{}' \
107     -- set Port_Binding baz type='""' options='{}'])
108 check_patches
109
110 AT_CLEANUP