AT_BANNER([ovn-sbctl]) # OVN_SBCTL_TEST_START m4_define([OVN_SBCTL_TEST_START], [dnl Create databases (ovn-nb, ovn-sb). AT_KEYWORDS([ovn]) for daemon in ovn-nb ovn-sb; do AT_CHECK([ovsdb-tool create $daemon.db $abs_top_srcdir/${daemon%%-*}/${daemon}.ovsschema]) done dnl Start ovsdb-servers. AT_CHECK([ovsdb-server --detach --no-chdir --pidfile=ovnnb_db.pid --unixctl=$OVS_RUNDIR/ovnnb_db.ctl --log-file=ovsdb_nb.log --remote=punix:$OVS_RUNDIR/ovnnb_db.sock ovn-nb.db ], [0], [], [stderr]) AT_CHECK([ovsdb-server --detach --no-chdir --pidfile=ovnsb_db.pid --unixctl=$OVS_RUNDIR/ovnsb_db.ctl --log-file=ovsdb_sb.log --remote=punix:$OVS_RUNDIR/ovnsb_db.sock ovn-sb.db], [0], [], [stderr]) on_exit "kill `cat ovnnb_db.pid` `cat ovnsb_db.pid`" AT_CHECK([[sed < stderr ' /vlog|INFO|opened log file/d /ovsdb_server|INFO|ovsdb-server (Open vSwitch)/d']]) AT_CAPTURE_FILE([ovsdb-server.log]) dnl Start ovn-northd. AT_CHECK([ovn-northd --detach --pidfile --log-file --ovnnb-db=unix:$OVS_RUNDIR/ovnnb_db.sock --ovnsb-db=unix:$OVS_RUNDIR/ovnsb_db.sock], [0], [], [stderr]) on_exit "kill `cat ovn-northd.pid`" AT_CHECK([[sed < stderr ' /vlog|INFO|opened log file/d']]) AT_CAPTURE_FILE([ovn-northd.log]) ]) # OVN_SBCTL_TEST_STOP m4_define([OVN_SBCTL_TEST_STOP], [# removes all 'Broken pipe' warning logs from ovsdb-server.log. this is in # that *ctl command (e.g. ovn-nbctl) exits right after committing the change # to database. however, in reaction, some daemon (e.g. ovn-controller-vtep) # may immediately update the database. this later update may cause database # sending update back to *ctl command if *ctl has not proceeded to exit yet. # and if *ctl command exits before database calling send, the send from # database will fail with 'Broken pipe' error. Also removes all "connection # reset" warning logs by a similar rationale (either EPIPE or ECONNRESET can # be returned on a send depending on whether the peer had unconsumed data when # it closed the socket). AT_CHECK([check_logs "$1 /reset by peer/d /Broken pipe/d"]) OVS_APP_EXIT_AND_WAIT([ovn-northd]) OVS_APP_EXIT_AND_WAIT_BY_TARGET([$OVS_RUNDIR/ovnnb_db.ctl], [$OVS_RUNDIR/ovnnb_db.pid]) OVS_APP_EXIT_AND_WAIT_BY_TARGET([$OVS_RUNDIR/ovnsb_db.ctl], [$OVS_RUNDIR/ovnsb_db.pid])]) dnl --------------------------------------------------------------------- AT_SETUP([ovn-sbctl - chassis commands]) OVN_SBCTL_TEST_START ovn_init_db ovn-sb AT_CHECK([ovn-sbctl chassis-add ch0 geneve 1.2.3.4]) AT_CHECK([ovn-sbctl -f csv -d bare --no-headings --columns ip,type list encap | sort], [0], [dnl 1.2.3.4,geneve ]) AT_CHECK([ovn-sbctl chassis-add ch1 stt,geneve,vxlan 1.2.3.5]) AT_CHECK([ovn-sbctl -f csv -d bare --no-headings --columns ip,type list encap | sort], [0], [dnl 1.2.3.4,geneve 1.2.3.5,geneve 1.2.3.5,stt 1.2.3.5,vxlan ]) AT_CHECK([ovn-sbctl chassis-del ch0]) AT_CHECK([ovn-sbctl -f csv -d bare --no-headings --columns ip,type list encap | sort], [0], [dnl 1.2.3.5,geneve 1.2.3.5,stt 1.2.3.5,vxlan ]) OVN_SBCTL_TEST_STOP as ovn-sb OVS_APP_EXIT_AND_WAIT([ovsdb-server]) AT_CLEANUP dnl --------------------------------------------------------------------- AT_SETUP([ovn-sbctl]) OVN_SBCTL_TEST_START AT_CHECK([ovn-nbctl ls-add br-test]) AT_CHECK([ovn-nbctl lsp-add br-test vif0]) AT_CHECK([ovn-nbctl lsp-set-addresses vif0 f0:ab:cd:ef:01:02]) AT_CHECK([ovn-sbctl chassis-add ch0 stt 1.2.3.5]) AT_CHECK([ovn-nbctl --wait=sb sync]) AT_CHECK([ovn-sbctl lsp-bind vif0 ch0]) AT_CHECK([ovn-sbctl show], [0], [dnl Chassis "ch0" Encap stt ip: "1.2.3.5" options: {csum="true"} Port_Binding "vif0" ]) # adds another 'vif1' AT_CHECK([ovn-nbctl --wait=sb lsp-add br-test vif1]) AT_CHECK([ovn-nbctl lsp-set-addresses vif1 f0:ab:cd:ef:01:03]) AT_CHECK([ovn-sbctl lsp-bind vif1 ch0]) AT_CHECK([ovn-sbctl show | sed 's/vif[[0-9]]/vif/'], [0], [dnl Chassis "ch0" Encap stt ip: "1.2.3.5" options: {csum="true"} Port_Binding "vif" Port_Binding "vif" ]) # deletes 'vif1' AT_CHECK([ovn-nbctl lsp-del vif1]) AT_CHECK([ovn-nbctl --wait=sb sync]) AT_CHECK([ovn-sbctl show], [0], [dnl Chassis "ch0" Encap stt ip: "1.2.3.5" options: {csum="true"} Port_Binding "vif0" ]) uuid=$(ovn-sbctl --columns=_uuid list Chassis ch0 | cut -d ':' -f2 | tr -d ' ') AT_CHECK_UNQUOTED([ovn-sbctl --columns=logical_port,mac,chassis list Port_Binding], [0], [dnl logical_port : "vif0" mac : [["f0:ab:cd:ef:01:02"]] chassis : ${uuid} ]) # test the passing down of logical port type and options. AT_CHECK([ovn-nbctl --wait=sb lsp-add br-test vtep0]) AT_CHECK([ovn-nbctl lsp-set-type vtep0 vtep]) AT_CHECK([ovn-nbctl lsp-set-options vtep0 vtep_physical_switch=p0 vtep_logical_switch=l0]) AT_CHECK([ovn-sbctl --timeout=10 wait-until Port_Binding vtep0 options!={}]) AT_CHECK([ovn-sbctl --columns=logical_port,mac,type,options list Port_Binding vtep0], [0], [dnl logical_port : "vtep0" mac : [[]] type : vtep options : {vtep_logical_switch="l0", vtep_physical_switch="p0"} ]) OVN_SBCTL_TEST_STOP AT_CLEANUP