X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=tests%2Fofproto-macros.at;h=18114d95f8e1f4bf1e42e32ffaf76eecd59c7371;hb=bb3384518673ec5672373b5176e77a6f0a5f9137;hp=a5aee3a4df188ecc2175e2db031dc7957c85d0e0;hpb=4b2b1a5e25260b7b27142062c6711132d5bda9c0;p=cascardo%2Fovs.git diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at index a5aee3a4d..18114d95f 100644 --- a/tests/ofproto-macros.at +++ b/tests/ofproto-macros.at @@ -12,11 +12,13 @@ s/ n_packets=0,// s/ n_bytes=0,// s/ idle_age=[0-9]*,// s/ hard_age=[0-9]*,// +s/dp_hash=0x[0-9a-f]*\//dp_hash=0x0\// +s/recirc_id=0x[0-9a-f]*,/recirc_id=0x0,/ ' } # Filter (multiline) vconn debug messages from ovs-vswitchd.log. -# Use with vconn_windows_sub() and ofctl_strip() +# Use with vconn_sub() and ofctl_strip() print_vconn_debug () { awk -F\| < ovs-vswitchd.log ' BEGIN { prt=0 } /\|vconn\|DBG\|/ { sub(/[ \t]*$/, ""); print $3 "|" $4 "|" $5; prt=1; next } @@ -25,28 +27,29 @@ prt==1 { sub(/[ \t]*$/, ""); print $0 } ' } -vconn_windows_sub() { +vconn_sub() { sed ' s/tcp:127.0.0.1:[0-9][0-9]*:/unix:/ s/No error/Success/ ' } +] -# parse_listening_port [SERVER] +# PARSE_LISTENING_PORT LOGFILE VARIABLE # -# Parses the TCP or SSL port on which a server is listening from the -# log, given that the server was told to listen on a kernel-chosen -# port, file provided on stdin, and prints the port number on stdout. -# You should specify the listening remote as ptcp:0:127.0.0.1 or +# Parses the TCP or SSL port on which a server is listening from +# LOGFILE, given that the server was told to listen on a kernel-chosen +# port, and assigns the port number to shell VARIABLE. You should +# specify the listening remote as ptcp:0:127.0.0.1 or # pssl:0:127.0.0.1, or the equivalent with [::1] instead of 127.0.0.1. # # Here's an example of how to use this with ovsdb-server: # # ovsdb-server --log-file --remote=ptcp:0:127.0.0.1 ... -# TCP_PORT=`parse_listening_port < ovsdb-server.log` -parse_listening_port () { - sed -n 's/.*0:.*: listening on port \([0-9]*\)$/\1/p' -}] +# PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT]) +# # Now $TCP_PORT holds the listening port. +m4_define([PARSE_LISTENING_PORT], + [OVS_WAIT_UNTIL([$2=`sed -n 's/.*0:.*: listening on port \([[0-9]]*\)$/\1/p' "$1"` && test X != X"[$]$2"])]) start_daemon () { "$@" -vconsole:off --detach --no-chdir --pidfile --log-file @@ -93,7 +96,7 @@ sim_add () { as $1 ovs-vsctl --no-wait -- init || return 1 # Start ovs-vswitchd - as $1 start_daemon ovs-vswitchd --enable-dummy=system -vvconn -vofproto_dpif + as $1 start_daemon ovs-vswitchd --enable-dummy=system -vvconn -vofproto_dpif -vunixctl } # "as $1" sets the OVS_*DIR environment variables to point to $ovs_base/$1. @@ -110,8 +113,10 @@ as() { # ovn_init_db DATABASE # -# Creates and initializes the given DATABASE (one of "ovn-sb" or "ovn-nb") -# and starts its ovsdb-server instance. +# Creates and initializes the given DATABASE (one of "ovn-sb" or "ovn-nb"), +# starts its ovsdb-server instance, and sets the appropriate environment +# variable (OVN_SB_DB or OVN_NB_DB) so that ovn-sbctl or ovn-nbctl uses the +# database by default. # # Usually invoked from ovn_start. ovn_init_db () { @@ -121,18 +126,20 @@ ovn_init_db () { : > "$d"/.$1.db.~lock~ as $1 ovsdb-tool create "$d"/$1.db "$abs_top_srcdir"/ovn/$1.ovsschema as $1 start_daemon ovsdb-server --remote=punix:"$d"/$1.sock "$d"/$1.db + local var=`echo $1_db | tr a-z- A-Z_` + AS_VAR_SET([$var], [unix:$ovs_base/$1/$1.sock]); export $var } # ovn_start # # Creates and initializes ovn-sb and ovn-nb databases and starts their -# ovsdb-server instance, and starts ovn-northd running against them. +# ovsdb-server instance, sets appropriate environment variables so that +# ovn-sbctl and ovn-nbctl use them by default, and starts ovn-northd running +# against them. ovn_start () { ovn_init_db ovn-sb ovn_init_db ovn-nb - OVN_NB_DB=unix:$ovs_base/ovn-nb/ovn-nb.sock; export OVN_NB_DB - echo "starting ovn-northd" mkdir "$ovs_base"/northd as northd start_daemon ovn-northd \ @@ -198,7 +205,7 @@ ovn_attach() { ovs-vsctl \ -- set Open_vSwitch . external-ids:system-id=$sandbox \ -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock \ - -- set Open_vSwitch . external-ids:ovn-encap-type=geneve \ + -- set Open_vSwitch . external-ids:ovn-encap-type=geneve,vxlan \ -- set Open_vSwitch . external-ids:ovn-encap-ip=$ip \ -- add-br br-int \ -- set bridge br-int fail-mode=secure other-config:disable-in-band=true \ @@ -218,17 +225,29 @@ ovn_populate_arp() { for e2 in $arp_table; do set `echo $e2 | sed 's/,/ /g'`; sb2=$1 br2=$2 if test $sb1,$br1 != $sb2,$br2; then - as $sb2 ovs-appctl tnl/arp/set $br2 $ip $mac + as $sb2 ovs-appctl tnl/neigh/set $br2 $ip $mac fi done done } + +# Strips 'xid=0x1234' from ovs-ofctl output. +strip_xids () { + sed 's/ (xid=0x[[0-9a-fA-F]]*)//' +} + +# Changes all 'used:...' to say 'used:0.0', to make output easier to compare. +strip_used () { + sed 's/used:[[0-9]]\.[[0-9]]*/used:0.0/' +} + +# Strips 'ufid:...' from output, to make it easier to compare. +# (ufids are random.) +strip_ufid () { + sed 's/ufid:[[-0-9a-f]]* //' +} m4_divert_pop([PREPARE_TESTS]) -m4_define([STRIP_XIDS], [[sed 's/ (xid=0x[0-9a-fA-F]*)//']]) -m4_define([STRIP_DURATION], [[sed 's/\bduration=[0-9.]*s/duration=?s/']]) -m4_define([STRIP_USED], [[sed 's/used:[0-9]\.[0-9]*/used:0.0/']]) -m4_define([STRIP_UFID], [[sed 's/ufid:[-0-9a-f]* //']]) m4_define([TESTABLE_LOG], [-vPATTERN:ANY:'%c|%p|%m']) # _OVS_VSWITCHD_START([vswitchd-aux-args]) @@ -253,7 +272,7 @@ m4_define([_OVS_VSWITCHD_START], AT_CHECK([ovs-vsctl --no-wait init]) dnl Start ovs-vswitchd. - AT_CHECK([ovs-vswitchd $1 --detach --no-chdir --pidfile --log-file -vvconn -vofproto_dpif], [0], [], [stderr]) + AT_CHECK([ovs-vswitchd $1 --detach --no-chdir --pidfile --log-file -vvconn -vofproto_dpif -vunixctl], [0], [], [stderr]) AT_CAPTURE_FILE([ovs-vswitchd.log]) on_exit "kill `cat ovs-vswitchd.pid`" AT_CHECK([[sed < stderr ' @@ -262,6 +281,7 @@ m4_define([_OVS_VSWITCHD_START], /vswitchd|INFO|ovs-vswitchd (Open vSwitch)/d /reconnect|INFO|/d /ofproto|INFO|using datapath ID/d +/netdev_linux|INFO|.*device has unknown hardware address family/d /ofproto|INFO|datapath ID changed to fedcba9876543210/d']]) ]) @@ -280,9 +300,7 @@ m4_define([_OVS_VSWITCHD_START], # system's real Ethernet devices). m4_define([OVS_VSWITCHD_START], [_OVS_VSWITCHD_START([--enable-dummy$3 --disable-system]) - - dnl Add bridges, ports, etc. - AT_CHECK([ovs-vsctl -- add-br br0 -- set bridge br0 datapath-type=dummy other-config:datapath-id=fedcba9876543210 other-config:hwaddr=aa:55:aa:55:00:00 protocols=[[OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14,OpenFlow15]] fail-mode=secure -- $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2]) + AT_CHECK([add_of_br 0 $1 m4_if([$2], [], [], [| ${PERL} $srcdir/uuidfilt.pl])], [0], [$2]) ]) # check_logs scans through all *.log files (except '*.log' and testsuite.log) @@ -308,6 +326,50 @@ check_logs () { /|ERR|/p /|EMER|/p" ${logs} } + +# add_of_br BRNUM [ARG...] +add_of_br () { + local brnum=$1; shift + local br=br$brnum + local dpid=fedcba987654321$brnum + local mac=aa:55:aa:55:00:0$brnum + ovs-vsctl --timeout=20 \ + -- add-br $br \ + -- set bridge $br datapath-type=dummy \ + fail-mode=secure \ + other-config:datapath-id=$dpid \ + other-config:hwaddr=$mac \ + protocols="[[OpenFlow10,OpenFlow11,OpenFlow12,\ + OpenFlow13,OpenFlow14,OpenFlow15]]" \ + -- "$@" +} + +# add_of_ports [--pcap] BRIDGE PNUM... +# +# Creates dummy interfaces in BRIDGE named pPNUM, OpenFlow port number +# PNUM, and datapath port number PNUM (the latter is a consequence of +# the dummy implementation, which tries to assign datapath port +# numbers based on port names). +# +# If --pcap is supplied then packets received from the interface will +# be written to $port-rx.pcap and those sent to it to $port-tx.pcap. +add_of_ports () { + local args + local pcap=false + if test "$1" = --pcap; then + pcap=: + shift + fi + local br=$1; shift + for pnum; do + AS_VAR_APPEND([args], [" -- add-port $br p$pnum -- set Interface p$pnum type=dummy ofport_request=$pnum"]) + if $pcap; then + AS_VAR_APPEND([args], [" -- set Interface p$pnum options:rxq_pcap=p$pnum-rx.pcap options:tx_pcap=p$pnum-tx.pcap"]) + fi + done + echo ovs-vsctl $args + ovs-vsctl $args +} m4_divert_pop([PREPARE_TESTS]) # OVS_VSWITCHD_STOP([WHITELIST]) @@ -328,17 +390,6 @@ m4_define([OVS_VSWITCHD_DISABLE_TUNNEL_PUSH_POP], Tunnel push-pop off ])]) -# ADD_OF_PORTS(BRIDGE, OF_PORT[, OF_PORT...]) -# -# Creates a dummy interface with an OpenFlow port number of OF_PORT and -# name of p{OF_PORT}. The dummy implementation will treat the OF_PORT -# as the datapath port number, which as the effect of making the -# OpenFlow and datapath numbers the same. -m4_define([ADD_OF_PORTS], - [ovs-vsctl m4_foreach([of_port], m4_cdr($@), - [ \ - -- add-port $1 p[]of_port -- set Interface p[]of_port type=dummy ofport_request=of_port])]) - # WAIT_FOR_DUMMY_PORTS(NETDEV_DUMMY_PORT[, NETDEV_DUMMY_PORT...]) # # Wait until the netdev dummy ports are connected to each other