From f0e9c6f92d5360173ef89491043a76f703f4154a Mon Sep 17 00:00:00 2001 From: Glen Gibb Date: Thu, 4 Mar 2010 17:34:59 -0800 Subject: [PATCH] regress: Provide support for testing Open vSwitch Change submitted by: Jean Tourrilhes --- regress/bin/of_ovs_eth.map | 8 ++++ regress/bin/of_ovs_setup.pl | 61 ++++++++++++++++++++++++++++ regress/bin/of_ovs_teardown.pl | 59 +++++++++++++++++++++++++++ regress/bin/of_ovs_test.pl | 51 +++++++++++++++++++++++ regress/bin/of_ovs_user_setup.pl | 58 ++++++++++++++++++++++++++ regress/bin/of_ovs_user_teardown.pl | 34 ++++++++++++++++ regress/bin/of_ovs_user_test.pl | 44 ++++++++++++++++++++ regress/bin/of_ovs_user_veth_test.pl | 41 +++++++++++++++++++ regress/bin/of_ovs_veth_test.pl | 44 ++++++++++++++++++++ regress/scripts/env_vars | 2 + 10 files changed, 402 insertions(+) create mode 100644 regress/bin/of_ovs_eth.map create mode 100755 regress/bin/of_ovs_setup.pl create mode 100755 regress/bin/of_ovs_teardown.pl create mode 100755 regress/bin/of_ovs_test.pl create mode 100755 regress/bin/of_ovs_user_setup.pl create mode 100755 regress/bin/of_ovs_user_teardown.pl create mode 100755 regress/bin/of_ovs_user_test.pl create mode 100755 regress/bin/of_ovs_user_veth_test.pl create mode 100755 regress/bin/of_ovs_veth_test.pl diff --git a/regress/bin/of_ovs_eth.map b/regress/bin/of_ovs_eth.map new file mode 100644 index 0000000..120ee51 --- /dev/null +++ b/regress/bin/of_ovs_eth.map @@ -0,0 +1,8 @@ +eth1:eth10.91 +eth2:eth10.92 +eth3:eth10.93 +eth4:eth10.94 +eth5:eth11.91 +eth6:eth11.92 +eth7:eth11.93 +eth8:eth11.94 diff --git a/regress/bin/of_ovs_setup.pl b/regress/bin/of_ovs_setup.pl new file mode 100755 index 0000000..7519833 --- /dev/null +++ b/regress/bin/of_ovs_setup.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl -w +# Jean Tourrilhes - HP-Labs + +use Getopt::Long; + +use OF::OFUtil; +use Test::TestLib; + +my $mapFile; + +# The map file is necessary. It assing the real interface to the +# fictious names used by the test suite. +# eth1->eth4 are capture interfaces used to send/receive probe packets +# eth5->eth8 are configured to run the OpenFlow switch +# Jean II + +# Process command line options +unless ( GetOptions( "map=s" => \$mapFile, ) ) { + print "unrecognized option\n"; + exit 1; +} + +# If not specified on command line, use enviroment variable. +# Try specific first, then try generic - Jean II +if ( (! defined($mapFile) ) && (defined($ENV{'OFT_OVS_MAP_ETH'})) ) { + $mapFile = "$ENV{OFT_OVS_MAP_ETH}"; +} +if ( (! defined($mapFile) ) && (defined($ENV{'OFT_MAP_ETH'})) ) { + $mapFile = "$ENV{OFT_MAP_ETH}"; +} + +# Set up the mappings +if ( defined($mapFile) ) { + nftest_process_iface_map($mapFile); +} + +# Debug... +#for ( my $i = 1 ; $i <= 8 ; $i++ ) { +# my $iface = nftest_get_iface("eth$i"); +# print "iface($i) = $iface\n"; +#} + +# Start capturing on eth1->eth4 +setup_pcap_interfaces(); + +# Get the directly where Open vSwitch resides +my $ovs_dir = $ENV{'OFT_OVS_ROOT'}; +my $of_port = get_of_port(); + +# create Open vSwitch openflow switch on four ports eth5->eth9 +`insmod ${ovs_dir}/datapath/linux-2.6/openvswitch_mod.ko`; +`${ovs_dir}/utilities/ovs-dpctl add-dp dp0`; + +for ( my $i = 5 ; $i <= 8 ; $i++ ) { + my $iface = nftest_get_iface("eth$i"); + `${ovs_dir}/utilities/ovs-dpctl add-if dp0 $iface`; +} + +# Up to 0.90.6, you would use secchan, after that you need to use ovs-openflowd +#system("${ovs_dir}/secchan/secchan dp0 tcp:127.0.0.1:${of_port} --listen=ptcp:6634 --fail=closed --inactivity-probe=999999 &"); +system("${ovs_dir}/utilities/ovs-openflowd dp0 tcp:127.0.0.1:${of_port} --listen=ptcp:6634 --fail=closed --inactivity-probe=999999 &"); diff --git a/regress/bin/of_ovs_teardown.pl b/regress/bin/of_ovs_teardown.pl new file mode 100755 index 0000000..303eb4a --- /dev/null +++ b/regress/bin/of_ovs_teardown.pl @@ -0,0 +1,59 @@ +#!/usr/bin/perl -w +# Jean Tourrilhes - HP-Labs + +use Getopt::Long; + +use OF::OFUtil; +use Test::TestLib; + +my $mapFile; + +# Process command line options +unless ( GetOptions( "map=s" => \$mapFile, ) ) { + print "unrecognized option\n"; + exit 1; +} + +# If not specified on command line, use enviroment variable. +# Try specific first, then try generic - Jean II +if ( (! defined($mapFile) ) && (defined($ENV{'OFT_OVS_MAP_ETH'})) ) { + $mapFile = "$ENV{OFT_OVS_MAP_ETH}"; +} +if ( (! defined($mapFile) ) && (defined($ENV{'OFT_MAP_ETH'})) ) { + $mapFile = "$ENV{OFT_MAP_ETH}"; +} + +if ( defined($mapFile) ) { + nftest_process_iface_map($mapFile); +} + +# Get the directly where Open vSwitch resides +my $ovs_dir = $ENV{'OFT_OVS_ROOT'}; + +# Start by killing secchan or ovs-openflowd +`killall secchan`; +`killall ovs-openflowd`; + +# check if openflow kernel module loaded +my $of_kmod_loaded = `lsmod | grep openvswitch_mod`; +if ( $of_kmod_loaded eq "" ) { exit 0; } + +print "tearing down interfaces and datapaths\n"; + +# remove interfaces from openflow +for ( my $i = 5 ; $i <= 8 ; $i++ ) { + my $iface = nftest_get_iface("eth$i"); + `${ovs_dir}/utilities/ovs-dpctl del-if dp0 $iface`; +} + +`${ovs_dir}/utilities/ovs-dpctl del-dp dp0`; + +my $of_kmod_removed = `rmmod openvswitch_mod`; +if ( $of_kmod_removed ne "" ) { + die "failed to remove kernel module... please fix!\n"; +} + +$of_kmod_loaded = `lsmod | grep openvswitch_mod`; +if ( $of_kmod_loaded ne "" ) { + die "failed to remove kernel module... please fix!\n"; +} diff --git a/regress/bin/of_ovs_test.pl b/regress/bin/of_ovs_test.pl new file mode 100755 index 0000000..2aa4241 --- /dev/null +++ b/regress/bin/of_ovs_test.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl -w + +############################################################################## +# +# Wrapper for running OpenFlow regression tests against Open vSwitch +# Jean Tourrilhes - HP-Labs - copyright 2009-2010 +# $Id: of_regress_test.pl 105 2008-06-06 04:07:05Z brandonh $ +# +############################################################################## + +use OF::Base; +use Test::RegressTest; +use strict; +use OF::OFUtil; + +# check vars are set. +check_OF_vars_set(); + +sub INT_Handler { + my $signame = shift; + print "\nNo interrupt handler implemented yet...\n"; + print "\nExited with SIG$signame\n"; + exit(1); +} + +# For Open vSwitch + +# Open vSwitch starts at port 1 +# Get a bit of speedup by tweaking send_delay and base_idle +# Jean II +my $of_port = get_of_port(); +push @ARGV, "--root=$ENV{'OFT_ROOT'}", "--common-st-args=ovs", "--controller=tcp:localhost:$of_port,tcp:localhost:$of_port", "--listener=tcp:127.0.0.1:6634", "--port_base=1", "--send_delay=2000", "--base_idle=2"; + +# Use a single random port instead of all four +push @ARGV, "--less_ports"; + +# Don't bother with VLAN if we go outside the box, too many issues... +#push @ARGV, "--no_vlan"; + +# Don't bother with QoS currently, it's broken... +push @ARGV, "--no_slicing"; + +# Don't forget to configure the OVS_ROOT environment variable +# Jean II + +# Check for specific MAP file... +if ( defined($ENV{'OFT_OVS_MAP_ETH'}) ) { + push @ARGV, "--map=$ENV{OFT_OVS_MAP_ETH}"; +} + +run_regress_test( \&INT_Handler, @ARGV ); diff --git a/regress/bin/of_ovs_user_setup.pl b/regress/bin/of_ovs_user_setup.pl new file mode 100755 index 0000000..91eee12 --- /dev/null +++ b/regress/bin/of_ovs_user_setup.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl -w +# Jean Tourrilhes - HP-Labs + +use Getopt::Long; + +use OF::OFUtil; +use Test::TestLib; + +my $mapFile; + +# The map file is necessary. It assing the real interface to the +# fictious names used by the test suite. +# eth1->eth4 are capture interfaces used to send/receive probe packets +# eth5->eth8 are configured to run the OpenFlow switch +# Jean II + +# Process command line options +unless ( GetOptions( "map=s" => \$mapFile, ) ) { + print "unrecognized option\n"; + exit 1; +} + +# If not specified on command line, use enviroment variable. +# Try specific first, then try generic - Jean II +if ( (! defined($mapFile) ) && (defined($ENV{'OFT_OVS_MAP_ETH'})) ) { + $mapFile = "$ENV{OFT_OVS_MAP_ETH}"; +} +if ( (! defined($mapFile) ) && (defined($ENV{'OFT_MAP_ETH'})) ) { + $mapFile = "$ENV{OFT_MAP_ETH}"; +} + +# Set up the mappings +if ( defined($mapFile) ) { + nftest_process_iface_map($mapFile); +} + +# Debug... +#for ( my $i = 1 ; $i <= 8 ; $i++ ) { +# my $iface = nftest_get_iface("eth$i"); +# print "iface($i) = $iface\n"; +#} + +# Start capturing on eth1->eth4 +setup_pcap_interfaces(); + +# Get the directly where Open vSwitch resides +my $ovs_dir = $ENV{'OFT_OVS_ROOT'}; +my $of_port = get_of_port(); + +# create command line arguments containing all four ports +my $if_string = ''; +for ( my $i = 5 ; $i <= 7 ; $i++ ) { + $if_string .= nftest_get_iface("eth$i") . ','; +} +$if_string .= nftest_get_iface("eth8"); + +# create userspace Open vSwitch openflow switch on four ports +system("${ovs_dir}/utilities/ovs-openflowd netdev:br0 --ports=${if_string} tcp:127.0.0.1:${of_port} --listen=ptcp:6634 --fail=closed --inactivity-probe=999999 &"); diff --git a/regress/bin/of_ovs_user_teardown.pl b/regress/bin/of_ovs_user_teardown.pl new file mode 100755 index 0000000..8112462 --- /dev/null +++ b/regress/bin/of_ovs_user_teardown.pl @@ -0,0 +1,34 @@ +#!/usr/bin/perl -w +# Jean Tourrilhes - HP-Labs + +use Getopt::Long; + +use OF::OFUtil; +use Test::TestLib; + +my $mapFile; + +# Process command line options +unless ( GetOptions( "map=s" => \$mapFile, ) ) { + print "unrecognized option\n"; + exit 1; +} + +# If not specified on command line, use enviroment variable. +# Try specific first, then try generic - Jean II +if ( (! defined($mapFile) ) && (defined($ENV{'OFT_OVS_MAP_ETH'})) ) { + $mapFile = "$ENV{OFT_OVS_MAP_ETH}"; +} +if ( (! defined($mapFile) ) && (defined($ENV{'OFT_MAP_ETH'})) ) { + $mapFile = "$ENV{OFT_MAP_ETH}"; +} + +if ( defined($mapFile) ) { + nftest_process_iface_map($mapFile); +} + +# Get the directly where Open vSwitch resides +my $ovs_dir = $ENV{'OFT_OVS_ROOT'}; + +# Just kill ovs-openflowd +`killall ovs-openflowd`; diff --git a/regress/bin/of_ovs_user_test.pl b/regress/bin/of_ovs_user_test.pl new file mode 100755 index 0000000..5f1d20b --- /dev/null +++ b/regress/bin/of_ovs_user_test.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl -w + +############################################################################## +# +# Wrapper for OpenFlow regression tests +# $Id: of_regress_test.pl 105 2008-06-06 04:07:05Z brandonh $ +# +############################################################################## + +use OF::Base; +use Test::RegressTest; +use strict; +use OF::OFUtil; + +# check vars are set. +check_OF_vars_set(); + +sub INT_Handler { + my $signame = shift; + print "\nNo interrupt handler implemented yet...\n"; + print "\nExited with SIG$signame\n"; + exit(1); +} + +# For Open vSwitch + +# Open vSwitch starts at port 1 +# Get a bit of speedup by tweaking send_delay and base_idle +# Jean II +my $of_port = get_of_port(); +push @ARGV, "--root=$ENV{'OFT_ROOT'}", "--common-st-args=ovs_user", "--controller=tcp:localhost:$of_port,tcp:localhost:$of_port", "--listener=tcp:127.0.0.1:6634", "--port_base=1", "--send_delay=2000", "--base_idle=2"; + +# Use a single random port instead of all four +push @ARGV, "--less_ports"; + +# Don't forget to configure the OVS_ROOT environment variable +# Jean II + +# Check for specific MAP file... +if ( defined($ENV{'OFT_OVS_MAP_ETH'}) ) { + push @ARGV, "--map=$ENV{OFT_OVS_MAP_ETH}"; +} + +run_regress_test( \&INT_Handler, @ARGV ); diff --git a/regress/bin/of_ovs_user_veth_test.pl b/regress/bin/of_ovs_user_veth_test.pl new file mode 100755 index 0000000..8bd2488 --- /dev/null +++ b/regress/bin/of_ovs_user_veth_test.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl -w + +############################################################################## +# +# Wrapper for running OpenFlow regression tests against Open vSwitch +# using veth +# Jean Tourrilhes - HP-Labs - copyright 2009-2010 +# $Id: of_regress_test.pl 105 2008-06-06 04:07:05Z brandonh $ +# +############################################################################## + +use OF::Base; +use Test::RegressTest; +use strict; +use OF::OFUtil; + +# check vars are set. +check_OF_vars_set(); + +sub INT_Handler { + my $signame = shift; + print "\nNo interrupt handler implemented yet...\n"; + print "\nExited with SIG$signame\n"; + exit(1); +} + +# For Open vSwitch + +# Open vSwitch starts at port 1 +# Get a bit of speedup by tweaking send_delay and base_idle +# Jean II +my $of_port = get_of_port(); +push @ARGV, "--root=$ENV{'OFT_ROOT'}", "--common-st-args=ovs_user", "--controller=tcp:localhost:$of_port,tcp:localhost:$of_port", "--listener=tcp:127.0.0.1:6634", "--port_base=1", "--send_delay=2000", "--base_idle=2", "--map=$ENV{'OFT_ROOT'}/bin/veth.map"; + +# Use a single random port instead of all four +push @ARGV, "--less_ports"; + +# Don't forget to configure the OVS_ROOT environment variable +# Jean II + +run_regress_test( \&INT_Handler, @ARGV ); diff --git a/regress/bin/of_ovs_veth_test.pl b/regress/bin/of_ovs_veth_test.pl new file mode 100755 index 0000000..7a56e1c --- /dev/null +++ b/regress/bin/of_ovs_veth_test.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl -w + +############################################################################## +# +# Wrapper for running OpenFlow regression tests against Open vSwitch +# using veth +# Jean Tourrilhes - HP-Labs - copyright 2009-2010 +# $Id: of_regress_test.pl 105 2008-06-06 04:07:05Z brandonh $ +# +############################################################################## + +use OF::Base; +use Test::RegressTest; +use strict; +use OF::OFUtil; + +# check vars are set. +check_OF_vars_set(); + +sub INT_Handler { + my $signame = shift; + print "\nNo interrupt handler implemented yet...\n"; + print "\nExited with SIG$signame\n"; + exit(1); +} + +# For Open vSwitch + +# Open vSwitch starts at port 1 +# Get a bit of speedup by tweaking send_delay and base_idle +# Jean II +my $of_port = get_of_port(); +push @ARGV, "--root=$ENV{'OFT_ROOT'}", "--common-st-args=ovs", "--controller=tcp:localhost:$of_port,tcp:localhost:$of_port", "--listener=tcp:127.0.0.1:6634", "--port_base=1", "--send_delay=2000", "--base_idle=2", "--map=$ENV{'OFT_ROOT'}/bin/veth.map"; + +# Use a single random port instead of all four +push @ARGV, "--less_ports"; + +# Don't bother with QoS currently, it's broken... +push @ARGV, "--no_slicing"; + +# Don't forget to configure the OVS_ROOT environment variable +# Jean II + +run_regress_test( \&INT_Handler, @ARGV ); diff --git a/regress/scripts/env_vars b/regress/scripts/env_vars index 99afa82..a8f2433 100644 --- a/regress/scripts/env_vars +++ b/regress/scripts/env_vars @@ -8,3 +8,5 @@ export OFT_HP_SWITCH_IP=10.10.10.2 export OFT_HP_VLAN=10 export OFT_HP_CONTROLLER="tcp:10.10.10.3:6633" export OFT_HP_LISTENER="tcp:10.10.10.2:6633" +export OFT_OVS_ROOT=/home/yourname/openvswitch +export OFT_OVS_MAP_ETH=${OFT_ROOT}/bin/of_ovs_eth.map