From b111866af4a311ef965443499bf46505f2c2a22a Mon Sep 17 00:00:00 2001 From: kubi Date: Fri, 15 Jan 2016 19:40:28 +0800 Subject: fix some bug in ipv6 to make it run in ci JIRA:YARDSTICK-187 Change-Id: Ia15d17afdef145f7b230a8a4d25a61eed5cdfd76 Signed-off-by: kubi --- yardstick/benchmark/scenarios/networking/ping6.py | 84 +++++++++++++++++++--- .../scenarios/networking/ping6_benchmark.bash | 24 +++++-- .../scenarios/networking/ping6_find_host.bash | 15 ++++ .../scenarios/networking/ping6_post_teardown.bash | 26 +++++++ .../scenarios/networking/ping6_pre_setup.bash | 28 ++++++++ .../scenarios/networking/ping6_setup.bash | 10 +-- .../scenarios/networking/ping6_teardown.bash | 11 ++- yardstick/cmd/commands/task.py | 0 8 files changed, 167 insertions(+), 31 deletions(-) create mode 100644 yardstick/benchmark/scenarios/networking/ping6_find_host.bash create mode 100644 yardstick/benchmark/scenarios/networking/ping6_post_teardown.bash create mode 100644 yardstick/benchmark/scenarios/networking/ping6_pre_setup.bash mode change 100755 => 100644 yardstick/cmd/commands/task.py (limited to 'yardstick') diff --git a/yardstick/benchmark/scenarios/networking/ping6.py b/yardstick/benchmark/scenarios/networking/ping6.py index 5d878eb8f..067b8893e 100644 --- a/yardstick/benchmark/scenarios/networking/ping6.py +++ b/yardstick/benchmark/scenarios/networking/ping6.py @@ -25,9 +25,12 @@ class Ping6(base.Scenario): # pragma: no cover __scenario_type__ = "Ping6" TARGET_SCRIPT = 'ping6_benchmark.bash' + PRE_SETUP_SCRIPT = 'ping6_pre_setup.bash' SETUP_SCRIPT = 'ping6_setup.bash' + FIND_HOST_SCRIPT = 'ping6_find_host.bash' TEARDOWN_SCRIPT = 'ping6_teardown.bash' METADATA_SCRIPT = 'ping6_metadata.txt' + POST_TEARDOWN_SCRIPT = 'ping6_post_teardown.bash' def __init__(self, scenario_cfg, context_cfg): self.scenario_cfg = scenario_cfg @@ -35,13 +38,23 @@ class Ping6(base.Scenario): # pragma: no cover self.setup_done = False self.run_done = False - def _ssh_host(self): - # ssh host1 - host = self.context_cfg['host'] - host_user = host.get('user', 'ubuntu') - host_ip = host.get('ip', None) - host_pwd = host.get('password', 'root') - LOG.info("user:%s, host:%s", host_user, host_ip) + def _pre_setup(self): + for node_name in self.host_list: + self._ssh_host(node_name) + self.client.run("cat > ~/pre_setup.sh", + stdin=open(self.pre_setup_script, "rb")) + 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) @@ -51,11 +64,24 @@ class Ping6(base.Scenario): # pragma: no cover 'yardstick.benchmark.scenarios.networking', Ping6.SETUP_SCRIPT) + self.pre_setup_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + Ping6.PRE_SETUP_SCRIPT) + self.ping6_metadata_script = pkg_resources.resource_filename( 'yardstick.benchmark.scenarios.networking', Ping6.METADATA_SCRIPT) + + options = self.scenario_cfg['options'] + host_str = options.get("host", 'host1') + self.host_list = host_str.split(',') + self.host_list.sort() + pre_setup = options.get("pre_setup", True) + if pre_setup: + self._pre_setup() + # ssh host1 - self._ssh_host() + self._ssh_host(self.host_list[0]) # run script to setup ipv6 self.client.run("cat > ~/setup.sh", stdin=open(self.setup_script, "rb")) @@ -73,9 +99,24 @@ class Ping6(base.Scenario): # pragma: no cover 'yardstick.benchmark.scenarios.networking', Ping6.TARGET_SCRIPT) - if not self.setup_done: - self._ssh_host() + 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'] + host_str = options.get("host", 'host1') + self.host_list = host_str.split(',') + self.host_list.sort() + self._ssh_host(self.host_list[0]) + 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) + status, stdout, stderr = self.client.execute(cmd) + host_name = stdout.strip() + print host_name + self._ssh_host(host_name) self.client.run("cat > ~/ping6.sh", stdin=open(self.ping6_script, "rb")) cmd = "sudo bash ping6.sh" @@ -99,8 +140,17 @@ class Ping6(base.Scenario): # pragma: no cover def teardown(self): """teardown the benchmark""" + self.post_teardown_script = pkg_resources.resource_filename( + 'yardstick.benchmark.scenarios.networking', + Ping6.POST_TEARDOWN_SCRIPT) + + options = self.scenario_cfg['options'] + host_str = options.get("host", 'node1') + self.host_list = host_str.split(',') + self.host_list.sort() + if not self.run_done: - self._ssh_host() + self._ssh_host(self.host_list[0]) self.teardown_script = pkg_resources.resource_filename( 'yardstick.benchmark.scenarios.networking', @@ -110,6 +160,10 @@ class Ping6(base.Scenario): # pragma: no cover cmd = "sudo bash teardown.sh" status, stdout, stderr = self.client.execute(cmd) + post_teardown = options.get("post_teardown", True) + if post_teardown: + self._post_teardown() + if status: raise RuntimeError(stderr) @@ -117,3 +171,11 @@ class Ping6(base.Scenario): # pragma: no cover pass else: LOG.error("ping6 teardown failed") + + def _post_teardown(self): + for node_name in self.host_list: + self._ssh_host(node_name) + self.client.run("cat > ~/post_teardown.sh", + stdin=open(self.post_teardown_script, "rb")) + status, stdout, stderr = self.client.execute( + "sudo bash post_teardown.sh") diff --git a/yardstick/benchmark/scenarios/networking/ping6_benchmark.bash b/yardstick/benchmark/scenarios/networking/ping6_benchmark.bash index 6df354a1b..bd02be76e 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_benchmark.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_benchmark.bash @@ -10,11 +10,23 @@ ############################################################################## # Run a single ping6 command towards a ipv6 router - set -e - +source /opt/admin-openrc.sh +chmod 600 vRouterKey # TODO find host -sudo ip netns exec qdhcp-$(neutron net-list | grep -w ipv4-int-network1 | awk '{print $2}') bash -# TODO find VM ip -ssh -i vRouterkey fedora@20.0.0.4 -ping6 -c 1 2001:db8:0:1::1 | grep ttl | awk -F [=\ ] '{printf $10}' +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 + do + sleep 10 + let retry+=1 + if [ $retry -ge 40 ]; + then + echo "vm ssh start timeout !!!" + exit 0 + fi + done +} +wait_vm_ok +sleep 600 +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 -c 1 2001:db8:0:1::1 | grep ttl | awk -F [=\ ] '{printf \$10}'" diff --git a/yardstick/benchmark/scenarios/networking/ping6_find_host.bash b/yardstick/benchmark/scenarios/networking/ping6_find_host.bash new file mode 100644 index 000000000..a1d50d418 --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/ping6_find_host.bash @@ -0,0 +1,15 @@ +#!/bin/bash + +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# 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 +scp vRouterKey $host_num:~ +echo $host_num \ No newline at end of file diff --git a/yardstick/benchmark/scenarios/networking/ping6_post_teardown.bash b/yardstick/benchmark/scenarios/networking/ping6_post_teardown.bash new file mode 100644 index 000000000..f40d47d64 --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/ping6_post_teardown.bash @@ -0,0 +1,26 @@ +#!/bin/bash + +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +sed -i 's/enable_security_group= False/enable_security_group = True/g' /etc/neutron/plugins/ml2/ml2_conf.ini +sed -i 3d /etc/neutron/plugins/ml2/ml2_conf.ini +sed -i 's/firewall_driver= neutron.agent.firewall.NoopFirewallDriver/firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver/g' /etc/neutron/plugins/ml2/ml2_conf.ini +sed -i 's/security_group_api= nova/security_group_api = neutron/g' /etc/nova/nova.conf + +service neutron-l3-agent restart +service neutron-dhcp-agent restart +service neutron-metadata-agent restart +service neutron-server restart +service nova-api restart +service nova-cert restart +service nova-conductor restart +service nova-consoleauth restart +service nova-novncproxy restart +service nova-scheduler restart +service nova-compute restart \ No newline at end of file diff --git a/yardstick/benchmark/scenarios/networking/ping6_pre_setup.bash b/yardstick/benchmark/scenarios/networking/ping6_pre_setup.bash new file mode 100644 index 000000000..4a781d21e --- /dev/null +++ b/yardstick/benchmark/scenarios/networking/ping6_pre_setup.bash @@ -0,0 +1,28 @@ +#!/bin/bash + +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +sed -i 's/enable_security_group = True/enable_security_group= False/g' /etc/neutron/plugins/ml2/ml2_conf.ini +sed -i '2a extension_drivers = port_security' /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 +sed -i 's/security_group_api = neutron/security_group_api= nova/g' /etc/nova/nova.conf + + +service neutron-l3-agent restart +service neutron-dhcp-agent restart +service neutron-metadata-agent restart +service neutron-server restart +service nova-api restart +service nova-cert restart +service nova-conductor restart +service nova-consoleauth restart +service nova-novncproxy restart +service nova-scheduler restart +service nova-compute restart diff --git a/yardstick/benchmark/scenarios/networking/ping6_setup.bash b/yardstick/benchmark/scenarios/networking/ping6_setup.bash index 2a54da2ba..ddb6c1cd9 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_setup.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_setup.bash @@ -9,17 +9,13 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## + # download and create image source /opt/admin-openrc.sh 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 -# create external network -neutron net-create net04_ext --router:external --provider:physical_network physnet \ ---provider:network_type vlan --provider:segmentation_id 1411 -neutron subnet-create net04_ext 10.145.140.0/24 --name net04_ext__subnet \ ---allocation-pool start=10.145.140.13,end=10.145.140.20 --disable-dhcp --gateway 10.145.140.1 # create router neutron router-create ipv4-router @@ -36,8 +32,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 net04_ext -neutron router-gateway-set ipv4-router net04_ext +neutron router-gateway-set ipv6-router ext-net +neutron router-gateway-set ipv4-router ext-net # 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_teardown.bash b/yardstick/benchmark/scenarios/networking/ping6_teardown.bash index 7ab145523..33eff5ca7 100644 --- a/yardstick/benchmark/scenarios/networking/ping6_teardown.bash +++ b/yardstick/benchmark/scenarios/networking/ping6_teardown.bash @@ -8,6 +8,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +source /opt/admin-openrc.sh # delete VM nova delete VM1 nova delete VM2 @@ -35,8 +36,8 @@ neutron subnet-delete --name ipv6-int-subnet2 neutron subnet-delete --name ipv4-int-subnet2 #clear gateway -neutron router-gateway-clear ipv4-router net04_ext -neutron router-gateway-clear ipv6-router net04_ext +neutron router-gateway-clear ipv4-router ext-net +neutron router-gateway-clear ipv6-router ext-net #delete ipv4 router interface neutron router-interface-delete ipv4-router ipv4-int-subnet1 @@ -50,9 +51,5 @@ neutron net-delete ipv4-int-network1 neutron router-delete ipv4-router neutron router-delete ipv6-router -# delete ext net -neutron subnet-delete net04_ext__subnet -neutron net-delete net04_ext - # delete glance image -glance --os-image-api-version 1 image-delete Fedora22 \ No newline at end of file +glance --os-image-api-version 1 image-delete Fedora22 diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py old mode 100755 new mode 100644 -- cgit 1.2.3-korg