X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=tests%2Fovs-vsctl.at;h=fc59652c7d1836e1952c84561da6be0404ea6961;hb=c6bd5e91520990ac2a227cafd98857fa672949ed;hp=56d9bae3747498870d83e34ec107034c41e1c436;hpb=a128bd8cbc24c55c2f4769c5943ba03d2ce98630;p=cascardo%2Fovs.git diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at index 56d9bae37..fc59652c7 100644 --- a/tests/ovs-vsctl.at +++ b/tests/ovs-vsctl.at @@ -143,8 +143,6 @@ dnl ---------------------------------------------------------------------- AT_BANNER([ovs-vsctl unit tests]) AT_SETUP([ovs-vsctl connection retry]) -OVS_RUNDIR=$PWD; export OVS_RUNDIR - dnl Without --retry, there should be no retry for active connections. AT_CHECK([ovs-vsctl --db=unix:foo --timeout=10 -vreconnect:emer -- init], [1], [], [stderr]) @@ -159,8 +157,14 @@ AT_CHECK( [0], [], [stderr]) AT_CHECK([grep -c 'terminating with signal' stderr], [0], [1 ]) -AT_CHECK([kill -l `cat status`], [0], [ALRM +if test "$IS_WIN32" = "yes"; then + AT_CHECK([cat status], [0], [3 +]) +else + # 128 + SIGALRM + AT_CHECK([cat status], [0], [142 ]) +fi dnl Without --retry, we should retry for passive connections. AT_CHECK( @@ -169,8 +173,14 @@ AT_CHECK( [0], [], [stderr]) AT_CHECK([grep -c 'terminating with signal' stderr], [0], [1 ]) -AT_CHECK([kill -l `cat status`], [0], [ALRM +if test "$IS_WIN32" = "yes"; then + AT_CHECK([cat status], [0], [3 +]) +else + # 128 + SIGALRM + AT_CHECK([cat status], [0], [142 ]) +fi AT_CLEANUP dnl ---------------------------------------------------------------------- @@ -323,6 +333,12 @@ AT_CHECK([RUN_OVS_VSCTL( ], [], [OVS_VSCTL_CLEANUP]) AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port b b1])], [0], [], [], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([del-port a])], [1], [], + [ovs-vsctl: cannot delete port a because it is the local port for bridge a (deleting this port requires deleting the entire bridge) +], + [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([--if-exists del-port a])], [0], [], [], + [OVS_VSCTL_CLEANUP]) AT_CHECK([RUN_OVS_VSCTL([--may-exist add-port a b1])], [1], [], [ovs-vsctl: "--may-exist add-port a b1" but b1 is actually attached to bridge b ], @@ -465,6 +481,9 @@ AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xxx $1])], [1], [], AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br xapi1 xenbr0 10])], [1], [], [ovs-vsctl: "--may-exist add-br xapi1 xenbr0 10" but xapi1 is a VLAN bridge for the wrong VLAN $1 ], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([--may-exist add-br dup xenbr0 $1])], [1], [], + [ovs-vsctl: bridge xenbr0 already has a child VLAN bridge xapi1 on VLAN $1 +], [OVS_VSCTL_CLEANUP]) CHECK_BRIDGES([xapi1, xenbr0, $1], [xenbr0, xenbr0, 0]) CHECK_PORTS([xenbr0], [eth0]) CHECK_IFACES([xenbr0], [eth0]) @@ -614,57 +633,64 @@ AT_SETUP([database commands -- positive checks]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK( - [RUN_OVS_VSCTL_TOGETHER([--id=@br0 create b name=br0], + [RUN_OVS_VSCTL_TOGETHER([--id=@br0 create bridge name=br123], + [set b br123 name=br0], [set o . bridges=@br0])], [0], [stdout], [], [OVS_VSCTL_CLEANUP]) cp stdout out1 -AT_CHECK([RUN_OVS_VSCTL([list b], [get b br0 _uuid])], +AT_CHECK([RUN_OVS_VSCTL([list bridge], [get bridge br0 _uuid])], [0], [stdout], [], [OVS_VSCTL_CLEANUP]) cp stdout out2 AT_CHECK([${PERL} $srcdir/uuidfilt.pl out1 out2], [0], [[<0> + _uuid : <0> +auto_attach : [] controller : [] datapath_id : [] datapath_type : "" +datapath_version : "" external_ids : {} fail_mode : [] flood_vlans : [] flow_tables : {} ipfix : [] +mcast_snooping_enable: false mirrors : [] name : "br0" netflow : [] other_config : {} ports : [] protocols : [] +rstp_enable : false +rstp_status : {} sflow : [] status : {} stp_enable : false <0> ]], [ignore], [test ! -e pid || kill `cat pid`]) AT_CHECK( - [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type list b])], + [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type list bridge])], [0], [[fail_mode : [] name : "br0" datapath_type : "" ]], [ignore], [test ! -e pid || kill `cat pid`]) AT_CHECK( - [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type find b])], + [RUN_OVS_VSCTL([--columns=fail_mode,name,datapath_type find bridge])], [0], [[fail_mode : [] name : "br0" datapath_type : "" ]], [ignore], [test ! -e pid || kill `cat pid`]) AT_CHECK([ - RUN_OVS_VSCTL_TOGETHER([--id=@br1 create b name=br1 datapath_type="foo"], - [--id=@br2 create b name=br2 external-ids:bar=quux], + RUN_OVS_VSCTL_TOGETHER([--id=@br1 create bridge name=br1 datapath_type="foo"], + [--id=@br2 create bridge name=br2 external-ids:bar=quux], [add o . bridges @br1 @br2])], [0], [stdout], [], [OVS_VSCTL_CLEANUP]) AT_CHECK( - [RUN_OVS_VSCTL([--columns=name find b datapath_type!=foo])], [0], [stdout], + [RUN_OVS_VSCTL([--columns=name find bridge datapath_type!=foo])], [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) AT_CHECK([sed -n '/./p' stdout | sort], [0], [[name : "br0" @@ -685,25 +711,25 @@ AT_CHECK([RUN_OVS_VSCTL([get bridge br0 other_config:hwaddr -- --if-exists get b [0], ["00:11:22:33:44:55" ], [], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([remove br br0 other_config hwaddr 'datapath_id=""' -- get br br0 other_config])], +AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 other_config hwaddr 'datapath_id=""' -- get bridge br0 other_config])], [0], [{datapath_id="0123456789ab"} ], [], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([remove br br0 other_config 'datapath_id="0123456789ab"' -- get br br0 other_config])], +AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 other_config 'datapath_id="0123456789ab"' -- get bridge br0 other_config])], [0], [{} ], [], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([clear br br0 external-ids -- get br br0 external_ids])], +AT_CHECK([RUN_OVS_VSCTL([clear bridge br0 external-ids -- get bridge br0 external_ids])], [0], [{} ], [], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL_TOGETHER([destroy b br0], - [destroy b br1], - [destroy b br2], +AT_CHECK([RUN_OVS_VSCTL_TOGETHER([destroy bridge br0], + [destroy bridge br1], + [destroy bridge br2], [clear o . bridges])], [0], [stdout], [], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([list b])], +AT_CHECK([RUN_OVS_VSCTL([list bridge])], [0], [], [], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([--if-exists get b x datapath_id])], +AT_CHECK([RUN_OVS_VSCTL([--if-exists get bridge x datapath_id])], [0], [], [], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([--if-exists list b x])], +AT_CHECK([RUN_OVS_VSCTL([--if-exists list bridge x])], [0], [], [], [OVS_VSCTL_CLEANUP]) AT_CHECK([RUN_OVS_VSCTL([--if-exists set controller x connection_mode=standalone])], [0], [], [], [OVS_VSCTL_CLEANUP]) @@ -757,46 +783,46 @@ targets : ["1.2.3.4:567"] AT_CHECK([RUN_OVS_VSCTL([list interx x])], [1], [], [ovs-vsctl: unknown table "interx" ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([list b x])], +AT_CHECK([RUN_OVS_VSCTL([list bridge x])], [1], [], [ovs-vsctl: no row "x" in table Bridge ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([get b x datapath_id])], +AT_CHECK([RUN_OVS_VSCTL([get bridge x datapath_id])], [1], [], [ovs-vsctl: no row "x" in table Bridge ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([get b br0 d])], +AT_CHECK([RUN_OVS_VSCTL([get bridge br0 d])], [1], [], [ovs-vsctl: Bridge contains more than one column whose name matches "d" ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([get b br0 x])], +AT_CHECK([RUN_OVS_VSCTL([get bridge br0 x])], [1], [], [ovs-vsctl: Bridge does not contain a column whose name matches "x" ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([get b br0 :y=z])], +AT_CHECK([RUN_OVS_VSCTL([get bridge br0 :y=z])], [1], [], [ovs-vsctl: :y=z: missing column name ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([get b br0 datapath_id:y=z])], +AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id:y=z])], [1], [], [ovs-vsctl: datapath_id:y=z: trailing garbage "=z" in argument ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([set b br0 'datapath_id:y>=z'])], +AT_CHECK([RUN_OVS_VSCTL([set bridge br0 'datapath_id:y>=z'])], [1], [], [ovs-vsctl: datapath_id:y>=z: argument does not end in "=" followed by a value. ], [OVS_VSCTL_CLEANUP]) AT_CHECK([RUN_OVS_VSCTL([set controller x connection_mode=standalone])], [1], [], [ovs-vsctl: no row "x" in table Controller ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([wait-until b br0 datapath_id:y,z])], +AT_CHECK([RUN_OVS_VSCTL([wait-until bridge br0 datapath_id:y,z])], [1], [], [ovs-vsctl: datapath_id:y,z: argument does not end in "=", "!=", "<", ">", "<=", ">=", "{=}", "{!=}", "{<}", "{>}", "{<=}", or "{>=}" followed by a value. ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([get b br0 datapath_id::])], +AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id::])], [1], [], [ovs-vsctl: datapath_id::: trailing garbage ":" in argument ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([get b br0 datapath_id:x])], +AT_CHECK([RUN_OVS_VSCTL([get bridge br0 datapath_id:x])], [1], [], [ovs-vsctl: cannot specify key to get for non-map column datapath_id ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([get b br0 external_ids:x])], +AT_CHECK([RUN_OVS_VSCTL([get bridge br0 external_ids:x])], [1], [], [ovs-vsctl: no key "x" in Bridge record "br0" column external_ids ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([set b br0 flood_vlans=-1])], +AT_CHECK([RUN_OVS_VSCTL([set bridge br0 flood_vlans=-1])], [1], [], [ovs-vsctl: constraint violation: -1 is not in the valid range 0 to 4095 (inclusive) ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([set b br0 flood_vlans=4096])], +AT_CHECK([RUN_OVS_VSCTL([set bridge br0 flood_vlans=4096])], [1], [], [ovs-vsctl: constraint violation: 4096 is not in the valid range 0 to 4095 (inclusive) ], [OVS_VSCTL_CLEANUP]) AT_CHECK([RUN_OVS_VSCTL([set c br1 'connection-mode=xyz'])], @@ -805,7 +831,7 @@ AT_CHECK([RUN_OVS_VSCTL([set c br1 'connection-mode=xyz'])], AT_CHECK([RUN_OVS_VSCTL([set c br1 connection-mode:x=y])], [1], [], [ovs-vsctl: cannot specify key to set for non-map column connection_mode ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([add b br1 datapath_id x y])], +AT_CHECK([RUN_OVS_VSCTL([add bridge br1 datapath_id x y])], [1], [], [ovs-vsctl: "add" operation would put 2 values in column datapath_id of table Bridge but the maximum number is 1 ], [OVS_VSCTL_CLEANUP]) AT_CHECK([RUN_OVS_VSCTL([remove netflow `cat netflow-uuid` targets '"1.2.3.4:567"'])], @@ -820,19 +846,22 @@ AT_CHECK([RUN_OVS_VSCTL([clear netflow x targets])], AT_CHECK([RUN_OVS_VSCTL([clear netflow `cat netflow-uuid` targets])], [1], [], [ovs-vsctl: "clear" operation cannot be applied to column targets of table NetFlow, which is not allowed to be empty ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([destroy b br2])], +AT_CHECK([RUN_OVS_VSCTL([destroy bridge br2])], [1], [], [ovs-vsctl: no row "br2" in table Bridge ], [OVS_VSCTL_CLEANUP]) AT_CHECK([RUN_OVS_VSCTL([add in br1 name x])], [1], [], [ovs-vsctl: cannot modify read-only column name in table Interface ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([set port br1 name br2])], +AT_CHECK([RUN_OVS_VSCTL([set port br0 name=br2])], [1], [], [ovs-vsctl: cannot modify read-only column name in table Port ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([remove b br1 name br1])], +AT_CHECK([RUN_OVS_VSCTL([remove bridge br0 name br1])], [1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge ], [OVS_VSCTL_CLEANUP]) -AT_CHECK([RUN_OVS_VSCTL([clear b br1 name])], +AT_CHECK([RUN_OVS_VSCTL([remove bridge br1 flood-vlans true])], + [1], [], [ovs-vsctl: "true" is not a valid integer +], [OVS_VSCTL_CLEANUP]) +AT_CHECK([RUN_OVS_VSCTL([clear bridge br1 name])], [1], [], [ovs-vsctl: cannot modify read-only column name in table Bridge ], [OVS_VSCTL_CLEANUP]) OVS_VSCTL_CLEANUP @@ -840,7 +869,7 @@ AT_CLEANUP AT_SETUP([database commands -- conditions]) AT_KEYWORDS([ovs-vsctl]) -ON_EXIT([kill `cat pid`]) +on_exit 'kill `cat pid`' OVS_VSCTL_SETUP AT_CHECK( [RUN_OVS_VSCTL_TOGETHER( @@ -1000,7 +1029,7 @@ OVS_VSCTL_SETUP # Start ovs-vsctls in background. (RUN_OVS_VSCTL([[wait-until o . bridges!=[] -- get bridge br10 other-config:abc]])) > stdout1 & (RUN_OVS_VSCTL([[wait-until bridge br1 -- get bridge br1 other-config:abc]])) > stdout2 & -(RUN_OVS_VSCTL([[wait-until b br1 other-config={abc=def} -- get bridge br1 other-config]])) > stdout3 & +(RUN_OVS_VSCTL([[wait-until bridge br1 other-config={abc=def} -- get bridge br1 other-config]])) > stdout3 & (RUN_OVS_VSCTL([[wait-until port bond0 'bond_updelay>50' -- get port bond0 bond-updelay]])) > stdout4 & # Give the ovs-vsctls a chance to read the database @@ -1082,7 +1111,7 @@ AT_CHECK( [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \ -- create Bridge name=br0 | ${PERL} $srcdir/uuidfilt.pl], [0], [<0> -], [vsctl|WARN|applying "create" command to table Bridge without --id option will have no effect +], [db_ctl_base|WARN|applying "create" command to table Bridge without --id option will have no effect ], [OVS_VSCTL_CLEANUP]) AT_CHECK( [ovs-vsctl -vPATTERN:console:'%c|%p|%m' --no-wait -vreconnect:emer --db=unix:socket \ @@ -1112,25 +1141,30 @@ dnl The bug is documented in ovs-vsctl.8. AT_SETUP([created row UUID is wrong in same execution]) AT_KEYWORDS([ovs-vsctl]) OVS_VSCTL_SETUP -AT_CHECK([RUN_OVS_VSCTL([--id=@br0 create Bridge name=br0 -- add Open_vSwitch . bridges @br0 -- list b])], +AT_CHECK([RUN_OVS_VSCTL([--id=@br0 create Bridge name=br0 -- add Open_vSwitch . bridges @br0 -- list bridge])], [0], [stdout], [], [OVS_VSCTL_CLEANUP]) AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[<0> _uuid : <1> +auto_attach : [] controller : [] datapath_id : [] datapath_type : "" +datapath_version : "" external_ids : {} fail_mode : [] flood_vlans : [] flow_tables : {} ipfix : [] +mcast_snooping_enable: false mirrors : [] name : "br0" netflow : [] other_config : {} ports : [] protocols : [] +rstp_enable : false +rstp_status : {} sflow : [] status : {} stp_enable : false @@ -1163,8 +1197,9 @@ AT_CHECK([RUN_OVS_VSCTL( type : linux-htb ], [], [OVS_VSCTL_CLEANUP]) AT_CHECK([RUN_OVS_VSCTL( - [--columns=other_config list Queue | sort | xargs echo])], [0], -[other_config : {max-rate=100000000, min-rate=100000000} other_config : {min-rate=500000000} + [--columns=other_config list Queue | sort | sed '/^$/d'])], [0], +[other_config : {max-rate="100000000", min-rate="100000000"} +other_config : {min-rate="500000000"} ], [], [OVS_VSCTL_CLEANUP]) AT_CHECK([RUN_OVS_VSCTL( [clear Port a1 qos], @@ -1185,3 +1220,144 @@ AT_CHECK([RUN_OVS_VSCTL( [-- list Queue])], [0], [], [], [OVS_VSCTL_CLEANUP]) OVS_VSCTL_CLEANUP AT_CLEANUP + +dnl ---------------------------------------------------------------------- +AT_BANNER([ovs-vsctl add-port -- reserved port names]) + +AT_SETUP([add-port -- reserved names 1]) +OVS_VSWITCHD_START + +# Test creating all reserved port names +m4_foreach( +[reserved_name], +[[ovs-netdev], +[ovs-dummy], +[genev_sys], +[gre_sys], +[lisp_sys], +[vxlan_sys]], +[ +# Try creating the port +AT_CHECK([ovs-vsctl add-port br0 reserved_name], [0], [], [dnl +ovs-vsctl: Error detected while setting up 'reserved_name'. See ovs-vswitchd log for details. +]) +# Prevent race. +OVS_WAIT_UNTIL([test `grep -- "|WARN|" ovs-vswitchd.log | wc -l` -ge 1]) +# Detect the warning log message +AT_CHECK([sed -n "s/^.*\(|bridge|WARN|.*\)$/\1/p" ovs-vswitchd.log], [0], [dnl +|bridge|WARN|could not create interface reserved_name, name is reserved +]) +# Delete the warning log message +AT_CHECK([sed "/|bridge|WARN|/d" ovs-vswitchd.log > ovs-vswitchd.log], [0], [], []) +# Delete the port +AT_CHECK([ovs-vsctl del-port br0 reserved_name], [0], [], [])]) +OVS_VSWITCHD_STOP +AT_CLEANUP + +AT_SETUP([add-port -- reserved names 2]) +# Creates all type of tunnel ports +OVS_VSWITCHD_START([add-port br0 p1 -- set Interface p1 type=gre \ + options:remote_ip=1.1.1.1 ofport_request=1\ + -- add-port br0 p3 -- set Interface p3 type=lisp \ + options:remote_ip=2.2.2.2 ofport_request=3 \ + -- add-port br0 p4 -- set Interface p4 type=vxlan \ + options:remote_ip=2.2.2.2 ofport_request=4 \ + -- add-port br0 p5 -- set Interface p5 type=geneve \ + options:remote_ip=2.2.2.2 ofport_request=5]) + +# Test creating all reserved tunnel port names +m4_foreach( +[reserved_name], +[[genev_sys], +[gre_sys], +[lisp_sys], +[vxlan_sys]], +[ +# Try creating the port +AT_CHECK([ovs-vsctl add-port br0 reserved_name], [0], [], [dnl +ovs-vsctl: Error detected while setting up 'reserved_name'. See ovs-vswitchd log for details. +]) +# Prevent race. +OVS_WAIT_UNTIL([test `grep -- "|WARN|" ovs-vswitchd.log | wc -l` -ge 1]) +# Detect the warning log message +AT_CHECK([sed -n "s/^.*\(|bridge|WARN|.*\)$/\1/p" ovs-vswitchd.log], [0], [dnl +|bridge|WARN|could not create interface reserved_name, name is reserved +]) +# Delete the warning log message +AT_CHECK([sed "/|bridge|WARN|/d" ovs-vswitchd.log > ovs-vswitchd.log], [0], [], []) +# Delete the port +AT_CHECK([ovs-vsctl del-port br0 reserved_name], [0], [], [])]) +OVS_VSWITCHD_STOP +AT_CLEANUP + +AT_SETUP([naming in db commands]) +OVS_VSCTL_SETUP + +dnl First check that the database commands can refer to row by database UUID. +AT_CHECK([RUN_OVS_VSCTL([add-br br0])]) +uuid=`[]RUN_OVS_VSCTL(get port br0 _uuid)` +AT_CHECK([RUN_OVS_VSCTL([get port $uuid name])], [0], ["br0" +]) + +dnl Next check that, if a database row is given a name that has the same form +dnl as the database UUIDs, the name can still be used to refer to rows. +AT_CHECK([RUN_OVS_VSCTL([add-br 0fcd11a1-2ba8-4b38-a358-4bccf2bf3057])]) +AT_CHECK([RUN_OVS_VSCTL([get interface 0fcd11a1-2ba8-4b38-a358-4bccf2bf3057 type])], [0], [internal +]) + +OVS_VSCTL_CLEANUP +AT_CLEANUP + +AT_SETUP([bootstrap ca cert]) +AT_KEYWORDS([ovs-vsctl ssl]) +AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) +PKIDIR=`pwd` +OVS_PKI="sh $abs_top_srcdir/utilities/ovs-pki.in --dir=$PKIDIR/pki --log=$PKIDIR/ovs-pki.log" +AT_CHECK([$OVS_PKI -B 1024 init && $OVS_PKI -B 1024 req+sign vsctl switch && $OVS_PKI -B 1024 req ovsdbserver && $OVS_PKI self-sign ovsdbserver], [0], [ignore], [ignore]) + +dnl Create database. +OVSDB_INIT([conf.db]) +AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --private-key=$PKIDIR/ovsdbserver-privkey.pem --certificate=$PKIDIR/ovsdbserver-cert.pem --ca-cert=$PKIDIR/pki/switchca/cacert.pem --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl --log-file="`pwd`"/ovsdb-server.log conf.db], [0], [ignore], [ignore]) +on_exit "kill `cat pid`" +PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT]) + +# During bootstrap, the connection gets torn down. So the o/p of ovs-vsctl is error. +AT_CHECK([ovs-vsctl -t 5 --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem show], [1], [ignore], [ignore]) + +# If the bootstrap was successful, the following file should exist. +OVS_WAIT_UNTIL([test -e $PKIDIR/cacert.pem]) + +# After bootstrap, the connection should be successful. +AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem add-br br0], [0]) +AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem list-br], [0], [br0 +]) + +OVSDB_SERVER_SHUTDOWN +AT_CLEANUP + +AT_SETUP([peer ca cert]) +AT_KEYWORDS([ovs-vsctl ssl]) +AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) +PKIDIR=`pwd` +OVS_PKI="sh $abs_top_srcdir/utilities/ovs-pki.in --dir=$PKIDIR/pki --log=$PKIDIR/ovs-pki.log" +AT_CHECK([$OVS_PKI -B 1024 init && $OVS_PKI -B 1024 req+sign vsctl switch && $OVS_PKI -B 1024 req+sign ovsdbserver controller], [0], [ignore], [ignore]) + +dnl Create database. +OVSDB_INIT([conf.db]) +AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --private-key=$PKIDIR/ovsdbserver-privkey.pem --certificate=$PKIDIR/ovsdbserver-cert.pem --ca-cert=$PKIDIR/pki/switchca/cacert.pem --peer-ca-cert=$PKIDIR/pki/controllerca/cacert.pem --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl --log-file="`pwd`"/ovsdb-server.log conf.db], [0], [ignore], [ignore]) +on_exit "kill `cat pid`" +PARSE_LISTENING_PORT([ovsdb-server.log], [SSL_PORT]) + +# During bootstrap, the connection gets torn down. So the o/p of ovs-vsctl is error. +AT_CHECK([ovs-vsctl -t 5 --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem show], [1], [ignore], [ignore]) + +# If the bootstrap was successful, the following file should exist. +OVS_WAIT_UNTIL([test -e $PKIDIR/cacert.pem]) + +# After bootstrap, the connection should be successful. +AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem add-br br0], [0]) +AT_CHECK([ovs-vsctl -t 5 --no-wait --db=ssl:127.0.0.1:$SSL_PORT --private-key=$PKIDIR/vsctl-privkey.pem --certificate=$PKIDIR/vsctl-cert.pem --bootstrap-ca-cert=$PKIDIR/cacert.pem list-br], [0], [br0 +]) + +OVSDB_SERVER_SHUTDOWN +AT_CLEANUP