diff options
8 files changed, 107 insertions, 65 deletions
diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml index 544118869..5032f3de3 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml @@ -3,13 +3,18 @@ # Measure IPV6 network latency using ping6 schema: "yardstick:task:0.1" +{% set openrc = openrc or "/opt/admin-openrc.sh" %} +{% set external_network = external_network or "ext-net" %} {% set pod_info = pod_info or "etc/yardstick/nodes/compass_sclab_physical/pod.yaml" %} scenarios: - type: Ping6 options: packetsize: 56 + ping_count: 5 host: host1,host2,host3,host4,host5 + openrc: {{openrc}} + external_network: {{external_network}} nodes: host1: node1.IPV6 host2: node2.IPV6 @@ -25,14 +30,9 @@ scenarios: max_rtt: 30 action: monitor -precondition: - installer_type: compass - deploy_scenarios: os-nosdn - pod_name: huawei-pod1 context: type: Node name: IPV6 file: {{pod_info}} - diff --git a/yardstick/benchmark/scenarios/networking/ping6.py b/yardstick/benchmark/scenarios/networking/ping6.py index 817f3e278..91183be25 100644 --- a/yardstick/benchmark/scenarios/networking/ping6.py +++ b/yardstick/benchmark/scenarios/networking/ping6.py @@ -37,9 +37,33 @@ class Ping6(base.Scenario): # pragma: no cover def __init__(self, scenario_cfg, context_cfg): self.scenario_cfg = scenario_cfg self.context_cfg = context_cfg + self.nodes = context_cfg['nodes'] + self.options = scenario_cfg['options'] self.setup_done = False self.run_done = False - self.ping_options = '' + self.external_network = self.options.get("external_network", "ext-net") + self.ping_options = "-s %s -c %s" % \ + (self.options.get("packetsize", '56'), + self.options.get("ping_count", '5')) + self.openrc = self.options.get("openrc", "/opt/admin-openrc.sh") + + def _ssh_host(self, node_name): + # ssh host + node = self.nodes.get(node_name, None) + user = node.get('user', 'ubuntu') + ip = node.get('ip', None) + pwd = node.get('password', None) + key_fname = node.get('key_filename', '/root/.ssh/id_rsa') + + if pwd is not None: + LOG.debug("Log in via pw, user:%s, host:%s, password:%s", + user, ip, pwd) + self.client = ssh.SSH(user, ip, password=pwd) + else: + LOG.debug("Log in via key, user:%s, host:%s, key_filename:%s", + user, ip, key_fname) + self.client = ssh.SSH(user, ip, key_filename=key_fname) + self.client.wait(timeout=60) def _pre_setup(self): for node_name in self.host_list: @@ -49,18 +73,6 @@ class Ping6(base.Scenario): # pragma: no cover status, stdout, stderr = self.client.execute( "sudo bash pre_setup.sh") - def _ssh_host(self, node_name): - # ssh host - print node_name - nodes = self.context_cfg['nodes'] - node = nodes.get(node_name, None) - host_user = node.get('user', 'ubuntu') - host_ip = node.get('ip', None) - host_pwd = node.get('password', 'root') - LOG.debug("user:%s, host:%s", host_user, host_ip) - self.client = ssh.SSH(host_user, host_ip, password=host_pwd) - self.client.wait(timeout=600) - def setup(self): '''scenario setup''' self.setup_script = pkg_resources.resource_filename( @@ -83,15 +95,10 @@ class Ping6(base.Scenario): # pragma: no cover 'yardstick.benchmark.scenarios.networking', Ping6.RADVD_SCRIPT) - options = self.scenario_cfg['options'] - self.ping_options = "-s %s" % \ - options.get("packetsize", '56') + \ - " -c %s" % \ - options.get("ping_count", '5') - host_str = options.get("host", 'host1') + host_str = self.options.get("host", 'host1') self.host_list = host_str.split(',') self.host_list.sort() - pre_setup = options.get("pre_setup", True) + pre_setup = self.options.get("pre_setup", True) if pre_setup: self._pre_setup() @@ -102,18 +109,20 @@ class Ping6(base.Scenario): # pragma: no cover stdin=open(self.ping6_metadata_script, "rb")) # run script to setup ipv6 with nosdn or odl - sdn = options.get("sdn", 'nosdn') + sdn = self.options.get("sdn", 'nosdn') if 'odl' in sdn: self.client.run("cat > ~/br-ex.radvd.conf", stdin=open(self.ping6_radvd_script, "rb")) self.client.run("cat > ~/setup_odl.sh", stdin=open(self.setup_odl_script, "rb")) - cmd = "sudo bash setup_odl.sh" + setup_bash_file = "setup_odl.sh" else: self.client.run("cat > ~/setup.sh", stdin=open(self.setup_script, "rb")) - cmd = "sudo bash setup.sh" - + setup_bash_file = "setup.sh" + cmd = "sudo bash %s %s %s" % \ + (setup_bash_file, self.openrc, self.external_network) + LOG.debug("Executing setup command: %s", cmd) status, stdout, stderr = self.client.execute(cmd) self.setup_done = True @@ -128,14 +137,8 @@ class Ping6(base.Scenario): # pragma: no cover self.ping6_find_host_script = pkg_resources.resource_filename( 'yardstick.benchmark.scenarios.networking', Ping6.FIND_HOST_SCRIPT) - if not self.setup_done: - options = self.scenario_cfg['options'] - self.ping_options = "-s %s" % \ - options.get("packetsize", '56') + \ - " -c %s" % \ - options.get("ping_count", '5') - host_str = options.get("host", 'host1') + host_str = self.options.get("host", 'host1') self.host_list = host_str.split(',') self.host_list.sort() self._ssh_host(self.host_list[0]) @@ -143,8 +146,8 @@ class Ping6(base.Scenario): # pragma: no cover # find ipv4-int-network1 to ssh VM self.client.run("cat > ~/find_host.sh", stdin=open(self.ping6_find_host_script, "rb")) - cmd = "sudo bash find_host.sh" - LOG.debug("Executing command: %s", cmd) + cmd = "sudo bash find_host.sh %s" % self.openrc + LOG.debug("Executing find_host command: %s", cmd) status, stdout, stderr = self.client.execute(cmd) host_name = stdout.strip() @@ -158,9 +161,8 @@ class Ping6(base.Scenario): # pragma: no cover # run ping6 benchmark self.client.run("cat > ~/ping6.sh", stdin=open(self.ping6_script, "rb")) - cmd_args = "%s" % (self.ping_options) - cmd = "sudo bash ping6.sh %s" % (cmd_args) - LOG.debug("Executing command: %s", cmd) + cmd = "sudo bash ping6.sh %s %s" % (self.openrc, self.ping_options) + LOG.debug("Executing ping6 command: %s", cmd) status, stdout, stderr = self.client.execute(cmd) if status: @@ -174,7 +176,7 @@ class Ping6(base.Scenario): # pragma: no cover assert result["rtt"] <= sla_max_rtt, \ "rtt %f > sla:max_rtt(%f); " % (result["rtt"], sla_max_rtt) else: - LOG.error("ping6 timeout") + LOG.error("ping6 timeout!!!") self.run_done = True def teardown(self): @@ -184,8 +186,7 @@ class Ping6(base.Scenario): # pragma: no cover 'yardstick.benchmark.scenarios.networking', Ping6.POST_TEARDOWN_SCRIPT) - options = self.scenario_cfg['options'] - host_str = options.get("host", 'node1') + host_str = self.options.get("host", 'node1') self.host_list = host_str.split(',') self.host_list.sort() @@ -197,10 +198,11 @@ class Ping6(base.Scenario): # pragma: no cover Ping6.TEARDOWN_SCRIPT) self.client.run("cat > ~/teardown.sh", stdin=open(self.teardown_script, "rb")) - cmd = "sudo bash teardown.sh" + cmd = "sudo bash teardown.sh %s %s" % \ + (self.openrc, self.external_network) status, stdout, stderr = self.client.execute(cmd) - post_teardown = options.get("post_teardown", True) + post_teardown = self.options.get("post_teardown", True) if post_teardown: self._post_teardown() diff --git a/yardstick/benchmark/scenarios/networking/ping6_benchmark.bash b/yardstick/benchmark/scenarios/networking/ping6_benchmark.bash index bf730eb65..a50e01f65 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_benchmark.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_benchmark.bash @@ -11,13 +11,18 @@ # Run a single ping6 command towards a ipv6 router set -e +openrc=$1 +source $openrc +shift ping6_options=$* -source /opt/admin-openrc.sh chmod 600 vRouterKey + # TODO find host +vm1_ip=$(nova list|grep VM1 | awk -F [=] '{print $2}' | awk '{print $1}') +# echo "vm1_ip=$vm1_ip" wait_vm_ok() { retry=0 - until timeout 100s sudo ip netns exec qdhcp-$(neutron net-list | grep -w ipv4-int-network1 | awk '{print $2}') ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i vRouterKey fedora@20.0.0.4 "exit" >/dev/null 2>&1 + until timeout 100s sudo ip netns exec qdhcp-$(neutron net-list | grep -w ipv4-int-network1 | awk '{print $2}') ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i vRouterKey fedora@$vm1_ip "exit" >/dev/null 2>&1 do sleep 10 let retry+=1 @@ -30,4 +35,4 @@ wait_vm_ok() { } wait_vm_ok sleep 360 -sudo ip netns exec qdhcp-$(neutron net-list | grep -w ipv4-int-network1 | awk '{print $2}') ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i vRouterKey fedora@20.0.0.4 "ping6 $ping6_options 2001:db8:0:1::1 | grep rtt | awk -F [\/\ ] '{printf \$8}'" +sudo ip netns exec qdhcp-$(neutron net-list | grep -w ipv4-int-network1 | awk '{print $2}') ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i vRouterKey fedora@$vm1_ip "ping6 $ping6_options 2001:db8:0:1::1 | grep rtt | awk -F [\/\ ] '{printf \$8}'" diff --git a/yardstick/benchmark/scenarios/networking/ping6_find_host.bash b/yardstick/benchmark/scenarios/networking/ping6_find_host.bash index 85c4b3898..db8dbe881 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_find_host.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_find_host.bash @@ -8,7 +8,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - -source /opt/admin-openrc.sh -host_num=$(neutron dhcp-agent-list-hosting-net ipv4-int-network1 | grep True | awk -F [=\ ] '{printf $4}') > /tmp/ipv6.log -echo $host_num
\ No newline at end of file +openrc=$* +source $openrc +host_num=$(neutron dhcp-agent-list-hosting-net ipv4-int-network1 | grep True | head -1 | awk -F [=\ ] '{printf $4}' | grep -o '[0-9]\+') > /tmp/ipv6.log +echo "host$host_num" diff --git a/yardstick/benchmark/scenarios/networking/ping6_pre_setup.bash b/yardstick/benchmark/scenarios/networking/ping6_pre_setup.bash index e790a0784..d50a800d7 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_pre_setup.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_pre_setup.bash @@ -9,9 +9,32 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -cp /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugins/ml2/ml2_conf.ini_bkp -sed -i '83a prevent_arp_spoofing = False' /etc/neutron/plugins/ml2/ml2_conf.ini -sed -i 's/firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver/firewall_driver= neutron.agent.firewall.NoopFirewallDriver/g' /etc/neutron/plugins/ml2/ml2_conf.ini + +ML2_CONF_FILE="/etc/neutron/plugins/ml2/ml2_conf.ini" +NOVA_CONF_FILE="/etc/nova/nova.conf" + +cp $ML2_CONF_FILE ${ML2_CONF_FILE}_bkp + +agent_line_num=$(grep -n '\[agent\]' $ML2_CONF_FILE | awk -F [:] '{print $1}') +if [ -z "$agent_line_num" ] +then + echo "[agent]" >> ml2_conf.ini + agent_line_num=$(wc -l ml2_conf.ini | awk '{print $1}') +fi +sed -i "${agent_line_num}a prevent_arp_spoofing = False" $ML2_CONF_FILE + +sed -i 's/firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver/firewall_driver= neutron.agent.firewall.NoopFirewallDriver/g' $ML2_CONF_FILE + +#check parameters +echo "check if parameters ok" +echo $ML2_CONF_FILE +grep 'enable_security_group = True' $ML2_CONF_FILE +grep 'extension_drivers = port_security' $ML2_CONF_FILE +grep 'prevent_arp_spoofing = False' $ML2_CONF_FILE +echo $NOVA_CONF_FILE +grep 'security_group_api = neutron' $NOVA_CONF_FILE +grep 'firewall_driver = nova.virt.firewall.NoopFirewallDriver' $NOVA_CONF_FILE +echo "check parameters end" # restart nova and neutron service service neutron-l3-agent restart diff --git a/yardstick/benchmark/scenarios/networking/ping6_setup.bash b/yardstick/benchmark/scenarios/networking/ping6_setup.bash index 267fb3ee9..f02dfa8ba 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_setup.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_setup.bash @@ -11,7 +11,11 @@ # download and create image -source /opt/admin-openrc.sh +openrc=$1 +external_network=$2 +echo "openrc=$openrc" +echo "external_network=$external_network" +source $openrc wget https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-22-20150521.x86_64.qcow2 >/dev/null 2>&1 glance image-create --name 'Fedora22' --disk-format qcow2 \ @@ -33,8 +37,8 @@ neutron subnet-create --name ipv4-int-subnet1 \ neutron router-interface-add ipv4-router ipv4-int-subnet1 # Associate the net04_ext to the Neutron routers -neutron router-gateway-set ipv6-router ext-net -neutron router-gateway-set ipv4-router ext-net +neutron router-gateway-set ipv6-router $external_network +neutron router-gateway-set ipv4-router $external_network # Create two subnets, one IPv4 subnet ipv4-int-subnet2 and # one IPv6 subnet ipv6-int-subnet2 in ipv6-int-network2, and associate both subnets to ipv6-router diff --git a/yardstick/benchmark/scenarios/networking/ping6_setup_with_odl.bash b/yardstick/benchmark/scenarios/networking/ping6_setup_with_odl.bash index f9a2c4094..21566d2aa 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_setup_with_odl.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_setup_with_odl.bash @@ -11,7 +11,11 @@ # need to debug # download and create image -source /opt/admin-openrc.sh +openrc=$1 +external_network=$2 +echo "openrc=$openrc" +echo "external_network=$external_network" +source $openrc wget https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-22-20150521.x86_64.qcow2 glance image-create --name 'Fedora22' --disk-format qcow2 \ --container-format bare --file ./Fedora-Cloud-Base-22-20150521.x86_64.qcow2 @@ -21,8 +25,8 @@ neutron router-create ipv4-router neutron router-create ipv6-router # Associate the net04_ext to the Neutron routers -neutron router-gateway-set ipv6-router ext-net -neutron router-gateway-set ipv4-router ext-net +neutron router-gateway-set ipv6-router $external_network +neutron router-gateway-set ipv4-router $external_network # create two ipv4 networks with associated subnets neutron net-create ipv4-int-network1 diff --git a/yardstick/benchmark/scenarios/networking/ping6_teardown.bash b/yardstick/benchmark/scenarios/networking/ping6_teardown.bash index 33eff5ca7..2fe3ef2fb 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_teardown.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_teardown.bash @@ -8,7 +8,11 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -source /opt/admin-openrc.sh +openrc=$1 +echo "openrc=$openrc" +source $openrc +external_network=$2 +echo "external_network=$external_network" # delete VM nova delete VM1 nova delete VM2 @@ -36,8 +40,8 @@ neutron subnet-delete --name ipv6-int-subnet2 neutron subnet-delete --name ipv4-int-subnet2 #clear gateway -neutron router-gateway-clear ipv4-router ext-net -neutron router-gateway-clear ipv6-router ext-net +neutron router-gateway-clear ipv4-router $external_network +neutron router-gateway-clear ipv6-router $external_network #delete ipv4 router interface neutron router-interface-delete ipv4-router ipv4-int-subnet1 |