Add a test to validate that a restart of the ovn-controller will program zoneids consistently on ports. Flows before restart are compared against flows after restart to detect problems with ofports or zone-ids.
Signed-off-by: Ramu Ramamurthy <ramu.ramamur...@us.ibm.com> --- tests/ovn-controller.at | 131 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index 971ea1e..7d17cd8 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -128,3 +128,134 @@ as ovn-sb OVS_APP_EXIT_AND_WAIT([ovsdb-server]) AT_CLEANUP + +AT_SETUP([ovn-controller - zone-id assignment]) +AT_KEYWORDS([ovn]) +# +# The purpose of this test is to validate the zone-id +# assigned to ports and programmed in the flow table. +# It verifies that the zone-id is assigned consistently +# after ovn-controller restart +# + +# create 2 localnet ports +# create 3 vifs +# create 5 cifs + +ovn_init_db ovn-sb +net_add n1 +sim_add hv +as hv +ovs-vsctl \ + -- add-br br-phys \ + -- add-br br-eth0 \ + -- add-br br-eth1 \ + -- add-br br-eth2 + +ovn_attach n1 br-phys 192.168.0.1 +ovs-appctl -t ovn-controller vlog/set any:any:dbg + +AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=physnet1:br-eth0,physnet2:br-eth1,physnet3:br-eth2]) + +# Create a localnet port +ovn-sbctl \ + -- --id=@dp101 create Datapath_Binding tunnel_key=101 \ + -- create Port_Binding datapath=@dp101 logical_port=localnet1 tunnel_key=1 \ + type=localnet options:network_name=physnet1 \ + -- create Port_Binding datapath=@dp101 logical_port=localvif1 tunnel_key=2 +ovs-vsctl add-port br-int localvif1 -- set Interface localvif1 external_ids:iface-id=localvif1 + +# Create a vif port +ovn-sbctl \ + -- --id=@dp102 create Datapath_Binding tunnel_key=102 \ + -- create Port_Binding datapath=@dp102 logical_port=localvif2 tunnel_key=3 +ovs-vsctl add-port br-int localvif2 -- set Interface localvif2 external_ids:iface-id=localvif2 + + +# Create a vif port and some cifs on it +ovn-sbctl \ + -- --id=@dp103 create Datapath_Binding tunnel_key=103 \ + -- create Port_Binding datapath=@dp103 logical_port=localvif3 tunnel_key=4 \ + -- create Port_Binding datapath=@dp103 logical_port=localcif1 tunnel_key=5 parent_port=localvif3 tag=1 \ + -- create Port_Binding datapath=@dp103 logical_port=localcif2 tunnel_key=6 parent_port=localvif3 tag=2 \ + -- create Port_Binding datapath=@dp103 logical_port=localcif3 tunnel_key=7 parent_port=localvif3 tag=3 \ + -- create Port_Binding datapath=@dp103 logical_port=localcif4 tunnel_key=8 parent_port=localvif3 tag=4 \ + -- create Port_Binding datapath=@dp103 logical_port=localcif5 tunnel_key=9 parent_port=localvif3 tag=5 +ovs-vsctl add-port br-int localvif3 -- set Interface localvif3 external_ids:iface-id=localvif3 + +# Create another localnet port +ovn-sbctl \ + -- --id=@dp201 create Datapath_Binding tunnel_key=201 \ + -- create Port_Binding datapath=@dp201 logical_port=localnet201 tunnel_key=1 \ + type=localnet options:network_name=physnet2 \ + -- create Port_Binding datapath=@dp201 logical_port=localvif201 tunnel_key=2 +ovs-vsctl add-port br-int localvif201 -- set Interface localvif201 external_ids:iface-id=localvif201 + +# wait until all expected flows are programmed in table 0 +OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=0 | ofctl_strip | tail -n+2 | sort | wc -l` -ge 13]) + +# dump the zoneids +ovs-vsctl get interface patch-br-int-to-localnet1 external-ids +ovs-vsctl get interface patch-br-int-to-localnet201 external-ids +ovs-vsctl get interface localvif1 external-ids +ovs-vsctl get interface localvif2 external-ids +ovs-vsctl get interface localvif3 external-ids + +# verify zone-id tags are set on the interface +OVS_WAIT_UNTIL([ovs-vsctl get interface patch-br-int-to-localnet1 external-ids:ovn-zone-id-localnet1]) +OVS_WAIT_UNTIL([ovs-vsctl get interface patch-br-int-to-localnet201 external-ids:ovn-zone-id-localnet201]) +OVS_WAIT_UNTIL([ovs-vsctl get interface localvif1 external-ids:ovn-zone-id-localvif1]) +OVS_WAIT_UNTIL([ovs-vsctl get interface localvif2 external-ids:ovn-zone-id-localvif2]) +OVS_WAIT_UNTIL([ovs-vsctl get interface localvif3 external-ids:ovn-zone-id-localvif3]) +OVS_WAIT_UNTIL([ovs-vsctl get interface localvif3 external-ids:ovn-zone-id-localcif1]) +OVS_WAIT_UNTIL([ovs-vsctl get interface localvif3 external-ids:ovn-zone-id-localcif2]) +OVS_WAIT_UNTIL([ovs-vsctl get interface localvif3 external-ids:ovn-zone-id-localcif3]) +OVS_WAIT_UNTIL([ovs-vsctl get interface localvif3 external-ids:ovn-zone-id-localcif4]) +OVS_WAIT_UNTIL([ovs-vsctl get interface localvif3 external-ids:ovn-zone-id-localcif5]) + +# save the table0 flows for a later comparison after restart +ovs-ofctl dump-flows br-int table=0 | ofctl_strip | tail -n+2 | sort > expout +cat expout + +#kill the ovn controller ungracefully, so nothing gets cleaned up +kill -9 `cat "$OVS_RUNDIR"/ovn-controller.pid` + +echo "killed the ovn-controller" + +#clean the flows +#ovs-ofctl del-flows br-int + +#dump the interfaces +ovs-vsctl get interface patch-br-int-to-localnet1 external-ids +ovs-vsctl get interface patch-br-int-to-localnet201 external-ids +ovs-vsctl get interface localvif1 external-ids +ovs-vsctl get interface localvif2 external-ids +ovs-vsctl get interface localvif3 external-ids + +#restart the ovn controller +start_daemon ovn-controller + +echo "restarted the ovn-controller" + +#wait for the table 0 flows to get reprogrammed +OVS_WAIT_UNTIL([test `ovs-ofctl dump-flows br-int table=0 | ofctl_strip | tail -n+2 | sort | wc -l` -ge 13]) + +#fetch flows in table=0 +ovs-ofctl dump-flows br-int table=0 | ofctl_strip | tail -n+2 | sort > afterrestart +cat afterrestart + +#compare the table 0 flows before and after restart +AT_CHECK([ovs-ofctl diff-flows afterrestart expout]) + +#delete a cif and verify that the parent interface has the zone-tag removed +uuid=`ovn-sbctl --columns=_uuid --format csv find Port_Binding tunnel_key=5 | tail -1` +echo "uuid is" +echo $uuid +echo "removing row for cif" +ovn-sbctl destroy Port_Binding $uuid +echo "done" + +#verify that the zone-id corresponding to that cif is deleted on parent port +OVS_WAIT_UNTIL([test `ovs-vsctl get interface localvif3 external-ids:ovn-zone-id-localcif1 2>/dev/null | wc -l` -eq 0]) + +AT_CLEANUP -- 2.3.9 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev