Also added tests for NetFlow and sFlow using IPv6 sockets. Signed-off-by: Nandan Nivgune <nandan.nivg...@calsoftinc.com> Signed-off-by: Abhijit Bhopatkar <abhijit.bhopat...@calsoftinc.com> Signed-off-by: Arun Sharma <arun.sha...@calsoftinc.com> --- tests/ofproto-dpif.at | 872 ++++++++++++++++++++++++----------------------- tests/ofproto-macros.at | 17 + tests/ovs-vsctl.at | 28 +- tests/ovsdb-idl.at | 24 +- tests/ovsdb-server.at | 225 ++++++++---- 5 files changed, 683 insertions(+), 483 deletions(-)
diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index 4d8d460..a6b7abd 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -1781,424 +1781,451 @@ AT_CHECK_UNQUOTED([ovs-appctl fdb/show br0 | sed 's/[[0-9]]\{1,\}$/?/' | sort], OVS_VSWITCHD_STOP AT_CLEANUP -dnl Test that sFlow samples packets correctly. -AT_SETUP([ofproto-dpif - sFlow packet sampling]) -OVS_VSWITCHD_START([set Bridge br0 fail-mode=standalone]) - -ON_EXIT([kill `cat test-sflow.pid`]) -AT_CHECK([test-sflow --log-file --detach --no-chdir --pidfile 0:127.0.0.1 > sflow.log], [0], [], [ignore]) -AT_CAPTURE_FILE([sflow.log]) -SFLOW_PORT=`parse_listening_port < test-sflow.log` - -ovs-appctl time/stop - -ADD_OF_PORTS([br0], 1, 2) -ovs-vsctl \ - set Interface br0 options:ifindex=1002 -- \ - set Interface p1 options:ifindex=1004 -- \ - set Interface p2 options:ifindex=1003 -- \ - set Bridge br0 sflow=@sf -- \ - --id=@sf create sflow targets=\"127.0.0.1:$SFLOW_PORT\" \ - header=128 sampling=1 polling=1 - -dnl open with ARP packets to seed the bridge-learning. The output -dnl ifIndex numbers should be reported predictably after that. -dnl Since we set sampling=1 we should see all of these packets -dnl reported. Sorting the output by data-source and seqNo makes -dnl it deterministic. Ensuring that we send at least two packets -dnl into each port means we get to check the seq nos are -dnl incrementing correctly. - -ovs-appctl netdev-dummy/receive p1 'in_port(2),eth(src=50:54:00:00:00:05,dst=FF:FF:FF:FF:FF:FF),eth_type(0x0806),arp(sip=192.168.0.2,tip=192.168.0.1,op=1,sha=50:54:00:00:00:05,tha=00:00:00:00:00:00)' -ovs-appctl netdev-dummy/receive p2 'in_port(1),eth(src=50:54:00:00:00:07,dst=FF:FF:FF:FF:FF:FF),eth_type(0x0806),arp(sip=192.168.0.1,tip=192.168.0.2,op=1,sha=50:54:00:00:00:07,tha=00:00:00:00:00:00)' -ovs-appctl netdev-dummy/receive p1 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' -ovs-appctl netdev-dummy/receive p2 'in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)' -ovs-appctl netdev-dummy/receive p2 'in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x86dd),ipv6(src=fe80::1,dst=fe80::2,label=0,proto=10,tclass=0x70,hlimit=128,frag=no)' - -dnl sleep long enough to get more than one counter sample -dnl from each datasource so we can check sequence numbers -for i in `seq 1 30`; do - ovs-appctl time/warp 100 -done -OVS_VSWITCHD_STOP -ovs-appctl -t test-sflow exit +# CHECK_SFLOW_SAMPLING_PACKET(LOOPBACK_ADDR, IP_VERSION_TYPE) +# +# Test that sFlow samples packets correctly using IPv4/IPv6 sFlow collector +# +# IP_VERSION_TYPE is used in AT_SETUP +m4_define([CHECK_SFLOW_SAMPLING_PACKET], + [AT_SETUP([ofproto-dpif - sFlow packet sampling - $2 collector]) + OVS_VSWITCHD_START([set Bridge br0 fail-mode=standalone]) + + ON_EXIT([kill `cat test-sflow.pid`]) + AT_CHECK([test-sflow --log-file --detach --no-chdir --pidfile 0:$1 > sflow.log], [0], [], [ignore]) + AT_CAPTURE_FILE([sflow.log]) + m4_if([$1], [127.0.0.1], + [SFLOW_PORT=`parse_listening_port < test-sflow.log` + DS_IN_SFLOW_OUTPUT=$1], + [SFLOW_PORT=`parse_ipv6_listening_port < test-sflow.log` + DS_IN_SFLOW_OUTPUT=0:0:0:0:0:0:0:1]) + + ovs-appctl time/stop + + ADD_OF_PORTS([br0], 1, 2) + ovs-vsctl \ + set Interface br0 options:ifindex=1002 -- \ + set Interface p1 options:ifindex=1004 -- \ + set Interface p2 options:ifindex=1003 -- \ + set Bridge br0 sflow=@sf -- \ + --id=@sf create sflow targets=\"$1:$SFLOW_PORT\" \ + header=128 sampling=1 polling=1 + + dnl open with ARP packets to seed the bridge-learning. The output + dnl ifIndex numbers should be reported predictably after that. + dnl Since we set sampling=1 we should see all of these packets + dnl reported. Sorting the output by data-source and seqNo makes + dnl it deterministic. Ensuring that we send at least two packets + dnl into each port means we get to check the seq nos are + dnl incrementing correctly. + + ovs-appctl netdev-dummy/receive p1 'in_port(2),eth(src=50:54:00:00:00:05,dst=FF:FF:FF:FF:FF:FF),eth_type(0x0806),arp(sip=192.168.0.2,tip=192.168.0.1,op=1,sha=50:54:00:00:00:05,tha=00:00:00:00:00:00)' + ovs-appctl netdev-dummy/receive p2 'in_port(1),eth(src=50:54:00:00:00:07,dst=FF:FF:FF:FF:FF:FF),eth_type(0x0806),arp(sip=192.168.0.1,tip=192.168.0.2,op=1,sha=50:54:00:00:00:07,tha=00:00:00:00:00:00)' + ovs-appctl netdev-dummy/receive p1 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' + ovs-appctl netdev-dummy/receive p2 'in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)' + ovs-appctl netdev-dummy/receive p2 'in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x86dd),ipv6(src=fe80::1,dst=fe80::2,label=0,proto=10,tclass=0x70,hlimit=128,frag=no)' + + dnl sleep long enough to get more than one counter sample + dnl from each datasource so we can check sequence numbers + for i in `seq 1 30`; do + ovs-appctl time/warp 100 + done + OVS_VSWITCHD_STOP + ovs-appctl -t test-sflow exit -AT_CHECK([[sort sflow.log | $EGREP 'HEADER|ERROR' | sed 's/ /\ - /g']], [0], [dnl + AT_CHECK_UNQUOTED([[sort sflow.log | $EGREP 'HEADER|ERROR' | sed 's/ /\ + /g']], [0], [dnl HEADER - dgramSeqNo=1 - ds=127.0.0.1>2:1000 - fsSeqNo=1 - in_vlan=0 - in_priority=0 - out_vlan=0 - out_priority=0 - meanSkip=1 - samplePool=1 - dropEvents=0 - in_ifindex=1004 - in_format=0 - out_ifindex=2 - out_format=2 - hdr_prot=1 - pkt_len=64 - stripped=4 - hdr_len=60 - hdr=FF-FF-FF-FF-FF-FF-50-54-00-00-00-05-08-06-00-01-08-00-06-04-00-01-50-54-00-00-00-05-C0-A8-00-02-00-00-00-00-00-00-C0-A8-00-01-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 + dgramSeqNo=1 + ds=$DS_IN_SFLOW_OUTPUT>2:1000 + fsSeqNo=1 + in_vlan=0 + in_priority=0 + out_vlan=0 + out_priority=0 + meanSkip=1 + samplePool=1 + dropEvents=0 + in_ifindex=1004 + in_format=0 + out_ifindex=2 + out_format=2 + hdr_prot=1 + pkt_len=64 + stripped=4 + hdr_len=60 + hdr=FF-FF-FF-FF-FF-FF-50-54-00-00-00-05-08-06-00-01-08-00-06-04-00-01-50-54-00-00-00-05-C0-A8-00-02-00-00-00-00-00-00-C0-A8-00-01-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 HEADER - dgramSeqNo=1 - ds=127.0.0.1>2:1000 - fsSeqNo=2 - in_vlan=0 - in_priority=0 - out_vlan=0 - out_priority=0 - meanSkip=1 - samplePool=2 - dropEvents=0 - in_ifindex=1003 - in_format=0 - out_ifindex=2 - out_format=2 - hdr_prot=1 - pkt_len=64 - stripped=4 - hdr_len=60 - hdr=FF-FF-FF-FF-FF-FF-50-54-00-00-00-07-08-06-00-01-08-00-06-04-00-01-50-54-00-00-00-07-C0-A8-00-01-00-00-00-00-00-00-C0-A8-00-02-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 + dgramSeqNo=1 + ds=$DS_IN_SFLOW_OUTPUT>2:1000 + fsSeqNo=2 + in_vlan=0 + in_priority=0 + out_vlan=0 + out_priority=0 + meanSkip=1 + samplePool=2 + dropEvents=0 + in_ifindex=1003 + in_format=0 + out_ifindex=2 + out_format=2 + hdr_prot=1 + pkt_len=64 + stripped=4 + hdr_len=60 + hdr=FF-FF-FF-FF-FF-FF-50-54-00-00-00-07-08-06-00-01-08-00-06-04-00-01-50-54-00-00-00-07-C0-A8-00-01-00-00-00-00-00-00-C0-A8-00-02-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 HEADER - dgramSeqNo=1 - ds=127.0.0.1>2:1000 - fsSeqNo=3 - in_vlan=0 - in_priority=0 - out_vlan=0 - out_priority=0 - meanSkip=1 - samplePool=3 - dropEvents=0 - in_ifindex=1004 - in_format=0 - out_ifindex=1003 - out_format=0 - hdr_prot=1 - pkt_len=64 - stripped=4 - hdr_len=60 - hdr=50-54-00-00-00-07-50-54-00-00-00-05-08-00-45-00-00-1C-00-00-00-00-40-01-F9-8D-C0-A8-00-01-C0-A8-00-02-08-00-F7-FF-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 + dgramSeqNo=1 + ds=$DS_IN_SFLOW_OUTPUT>2:1000 + fsSeqNo=3 + in_vlan=0 + in_priority=0 + out_vlan=0 + out_priority=0 + meanSkip=1 + samplePool=3 + dropEvents=0 + in_ifindex=1004 + in_format=0 + out_ifindex=1003 + out_format=0 + hdr_prot=1 + pkt_len=64 + stripped=4 + hdr_len=60 + hdr=50-54-00-00-00-07-50-54-00-00-00-05-08-00-45-00-00-1C-00-00-00-00-40-01-F9-8D-C0-A8-00-01-C0-A8-00-02-08-00-F7-FF-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 HEADER - dgramSeqNo=1 - ds=127.0.0.1>2:1000 - fsSeqNo=4 - in_vlan=0 - in_priority=0 - out_vlan=0 - out_priority=0 - meanSkip=1 - samplePool=4 - dropEvents=0 - in_ifindex=1003 - in_format=0 - out_ifindex=1004 - out_format=0 - hdr_prot=1 - pkt_len=64 - stripped=4 - hdr_len=60 - hdr=50-54-00-00-00-05-50-54-00-00-00-07-08-00-45-00-00-1C-00-00-00-00-40-01-F9-8D-C0-A8-00-02-C0-A8-00-01-00-00-FF-FF-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 + dgramSeqNo=1 + ds=$DS_IN_SFLOW_OUTPUT>2:1000 + fsSeqNo=4 + in_vlan=0 + in_priority=0 + out_vlan=0 + out_priority=0 + meanSkip=1 + samplePool=4 + dropEvents=0 + in_ifindex=1003 + in_format=0 + out_ifindex=1004 + out_format=0 + hdr_prot=1 + pkt_len=64 + stripped=4 + hdr_len=60 + hdr=50-54-00-00-00-05-50-54-00-00-00-07-08-00-45-00-00-1C-00-00-00-00-40-01-F9-8D-C0-A8-00-02-C0-A8-00-01-00-00-FF-FF-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 HEADER - dgramSeqNo=1 - ds=127.0.0.1>2:1000 - fsSeqNo=5 - in_vlan=0 - in_priority=0 - out_vlan=0 - out_priority=0 - meanSkip=1 - samplePool=5 - dropEvents=0 - in_ifindex=1003 - in_format=0 - out_ifindex=1004 - out_format=0 - hdr_prot=1 - pkt_len=64 - stripped=4 - hdr_len=60 - hdr=50-54-00-00-00-05-50-54-00-00-00-07-86-DD-67-00-00-00-00-00-0A-80-FE-80-00-00-00-00-00-00-00-00-00-00-00-00-00-01-FE-80-00-00-00-00-00-00-00-00-00-00-00-00-00-02-00-00-00-00-00-00 -]) - -AT_CHECK([[sort sflow.log | $EGREP 'IFCOUNTERS|ERROR' | head -6 | sed 's/ /\ - /g']], [0], [dnl + dgramSeqNo=1 + ds=$DS_IN_SFLOW_OUTPUT>2:1000 + fsSeqNo=5 + in_vlan=0 + in_priority=0 + out_vlan=0 + out_priority=0 + meanSkip=1 + samplePool=5 + dropEvents=0 + in_ifindex=1003 + in_format=0 + out_ifindex=1004 + out_format=0 + hdr_prot=1 + pkt_len=64 + stripped=4 + hdr_len=60 + hdr=50-54-00-00-00-05-50-54-00-00-00-07-86-DD-67-00-00-00-00-00-0A-80-FE-80-00-00-00-00-00-00-00-00-00-00-00-00-00-01-FE-80-00-00-00-00-00-00-00-00-00-00-00-00-00-02-00-00-00-00-00-00 +]) + + AT_CHECK_UNQUOTED([[sort sflow.log | $EGREP 'IFCOUNTERS|ERROR' | head -6 | sed 's/ /\ + /g']], [0], [dnl IFCOUNTERS - dgramSeqNo=2 - ds=127.0.0.1>0:1002 - csSeqNo=1 - ifindex=1002 - type=6 - ifspeed=100000000 - direction=0 - status=3 - in_octets=0 - in_unicasts=0 - in_multicasts=0 - in_broadcasts=4294967295 - in_discards=0 - in_errors=0 - in_unknownprotos=4294967295 - out_octets=120 - out_unicasts=2 - out_multicasts=4294967295 - out_broadcasts=4294967295 - out_discards=0 - out_errors=0 - promiscuous=0 + dgramSeqNo=2 + ds=$DS_IN_SFLOW_OUTPUT>0:1002 + csSeqNo=1 + ifindex=1002 + type=6 + ifspeed=100000000 + direction=0 + status=3 + in_octets=0 + in_unicasts=0 + in_multicasts=0 + in_broadcasts=4294967295 + in_discards=0 + in_errors=0 + in_unknownprotos=4294967295 + out_octets=120 + out_unicasts=2 + out_multicasts=4294967295 + out_broadcasts=4294967295 + out_discards=0 + out_errors=0 + promiscuous=0 IFCOUNTERS - dgramSeqNo=2 - ds=127.0.0.1>0:1003 - csSeqNo=1 - ifindex=1003 - type=6 - ifspeed=100000000 - direction=0 - status=0 - in_octets=138 - in_unicasts=3 - in_multicasts=0 - in_broadcasts=4294967295 - in_discards=0 - in_errors=0 - in_unknownprotos=4294967295 - out_octets=120 - out_unicasts=2 - out_multicasts=4294967295 - out_broadcasts=4294967295 - out_discards=0 - out_errors=0 - promiscuous=0 + dgramSeqNo=2 + ds=$DS_IN_SFLOW_OUTPUT>0:1003 + csSeqNo=1 + ifindex=1003 + type=6 + ifspeed=100000000 + direction=0 + status=0 + in_octets=138 + in_unicasts=3 + in_multicasts=0 + in_broadcasts=4294967295 + in_discards=0 + in_errors=0 + in_unknownprotos=4294967295 + out_octets=120 + out_unicasts=2 + out_multicasts=4294967295 + out_broadcasts=4294967295 + out_discards=0 + out_errors=0 + promiscuous=0 IFCOUNTERS - dgramSeqNo=2 - ds=127.0.0.1>0:1004 - csSeqNo=1 - ifindex=1004 - type=6 - ifspeed=100000000 - direction=0 - status=0 - in_octets=84 - in_unicasts=2 - in_multicasts=0 - in_broadcasts=4294967295 - in_discards=0 - in_errors=0 - in_unknownprotos=4294967295 - out_octets=180 - out_unicasts=3 - out_multicasts=4294967295 - out_broadcasts=4294967295 - out_discards=0 - out_errors=0 - promiscuous=0 + dgramSeqNo=2 + ds=$DS_IN_SFLOW_OUTPUT>0:1004 + csSeqNo=1 + ifindex=1004 + type=6 + ifspeed=100000000 + direction=0 + status=0 + in_octets=84 + in_unicasts=2 + in_multicasts=0 + in_broadcasts=4294967295 + in_discards=0 + in_errors=0 + in_unknownprotos=4294967295 + out_octets=180 + out_unicasts=3 + out_multicasts=4294967295 + out_broadcasts=4294967295 + out_discards=0 + out_errors=0 + promiscuous=0 IFCOUNTERS - dgramSeqNo=3 - ds=127.0.0.1>0:1002 - csSeqNo=2 - ifindex=1002 - type=6 - ifspeed=100000000 - direction=0 - status=3 - in_octets=0 - in_unicasts=0 - in_multicasts=0 - in_broadcasts=4294967295 - in_discards=0 - in_errors=0 - in_unknownprotos=4294967295 - out_octets=120 - out_unicasts=2 - out_multicasts=4294967295 - out_broadcasts=4294967295 - out_discards=0 - out_errors=0 - promiscuous=0 + dgramSeqNo=3 + ds=$DS_IN_SFLOW_OUTPUT>0:1002 + csSeqNo=2 + ifindex=1002 + type=6 + ifspeed=100000000 + direction=0 + status=3 + in_octets=0 + in_unicasts=0 + in_multicasts=0 + in_broadcasts=4294967295 + in_discards=0 + in_errors=0 + in_unknownprotos=4294967295 + out_octets=120 + out_unicasts=2 + out_multicasts=4294967295 + out_broadcasts=4294967295 + out_discards=0 + out_errors=0 + promiscuous=0 IFCOUNTERS - dgramSeqNo=3 - ds=127.0.0.1>0:1003 - csSeqNo=2 - ifindex=1003 - type=6 - ifspeed=100000000 - direction=0 - status=0 - in_octets=138 - in_unicasts=3 - in_multicasts=0 - in_broadcasts=4294967295 - in_discards=0 - in_errors=0 - in_unknownprotos=4294967295 - out_octets=120 - out_unicasts=2 - out_multicasts=4294967295 - out_broadcasts=4294967295 - out_discards=0 - out_errors=0 - promiscuous=0 + dgramSeqNo=3 + ds=$DS_IN_SFLOW_OUTPUT>0:1003 + csSeqNo=2 + ifindex=1003 + type=6 + ifspeed=100000000 + direction=0 + status=0 + in_octets=138 + in_unicasts=3 + in_multicasts=0 + in_broadcasts=4294967295 + in_discards=0 + in_errors=0 + in_unknownprotos=4294967295 + out_octets=120 + out_unicasts=2 + out_multicasts=4294967295 + out_broadcasts=4294967295 + out_discards=0 + out_errors=0 + promiscuous=0 IFCOUNTERS - dgramSeqNo=3 - ds=127.0.0.1>0:1004 - csSeqNo=2 - ifindex=1004 - type=6 - ifspeed=100000000 - direction=0 - status=0 - in_octets=84 - in_unicasts=2 - in_multicasts=0 - in_broadcasts=4294967295 - in_discards=0 - in_errors=0 - in_unknownprotos=4294967295 - out_octets=180 - out_unicasts=3 - out_multicasts=4294967295 - out_broadcasts=4294967295 - out_discards=0 - out_errors=0 - promiscuous=0 -]) -AT_CLEANUP - - - -dnl Test that basic NetFlow reports flow statistics correctly: -dnl - The initial packet of a flow are correctly accounted. -dnl - Later packets within a flow are correctly accounted. -dnl - Flow actions changing (in this case, due to MAC learning) -dnl cause a record to be sent. -AT_SETUP([ofproto-dpif - NetFlow flow expiration]) - -OVS_VSWITCHD_START([set Bridge br0 fail-mode=standalone]) -ADD_OF_PORTS([br0], 1, 2) - -ovs-appctl time/stop -ON_EXIT([kill `cat test-netflow.pid`]) -AT_CHECK([test-netflow --log-file --detach --no-chdir --pidfile 0:127.0.0.1 > netflow.log], [0], [], [ignore]) -AT_CAPTURE_FILE([netflow.log]) -NETFLOW_PORT=`parse_listening_port < test-netflow.log` - -ovs-vsctl \ - set Bridge br0 netflow=@nf -- \ - --id=@nf create NetFlow targets=\"127.0.0.1:$NETFLOW_PORT\" \ - engine_id=1 engine_type=2 active_timeout=30 add-id-to-interface=false - -for delay in 1000 30000; do - ovs-appctl netdev-dummy/receive p1 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' - ovs-appctl netdev-dummy/receive p2 'in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)' - - ovs-appctl time/warp $delay -done + dgramSeqNo=3 + ds=$DS_IN_SFLOW_OUTPUT>0:1004 + csSeqNo=2 + ifindex=1004 + type=6 + ifspeed=100000000 + direction=0 + status=0 + in_octets=84 + in_unicasts=2 + in_multicasts=0 + in_broadcasts=4294967295 + in_discards=0 + in_errors=0 + in_unknownprotos=4294967295 + out_octets=180 + out_unicasts=3 + out_multicasts=4294967295 + out_broadcasts=4294967295 + out_discards=0 + out_errors=0 + promiscuous=0 +]) + AT_CLEANUP]) + +CHECK_SFLOW_SAMPLING_PACKET([127.0.0.1], [IPv4]) +CHECK_SFLOW_SAMPLING_PACKET([::1], [IPv6]) + +# CHECK_NETFLOW_EXPIRATION(LOOPBACK_ADDR, IP_VERSION_TYPE) +# +# Test that basic NetFlow reports flow statistics correctly: +# The initial packet of a flow are correctly accounted. +# Later packets within a flow are correctly accounted. +# Flow actions changing (in this case, due to MAC learning) +# cause a record to be sent. +# +# IP_VERSION_TYPE is used in AT_SETUP +m4_define([CHECK_NETFLOW_EXPIRATION], + [AT_SETUP([ofproto-dpif - NetFlow flow expiration - $2 collector]) + OVS_VSWITCHD_START([set Bridge br0 fail-mode=standalone]) + ADD_OF_PORTS([br0], 1, 2) + + ON_EXIT([kill `cat test-netflow.pid`]) + AT_CHECK([test-netflow --log-file --detach --no-chdir --pidfile 0:$1 > netflow.log], [0], [], [ignore]) + AT_CAPTURE_FILE([netflow.log]) + m4_if([$1], [127.0.0.1], + [NETFLOW_PORT=`parse_listening_port < test-netflow.log`], + [NETFLOW_PORT=`parse_ipv6_listening_port < test-netflow.log`]) + + ovs-vsctl \ + set Bridge br0 netflow=@nf -- \ + --id=@nf create NetFlow targets=\"$1:$NETFLOW_PORT\" \ + engine_id=1 engine_type=2 active_timeout=30 add-id-to-interface=false + + for delay in 1000 30000; do + ovs-appctl netdev-dummy/receive p1 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)' + ovs-appctl netdev-dummy/receive p2 'in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=0,code=0)' + + ovs-appctl time/warp $delay + done -sleep 1 -OVS_VSWITCHD_STOP -ovs-appctl -t test-netflow exit + sleep 1 + OVS_VSWITCHD_STOP + ovs-appctl -t test-netflow exit -AT_CHECK([[sed -e 's/, uptime [0-9]*// -s/, now [0-9.]*// -s/time \([0-9]*\)\.\.\.\1$/time <moment>/ -s/time [0-9]*\.\.\.[0-9]*/time <range>/ -' netflow.log | sort]], [0], - [ + AT_CHECK([[sed -e 's/, uptime [0-9]*// + s/, now [0-9.]*// + s/time \([0-9]*\)\.\.\.\1$/time <moment>/ + s/time [0-9]*\.\.\.[0-9]*/time <range>/ + ' netflow.log | sort]], [0], + [ header: v5, seq 0, engine 2,1 header: v5, seq 1, engine 2,1 seq 0: 192.168.0.1 > 192.168.0.2, if 1 > 65535, 1 pkts, 60 bytes, ICMP 8:0, time <moment> seq 1: 192.168.0.1 > 192.168.0.2, if 1 > 2, 1 pkts, 60 bytes, ICMP 8:0, time <moment> seq 1: 192.168.0.2 > 192.168.0.1, if 2 > 1, 2 pkts, 120 bytes, ICMP 0:0, time <range> ]) -AT_CLEANUP + AT_CLEANUP]) -dnl Test that basic NetFlow reports active expirations correctly. -AT_SETUP([ofproto-dpif - NetFlow active expiration]) +CHECK_NETFLOW_EXPIRATION([127.0.0.1], [IPv4]) +CHECK_NETFLOW_EXPIRATION([::1], [IPv6]) -OVS_VSWITCHD_START([set Bridge br0 fail-mode=standalone]) -ADD_OF_PORTS([br0], 1, 2) - -ON_EXIT([kill `cat test-netflow.pid`]) -AT_CHECK([test-netflow --log-file --detach --no-chdir --pidfile 0:127.0.0.1 > netflow.log], [0], [], [ignore]) -AT_CAPTURE_FILE([netflow.log]) -NETFLOW_PORT=`parse_listening_port < test-netflow.log` - -ovs-vsctl \ - set Bridge br0 netflow=@nf -- \ - --id=@nf create NetFlow targets=\"127.0.0.1:$NETFLOW_PORT\" \ - engine_id=1 engine_type=2 active_timeout=10 add-id-to-interface=false - -AT_CHECK([ovs-appctl time/stop]) -n=1 -while test $n -le 60; do - n=`expr $n + 1` - - ovs-appctl netdev-dummy/receive p1 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=1234,dst=80)' - ovs-appctl netdev-dummy/receive p2 'in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.0.1,proto=6,tos=0,ttl=64,frag=no),tcp(src=80,dst=1234)' - - ovs-appctl time/warp 1000 -done - -ovs-appctl time/warp 10000 +# CHECK_NETFLOW_ACTIVE_EXPIRATION(LOOPBACK_ADDR, IP_VERSION_TYPE) +# +# Test that basic NetFlow reports active expirations correctly. +# +# IP_VERSION_TYPE is used in AT_SETUP +m4_define([CHECK_NETFLOW_ACTIVE_EXPIRATION], + [AT_SETUP([ofproto-dpif - NetFlow active expiration - $2 collector]) + + OVS_VSWITCHD_START([set Bridge br0 fail-mode=standalone]) + ADD_OF_PORTS([br0], 1, 2) + + ON_EXIT([kill `cat test-netflow.pid`]) + AT_CHECK([test-netflow --log-file --detach --no-chdir --pidfile 0:$1 > netflow.log], [0], [], [ignore]) + AT_CAPTURE_FILE([netflow.log]) + m4_if([$1], [127.0.0.1], + [NETFLOW_PORT=`parse_listening_port < test-netflow.log`], + [NETFLOW_PORT=`parse_ipv6_listening_port < test-netflow.log`]) + + ovs-vsctl \ + set Bridge br0 netflow=@nf -- \ + --id=@nf create NetFlow targets=\"$1:$NETFLOW_PORT\" \ + engine_id=1 engine_type=2 active_timeout=10 add-id-to-interface=false + + AT_CHECK([ovs-appctl time/stop]) + n=1 + while test $n -le 60; do + n=`expr $n + 1` + + ovs-appctl netdev-dummy/receive p1 'in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=6,tos=0,ttl=64,frag=no),tcp(src=1234,dst=80)' + ovs-appctl netdev-dummy/receive p2 'in_port(1),eth(src=50:54:00:00:00:07,dst=50:54:00:00:00:05),eth_type(0x0800),ipv4(src=192.168.0.2,dst=192.168.0.1,proto=6,tos=0,ttl=64,frag=no),tcp(src=80,dst=1234)' + + ovs-appctl time/warp 1000 + done -sleep 1 -OVS_VSWITCHD_STOP -ovs-appctl -t test-netflow exit - -# Count the number of reported packets: -# - From source to destination before MAC learning kicks in (just one). -# - From source to destination after that. -# - From destination to source. -n_learn=0 -n_in=0 -n_out=0 -n_other=0 -n_recs=0 -none=0 -while read line; do - pkts=`echo "$line" | sed 's/.*, \([[0-9]]*\) pkts,.*/\1/'` - case $pkts in - [[0-9]]*) ;; - *) continue ;; - esac - - case $line in - "seq "*": 192.168.0.1 > 192.168.0.2, if 1 > 65535, "*" pkts, "*" bytes, TCP 1234 > 80, time "*) - counter=n_learn - ;; - "seq "*": 192.168.0.1 > 192.168.0.2, if 1 > 2, "*" pkts, "*" bytes, TCP 1234 > 80, time "*) - counter=n_in - ;; - "seq "*": 192.168.0.2 > 192.168.0.1, if 2 > 1, "*" pkts, "*" bytes, TCP 80 > 1234, time "*) - counter=n_out - ;; - *) - counter=n_other - ;; - esac - eval $counter=\`expr \$$counter + \$pkts\` - n_recs=`expr $n_recs + 1` -done < netflow.log - -# There should be exactly 1 MAC learning packet, -# exactly 59 other packets in that direction, -# and exactly 60 packets in the other direction. -AT_CHECK([echo $n_learn $n_in $n_out $n_other], [0], [1 59 60 0 -]) - -# There should be 1 expiration for MAC learning, -# at least 5 active and a final expiration in one direction, -# and at least 5 active and a final expiration in the other direction. -echo $n_recs -AT_CHECK([test $n_recs -ge 13]) - -AT_CLEANUP + ovs-appctl time/warp 10000 + + sleep 1 + OVS_VSWITCHD_STOP + ovs-appctl -t test-netflow exit + + # Count the number of reported packets: + # - From source to destination before MAC learning kicks in (just one). + # - From source to destination after that. + # - From destination to source. + n_learn=0 + n_in=0 + n_out=0 + n_other=0 + n_recs=0 + none=0 + while read line; do + pkts=`echo "$line" | sed 's/.*, \([[0-9]]*\) pkts,.*/\1/'` + case $pkts in + [[0-9]]*) ;; + *) continue ;; + esac + + case $line in + "seq "*": 192.168.0.1 > 192.168.0.2, if 1 > 65535, "*" pkts, "*" bytes, TCP 1234 > 80, time "*) + counter=n_learn + ;; + "seq "*": 192.168.0.1 > 192.168.0.2, if 1 > 2, "*" pkts, "*" bytes, TCP 1234 > 80, time "*) + counter=n_in + ;; + "seq "*": 192.168.0.2 > 192.168.0.1, if 2 > 1, "*" pkts, "*" bytes, TCP 80 > 1234, time "*) + counter=n_out + ;; + *) + counter=n_other + ;; + esac + eval $counter=\`expr \$$counter + \$pkts\` + n_recs=`expr $n_recs + 1` + done < netflow.log + + # There should be exactly 1 MAC learning packet, + # exactly 59 other packets in that direction, + # and exactly 60 packets in the other direction. + AT_CHECK([echo $n_learn $n_in $n_out $n_other], [0], [1 59 60 0 +]) + + # There should be 1 expiration for MAC learning, + # at least 5 active and a final expiration in one direction, + # and at least 5 active and a final expiration in the other direction. + echo $n_recs + AT_CHECK([test $n_recs -ge 13]) + AT_CLEANUP]) + +CHECK_NETFLOW_ACTIVE_EXPIRATION([127.0.0.1], [IPv4]) +CHECK_NETFLOW_ACTIVE_EXPIRATION([::1], [IPv6]) AT_SETUP([idle_age and hard_age increase over time]) OVS_VSWITCHD_START @@ -2631,29 +2658,38 @@ skb_priority(0),in_port(1),eth(src=50:54:00:00:00:0b/ff:ff:ff:ff:ff:ff,dst=50:54 OVS_VSWITCHD_STOP AT_CLEANUP -AT_SETUP([ofproto-dpif megaflow - netflow]) -OVS_VSWITCHD_START -ADD_OF_PORTS([br0], [1], [2]) - -dnl NetFlow configuration disables wildcarding relevant fields -ON_EXIT([kill `cat test-netflow.pid`]) -AT_CHECK([test-netflow --log-file --detach --no-chdir --pidfile 0:127.0.0.1 > netflow.log], [0], [], [ignore]) -AT_CAPTURE_FILE([netflow.log]) -NETFLOW_PORT=`parse_listening_port < test-netflow.log` -ovs-vsctl \ - set Bridge br0 netflow=@nf -- \ - --id=@nf create NetFlow targets=\"127.0.0.1:$NETFLOW_PORT\" \ - engine_id=1 engine_type=2 active_timeout=30 add-id-to-interface=false - -AT_CHECK([ovs-ofctl add-flow br0 action=normal]) -AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)']) -AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.4,dst=10.0.0.3,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)']) -AT_CHECK([ovs-appctl dpif/dump-flows br0 | STRIP_XOUT], [0], [dnl -skb_priority(0),in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2/255.255.255.255,dst=10.0.0.1/255.255.255.255,proto=1/0xff,tos=0/0xfc,ttl=64/0,frag=no/0xff),icmp(type=8,code=0), packets:0, bytes:0, used:0.0s, actions: <del> -skb_priority(0),in_port(1),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.4/255.255.255.255,dst=10.0.0.3/255.255.255.255,proto=1/0xff,tos=0/0xfc,ttl=64/0,frag=no/0xff),icmp(type=8,code=0), packets:0, bytes:0, used:0.0s, actions: <del> -]) -OVS_VSWITCHD_STOP -AT_CLEANUP +# CHECK_MEGAFLOW_NETFLOW(LOOPBACK_ADDR, IP_VERSION_TYPE) +# +# IP_VERSION_TYPE is used in AT_SETUP +m4_define([CHECK_MEGAFLOW_NETFLOW], + [AT_SETUP([ofproto-dpif megaflow - netflow - $2 collector]) + OVS_VSWITCHD_START + ADD_OF_PORTS([br0], [1], [2]) + + dnl NetFlow configuration disables wildcarding relevant fields + ON_EXIT([kill `cat test-netflow.pid`]) + AT_CHECK([test-netflow --log-file --detach --no-chdir --pidfile 0:$1 > netflow.log], [0], [], [ignore]) + AT_CAPTURE_FILE([netflow.log]) + m4_if([$1], [127.0.0.1], + [NETFLOW_PORT=`parse_listening_port < test-netflow.log`], + [NETFLOW_PORT=`parse_ipv6_listening_port < test-netflow.log`]) + ovs-vsctl \ + set Bridge br0 netflow=@nf -- \ + --id=@nf create NetFlow targets=\"$1:$NETFLOW_PORT\" \ + engine_id=1 engine_type=2 active_timeout=30 add-id-to-interface=false + + AT_CHECK([ovs-ofctl add-flow br0 action=normal]) + AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x0800),ipv4(src=10.0.0.2,dst=10.0.0.1,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)']) + AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:0b,dst=50:54:00:00:00:0c),eth_type(0x0800),ipv4(src=10.0.0.4,dst=10.0.0.3,proto=1,tos=0,ttl=64,frag=no),icmp(type=8,code=0)']) + AT_CHECK([ovs-appctl dpif/dump-megaflows br0 | STRIP_XOUT], [0], [dnl +skb_priority=0,icmp,in_port=1,vlan_tci=0x0000/0x1fff,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.0.0.2,nw_dst=10.0.0.1,nw_tos=0,nw_frag=no,icmp_type=8,icmp_code=0, n_subfacets:1, used:0.0s, Datapath actions: <del> +skb_priority=0,icmp,in_port=1,vlan_tci=0x0000/0x1fff,dl_src=50:54:00:00:00:0b,dl_dst=50:54:00:00:00:0c,nw_src=10.0.0.4,nw_dst=10.0.0.3,nw_tos=0,nw_frag=no,icmp_type=8,icmp_code=0, n_subfacets:1, used:0.0s, Datapath actions: <del> +]) + OVS_VSWITCHD_STOP + AT_CLEANUP]) + +CHECK_MEGAFLOW_NETFLOW([127.0.0.1], [IPv4]) +CHECK_MEGAFLOW_NETFLOW([::1], [IPv6]) AT_SETUP([ofproto-dpif megaflow - normal, active-backup bonding]) OVS_VSWITCHD_START( diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at index 3bcffc2..c7ec8e4 100644 --- a/tests/ofproto-macros.at +++ b/tests/ofproto-macros.at @@ -30,6 +30,23 @@ s/ hard_age=[0-9]*,// # TCP_PORT=`parse_listening_port < ovsdb-server.log` parse_listening_port () { sed -n 's/.*0:127\.0\.0\.1: listening on port \([0-9]*\)$/\1/p' +} + +# parse_ipv6_listening_port [SERVER] +# +# 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:::1 or +# pssl:0:::1. +# +# Here's an example of how to use this with ovsdb-server: +# +# OVS_LOGDIR=`pwd`; export OVS_LOGDIR +# ovsdb-server --log-file --remote=ptcp:0:::1 ... +# TCP_PORT=`parse_ipv6_listening_port < ovsdb-server.log` +parse_ipv6_listening_port () { + sed -n 's/.*0:::1: listening on port \([0-9]*\)$/\1/p' }] m4_divert_pop([PREPARE_TESTS]) diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at index 851e4d8..ecebe20 100644 --- a/tests/ovs-vsctl.at +++ b/tests/ovs-vsctl.at @@ -414,7 +414,7 @@ CHECK_IFACES([a], [a1], [a2], [a3]) OVS_VSCTL_CLEANUP AT_CLEANUP -AT_SETUP([controllers]) +AT_SETUP([controllers IPv4]) AT_KEYWORDS([controller ovs-vsctl]) OVS_VSCTL_SETUP AT_CHECK([RUN_OVS_VSCTL_TOGETHER( @@ -440,6 +440,32 @@ tcp:5.4.3.2\ntcp:8.9.10.11 OVS_VSCTL_CLEANUP AT_CLEANUP +AT_SETUP([controllers IPv6]) +AT_KEYWORDS([controller ovs-vsctl]) +OVS_VSCTL_SETUP +AT_CHECK([RUN_OVS_VSCTL_TOGETHER( + [add-br br0], + + [get-controller br0], + [set-controller br0 tcp:2607:f0d0:2001:a::10], + [get-controller br0], + + [del-controller br0], + [get-controller br0], + + [set-controller br0 tcp:2607:f0d0:2001:a::11 tcp:2607:f0d0:2001:a::12], + [get-controller br0])], [0], [ + + +tcp:2607:f0d0:2001:a::10 + + + +tcp:2607:f0d0:2001:a::11\ntcp:2607:f0d0:2001:a::12 +], [], [OVS_VSCTL_CLEANUP]) +OVS_VSCTL_CLEANUP +AT_CLEANUP + dnl ---------------------------------------------------------------------- dnl OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF([VLAN]) m4_define([OVS_VSCTL_SETUP_SIMPLE_FAKE_CONF], diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at index 9ff7b1b..dd9ffa0 100644 --- a/tests/ovsdb-idl.at +++ b/tests/ovsdb-idl.at @@ -72,10 +72,32 @@ m4_define([OVSDB_CHECK_IDL_TCP_PY], OVSDB_SERVER_SHUTDOWN AT_CLEANUP]) +# same as OVSDB_CHECK_IDL but uses the Python IDL implementation with tcp6 +m4_define([OVSDB_CHECK_IDL_TCP6_PY], + [AT_SETUP([$1 - Python tcp6]) + AT_SKIP_IF([test $HAVE_PYTHON = no]) + AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5]) + OVS_RUNDIR=`pwd`; export OVS_RUNDIR + OVS_LOGDIR=`pwd`; export OVS_LOGDIR + AT_CHECK([ovsdb-tool create db $abs_srcdir/idltest.ovsschema], + [0], [stdout], [ignore]) + AT_CHECK([ovsdb-server --log-file '-vPATTERN:console:ovsdb-server|%c|%m' --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:::1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore]) + TCP_PORT=`parse_ipv6_listening_port < ovsdb-server.log` + + m4_if([$2], [], [], + [AT_CHECK([ovsdb-client transact tcp:::1:$TCP_PORT $2], [0], [ignore], [ignore], [kill `cat pid`])]) + AT_CHECK([$PYTHON $srcdir/test-ovsdb.py -t10 idl $srcdir/idltest.ovsschema tcp:::1:$TCP_PORT $3], + [0], [stdout], [ignore], [kill `cat pid`]) + AT_CHECK([sort stdout | ${PERL} $srcdir/uuidfilt.pl]m4_if([$6],,, [[| $6]]), + [0], [$4], [], [kill `cat pid`]) + OVSDB_SERVER_SHUTDOWN + AT_CLEANUP]) + m4_define([OVSDB_CHECK_IDL], [OVSDB_CHECK_IDL_C($@) OVSDB_CHECK_IDL_PY($@) - OVSDB_CHECK_IDL_TCP_PY($@)]) + OVSDB_CHECK_IDL_TCP_PY($@) + OVSDB_CHECK_IDL_TCP6_PY($@)]) OVSDB_CHECK_IDL([simple idl, initially empty, no ops], [], diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at index 444ab96..0d5b1c4 100644 --- a/tests/ovsdb-server.at +++ b/tests/ovsdb-server.at @@ -1,6 +1,6 @@ AT_BANNER([OVSDB -- ovsdb-server transactions (Unix sockets)]) -m4_define([OVSDB_SERVER_SHUTDOWN], +m4_define([OVSDB_SERVER_SHUTDOWN], [cp pid savepid AT_CHECK([ovs-appctl -t "`pwd`"/unixctl -e exit], [0], [ignore], [ignore]) OVS_WAIT_WHILE([kill -0 `cat savepid`], [kill `cat savepid`])]) @@ -19,14 +19,14 @@ m4_define([OVSDB_SERVER_SHUTDOWN], # same marker. # # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. -m4_define([OVSDB_CHECK_EXECUTION], +m4_define([OVSDB_CHECK_EXECUTION], [AT_SETUP([$1]) OVS_RUNDIR=`pwd`; export OVS_RUNDIR AT_KEYWORDS([ovsdb server positive unix $5]) $2 > schema AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --remote=punix:socket --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore]) - m4_foreach([txn], [$3], + m4_foreach([txn], [$3], [AT_CHECK([ovsdb-client transact unix:socket 'txn'], [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) cat stdout >> output @@ -153,7 +153,7 @@ AT_CHECK([ovsdb-tool create db1 schema1], [0], [ignore], [ignore]) AT_CHECK([ovsdb-tool create db2 schema2], [0], [ignore], [ignore]) AT_CHECK([ovsdb-server --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=punix:socket db1 db2], [0], [ignore], [ignore]) AT_CHECK( - [[ovsdb-client list-dbs unix:socket]], + [[ovsdb-client list-dbs unix:socket]], [0], [constraints ordinals ], [ignore], [test ! -e pid || kill `cat pid`]) @@ -363,10 +363,10 @@ AT_CHECK( "columns": ["target", "is_connected"]}]']], [0], [stdout], [ignore]) AT_CHECK( - [${PERL} $srcdir/uuidfilt.pl stdout], - [0], + [${PERL} $srcdir/uuidfilt.pl stdout], + [0], [[[{"rows":[{"managers":"punix:socket1"}]},{"rows":[{"is_connected":false,"target":"punix:socket2"}]}] -]], +]], [ignore]) AT_CLEANUP @@ -476,59 +476,69 @@ OVS_WAIT_UNTIL( AT_CHECK([test ! -e socket1]) AT_CLEANUP -AT_SETUP([SSL db: implementation]) -AT_KEYWORDS([ovsdb server positive ssl $5]) -AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) -PKIDIR=$abs_top_builddir/tests -AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" +# CHECK_SSL_DB_IMPLEMENTATION(LOOPBACK_ADDR, IP_VERSION_TYPE) +# +# IP_VERSION_TYPE is used in AT_SETUP +m4_define([CHECK_SSL_DB_IMPLEMENTATION], + [AT_SETUP([SSL db: implementation using $2]) + AT_KEYWORDS([ovsdb server positive ssl $5]) + AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) + PKIDIR=$abs_top_builddir/tests + AT_SKIP_IF([expr "$PKIDIR" : ".*[ '\" \\]"]) -AT_DATA([schema], - [[{"name": "mydb", - "tables": { - "SSL": { - "columns": { - "private_key": {"type": "string"}, - "certificate": {"type": "string"}, - "ca_cert": {"type": "string"}}}}} + AT_DATA([schema], + [[{"name": "mydb", + "tables": { + "SSL": { + "columns": { + "private_key": {"type": "string"}, + "certificate": {"type": "string"}, + "ca_cert": {"type": "string"}}}}} ]]) -AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) -AT_CHECK( - [[ovsdb-tool transact db \ - '["mydb", - {"op": "insert", - "table": "SSL", - "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'", - "certificate": "'"$PKIDIR/testpki-cert2.pem"'", - "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']], - [0], [ignore], [ignore]) -OVS_LOGDIR=`pwd`; export OVS_LOGDIR -AT_CHECK( - [ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid \ - --private-key=db:mydb,SSL,private_key \ - --certificate=db:mydb,SSL,certificate \ - --ca-cert=db:mydb,SSL,ca_cert \ - --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db], - [0], [ignore], [ignore]) -SSL_PORT=`parse_listening_port < ovsdb-server.log` -AT_CHECK( - [[ovsdb-client \ - --private-key=$PKIDIR/testpki-privkey.pem \ - --certificate=$PKIDIR/testpki-cert.pem \ - --ca-cert=$PKIDIR/testpki-cacert.pem \ - transact ssl:127.0.0.1:$SSL_PORT \ - '["mydb", - {"op": "select", - "table": "SSL", - "where": [], - "columns": ["private_key"]}]']], - [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) -cat stdout >> output -AT_CHECK_UNQUOTED( - [cat output], [0], - [[[{"rows":[{"private_key":"$PKIDIR/testpki-privkey2.pem"}]}] + AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) + AT_CHECK( + [[ovsdb-tool transact db \ + '["mydb", + {"op": "insert", + "table": "SSL", + "row": {"private_key": "'"$PKIDIR/testpki-privkey2.pem"'", + "certificate": "'"$PKIDIR/testpki-cert2.pem"'", + "ca_cert": "'"$PKIDIR/testpki-cacert.pem"'"}}]']], + [0], [ignore], [ignore]) + OVS_LOGDIR=`pwd`; export OVS_LOGDIR + AT_CHECK( + [ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid \ + --private-key=db:mydb,SSL,private_key \ + --certificate=db:mydb,SSL,certificate \ + --ca-cert=db:mydb,SSL,ca_cert \ + --remote=pssl:0:$1 --unixctl="`pwd`"/unixctl db], + [0], [ignore], [ignore]) + m4_if([$1], [127.0.0.1], + [SSL_PORT=`parse_listening_port < ovsdb-server.log`], + [SSL_PORT=`parse_ipv6_listening_port < ovsdb-server.log`]) + + AT_CHECK( + [[ovsdb-client \ + --private-key=$PKIDIR/testpki-privkey.pem \ + --certificate=$PKIDIR/testpki-cert.pem \ + --ca-cert=$PKIDIR/testpki-cacert.pem \ + transact ssl:$1:$SSL_PORT \ + '["mydb", + {"op": "select", + "table": "SSL", + "where": [], + "columns": ["private_key"]}]']], + [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) + cat stdout >> output + AT_CHECK_UNQUOTED( + [cat output], [0], + [[[{"rows":[{"private_key":"$PKIDIR/testpki-privkey2.pem"}]}] ]], [ignore], [test ! -e pid || kill `cat pid`]) -OVSDB_SERVER_SHUTDOWN -AT_CLEANUP + OVSDB_SERVER_SHUTDOWN + AT_CLEANUP]) + +CHECK_SSL_DB_IMPLEMENTATION([127.0.0.1], [IPv4]) +CHECK_SSL_DB_IMPLEMENTATION([::1], [IPv6]) AT_SETUP([compacting online]) AT_KEYWORDS([ovsdb server compact]) @@ -663,7 +673,7 @@ _uuid name number OVSDB_SERVER_SHUTDOWN AT_CLEANUP -AT_BANNER([OVSDB -- ovsdb-server transactions (SSL sockets)]) +AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv4 sockets)]) # OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) # @@ -679,7 +689,7 @@ AT_BANNER([OVSDB -- ovsdb-server transactions (SSL sockets)]) # same marker. # # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. -m4_define([OVSDB_CHECK_EXECUTION], +m4_define([OVSDB_CHECK_EXECUTION], [AT_SETUP([$1]) AT_KEYWORDS([ovsdb server positive ssl $5]) AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) @@ -690,7 +700,7 @@ m4_define([OVSDB_CHECK_EXECUTION], AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --private-key=$PKIDIR/testpki-privkey2.pem --certificate=$PKIDIR/testpki-cert2.pem --ca-cert=$PKIDIR/testpki-cacert.pem --remote=pssl:0:127.0.0.1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore]) SSL_PORT=`parse_listening_port < ovsdb-server.log` - m4_foreach([txn], [$3], + m4_foreach([txn], [$3], [AT_CHECK([ovsdb-client --private-key=$PKIDIR/testpki-privkey.pem --certificate=$PKIDIR/testpki-cert.pem --ca-cert=$PKIDIR/testpki-cacert.pem transact ssl:127.0.0.1:$SSL_PORT 'txn'], [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) cat stdout >> output @@ -702,7 +712,46 @@ cat stdout >> output EXECUTION_EXAMPLES -AT_BANNER([OVSDB -- ovsdb-server transactions (TCP sockets)]) +AT_BANNER([OVSDB -- ovsdb-server transactions (SSL IPv6 sockets)]) + +# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) +# +# Creates a database with the given SCHEMA, starts an ovsdb-server on +# that database, and runs each of the TRANSACTIONS (which should be a +# quoted list of quoted strings) against it with ovsdb-client one at a +# time. +# +# Checks that the overall output is OUTPUT, but UUIDs in the output +# are replaced by markers of the form <N> where N is a number. The +# first unique UUID is replaced by <0>, the next by <1>, and so on. +# If a given UUID appears more than once it is always replaced by the +# same marker. +# +# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. +m4_define([OVSDB_CHECK_EXECUTION], + [AT_SETUP([$1]) + AT_KEYWORDS([ovsdb server positive ssl6 $5]) + AT_SKIP_IF([test "$HAVE_OPENSSL" = no]) + OVS_RUNDIR=`pwd`; export OVS_RUNDIR + OVS_LOGDIR=`pwd`; export OVS_LOGDIR + $2 > schema + PKIDIR=$abs_top_builddir/tests + AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) + AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --private-key=$PKIDIR/testpki-privkey2.pem --certificate=$PKIDIR/testpki-cert2.pem --ca-cert=$PKIDIR/testpki-cacert.pem --remote=pssl:0:::1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore]) + SSL_PORT=`parse_ipv6_listening_port < ovsdb-server.log` + m4_foreach([txn], [$3], + [AT_CHECK([ovsdb-client --private-key=$PKIDIR/testpki-privkey.pem --certificate=$PKIDIR/testpki-cert.pem --ca-cert=$PKIDIR/testpki-cacert.pem transact ssl:::1:$SSL_PORT 'txn'], [0], [stdout], [ignore], + [test ! -e pid || kill `cat pid`]) +cat stdout >> output +]) + AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], + [test ! -e pid || kill `cat pid`]) + OVSDB_SERVER_SHUTDOWN + AT_CLEANUP]) + +EXECUTION_EXAMPLES + +AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv4 sockets)]) AT_SETUP([ovsdb-client get-schema-version - tcp socket]) AT_KEYWORDS([ovsdb server positive tcp]) @@ -751,6 +800,56 @@ cat stdout >> output AT_CLEANUP]) EXECUTION_EXAMPLES + +AT_BANNER([OVSDB -- ovsdb-server transactions (TCP IPv6 sockets)]) + +AT_SETUP([ovsdb-client get-schema-version - tcp6 socket]) +AT_KEYWORDS([ovsdb server positive tcp6]) +ordinal_schema > schema +AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore]) +OVS_LOGDIR=`pwd`; export OVS_LOGDIR +AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --unixctl="`pwd`"/unixctl --remote=ptcp:0:::1 db], [0], [ignore], [ignore]) +TCP_PORT=`parse_ipv6_listening_port < ovsdb-server.log` +AT_CHECK([ovsdb-client get-schema-version tcp:::1:$TCP_PORT ordinals], [0], [5.1.3 +]) +OVSDB_SERVER_SHUTDOWN +AT_CLEANUP]) + +# OVSDB_CHECK_EXECUTION(TITLE, SCHEMA, TRANSACTIONS, OUTPUT, [KEYWORDS]) +# +# Creates a database with the given SCHEMA, starts an ovsdb-server on +# that database, and runs each of the TRANSACTIONS (which should be a +# quoted list of quoted strings) against it with ovsdb-client one at a +# time. +# +# Checks that the overall output is OUTPUT, but UUIDs in the output +# are replaced by markers of the form <N> where N is a number. The +# first unique UUID is replaced by <0>, the next by <1>, and so on. +# If a given UUID appears more than once it is always replaced by the +# same marker. +# +# TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. +m4_define([OVSDB_CHECK_EXECUTION], + [AT_SETUP([$1]) + AT_KEYWORDS([ovsdb server positive tcp6 $5]) + OVS_RUNDIR=`pwd`; export OVS_RUNDIR + OVS_LOGDIR=`pwd`; export OVS_LOGDIR + $2 > schema + PKIDIR=$abs_top_builddir/tests + AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) + AT_CHECK([ovsdb-server --log-file --detach --no-chdir --pidfile="`pwd`"/pid --remote=ptcp:0:::1 --unixctl="`pwd`"/unixctl db], [0], [ignore], [ignore]) + TCP_PORT=`parse_ipv6_listening_port < ovsdb-server.log` + m4_foreach([txn], [$3], + [AT_CHECK([ovsdb-client transact tcp:::1:$TCP_PORT 'txn'], [0], [stdout], [ignore], + [test ! -e pid || kill `cat pid`]) +cat stdout >> output +]) + AT_CHECK([${PERL} $srcdir/uuidfilt.pl output], [0], [$4], [ignore], + [test ! -e pid || kill `cat pid`]) + OVSDB_SERVER_SHUTDOWN + AT_CLEANUP]) + +EXECUTION_EXAMPLES AT_BANNER([OVSDB -- transactions on transient ovsdb-server]) @@ -771,13 +870,13 @@ AT_BANNER([OVSDB -- transactions on transient ovsdb-server]) # same marker. # # TITLE is provided to AT_SETUP and KEYWORDS to AT_KEYWORDS. -m4_define([OVSDB_CHECK_EXECUTION], +m4_define([OVSDB_CHECK_EXECUTION], [AT_SETUP([$1]) AT_KEYWORDS([ovsdb server positive transient $5]) OVS_RUNDIR=`pwd`; export OVS_RUNDIR $2 > schema AT_CHECK([ovsdb-tool create db schema], [0], [stdout], [ignore]) - m4_foreach([txn], [$3], + m4_foreach([txn], [$3], [AT_DATA([txnfile], [ovsdb-client transact unix:socket 'txn' ]) AT_CHECK([ovsdb-server --remote=punix:socket --unixctl="`pwd`"/unixctl db --run="sh txnfile"], [0], [stdout], [ignore]) -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev